Skip to content

Commit

Permalink
Refactor preview e2e tests to use Playwright. (#41380)
Browse files Browse the repository at this point in the history
* Refactor preview e2e tests to use Playwright.

* Fix failing test

* Address review feedback

* remove only :P

* Update test/e2e/specs/editor/various/preview.spec.js

Co-authored-by: Kai Hao <[email protected]>

* Update test/e2e/specs/editor/various/preview.spec.js

Co-authored-by: Kai Hao <[email protected]>

* Update test/e2e/specs/editor/various/preview.spec.js

Co-authored-by: Kai Hao <[email protected]>

* Update test/e2e/specs/editor/various/preview.spec.js

Co-authored-by: Kai Hao <[email protected]>

* Update test/e2e/specs/editor/various/preview.spec.js

Co-authored-by: Kai Hao <[email protected]>

* Update test/e2e/specs/editor/various/preview.spec.js

Co-authored-by: Kai Hao <[email protected]>

* Update test/e2e/specs/editor/various/preview.spec.js

Co-authored-by: Kai Hao <[email protected]>

* Update test/e2e/specs/editor/various/preview.spec.js

Co-authored-by: Kai Hao <[email protected]>

* Update to role selector

* Remove old test

* Specify dialog's name

* Add comments for unnamed dialog

Co-authored-by: Kai Hao <[email protected]>
Co-authored-by: Kai Hao <[email protected]>
  • Loading branch information
3 people authored Jun 16, 2022
1 parent 965048c commit 36fd7f6
Show file tree
Hide file tree
Showing 4 changed files with 376 additions and 425 deletions.
2 changes: 2 additions & 0 deletions packages/e2e-test-utils-playwright/src/editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { getEditedPostContent } from './get-edited-post-content';
import { insertBlock } from './insert-block';
import { openDocumentSettingsSidebar } from './open-document-settings-sidebar';
import { openPreviewPage } from './preview';
import { publishPost } from './publish-post';
import { selectBlocks } from './select-blocks';
import { showBlockToolbar } from './show-block-toolbar';
import { saveSiteEditorEntities } from './site-editor';
Expand Down Expand Up @@ -58,6 +59,7 @@ export class Editor {
insertBlock = insertBlock;
openDocumentSettingsSidebar = openDocumentSettingsSidebar;
openPreviewPage = openPreviewPage;
publishPost = publishPost;
saveSiteEditorEntities = saveSiteEditorEntities;
selectBlocks = selectBlocks;
showBlockToolbar = showBlockToolbar;
Expand Down
32 changes: 32 additions & 0 deletions packages/e2e-test-utils-playwright/src/editor/publish-post.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Internal dependencies
*/
import type { Editor } from './index';

/**
* Publishes the post, resolving once the request is complete (once a notice
* is displayed).
*
* @param {Editor} this
*/
export async function publishPost( this: Editor ) {
await this.page.click( 'role=button[name="Publish"i]' );
const publishEditorPanel = this.page.locator(
'role=region[name="Publish editor"i]'
);

const isPublishEditorVisible = await publishEditorPanel.isVisible();

// Save any entities.
if ( isPublishEditorVisible ) {
// Handle saving entities.
await this.page.click(
'role=region[name="Editor publish"i] >> role=button[name="Save"i]'
);
}

// Handle saving just the post.
await this.page.click(
'role=region[name="Editor publish"i] >> role=button[name="Publish"i]'
);
}
Loading

0 comments on commit 36fd7f6

Please sign in to comment.