-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate 'block context' e2e tests to Playwright (#55793)
* Migrate 'block context' e2e tests to Playwright * Delete old test file
- Loading branch information
Showing
3 changed files
with
79 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 0 additions & 84 deletions
84
packages/e2e-tests/specs/editor/plugins/block-context.test.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | ||
|
||
test.describe( 'Block context', () => { | ||
test.beforeAll( async ( { requestUtils } ) => { | ||
await requestUtils.activatePlugin( 'gutenberg-test-block-context' ); | ||
} ); | ||
|
||
test.beforeEach( async ( { admin } ) => { | ||
await admin.createNewPost(); | ||
} ); | ||
|
||
test.afterAll( async ( { requestUtils } ) => { | ||
await requestUtils.deactivatePlugin( 'gutenberg-test-block-context' ); | ||
} ); | ||
|
||
test( 'Block context propagates to inner blocks', async ( { | ||
editor, | ||
page, | ||
} ) => { | ||
await editor.insertBlock( { name: 'gutenberg/test-context-provider' } ); | ||
|
||
const providerBlock = page.getByRole( 'document', { | ||
name: 'Block: Test Context Provider', | ||
} ); | ||
const consumerBlock = page.getByRole( 'document', { | ||
name: 'Block: Test Context Consumer', | ||
} ); | ||
|
||
await expect( consumerBlock ).toBeVisible(); | ||
|
||
// Verify initial contents of consumer. | ||
await expect( consumerBlock ).toHaveText( 'The record ID is: 0' ); | ||
|
||
// Change the attribute value associated with the context. | ||
await providerBlock.getByRole( 'textbox' ).fill( '123' ); | ||
|
||
await expect( consumerBlock ).toHaveText( 'The record ID is: 123' ); | ||
} ); | ||
|
||
test( 'Block context is reflected in the preview', async ( { | ||
editor, | ||
page, | ||
} ) => { | ||
const editorPage = page; | ||
|
||
await editor.insertBlock( { name: 'gutenberg/test-context-provider' } ); | ||
|
||
// Open the preview page. | ||
const previewPage = await editor.openPreviewPage(); | ||
const previewContent = previewPage.locator( '.entry-content p' ); | ||
|
||
await expect( previewContent ).toHaveText( /^0,\d+,post$/ ); | ||
|
||
// Return to editor to change context value to non-default. | ||
await editorPage.bringToFront(); | ||
await editorPage | ||
.getByRole( 'document', { | ||
name: 'Block: Test Context Provider', | ||
} ) | ||
.getByRole( 'textbox' ) | ||
.fill( '123' ); | ||
|
||
await editorPage | ||
.getByRole( 'button', { name: 'Preview', expanded: false } ) | ||
.click(); | ||
await editorPage | ||
.getByRole( 'menuitem', { name: 'Preview in new tab' } ) | ||
.click(); | ||
|
||
// Check non-default context values are populated. | ||
await expect( previewContent ).toHaveText( /^123,\d+,post$/ ); | ||
await editorPage.bringToFront(); | ||
await previewPage.close(); | ||
} ); | ||
} ); |