Repository navigation
Commit 872cdaf
test: MMQA-1556 - consolidate network names and chainIds in E2E constants (#47778)
<!--
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**
E2E specs repeated network chain ids and display names as local string
literals, and the `NetworkId` enum lived inside the `SelectNetworkModal`
page object file even though the class never used it.
This refactor consolidates them in one E2E helper module,
[`test/e2e/helpers/network-constants.ts`](test/e2e/helpers/network-constants.ts):
- `NetworkId`: CAIP-2 chain ids (including `LOCALHOST`, `ZKSYNC_ERA` and
`SOLANA`), EVM ones derived from the shared `CHAIN_IDS` via
`toEvmCaipChainId` and Solana from `MultichainNetworks`, instead of
hand-typed `eip155:*` strings. It is a `const` object (a TS enum cannot
call a function), and the same-named type is exported.
- `NetworkName`: built-in network display names (Ethereum, Sepolia,
Arbitrum, Avalanche, Linea, Localhost, Bitcoin, Tron), taken from the
`*_DISPLAY_NAME` constants and `MULTICHAIN_NETWORK_TO_NICKNAME` in
`shared/constants`.
Specs that defined their own `'Ethereum'` / `'Sepolia'` / `'Bitcoin'` /
`'Tron'` constants now use `NetworkName`. The values are identical, so
there is no behavior change. A colocated unit test pins every value.
Behavior impact: none. Test-only change.
Files changed:
- `test/e2e/helpers/network-constants.ts` (new)
- `test/e2e/helpers/network-constants.test.ts` (new)
- `test/e2e/page-objects/pages/networks/select-network-modal.ts`
(removed `NetworkId` enum)
- `test/e2e/tests/request-queuing/ui.spec.ts`,
`tokens/import-tokens.spec.ts`, `tokens/nft/filter-nfts.spec.ts`,
`network/network-manager.spec.ts` (import `NetworkId` from the new
module)
- `test/e2e/tests/multichain/aggregated-balances.spec.ts`,
`multichain/asset-list.spec.ts`, `network/is-present-bitcoin.spec.ts`,
`network/is-present-tron.spec.ts` (use `NetworkName`)
- `test/e2e/tests/network/multi-rpc.spec.ts`, `update-network.spec.ts`,
`custom-rpc-history.spec.ts`, `network-manager.spec.ts`,
`linea-discover-button.spec.ts`, `switch-network.spec.ts` (hardcoded
`eip155:*` ids and network names replaced with `NetworkId` /
`NetworkName`)
- `test/e2e/tests/mm-connect/connect-multichain.spec.ts` (expected
`eth_chainId` hex values use `CHAIN_IDS`)
- `test/e2e/tests/network/popular-network.spec.ts` (Avalanche/Arbitrum
hex ids, CAIP id and display names now come from `CHAIN_IDS`,
`NetworkId` and `NetworkName`)
- `test/e2e/constants.ts` (`SOLANA_MAINNET_SCOPE`,
`SOLANA_MAINNET_CHAIN_ID`, `MM_CONNECT_EVM_CHAINS`,
`MM_CONNECT_FEATURED_CHAIN_IDS` and the mock `chain_id` are built from
`NetworkId` / `CHAIN_IDS` instead of hand-typed strings; exported names
and values are unchanged)
Not changed: `TRON_NILE_NAME` / `TRON_SHASTA_NAME` (shared nicknames
differ), custom/fake network names, and other hardcoded chain ids
(status codes, asset ids, custom-network harness).
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes: MMQA-1556
## **Manual testing steps**
N/A: this is a structural move in E2E test code with no product or UI
change. The moved values are pinned by `yarn test:unit
test/e2e/helpers/network-constants.test.ts`.
## **Screenshots/Recordings**
### **Before**
No UI change. Ticket context: the Linear-style ticket header shows
parent MMQA-325 and the checked child MMQA-1556, "Consolidate network
name, chainIds in constants", with an empty description. Before this
change, network names and chain ids were repeated as local literals
across E2E specs, and the `NetworkId` enum lived in the
`SelectNetworkModal` page object.
### **After**
No UI change. Network names and chain ids are defined once in
`test/e2e/helpers/network-constants.ts` and imported by the specs.
## **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/main/.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/main/.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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Test-only refactor with values pinned by unit tests; no production
code or runtime behavior changes.
>
> **Overview**
> E2E tests no longer repeat CAIP-2 chain IDs and network display names
as literals. A new **`test/e2e/helpers/network-constants.ts`** module
centralizes **`NetworkId`** (derived from shared `CHAIN_IDS` /
`MultichainNetworks`) and **`NetworkName`** (from product display-name
constants), with a unit test that locks the expected values.
>
> The **`NetworkId` enum is removed** from `select-network-modal.ts`;
specs and **`test/e2e/constants.ts`** now import these helpers instead
of hardcoded `eip155:*` strings, hex chain IDs, or labels like
`'Ethereum'`. MM Connect and analytics mock constants are wired through
the same shared sources so E2E identifiers stay aligned with the
extension.
>
> **Behavior is unchanged**—this is structural test maintenance only.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
805583e. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent f0ab05f commit 872cdaf
19 files changed
Lines changed: 162 additions & 70 deletions
File tree
- test/e2e
- helpers
- page-objects/pages/networks
- tests
- mm-connect
- multichain
- network
- request-queuing
- tokens
- nft
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
| 4 | + | |
2 | 5 | | |
3 | 6 | | |
4 | 7 | | |
| |||
268 | 271 | | |
269 | 272 | | |
270 | 273 | | |
271 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
272 | 277 | | |
273 | 278 | | |
274 | | - | |
| 279 | + | |
275 | 280 | | |
276 | 281 | | |
277 | 282 | | |
278 | 283 | | |
279 | 284 | | |
280 | 285 | | |
281 | | - | |
282 | | - | |
283 | | - | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
284 | 289 | | |
285 | 290 | | |
286 | 291 | | |
287 | 292 | | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
299 | 304 | | |
300 | 305 | | |
301 | 306 | | |
| |||
379 | 384 | | |
380 | 385 | | |
381 | 386 | | |
382 | | - | |
| 387 | + | |
383 | 388 | | |
384 | 389 | | |
385 | 390 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | 5 | | |
18 | 6 | | |
19 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
203 | 204 | | |
204 | 205 | | |
205 | 206 | | |
206 | | - | |
207 | | - | |
208 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
209 | 210 | | |
210 | 211 | | |
211 | 212 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
28 | | - | |
| 28 | + | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | | - | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
189 | 190 | | |
190 | 191 | | |
191 | 192 | | |
192 | | - | |
| 193 | + | |
193 | 194 | | |
194 | 195 | | |
195 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | | - | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | | - | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
0 commit comments