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

test: add simple notifications test, add page objects for test #27096

Draft
wants to merge 33 commits into
base: develop
Choose a base branch
from

Conversation

cmd-ob
Copy link

@cmd-ob cmd-ob commented Sep 12, 2024

Description

E2E Test for enabling notifications for the first time

Key Changes:

  1. E2E Testing:

    • Added new page objects for notification-related flows and pages enable-notifications.ts, first-time-turn-on-modal.ts, and notifications-list.ts.
    • Implemented a new E2E test for enabling notifications for the first time (enable-notifications-first-time.js).
    • Updated mock data for user-storage (mocks.ts).
  2. Added a data-testid for the Notifications menu item.

  3. Added a utility selectors (util.js) for using test id selector.

Testing:

  • Ran the new E2E test to ensure it passes and correctly simulate user interactions with enabling notifications.
  • Manually tested the updated UI components to verify proper functionality

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

github-actions bot commented Sep 12, 2024

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@cmd-ob cmd-ob added area-qa Relating to QA work (Quality Assurance) team-notifications Notifications team e2e-test End to end test for the MetaMask extension labels Sep 17, 2024
@cmd-ob
Copy link
Author

cmd-ob commented Sep 17, 2024

I have read the CLA Document and I hereby sign the CLA

@cmd-ob cmd-ob marked this pull request as ready for review September 17, 2024 09:50
@cmd-ob cmd-ob requested review from a team as code owners September 17, 2024 09:50
cmd-ob and others added 13 commits September 17, 2024 10:50
…iles to POM and TS (#27201)

This pull request creates the AccountListPage class for the E2E tests
page object model and migrates 4 test files in `test/e2e/tests/account`
to POM **and** TypeScript, with enhanced log messages.

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27155?quickstart=1)

Fixes: #27163

Check code readability, make sure tests pass.

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

<!-- [screenshots/recordings] -->

<!-- [screenshots/recordings] -->

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Chloe Gao <chloe.gao@consensys.net>
Co-authored-by: chloeYue <105063779+chloeYue@users.noreply.github.com>
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
Refer to [Slack
thread](https://consensys.slack.com/archives/G01FXS64DFA/p1725383758137349?thread_ts=1724763550.024349&cid=G01FXS64DFA),
it is discovered that `Application Opened` event is only emitted during
the on-boarding flow, not every time the application is opened. And
further is discussed in [this
issue](MetaMask/MetaMask-planning#2847). In
the end the decision made was to remove this event from codebase
completely

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27102?quickstart=1)

## **Related issues**

Fixes: MetaMask/MetaMask-planning#3210

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

The fix for the flaky test is related to the custom screen size of the
window during execution.

The flaky test was identified in multiple test scenarios with a similar
pattern of false negatives in the automation tests. There were browser
errors that appeared after navigating and opening the devTools, with the
following error mentioned:

```
2024-08-22T20:14:57.507Z [driver] Called 'navigate' with arguments []

-----Received an error from Chrome-----
Request Storage.getStorageKeyForFrame failed. {"code":-32602,"message":"Frame tree node for given frame not found"}
Request Storage.getStorageKeyForFrame failed. {"code":-32602,"message":"Frame tree node for given frame not found"}
----------End of Chrome error----------

2024-08-22T20:15:04.239Z [driver] Called 'fill' with arguments ["#password","correct horse battery staple"]
```
And due to this error, the code mistakenly flags the test as failed and
attempts to capture a screenshot, leading to Due to this error, the code
mistakenly flags the test as failed and attempts to capture a
screenshot, leading to another false `error: NoSuchWindowError: no such
window: target window already closed.`

- The test specific to responive UI requires a specific window size
inorder to perform correctly and with help of @danjm suggestion I have
include the `constrainWindowSize: true` which meets the test criteria.
- Also I have noticed that the windows size is not required for the
`swap-send-test-utils.ts` and hence removed it.

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27067?quickstart=1)

## **Related issues**

Fixes:
#26898
#26900
#26637
#26112
#24624

