feat: Add E2E test for storage operations failure recovery#39317
feat: Add E2E test for storage operations failure recovery#39317itsyoboieltr merged 12 commits intomainfrom
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. |
|
|
||
| return accountAddress; | ||
| } | ||
|
|
There was a problem hiding this comment.
These are all moved to helpers.ts file
| getConfig(this.test?.title), | ||
| async ({ driver }: { driver: Driver }) => { | ||
| const initialFirstAddress = await onboardThenCorruptVault( | ||
| const initialFirstAddress = await onboardThenTriggerCorruption( |
There was a problem hiding this comment.
onboardThenCorruptVault has just been renamed into onboardThenTriggerCorruption to have a more generic name that's more compatible with new E2E test scenarios we're adding in this PR (we're not specifically corrupting the vault, we're corrupting/breaking the database).
Builds ready [d098277]
UI Startup Metrics (1286 ± 113 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [801f437]
UI Startup Metrics (1255 ± 99 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [d256427]
UI Startup Metrics (1272 ± 104 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
| await homePage.checkPageIsLoaded(); | ||
|
|
||
| // The toast should appear because writes are failing | ||
| await driver.waitForSelector('[data-testid="storage-error-toast"]'); |
There was a problem hiding this comment.
we should avoid using selectors directly in a spec file. Rather, we should create a method in the corresponding page object class, and then call it from here
There was a problem hiding this comment.
thanks for the feedback, it's now updated in this commit: 76903ac
| // Click the toast action button to navigate to reveal SRP page | ||
| // The button text is inside a nested span, so we target the span's text | ||
| await driver.clickElement({ | ||
| text: 'Back up Secret Recovery Phrase', |
| }); | ||
|
|
||
| // Verify we navigated to the reveal SRP page (password prompt) | ||
| await driver.waitForSelector('[data-testid="input-password"]'); |
Move vault recovery-specific selectors and methods from helpers.ts to a new VaultRecoveryPage class that extends CriticalErrorPage, following the page object pattern with separation of concerns by feature. Changes: - Create VaultRecoveryPage with recovery button methods - Revert CriticalErrorPage to base error page functionality - Change CriticalErrorPage fields from private to protected for inheritance - Update helpers.ts to use VaultRecoveryPage
✨ Files requiring CODEOWNER review ✨🧪 @MetaMask/qa (4 files, +249 -10)
|
Builds ready [0205518]
UI Startup Metrics (1287 ± 101 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
seaona
left a comment
There was a problem hiding this comment.
hi there 👋 thanks for the changes! Looking good! I added a couple of more comments in regards to stick withthe page object standard practices using flows🙏
Let me know if this makes sense or have any questions!
| password: WALLET_PASSWORD, | ||
| skipSRPBackup: true, | ||
| }); | ||
| } |
There was a problem hiding this comment.
instead of having a helper function which just calls a flow, can we call the flow directly in the spec file?
In our spec files we should try to use page objects methods or flows (under flow folder). Adding extra layers on top can make it harded to debug, when we are investigating flakiness etc.
The general POM guidelines for performing test actions are eitherto work with:
- page objects
- flows
So we could remove this wrapper. Wdyt?
There was a problem hiding this comment.
Makes total sense, it's updated in this commit: 4a60f05
| }); | ||
|
|
||
| // now that we are re-onboarded, get the first account's address | ||
| return await getFirstAddress(driver); |
There was a problem hiding this comment.
same here, could we omit this extra layer onboardAfterRecovery and call the inside flows in the spec file?
There was a problem hiding this comment.
Same here, updated in this commit: 4a60f05
| */ | ||
| async function waitForVaultRestorePage(driver: Driver): Promise<void> { | ||
| const vaultRecoveryPage = new VaultRecoveryPage(driver); | ||
| await vaultRecoveryPage.waitForPageAfterExtensionReload(); |
There was a problem hiding this comment.
Same here, updated in this commit: 4a60f05
| * background page for MV2 or offscreen page for MV3. | ||
| * @returns The initial first account's address. | ||
| */ | ||
| export async function onboardThenTriggerCorruption( |
There was a problem hiding this comment.
could we place this under the page-objects/flow folder? to follow our POM guidelines -> if there are actions which need multiple pages, and it's re-used in multiple places, we can create a flow for that
There was a problem hiding this comment.
Sure, it's now moved to the flow folder in this commit: e560fb0
| * @param options.driver - The WebDriver instance. | ||
| * @param options.confirm - Whether to confirm the action or not. | ||
| */ | ||
| export async function clickRecover({ |
There was a problem hiding this comment.
this abstraction can also be removed and instead, call the actions from the spec file
There was a problem hiding this comment.
Same here, updated in this commit: 4a60f05
| * @param driver - The WebDriver instance. | ||
| * @param headerNavbar | ||
| */ | ||
| export async function getFirstAddress( |
There was a problem hiding this comment.
it seems like we need a flow here as well
There was a problem hiding this comment.
Same here, moved to the flow folder in this commit: e560fb0
Remove wrapper functions that just call flows/page objects directly, following POM guidelines to reduce indirection and improve debuggability. Removed wrappers: - onboard() - now call completeCreateNewWalletOnboardingFlow directly - clickRecover() - now call vaultRecoveryPage.clickRecoveryButton directly - onboardAfterRecovery() - now call flow + getFirstAddress directly - waitForVaultRestorePage() - inlined in onboardThenTriggerCorruption Spec files now import and use flows/page objects directly.
Move multi-page orchestration functions to page-objects/flows following POM guidelines for reusable flows that span multiple pages. Changes: - Create vault-corruption.flow.ts with getFirstAddress and onboardThenTriggerCorruptionFlow - Reduce helpers.ts to only contain getConfig test configuration - Update spec files to import from the new flow file
Builds ready [69d22bb]
UI Startup Metrics (1304 ± 117 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs
|
| * | ||
| * @throws Error if simulating storage failure for testing | ||
| */ | ||
| #maybeSimulateSetFailure(): void { |
There was a problem hiding this comment.
Why is the set failure in its own function but not the get failure? This is not a request for change in either direction, just curious.
There was a problem hiding this comment.
The get failure is only called in one method (get).
The set failure is called from two different methods (set and persist), so extracting logic to a separate function (maybeSimulateSetFailure) avoids code duplication.
Description
This PR is a follow-up PR for #39010
It adds E2E tests
Changelog
CHANGELOG entry: null
Related issues
Fixes: #10091
Manual testing steps
Screenshots/Recordings
NA
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Adds targeted E2E tests to validate recovery behavior when
browser.storage.localoperations fail, plus supporting test hooks and small UI/test utilities.storage-operations-failure.spec.tsverifies vault recovery on simulatedget()failure and storage error toast on simulatedset()failure; refactorsvault-corruption.spec.tsto reuse shared flowstesting.simulateStorageGetFailureandtesting.simulateStorageSetFailureinmanifestFlags.ts#getFromLocalStore,#setInLocalStore,#setKeyValuesInLocalStorewith optional failure simulation; integrates intoget,set, andpersistVaultRecoveryPage, sharedvault-corruption.flow.ts, and helpers; updatesCriticalErrorPagevisibility for reusedata-testid="storage-error-toast"to the storage error toast and page object methods to assert and act on itWritten by Cursor Bugbot for commit 69d22bb. This will update automatically on new commits. Configure here.