Skip to content
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 'iframed masonry block' tests to Playwright #55016

Merged
merged 3 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions packages/e2e-tests/plugins/iframed-masonry-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
* @package gutenberg-test-iframed-masonry-block
*/

add_action(
'setup_theme',
static function () {
add_theme_support( 'block-templates' );
}
);

add_action(
'init',
static function () {
Expand Down

This file was deleted.

This file was deleted.

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

test.describe( 'iframed masonry block', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activatePlugin(
'gutenberg-test-iframed-masonry-block'
);
} );

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

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.deactivatePlugin(
'gutenberg-test-iframed-masonry-block'
);
} );

test( 'should load script and dependencies in iframe', async ( {
editor,
} ) => {
await editor.insertBlock( { name: 'test/iframed-masonry-block' } );

const masonry = editor.canvas.getByRole( 'document', {
name: 'Block: Iframed Masonry Block',
} );
await expect( masonry ).toBeVisible();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've replaced the snapshot assertion with this. Do we need to assert the block's whole edit markup?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we do. If we want anything tested then we should probably add the assertions below anyway.


const masonryBox = await masonry.boundingBox();

// Expect Masonry to set a non-zero height.
expect( masonryBox.height ).toBeGreaterThan( 0 );

// Expect Masonry to absolute position items.
await expect( masonry.locator( '.grid-item' ).first() ).toHaveCSS(
'position',
'absolute'
);
} );
} );