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 Block Mover Test For Playwright #42039

Merged

Conversation

pooja-muchandikar
Copy link
Contributor

What?

Part of #38851.
Migrate block-mover.test.js to its Playwright version.

Why?

Part of #38851.

How?

See MIGRATION.md for migration steps.

Testing Instructions

Run npm run test-e2e:playwright test/e2e/specs/editor/various/block-mover.spec.js

@pooja-muchandikar
Copy link
Contributor Author

Hi @kevin940726,

I hope you are doing well!

Could you please help me in reviewing this PR?

Thanks!!

Copy link
Contributor

@talldan talldan left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! I left a few comments about how we can take advantage playwright's nicer API. I haven't tested the code snippets, so you might need to double check they're correct.

Comment on lines 16 to 19
await page.click( '.block-editor-default-block-appender' );
await page.keyboard.type( 'First Paragraph' );
await page.keyboard.press( 'Enter' );
await page.keyboard.type( 'Second Paragraph' );
Copy link
Contributor

@talldan talldan Jul 1, 2022

Choose a reason for hiding this comment

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

I think it would be good to simplify this part with something like:

await editor.insertBlock( { name: 'core/paragraph', attributes: { content: 'First Paragraph' } } );
await editor.insertBlock( { name: 'core/paragraph', attributes: { content: 'Second Paragraph' } } );

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Worked on the feedbacks

Comment on lines 24 to 28
const count = await page.$$eval(
'.block-editor-block-mover',
( el ) => el.length
);
expect( count ).toBe( 1 );
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be good to take advantage of Playwright's locator system here, and use the role selector:

const moveDownButton = page.locator( 'role=toolbar[name="Block tools"i] >> role=button[name="Move down"i]' );
const moveUpButton = page.locator( 'role=toolbar[name="Block tools"i] >> role=button[name="Move up"i]' );
await expect( moveDownButton ).toBeVisible();
await expect( moveUpButton ).toBeVisible();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Worked on the feedbacks

Comment on lines 36 to 37
await page.click( '.block-editor-default-block-appender' );
await page.keyboard.type( 'First Paragraph' );
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to the previous comment, this can change to:

await editor.insertBlock( { name: 'core/paragraph', attributes: { content: 'First Paragraph' } );

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Worked on the feedbacks

Comment on lines 44 to 48
const count = await page.$$eval(
'.block-editor-block-mover',
( el ) => el.length
);
expect( count ).toBe( 0 );
Copy link
Contributor

Choose a reason for hiding this comment

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

And this part could also be refactored to be use locators:

const moveDownButton = page.locator( 'role=toolbar[name="Block tools"i] >> role=button[name="Move down"i]' );
const moveUpButton = page.locator( 'role=toolbar[name="Block tools"i] >> role=button[name="Move up"i]' );
await expect( moveDownButton ).toBeHidden();
await expect( moveUpButton ).toBeHidden();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Worked on the feedbacks.

@pooja-muchandikar
Copy link
Contributor Author

Hi @talldan,

I have addressed all the feedbacks, could you please review again?

Also I noticed that CI is failing but not related to the test case I worked on. I am little confused here 🤔

image


image

@talldan
Copy link
Contributor

talldan commented Jul 5, 2022

Thanks for making those changes!

Also I noticed that CI is failing but not related to the test case I worked on. I am little confused here

Some of our old tests are not very reliable, which is one of the reasons for migrating them to Playwright.

I've restarted them to see if they pass.

@pooja-muchandikar
Copy link
Contributor Author

pooja-muchandikar commented Jul 5, 2022

Hi @talldan, good morning..

All the CI checks have passed except the End to End Tests / Admin -3 🤔

image

@talldan
Copy link
Contributor

talldan commented Jul 5, 2022

Did a another retry and managed to get it passing 👍

@talldan talldan added [Type] Task Issues or PRs that have been broken down into an individual action to take [Package] E2E Tests /packages/e2e-tests labels Jul 5, 2022
Copy link
Contributor

@talldan talldan left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

@talldan talldan merged commit 65ae763 into WordPress:trunk Jul 5, 2022
@github-actions github-actions bot added this to the Gutenberg 13.7 milestone Jul 5, 2022
@pooja-muchandikar
Copy link
Contributor Author

Thank you :)

@pooja-muchandikar pooja-muchandikar deleted the add/playwright-block-mover-test branch July 5, 2022 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] E2E Tests /packages/e2e-tests [Type] Task Issues or PRs that have been broken down into an individual action to take
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants