Files
05cab32f0e tests(web): connect wallet via seeded storage in e2e (#8350)
* tests(web): connect wallet via seeded storage in e2e

Replace the UI-driven connectSigner flow with storage-seeded auto-reconnect
across the Cypress suite. Adds connectSignerViaStorage (seed on visit, or seed
+ reload) and migrates 139 entry connects; keeps UI connectSigner for the 27
connect/switch-flow sites that act on in-page state.

* tests(web): seed batch via single page load in batch e2e

Add optional extraStorage to connectSignerViaStorage so localStorage is
seeded in onBeforeLoad on the initial visit. Split batch_tx into
build-via-UI and pre-seeded describes, dropping addToLocalStorage +
cy.reload() double-loads.

* tests(web): seed state on a single page load across e2e specs

Replace visit-then-write-then-reload double-loads with a single seeded
load (extraStorage on connectSignerViaStorage, or onBeforeLoad on
cy.visit), and drop the arbitrary post-reload settle waits. Covers the
multichain, nested-safes, batch, address-book, safe-selector and
create-safe specs (regression, smoke, visual).

* tests(web): seed state on a single page load in more e2e specs

Fold pre-seeded localStorage into the initial visit (extraStorage /
onBeforeLoad) and drop the follow-up reloads across the address-book,
messages-popup, CF-safe, import/export and load-safe specs. Split specs
whose shared beforeEach served both seeding and non-seeding tests into
nested describes so no test double-loads.

* tests(web): remove redundant wallet reconnect reloads in e2e specs

Pass the URL to connectSignerViaStorage so the wallet is seeded on the
initial visit instead of visiting then reconnecting (which reloaded).
Where a shared beforeEach served both connected and disconnected (or
differently-seeded) tests, split into nested describes so no test
double-loads. Covers proposers, swaps, twaps, assets, swaps_tokens,
sidebar, spending_limits, bulk_execution, proposers_2, safe_selector.

* tests(web): single-load owner-management e2e specs

Split add/remove/replace-owner specs into connected / disconnected /
non-owner / pre-seeded describes so the wallet is seeded on the initial
visit (no reconnect reload) without forcing a connect onto tests that
assert disconnected or non-owner state.

* tests(web): wait for wallet connection after seeded connect

The last wallet reconnects asynchronously after the page loads, so
connectSignerViaStorage now waits for the connected-wallet header chip
(open-account-center) before resolving, instead of letting tests proceed
while still disconnected. Opt out via waitForConnection:false for pages
without that chip (welcome/accounts in safe_selector).

* tests(web): address review on seeded-connect PR

- Drop the explicit 30s timeout on the connected-wallet wait; the repo
  default (10s) is plenty for the post-load reconnect and fails faster.
- Make recovery.cy.js consistent: the remaining connectSigner calls now
  use connectSignerViaStorage like the rest of the file. All connects are
  at test start (none mid-flow), matching the already-converted tests.

* fix: wait for the wallet connection to establish to avoid failing tests due to disconnected wallet

---------

Co-authored-by: vmosharova <[email protected]>
2026-07-31 17:00:56 +02:00

117 lines
4.3 KiB
JavaScript

import * as constants from '../../support/constants'
import * as main from '../pages/main.page'
import * as safe from '../pages/load_safe.pages'
import * as ls from '../../support/localstorage_data.js'
import * as owner from '../pages/owners.pages'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'
import { getMockAddress } from '../../support/utils/ethers.js'
let staticSafes,
fundSafes = []
const ownerNames = ['Automation owner']
const ownerSepolia = ['Automation owner Sepolia']
const ownerEth = ['Automation owner Eth']
const seedStorage = (entries) => (win) => {
Object.entries(entries).forEach(([key, value]) => win.localStorage.setItem(key, JSON.stringify(value)))
}
describe('Load Safe tests 2', () => {
before(() => {
getSafes(CATEGORIES.funds)
.then((funds) => {
fundSafes = funds
return getSafes(CATEGORIES.static)
})
.then((statics) => {
staticSafes = statics
})
})
describe('Without pre-seeded data', () => {
beforeEach(() => {
cy.visit(constants.loadNewSafeSepoliaUrl)
cy.wait(2000)
})
it('Verify Safe address checksum', () => {
safe.verifyAddressCheckSum(staticSafes.SEP_STATIC_SAFE_13)
safe.verifyAddressInputValue(staticSafes.SEP_STATIC_SAFE_13)
safe.inputAddress(staticSafes.SEP_STATIC_SAFE_13.split(':')[1].toLowerCase())
safe.verifyAddressInputValue(staticSafes.SEP_STATIC_SAFE_13)
})
it('Verify owner name cannot be longer than 50 characters', () => {
safe.inputAddress(staticSafes.SEP_STATIC_SAFE_13)
safe.clickOnNextBtn()
safe.inputOwnerName(0, main.generateRandomString(51))
owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.exceedChars)
})
it('Verify names with primary ENS name are filled by default', () => {
safe.inputAddress(staticSafes.SEP_STATIC_SAFE_13)
safe.clickOnNextBtn()
safe.verifyOnwerNameENS(1, constants.ENS_TEST_SEPOLIA_VALID)
})
it('Verify random text is in the safe address input is not allowed', () => {
safe.inputAddress(main.generateRandomString(10))
owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.invalidFormat)
})
it('Verify a valid address can be entered', () => {
safe.inputAddress(getMockAddress())
safe.verifyAddresFormatIsValid()
})
it('Verify that the wrong prefix is not allowed', () => {
safe.inputAddress(`eth:${getMockAddress()}`)
owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.prefixMismatch)
safe.verifyNextButtonStatus(constants.enabledStates.disabled)
})
})
describe('With pre-seeded data', () => {
it('Verify names in address book are filled by default from address book', () => {
cy.visit(constants.loadNewSafeSepoliaUrl, {
onBeforeLoad: seedStorage({
[constants.localStorageKeys.SAFE_v2__addressBook]: ls.addressBookData.sameOwnerName,
}),
})
safe.inputAddress(staticSafes.SEP_STATIC_SAFE_13)
safe.clickOnNextBtn()
safe.verifyOwnerNames(ownerNames)
safe.verifyOnwerInputIsNotEmpty(0)
})
it('Verify correct owner names are displayed for certain networks', () => {
cy.visit(constants.loadNewSafeSepoliaUrl, {
onBeforeLoad: seedStorage({
[constants.localStorageKeys.SAFE_v2__addressBook]: ls.addressBookData.sameOwnerName,
}),
})
safe.clickNetworkSelector(constants.networks.sepolia)
safe.selectEth()
safe.inputAddress(fundSafes.ETH_FUNDS_SAFE_13)
safe.clickOnNextBtn()
safe.verifyOwnerNames(ownerEth)
safe.clickOnBackBtn()
safe.clickNetworkSelector(constants.networks.ethereum)
safe.selectSepolia()
safe.inputAddress(staticSafes.SEP_STATIC_SAFE_13)
safe.clickOnNextBtn()
safe.verifyOwnerNames(ownerSepolia)
})
it('Verify that safes already added to the watchlist cannot be added again', () => {
cy.visit(constants.loadNewSafeSepoliaUrl, {
onBeforeLoad: seedStorage({ [constants.localStorageKeys.SAFE_v2__addedSafes]: ls.addedSafes.set1 }),
})
safe.inputAddress(staticSafes.SEP_STATIC_SAFE_13)
owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.safeAlreadyAdded)
safe.verifyNextButtonStatus(constants.enabledStates.disabled)
})
})
})