-
Notifications
You must be signed in to change notification settings - Fork 2k
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
E2E: use API calls in Widgets: Legacy spec to deactivate/remove widgets before the spec is run. #74479
Conversation
- add API methods to perform actions on widgets. packages/calypso-e2e/src/types/rest-api-client.types.ts - add types
- update Widgets: Legacy spec.
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
- add JSDoc. - remove console.log
skipDescribeIf( envVariables.TEST_ON_ATOMIC )( | ||
DataHelper.createSuiteTitle( 'Widgets' ), | ||
// Mobile viewport is skipped due to https://github.com/Automattic/wp-calypso/issues/64536. | ||
skipDescribeIf( envVariables.TEST_ON_ATOMIC || envVariables.VIEWPORT_NAME === 'mobile' )( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved the skip clause if the viewport size is mobile up to the top-level describe
block.
It felt silly, as mobile viewport, to go through the setup for this spec only to not actually execute the all-important check.
await page.fill( 'input[placeholder="Search"]', 'Top Posts and Pages' ); | ||
await page.click( 'button.editor-block-list-item-legacy-widget\\/top-posts' ); | ||
} ); | ||
it( 'Insert a Legacy Widget', async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test hierarchy has been flattened here as the skip clause has been moved up to the top-level describe
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
await page.click( 'button.editor-block-list-item-legacy-widget\\/top-posts' ); | ||
} ); | ||
it( 'Insert a Legacy Widget', async function () { | ||
await page.getByRole( 'button', { name: 'Add block' } ).click(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: I like how you changed this to use getByRole
. Personally, I also prefer this approach and we give early feedback about the ARIA guidelines!
if ( response.hasOwnProperty( 'error' ) && response.error === 'not_found' ) { | ||
console.info( `Widget ${ widgetID } not found.` ); | ||
return; | ||
} else if ( response === [] ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @worldomonation, I noticed this while working on #74540 -- this probably doesn't work since JS will compare by reference, and a new empty array will always have a different reference.
What's the intended behavior here? (Empty array check?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the intended behavior here? (Empty array check?)
Yes, that's correct - empty array check. I should have checked whether this was acceptable before putting it into production - looks like I should be checking with .length
, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR opened: #74741
Proposed Changes
This PR updates the Widgets: Legacy spec to use API calls in order to first deactivate all widgets.
Context: Gutenberg 15.3.1 release.
Thread: p1678383789296349/1678381006.233999-slack-CBTN58FTJ
Mobile viewport is not supported due to #64536.
Testing Instructions
Ensure the following build configurations are passing:
Pre-merge Checklist