Skip to content

test: Initial PR for integrating the Page Object Model (POM) into e2e test suite#25373

Merged
chloeYue merged 13 commits intodevelopfrom
chlod-pom-first-pr
Jul 2, 2024
Merged

test: Initial PR for integrating the Page Object Model (POM) into e2e test suite#25373
chloeYue merged 13 commits intodevelopfrom
chlod-pom-first-pr

Conversation

@chloeYue
Copy link
Copy Markdown
Contributor

@chloeYue chloeYue commented Jun 18, 2024

Description

The Page Object Model (POM) is a design pattern that promotes code reusability and maintainability in e2e testing by encapsulating UI element selectors and interactions within page objects. This initial PR is the beginning of integrating POM into e2e test suite, aiming to enhance test code quality.

The entire implementation is done in TypeScript instead of JavaScript.

Key Considerations for Implementation:

  • Easy Adaptation: ensure that the structure is straightforward and intuitive, thereby accelerating the development speed and facilitating easier migration.

  • Enhanced Logging: offer better insights during test execution and debugging, making it easier to investigate flaky test

Structure:
The POM structure is organized around distinct page objects for each application UI screen. (Common components, such as the HeaderNavbar, are directly integrated as part of a screen's component when interaction is required. This approach eliminates the need for explicit class extension and allows for the exclusion of the HeaderNavbar in screens where interaction with it is unnecessary.)

Page functions and process:
I've introduced page objects, each designed to encapsulate the elements and interactions specific to their respective pages. Additionally, I've implemented processes such as loginWaitBalance and sendTransaction to efficiently manage common test flows that require interactions across multiple screens.

Processes should be defined for sequences that involve multiple page objects, facilitating broader testing objectives like completing transactions or logging in. These are typically actions that navigate through several screens.

Functions within a class (page object) are best used for actions and verifications that are specific to a single page. This approach promotes the encapsulation and reusability of code for individual UI components or screens, making the tests more modular and maintainable.

3 Migrated Test Cases:
Migrated 3 transaction test cases to the new POM structure, showcasing the improved test architecture and log information. These migrations serve as a POC, demonstrating the effectiveness of POM in our testing environment and provide the base for future migrations.

Additionally, I'm eliminating CSS selectors that aren't robust and replacing them with more stable selectors in this PR.

Open in GitHub Codespaces

Related issues

Fixes: #24985
Relates to: #22464

Manual testing steps

Tests should pass on CI. Code should be easy to understand.

Screenshots/Recordings

Before

Screenshot 2024-06-14 at 12 01 32

Screenshot 2024-06-18 at 11 25 05

After

Screenshot 2024-06-14 at 22 38 22

Screenshot 2024-06-18 at 11 28 10

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.

@chloeYue chloeYue added team-extension-platform Extension Platform team e2e-test End to end test for the MetaMask extension labels Jun 18, 2024
@chloeYue chloeYue self-assigned this Jun 18, 2024
@chloeYue chloeYue requested a review from a team as a code owner June 18, 2024 08:12
@chloeYue chloeYue marked this pull request as draft June 18, 2024 08:12
@github-actions
Copy link
Copy Markdown
Contributor

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.

@chloeYue chloeYue changed the title test: first pr for pom test: Initial PR for integrating the Page Object Model (POM) into e2e test suite Jun 18, 2024
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 18, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 69.69%. Comparing base (721673e) to head (7b605bd).
Report is 10 commits behind head on develop.

Files Patch % Lines
...s/send/components/domain-input-resolution-cell.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #25373   +/-   ##
========================================
  Coverage    69.69%   69.69%           
========================================
  Files         1350     1350           
  Lines        47865    47865           
  Branches     13199    13199           
========================================
  Hits         33355    33355           
  Misses       14510    14510           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [3cfbb54]
Page Load Metrics (55 ± 8 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint6714086157
domContentLoaded9391474
load4011055168
domInteractive9391474
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@chloeYue chloeYue marked this pull request as ready for review June 18, 2024 11:49
@chloeYue chloeYue marked this pull request as draft June 18, 2024 16:10
@chloeYue chloeYue marked this pull request as ready for review June 19, 2024 09:03
@chloeYue chloeYue requested a review from a team as a code owner June 19, 2024 09:03
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [4a0fb1d]
Page Load Metrics (51 ± 3 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint67948184
domContentLoaded9141011
load41665173
domInteractive9141011
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 99 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@DDDDDanica
Copy link
Copy Markdown
Contributor

🔥

@chloeYue chloeYue requested a review from DDDDDanica June 19, 2024 16:17
sleepytanya
sleepytanya previously approved these changes Jun 21, 2024
@chloeYue
Copy link
Copy Markdown
Contributor Author

Thank you, @chloeYue for your effort. I have a small suggestion: could we adopt the model used by the mobile team?

It could help developers working across both repositories by providing commonality, naming convention and making maintenance easier. cc @cortisiko Screenshot 2024-06-21 at 4 32 22 PM

Hi @hjetpoluru, thanks for your suggestion! I've reviewed the page organization for Mobile and agree that alignment is beneficial. I've now created a send folder for all transaction-related pages, like the sendToken and confirmTransaction pages. Other pages, like the homepage, remain in the root for now. Regarding selectors, I prefer keeping them in the same file as the page functions. Since the selector strategy differs between extension and mobile, this approach simplifies development by reducing the need to switch files frequently to copy variable names.

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [68289f5]
Page Load Metrics (44 ± 2 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint65957863
domContentLoaded8111010
load39554442
domInteractive8111010
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 141 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

DDDDDanica
DDDDDanica previously approved these changes Jun 25, 2024
seaona
seaona previously approved these changes Jun 26, 2024
@hjetpoluru
Copy link
Copy Markdown
Contributor

@chloeYue, let me share a screenshot of another folder structure in the development code, which will help you understand the selectors I am mentioning, this is specifically the getters/setters. For easy maintenance we need to organize this folder structure, reduces the duplication of the selectors and readable.
Screenshot 2024-06-26 at 8 56 49 AM

@chloeYue chloeYue dismissed stale reviews from seaona and DDDDDanica via 1751fa5 June 27, 2024 10:26
@chloeYue
Copy link
Copy Markdown
Contributor Author

chloeYue commented Jun 27, 2024

@chloeYue, let me share a screenshot of another folder structure in the development code, which will help you understand the selectors I am mentioning, this is specifically the getters/setters. For easy maintenance we need to organize this folder structure, reduces the duplication of the selectors and readable. Screenshot 2024-06-26 at 8 56 49 AM

Thank you for your suggestion. I understand the structure you're proposing. At this current phase, I believe it's beneficial to define the selectors within the same file as the page functions.

  • If you review the implementation in this PR, you'll notice that all interactions with selectors occur within the page functions themselves, we never need to reference a selector from other files, which is why we've encapsulated them with interaction functions in same file.
  • As we're in the adoption phase of the POM, keeping the selectors and page functions in a single file significantly reduces the need to switch files just to copy selector variable names.
  • The biggest challenge for adopting POM is ensuring it's user-friendly and easy for everyone to adapt to. We should aim for the most straightforward organization and implementation possible, keeping in mind not to over-engineering.
    In conclusion, I believe it's better to keep the selectors organized in the current way during this phase.

@chloeYue chloeYue requested a review from seaona June 27, 2024 10:55
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [7b605bd]
Page Load Metrics (48 ± 4 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint59947894
domContentLoaded8201131
load39664894
domInteractive8201131
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 141 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@hjetpoluru
Copy link
Copy Markdown
Contributor

Thanks @chloeYue for explaining. I agree to you this is also easy pattern to maintain as it available in the page and any flakiness would be resolved.

@chloeYue chloeYue requested a review from a team June 28, 2024 20:01
Copy link
Copy Markdown
Member

@seaona seaona left a comment

Choose a reason for hiding this comment

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

Awesome job!

@chloeYue chloeYue merged commit b893161 into develop Jul 2, 2024
@chloeYue chloeYue deleted the chlod-pom-first-pr branch July 2, 2024 08:33
@github-actions github-actions bot locked and limited conversation to collaborators Jul 2, 2024
@metamaskbot metamaskbot added the release-12.2.0 Issue or pull request that will be included in release 12.2.0 label Jul 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

e2e-test End to end test for the MetaMask extension release-12.2.0 Issue or pull request that will be included in release 12.2.0 team-extension-platform Extension Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[POM] First PR to create new Page Object Model standard

7 participants