-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate site editor multi-entity save flow tests #52372
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | ||
|
||
test.describe( 'Site Editor - Multi-entity save flow', () => { | ||
test.beforeAll( async ( { requestUtils } ) => { | ||
await Promise.all( [ | ||
requestUtils.activateTheme( 'emptytheme' ), | ||
requestUtils.deleteAllTemplates( 'wp_template' ), | ||
] ); | ||
} ); | ||
|
||
test.afterAll( async ( { requestUtils } ) => { | ||
await Promise.all( [ | ||
requestUtils.activateTheme( 'twentytwentyone' ), | ||
requestUtils.deleteAllTemplates( 'wp_template' ), | ||
] ); | ||
} ); | ||
|
||
test.beforeEach( async ( { admin, editor } ) => { | ||
await admin.visitSiteEditor( { | ||
postId: 'emptytheme//index', | ||
postType: 'wp_template', | ||
} ); | ||
await editor.canvas.click( 'body' ); | ||
} ); | ||
|
||
test( 'save flow should work as expected', async ( { editor, page } ) => { | ||
await editor.insertBlock( { | ||
name: 'core/paragraph', | ||
attributes: { | ||
content: 'Testing', | ||
}, | ||
} ); | ||
|
||
await expect( | ||
page | ||
.getByRole( 'region', { name: 'Editor top bar' } ) | ||
.getByRole( 'button', { name: 'Save' } ) | ||
).toBeEnabled(); | ||
await expect( | ||
page | ||
.getByRole( 'region', { name: 'Save panel' } ) | ||
.getByRole( 'button', { name: 'Open save panel' } ) | ||
).toBeVisible(); | ||
|
||
await editor.saveSiteEditorEntities(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we delete template parts before/after the tests to avoid the changes to persist between tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A good idea. Added the template cleanup to the tests since we only change the templates now. |
||
await expect( | ||
page | ||
.getByRole( 'region', { name: 'Editor top bar' } ) | ||
.getByRole( 'button', { name: 'Saved' } ) | ||
).toBeDisabled(); | ||
} ); | ||
|
||
test( 'save flow should allow re-saving after changing the same block attribute', async ( { | ||
editor, | ||
page, | ||
} ) => { | ||
await editor.openDocumentSettingsSidebar(); | ||
await editor.insertBlock( { | ||
name: 'core/paragraph', | ||
attributes: { | ||
content: 'Testing', | ||
}, | ||
} ); | ||
|
||
const fontSizePicker = page | ||
.getByRole( 'region', { name: 'Editor Settings' } ) | ||
.getByRole( 'group', { name: 'Font size' } ); | ||
|
||
// Change font size. | ||
await fontSizePicker.getByRole( 'radio', { name: 'Small' } ).click(); | ||
|
||
await editor.saveSiteEditorEntities(); | ||
|
||
// Change font size again. | ||
await fontSizePicker.getByRole( 'radio', { name: 'Medium' } ).click(); | ||
|
||
// The save button has been re-enabled. | ||
await expect( | ||
page | ||
.getByRole( 'region', { name: 'Editor top bar' } ) | ||
.getByRole( 'button', { name: 'Save' } ) | ||
).toBeEnabled(); | ||
} ); | ||
} ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This step wasn't relevant to the tests, so I omitted it from migration.