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

100 lines
3.9 KiB
JavaScript

import * as constants from '../../support/constants.js'
import * as addressBook from '../pages/address_book.page.js'
import * as ls from '../../support/localstorage_data.js'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'
import * as wallet from '../../support/utils/wallet.js'
let staticSafes = []
const NAME = 'Owner1'
const NAME_2 = 'Owner2'
const EDITED_NAME = 'Edited Owner1'
const duplicateEntry = 'test-sepolia-90'
const owner1 = 'Automation owner'
const walletCredentials = JSON.parse(Cypress.env('CYPRESS_WALLET_CREDENTIALS'))
const signer = walletCredentials.OWNER_4_PRIVATE_KEY
const recipientData = [owner1, constants.DEFAULT_OWNER_ADDRESS]
describe('Address book tests - 3', () => {
before(async () => {
staticSafes = await getSafes(CATEGORIES.static)
})
describe('Without pre-seeded data', () => {
beforeEach(() => {
cy.visit(constants.addressBookUrl + staticSafes.SEP_STATIC_SAFE_4)
})
it('Verify entry can be added', () => {
addressBook.clickOnCreateEntryBtn()
addressBook.addEntry(NAME, constants.RECIPIENT_ADDRESS)
})
it('Verify csv file can be imported', () => {
addressBook.clickOnImportFileBtn()
addressBook.importCSVFile(addressBook.validCSVFile)
addressBook.verifyImportBtnStatus(constants.enabledStates.enabled)
addressBook.clickOnImportBtn()
addressBook.verifyDataImported(addressBook.entries)
addressBook.verifyNumberOfRows(4)
})
it('Import a csv file with an empty address/name/network in one row', () => {
addressBook.clickOnImportFileBtn()
addressBook.importCSVFile(addressBook.emptyCSVFile)
addressBook.verifyImportBtnStatus(constants.enabledStates.disabled)
addressBook.verifyUploadExportMessage([addressBook.uploadErrorMessages.emptyFile])
})
it('Import a non-csv file', () => {
addressBook.clickOnImportFileBtn()
addressBook.importCSVFile(addressBook.nonCSVFile)
addressBook.verifyImportBtnStatus(constants.enabledStates.disabled)
addressBook.verifyUploadExportMessage([addressBook.uploadErrorMessages.fileType])
})
it('Import a csv file with a repeated address and same network', () => {
addressBook.clickOnImportFileBtn()
addressBook.importCSVFile(addressBook.duplicatedCSVFile)
addressBook.verifyImportBtnStatus(constants.enabledStates.enabled)
addressBook.clickOnImportBtn()
addressBook.verifyDataImported([duplicateEntry])
addressBook.verifyNumberOfRows(1)
})
it('Verify modal shows the amount of entries and networks detected', () => {
addressBook.clickOnImportFileBtn()
addressBook.importCSVFile(addressBook.networksCSVFile)
addressBook.verifyImportBtnStatus(constants.enabledStates.enabled)
addressBook.verifyModalSummaryMessage(4, 3)
})
it('Verify an entry can be added by ENS name', () => {
addressBook.clickOnCreateEntryBtn()
addressBook.addEntryByENS(NAME_2, constants.ENS_TEST_SEPOLIA)
})
})
describe('With pre-seeded data', () => {
const seedAddressBook = (value) => (win) =>
win.localStorage.setItem(constants.localStorageKeys.SAFE_v2__addressBook, JSON.stringify(value))
it('Verify entry can be deleted', () => {
cy.visit(constants.addressBookUrl + staticSafes.SEP_STATIC_SAFE_4, {
onBeforeLoad: seedAddressBook(ls.addressBookData.sepoliaAddress1),
})
addressBook.clickDeleteEntryButton()
addressBook.clickDeleteEntryModalDeleteButton()
addressBook.verifyEditedNameNotExists(EDITED_NAME)
})
it('Verify clicking on Send button autofills the recipient filed with correct value', () => {
wallet.connectSignerViaStorage(signer, constants.addressBookUrl + staticSafes.SEP_STATIC_SAFE_4, {
extraStorage: { [constants.localStorageKeys.SAFE_v2__addressBook]: ls.addressBookData.sepoliaAddress2 },
})
addressBook.clickOnSendBtn()
addressBook.verifyRecipientData(recipientData)
})
})
})