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 Preferences Test to Playwright #44107

Conversation

pooja-muchandikar
Copy link
Contributor

What?

Part of #38851.
Migrate preferences.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/preferences.spec.js

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.

Comment on lines 13 to 17
await expect(
page.locator(
'.components-button.edit-post-sidebar__panel-tab.is-active'
)
).toHaveText( 'Post' );
Copy link
Contributor

Choose a reason for hiding this comment

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

The test seems to be failing on this line.

The issue could be that Playwright isn't waiting for the element. You could try using expect.poll.

It'd be good to try changing the classname selector to a role selector. This is what my browser dev tools shows as the accessibility properties:
Screen Shot 2022-09-15 at 5 05 05 pm

(so role is "button", name is "Post (selected)")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @talldan, Previously also tried expect.poll but expect.poll excepts function only. I also tried to pass the async function within it but still it seems to be not working.

image

Let me know your thoughts on same.

Comment on lines 23 to 25
page.locator(
'.components-button.edit-post-sidebar__panel-tab.is-active'
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Again I think a role selector can be used for this. It will be different to the one above as it's a different button:
Screen Shot 2022-09-15 at 5 09 40 pm

Comment on lines 35 to 37
page.locator(
'.components-button.edit-post-sidebar__panel-tab.is-active'
)
Copy link
Contributor

@talldan talldan Sep 15, 2022

Choose a reason for hiding this comment

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

This is the same element as the locator from my first comment (role "button", name "Post (selected)").

It could be assigned to a variable at the start of the test and that variable used here.


// Dismiss.
await page.click(
'.edit-post-sidebar__panel-tabs [aria-label="Close settings"]'
Copy link
Contributor

Choose a reason for hiding this comment

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

This one can be a role locator too:
Screen Shot 2022-09-15 at 5 13 42 pm

( button / "Close settings" )

// See: https://github.com/WordPress/gutenberg/issues/6377
// See: https://github.com/WordPress/gutenberg/pull/8995
await page.reload();
await page.waitForSelector( '.edit-post-layout' );
Copy link
Contributor

Choose a reason for hiding this comment

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

This line essentially waits for the block editor to load, but I think it line can be removed. The line below it could be changed to await expect.poll(, which would make the test wait for the panel tab to be present (so it would have the same result of waiting for the editor to load).

'.edit-post-sidebar__panel-tabs [aria-label="Close settings"]'
);
await expect(
page.locator( '.edit-post-sidebar__panel-tab.is-active' )
Copy link
Contributor

Choose a reason for hiding this comment

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

Again I think it'd be fine to use the locator from my first comment (assign it to a variable and use the variable here).


// Remember after reload.
await page.reload();
await page.waitForSelector( '.edit-post-layout' );
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not a huge fan of this line because it waits for something that's unrelated to the user interface being tested.

If it could be changed to a role selector for this element, that would be great:
Screen Shot 2022-09-15 at 5 20 37 pm

await page.reload();
await page.waitForSelector( '.edit-post-layout' );
await expect(
page.locator( '.edit-post-sidebar__panel-tab.is-active' )
Copy link
Contributor

Choose a reason for hiding this comment

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

Same again, it'd be fine to use the locator from my first comment (assign it to a variable and use the variable here).

@pooja-muchandikar
Copy link
Contributor Author

Hi @talldan,

Thanks for the feedbacks, I have resolved all of those.

Could you please review once?

@pooja-muchandikar
Copy link
Contributor Author

Hi @talldan,

Any further suggestions on this PR?

@skorasaurus skorasaurus added the [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. label Nov 14, 2022
Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

Hi, @pooja-muchandikar

It looks like there's a merge conflict. Can you rebase your branch on top of the latest trunk and resolve the conflict?

Thank you!

@pooja-muchandikar
Copy link
Contributor Author

Hi, @Mamaduka Closing this PR as it had conflicts and created new PR for same test - #57443

@pooja-muchandikar pooja-muchandikar deleted the add/preferences-test branch December 29, 2023 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.
4 participants