Skip to content

Commit

Permalink
Update the 'Iframe block' test and fix flakiness (#51631)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored Jun 19, 2023
1 parent b13519b commit 69ad3d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions test/e2e/specs/editor/plugins/iframed-block.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,17 @@ test.describe( 'Iframed block', () => {
await requestUtils.deactivatePlugin( 'gutenberg-test-iframed-block' );
} );

test( 'Should save the changes', async ( { editor, page } ) => {
test( 'should load script and dependencies in iframe', async ( {
editor,
} ) => {
await editor.insertBlock( { name: 'test/iframed-block' } );
expect( await editor.getEditedPostContent() ).toMatchSnapshot();

// Expect the script to load in the iframe, which replaces the block text.
await expect(
editor.canvas.locator(
'role=document[name="Block: Iframed Block"i]'
)
).toContainText( 'Iframed Block (set with jQuery)' );

// open page from sidebar settings
await page.click(
'role=region[name="Editor settings"i] >> role=button[name="Page"i]'
);

// Opens the template editor with a newly created template.
await page.click( 'role=button[name="Select template"i]' );
await page.click( 'role=button[name="Add template"i]' );
await page.fill( 'role=textbox[name="NAME"i]', 'Test template' );
await page.click( 'role=button[name="Create"i]' );

// Expect iframe canvas to be visible
await expect(
page.locator( 'iframe[name="editor-canvas"]' )
).toBeVisible();

// Expect the script to load in the iframe, which replaces the block text.
const iframedText = page.frameLocator( 'iframe' ).locator( 'body' );
await expect( iframedText ).toContainText(
'Iframed Block (set with jQuery)'
);
} );
} );

0 comments on commit 69ad3d4

Please sign in to comment.