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

E2E: use API calls in Widgets: Legacy spec to deactivate/remove widgets before the spec is run. #74479

Merged
merged 3 commits into from
Mar 16, 2023

Conversation

worldomonation
Copy link
Contributor

@worldomonation worldomonation commented Mar 15, 2023

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:

  • Gutenberg E2E (desktop)
  • Gutenberg E2E (mobile) (suite is skipped)

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-ajp-p2)?

- add API methods to perform actions on widgets.

packages/calypso-e2e/src/types/rest-api-client.types.ts
- add types
@worldomonation worldomonation self-assigned this Mar 15, 2023
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Mar 15, 2023
@github-actions
Copy link

github-actions bot commented Mar 15, 2023

@matticbot
Copy link
Contributor

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.

@worldomonation worldomonation marked this pull request as ready for review March 15, 2023 19:04
@worldomonation worldomonation requested a review from a team as a code owner March 15, 2023 19:04
@worldomonation worldomonation changed the title E2E: use API calls in Widgets: Legacy spec for more reliability. E2E: use API calls in Widgets: Legacy spec to deactivate/remove widgets before the spec is run. Mar 15, 2023
- 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' )(
Copy link
Contributor Author

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 () {
Copy link
Contributor Author

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.

Copy link
Contributor

@karenroldan karenroldan left a 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();
Copy link
Contributor

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!

@worldomonation worldomonation merged commit 7c11eda into trunk Mar 16, 2023
@worldomonation worldomonation deleted the update/e2e-widgets-legacy branch March 16, 2023 20:03
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Mar 16, 2023
if ( response.hasOwnProperty( 'error' ) && response.error === 'not_found' ) {
console.info( `Widget ${ widgetID } not found.` );
return;
} else if ( response === [] ) {
Copy link
Contributor

@noahtallen noahtallen Mar 21, 2023

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?)

Copy link
Contributor Author

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PR opened: #74741

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants