Skip to content

Commit

Permalink
Migrate demo page tests to Playwright (#55054)
Browse files Browse the repository at this point in the history
* Migrate demo page tests to Playwright
* Remove old test file
* make check more strict

Co-authored-by: Bart Kalisz <[email protected]>
  • Loading branch information
Mamaduka and WunderBart authored Oct 5, 2023
1 parent 9ef96c5 commit c0cacda
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 50 deletions.
50 changes: 0 additions & 50 deletions packages/e2e-tests/specs/local/demo.test.js

This file was deleted.

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

test.describe( 'New editor state', () => {
test( 'content should load, making the post dirty', async ( {
page,
admin,
} ) => {
await admin.visitAdminPage( 'post-new.php', 'gutenberg-demo' );
await page.waitForFunction( () => {
if ( ! window?.wp?.data?.dispatch ) {
return false;
}
window.wp.data
.dispatch( 'core/preferences' )
.set( 'core/edit-post', 'welcomeGuide', false );

window.wp.data
.dispatch( 'core/preferences' )
.set( 'core/edit-post', 'fullscreenMode', false );

return true;
} );

const isDirty = await page.evaluate( () => {
return window.wp.data.select( 'core/editor' ).isEditedPostDirty();
} );
expect( isDirty ).toBe( true );

await expect(
page
.getByRole( 'region', { name: 'Editor top bar' } )
.getByRole( 'button', { name: 'Save draft' } )
).toBeEnabled();
} );
} );

0 comments on commit c0cacda

Please sign in to comment.