Skip to content

Commit

Permalink
test: Fix flaky test: "Custom network customNetwork should add mainne…
Browse files Browse the repository at this point in the history
…t network" (#24895)

## **Description**

This PR addresses the flakiness in e2e test "Custom network
customNetwork should add mainnet network."

Root Cause: The flakiness happens due to occasionally hitting the API
rate limit while fetching the token symbol, resulting in the warning
message `"Ticker symbol verification data is currently unavailable..."`,
as indicated by the failure screenshots in the CI job. However, the test
is intended to verify the presence of a different warning: `"The token
symbol doesn't match the network or chainID..."`. Both warnings share
the same data-testid but differ in text. Consequently, when the first
warning appears, the test mistakenly identifies it as the second
warning, leading to test failure.

Fix Implemented: The solution for this test is to refine the selector
for the specific warning message we aim to verify. By making the
selector more precise, we ensure that the test accurately checks for the
intended warning, thereby eliminating the flakiness caused by the
confusion between the two warnings.


![Screenshot 2024-05-30 at 13 55
57](https://github.com/MetaMask/metamask-extension/assets/105063779/85e9dd36-6be1-4960-8920-f2e9f5d505a0)


![Screenshot 2024-05-30 at 11 57
16](https://github.com/MetaMask/metamask-extension/assets/105063779/5e47af8d-4c0f-4b31-a05e-0b9f9da04106)


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

## **Related issues**

Fixes: #24634 

## **Manual testing steps**

1. Run the test several times yarn test:e2e:single
test/e2e/tests/network/add-custom-network.spec.js --browser=firefox
--leave-running --retryUntilFailure --retries=10
2. Check ci jobs

## **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 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.

---------

Co-authored-by: seaona <[email protected]>
  • Loading branch information
chloeYue and seaona authored Jun 28, 2024
1 parent fde960a commit 3cde035
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/e2e/tests/network/add-custom-network.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ const selectors = {
},
suggestedTicker: '[data-testid="network-form-ticker-suggestion"]',
tickerWarning: '[data-testid="network-form-ticker-warning"]',
suggestedTickerForXDAI: {
css: '[data-testid="network-form-ticker-suggestion"]',
text: 'Suggested ticker symbol: XDAI',
},
tickerWarningTokenSymbol: {
css: '[data-testid="network-form-ticker-warning"]',
text: "This token symbol doesn't match the network name or chain ID entered.",
},
tickerButton: { text: 'PETH', tag: 'button' },
networkAdded: { text: 'Network added successfully!', tag: 'h4' },

Expand Down Expand Up @@ -735,11 +743,11 @@ describe('Custom network', function () {
await driver.fill(selectors.explorerInputField, 'https://test.com');

const suggestedTicker = await driver.isElementPresent(
selectors.suggestedTicker,
selectors.suggestedTickerForXDAI,
);

const tickerWarning = await driver.isElementPresent(
selectors.tickerWarning,
selectors.tickerWarningTokenSymbol,
);

assert.equal(suggestedTicker, false);
Expand Down

0 comments on commit 3cde035

Please sign in to comment.