## **Manual testing steps**

Run the below commands locally or in codespaces
Webpack build
yarn
yarn build:test:webpack
yarn build:test:webpack
ENABLE_MV3=false yarn test:e2e:single
test/e2e/tests/swap-send/swap-send-erc20.spec.ts --browser=chrome
ENABLE_MV3=false yarn test:e2e:single
test/e2e/tests/swap-send/swap-send-eth.spec.ts --browser=chrome
ENABLE_MV3=false yarn test:e2e:single
test/e2e/tests/account/metamask-responsive-ui.spec.js --browser=chrome

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
## **Description**

Removes unused code.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27211?quickstart=1)

## **Related issues**

Fixes: None


## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

Bumps:
- `@metamask/profile-sync-controller` from `^0.7.0` to `^0.8.0`
- `@metamask/notification-services-controller` from `^0.6.0` to `^0.7.0`

This fixes a critical issue where we were not using the same UserStorage
hashed entry. See release library changelog

https://github.com/MetaMask/core/blob/main/packages/profile-sync-controller/CHANGELOG.md#fixed

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27224?quickstart=1)

## **Related issues**

Fixes: https://consensyssoftware.atlassian.net/browse/NOTIFY-1118

## **Manual testing steps**

Test notifications flow:
- Enable/Disable Notifications

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
## **Description**

In order to figure out which currencies we should support 24hr % change,
we need to know which currencies are the most popular.

Adds currency change dropdown event to telemetry events.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/26876?quickstart=1)

## **Related issues**

Fixes: https://consensyssoftware.atlassian.net/browse/MMASSETS-344

## **Screenshots/Recordings**

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

This PR fixes a typo for a property used by the event emitted by the
toggle to turn basic functionality on or off.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27228?quickstart=1)

## **Related issues**

N/A

## **Manual testing steps**

N/A

## **Screenshots/Recordings**

N/A

### **Before**

N/A

### **After**

N/A

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
@cmd-ob cmd-ob requested a review from a team as a code owner September 18, 2024 07:44
Copy link

sonarcloud bot commented Sep 18, 2024

@metamaskbot
Copy link
Collaborator

Builds ready [c7f7fb2]
Page Load Metrics (1912 ± 138 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint22726761517769369
domContentLoaded146826651881280135
load147726781912287138
domInteractive15104402311
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 40 Bytes (0.00%)
  • common: 42 Bytes (0.00%)

Copy link

sonarcloud bot commented Sep 19, 2024

async goToNotifiationsList(): Promise<void> {
this.openAccountOptionsMenu();
this.accountOptionsMenu.clickNotificationsMenuItem();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

With this implementation, for notifications, we use clickNotificationsMenuItem in the AccountOptionsMenu page, but we click lockMetaMaskButton using the selectors in the header-navbar page directly. However, the notificationsMenuItem and the lockMetaMaskButton are on the same modal, which creates inconsistency. I suggest that we don't create a new page class for AccountOptionsMenu because it only has a few buttons without complex interactions on AccountOptionsMenu. We can just add the notificationsMenuItem selector in the header-navbar page and click on it directly here. This provides an easier implementation.
Screenshot 2024-09-20 at 09 35 19

constructor(driver: Driver) {
this.driver = driver;
this.headerNavbar = new HeaderNavbar(driver);
this.accountOptionsMenu = new AccountOptionsMenu(driver);
Copy link
Contributor

Choose a reason for hiding this comment

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

since we will not create accountOptionsMenu page class, this line can be deleted, accountOptionsMenu is a part of headerNavbar

}

async clickTurnOnNotifications(): Promise<void> {
await this.driver.clickElement(this.turnOnButton);
Copy link
Contributor

Choose a reason for hiding this comment

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

use clickElementAndWaitToDisappear to make sure the modal closes, that will reduce flakiness in the test execution

@cmd-ob cmd-ob marked this pull request as draft September 24, 2024 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-qa Relating to QA work (Quality Assurance) e2e-test End to end test for the MetaMask extension team-notifications Notifications team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants