test: MMQA - 1908 - Refactor nft.permit.spec.ts to good practices#43484
test: MMQA - 1908 - Refactor nft.permit.spec.ts to good practices#43484LeVinhGithub wants to merge 12 commits into
Conversation
|
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. |
✨ Files requiring CODEOWNER review ✨✅ @MetaMask/confirmations (17 files, +59 -1)
🧪 @MetaMask/qa (2 files, +55 -120)
|
Builds ready [334e86c]
⚡ Performance Benchmarks (Total: 🟢 16 pass · 🟡 9 warn · 🔴 0 fail)
Bundle size diffs
|
Builds ready [3164718]
⚡ Performance Benchmarks (Total: 🟢 15 pass · 🟡 10 warn · 🔴 0 fail)
Bundle size diffs
|
Builds ready [d074f57] [reused from 3164718]
⚡ Performance Benchmarks (Total: 🟢 15 pass · 🟡 10 warn · 🔴 0 fail)
Bundle size diffs
|
Builds ready [fae7fc1] [reused from 022d2d8]
⚡ Performance Benchmarks (Total: 🟢 16 pass · 🟡 7 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [69d93b0] [reused from e0aedfe]
⚡ Performance Benchmarks (Total: 🟢 17 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [89893dd]
⚡ Performance Benchmarks (Total: 🟢 17 pass · 🟡 7 warn · 🔴 0 fail)
Bundle size diffs
|
Builds ready [57116c2]
⚡ Performance Benchmarks (Total: 🟢 18 pass · 🟡 7 warn · 🔴 0 fail)
Bundle size diffs
|
Description
Refactors NFT permit E2E coverage and the shared
PermitConfirmationpage object to follow repository E2E best practices (MMQA-1908 / MMQA-325).Problem:
nft-permit.spec.tskept assertion helpers and hardcoded expected values in the spec, whilepermit-confirmation.tsused brittle text/CSS locators, duplicated.name__valueselectors, andfindElement+assert.okinstead of resilient waits.Changes:
permit-confirmation.ts: Rebuilt as a thin page object with parameterized locator factories (addressValue,addressName,dataTreeRowWithText,confirmTitle,confirmDescription,origin,primaryType). Renamedverify*methods tocheck*and switched all assertions towaitForSelector. Locators now use stabledata-testidselectors where available:confirmation_data-{field}confirm-title-text,confirm-title-descriptionconfirmation__details-originconfirmation__message-primary-typenft-permit.spec.ts: Moved expected field values into a localassertInfoValueshelper; usesPermitConfirmationthroughout; simplified deploy/window switching; aligned signature verification withpermit.spec.ts(waitUntilXWindowHandles, reusetestDappinstance).permit.spec.ts: UpdatedassertInfoValuesto pass expected values from the spec into the newcheck*page object methods.title.tsx: Addeddata-testid="confirm-title-text"anddata-testid="confirm-title-description"so permit confirmation title/description can be targeted reliably in E2E.url.tsx: Addeddata-testid="confirmation__details-origin"on the request-origin URL value (shared across typed sign, personal sign, and transaction confirmations).typedSignData.tsx: Addeddata-testid="confirmation__message-primary-type"on the primary type value row.sign.flow.ts,erc721-approve-redesign.spec.ts: Updated call sites for renamed page object API.url.test.tsx,typedSignData.test.tsx,typed-sign.test.tsx, andconfirm.test.tsxto reflect new test IDs.Files changed:
test/e2e/page-objects/pages/confirmations/permit-confirmation.tstest/e2e/tests/confirmations/signatures/nft-permit.spec.tstest/e2e/tests/confirmations/signatures/permit.spec.tstest/e2e/page-objects/flows/sign.flow.tstest/e2e/tests/confirmations/transactions/erc721-approve-redesign.spec.tsui/pages/confirmations/components/confirm/title/title.tsxui/components/app/confirm/info/row/url.tsxui/pages/confirmations/components/confirm/row/typed-sign-data/typedSignData.tsxui/components/app/confirm/info/row/__snapshots__/url.test.tsx.snapui/pages/confirmations/components/confirm/row/typed-sign-data/__snapshots__/typedSignData.test.tsx.snapui/pages/confirmations/components/confirm/info/typed-sign/__snapshots__/typed-sign.test.tsx.snapui/pages/confirmations/confirm/__snapshots__/confirm.test.tsx.snapChangelog
CHANGELOG entry: null
Related issues
Fixes: MMQA-1908
Fixes: MMQA-325
Manual testing steps
checkTitle):Confirm both NFT permit tests pass:
initiates and confirms and emits the correct eventsinitiates and rejects and emits the correct eventsRun unit tests for components with updated test IDs:
Screenshots/Recordings
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Changes are limited to E2E page objects, test specs, and additive data-testid attributes on confirmation UI with snapshot updates; no signing or transaction logic changes.
Overview
Refactors permit signature E2E coverage and adds stable
data-testidhooks on confirmation UI so tests can assert origin, titles, and typed-data fields reliably.PermitConfirmationis rebuilt as a thin page object: hardcodedverify*helpers are replaced with parameterizedcheck*methods that usewaitForSelectorand locator factories (origin,primaryType,dataTreeRowWithText, etc.). NFT and ERC-20 permit specs now pass expected strings from the spec into those methods instead of baking values into the page object.Confirmation UI gains test IDs on the request origin (
confirmation__details-origininurl.tsx), confirm title/description (confirm-title-text,confirm-title-description), and primary type (confirmation__message-primary-type). Jest snapshots are updated accordingly.sign.flow.tsanderc721-approve-redesign.spec.tscall the renamed API (e.g.checkOrigin(DAPP_HOST_ADDRESS),checkTitle('Withdrawal request')).nft-permit.spec.tsusesPermitConfirmationend-to-end and aligns post-confirm assertions withpermit.spec.ts.Reviewed by Cursor Bugbot for commit 69d93b0. Bugbot is set up for automated code reviews on this repo. Configure here.