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

Permafail E2E: fix Notifications spec. #78616

Merged
merged 3 commits into from
Jun 27, 2023

Conversation

worldomonation
Copy link
Contributor

@worldomonation worldomonation commented Jun 26, 2023

Fixes #78103.

Proposed Changes

This PR fixes the cause of the permafailing Notifications spec and refactors the spec to modern standards.

Key changes:

  • remove action pairs (eg. Approve/Unapprove), restricting the test to the happy path.
  • update NotificationComponent to use modern accessible locators.
  • update the commentingUser entry in the encrypted secrets file to modern standards.
  • add new optional parameter waitUntilStable in the TestAccount.authenticate method.

Testing Instructions

sEnsure the following build configurations are passing:

  • Calypso E2E (desktop)
  • Calypso E2E (mobile)

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

@worldomonation worldomonation self-assigned this Jun 26, 2023
@github-actions
Copy link

github-actions bot commented Jun 26, 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.

- migrate commentingUser to the new schema.
- refactor the component POM to use modern meethods.

packages/calypso-e2e/src/lib/test-account.ts
- add new flag for `authenticate` call to allow waiting for the full load.

test/e2e/specs/infrastructure/notification__actions.ts
- refactor the spec to only perform one action, not to perform and undo the action.
- explain the purpose of the spec with JSDoc.
- rename the file.

packages/calypso-e2e/src/lib/test-account.ts
- change optional parameter for `authenticate` to "waitUntiLStable".
@worldomonation worldomonation force-pushed the fix/e2e-notification-actions-78103 branch from 98c58d8 to 1565b3d Compare June 26, 2023 05:10
@worldomonation worldomonation marked this pull request as ready for review June 26, 2023 06:19
@worldomonation worldomonation requested a review from a team as a code owner June 26, 2023 06:19
@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 Jun 26, 2023
@@ -23,6 +14,8 @@ export class NotificationsComponent {
*/
constructor( page: Page ) {
this.page = page;
// There is no accessible locator for this panel.
this.anchor = page.locator( 'div[id=wpnc-panel]' );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is something I've yet to codify in the E2E documentation but follows the precedent set in WordPress/gutenberg (example).

Copy link
Contributor

Choose a reason for hiding this comment

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

I see what you meant. TIL about the full accessibility tree in Chrome DevTools!

async authenticate( page: Page, { url }: { url?: string | RegExp } = {} ): Promise< void > {
async authenticate(
page: Page,
{ url, waitUntilStable }: { url?: string | RegExp; waitUntilStable?: boolean } = {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change and the accompanying changes in Line 57-60 are important for stable loading of specs that rely on interaction in the My Home page.

Because Calypso loads so slowly but Playwright executes at lightning speed, we can often end up in a situation where Calypso "swallows" interactions on the page. To work around this issue, we can wait until the page loads entirely, but on Simple sites, this is often in excess of 15-20 seconds.

However, the Sidebar component is rendered and ready to interact towards the middle-later portions of the loading process. Waiting for the Sidebar component to become ready is suitable 98% of the time.


it( 'Mark comment as spam', async function () {
await notificationsComponent.clickNotificationAction( 'Spam' );
await notificationsComponent.clickUndo();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Undo the action to mark the comment as spam so:

  1. we don't need to create another comment to perform the Trash action, and;
  2. we don't inadvertently train the backend systems to consider commentingUser as a spammer.

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 🚀

@@ -23,6 +14,8 @@ export class NotificationsComponent {
*/
constructor( page: Page ) {
this.page = page;
// There is no accessible locator for this panel.
this.anchor = page.locator( 'div[id=wpnc-panel]' );
Copy link
Contributor

Choose a reason for hiding this comment

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

I see what you meant. TIL about the full accessibility tree in Chrome DevTools!

@worldomonation worldomonation merged commit 0e0c171 into trunk Jun 27, 2023
@worldomonation worldomonation deleted the fix/e2e-notification-actions-78103 branch June 27, 2023 08:02
@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 Jun 27, 2023
worldomonation added a commit that referenced this pull request Jun 27, 2023
worldomonation added a commit that referenced this pull request Jun 28, 2023
* test/e2e/specs/support/support__popover.ts
- remove spec in favor of a (yet-to-be-written) component test.

test/e2e/specs/support/support__showme-where.ts
- renamed.

test/e2e/specs/help-center/help-center__general-interaction.ts
- refactored to run through the support help docs, then the calypso link.

packages/calypso-e2e/src/lib/components/support-component.ts
- use accessible selectors.
- remove methods no longer used.

* Fix issues pointed out in review.

packages/calypso-e2e/src/lib/components/support-component.ts
- fix typo.

test/e2e/specs/help-center/help-center__general-interaction.ts
- select the second help doc instead of first.

* test/e2e/specs/help-center/help-center__general-interaction.ts
- use changes introduced in #78616.

* test/e2e/specs/help-center/help-center__general-interaction.ts
- add step to clear results.

* packages/calypso-e2e/src/lib/components/support-component.ts
- add workaround for mobile by checking whether the Close Search button is present.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Permafailing E2E: See and click notification for the comment left by commentingUser
3 participants