Skip to content

Commit

Permalink
Migrate site-editor-inserter e2e test to Playwright (#44507)
Browse files Browse the repository at this point in the history
* Add site editor test case

* Addressed feedbacks

* Addressed feedbacks

* Addressed locator feedback

* Add role locators intead of class and assert both state

* Delete original file
  • Loading branch information
alvitazwar authored Oct 25, 2022
1 parent c3ae088 commit 3ed9aca
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 33 deletions.
33 changes: 0 additions & 33 deletions packages/e2e-tests/specs/site-editor/site-editor-inserter.test.js

This file was deleted.

42 changes: 42 additions & 0 deletions test/e2e/specs/site-editor/site-editor-inserter.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Site Editor Inserter', () => {
test.beforeAll( async ( { requestUtils } ) => {
await Promise.all( [
requestUtils.activateTheme( 'emptytheme' ),
requestUtils.deleteAllTemplates( 'wp_template' ),
requestUtils.deleteAllTemplates( 'wp_template_part' ),
] );
} );

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'twentytwentyone' );
} );

test.beforeEach( async ( { admin } ) => {
await admin.visitSiteEditor();
} );

test( 'inserter toggle button should toggle global inserter', async ( {
page,
} ) => {
await page.click( 'role=button[name="Toggle block inserter"i]' );

// Visibility check
await expect(
page.locator(
'role=searchbox[name="Search for blocks and patterns"i]'
)
).toBeVisible();
await page.click( 'role=button[name="Toggle block inserter"i]' );
//Hidden State check
await expect(
page.locator(
'role=searchbox[name="Search for blocks and patterns"i]'
)
).toBeHidden();
} );
} );

0 comments on commit 3ed9aca

Please sign in to comment.