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

208 lines
7.9 KiB
JavaScript

import * as constants from '../../support/constants.js'
import * as space from '../pages/spaces.page.js'
import * as wallet from '../../support/utils/wallet.js'
import staticSpaces from '../../fixtures/spaces/staticSpaces.js'
const walletCredentials = JSON.parse(Cypress.env('CYPRESS_WALLET_CREDENTIALS'))
const owner = walletCredentials.OWNER_1_PRIVATE_KEY
describe('Spaces dashboard tests', () => {
beforeEach(() => {
wallet.connectSignerViaStorage(owner, constants.spacesUrl)
space.clickOnSignInBtn()
space.waitForSpacesWelcomeReady()
space.visitSpaceDashboard(staticSpaces.dashboardWithSafes.uuid)
})
// ===========================================
// Spaces Dashboard
// ===========================================
it('Verify that the Space dashboard loads correctly after login for a user with an existing Space and Safes', () => {
space.verifySpaceDashboardTotalValueFormat()
space.verifySpaceDashboardWidgetVisible('Accounts')
space.verifySpaceDashboardAccountsWidgetRowCount(3)
space.verifySpaceDashboardWidgetVisible('Pending')
space.verifyPendingTxWidgetItemCount(3)
})
// ===========================================
// Accounts Widget
// ===========================================
it('Verify that a click on a single-chain account row opens that Safe dashboard with URL and header', () => {
space.verifySpaceDashboardWidgetVisible('Accounts')
const row = staticSpaces.dashboardWithSafes.pendingTxAccount
space.clickSingleChainAccountRow()
space.verifyOpenedSafeDashboardFromSpaceAccountsRow({
safeFullQuery: row.safeUrlParam,
expectedName: row.name,
fullAddress: row.address,
chainShortName: row.chainShortName,
balanceRegex: space.nonZeroBalanceRegex,
ownersThreshold: row.ownersThreshold,
})
})
it('Verify that clicking View all accounts in the Accounts widget opens the Accounts tab of the Space', () => {
space.verifySpaceDashboardWidgetVisible('Accounts')
space.clickViewAllAccounts()
space.verifyViewAllAccountsPageOpened(staticSpaces.dashboardWithSafes.safeAccountsPageCount)
})
// ===========================================
// Space-level Sidebar Navigation
// ===========================================
describe('Space-level Sidebar', () => {
it('Verify that clicking each Space-level sidebar item navigates to the correct page', () => {
space.verifySidebarItemNavigates(space.sidebarItemAccounts, '/spaces/safe-accounts')
space.verifySidebarItemNavigates(space.sidebarItemAddressBook, '/spaces/address-book')
space.verifySidebarItemNavigates(space.sidebarItemTeam, '/spaces/members')
space.verifySidebarItemNavigates(space.sidebarItemSettings, '/spaces/settings')
space.verifySidebarItemNavigates(space.sidebarItemDashboard, '/spaces')
})
it('Verify that the sidebar correctly switches from Space-level to Safe-level navigation when entering a Safe', () => {
const safeData = staticSpaces.dashboardWithSafes.pendingTxAccount
// Precondition: space sidebar is visible
space.verifySpaceSidebarItemsVisible()
// Action: click on a safe in the accounts widget
space.verifySpaceDashboardWidgetVisible('Accounts')
space.clickSingleChainAccountRow()
space.verifySpaceSidebarItemsNotVisible()
space.verifySafeLevelNavigationElements()
})
})
// ===========================================
// Space Selector
// ===========================================
describe('Space Selector', () => {
it('Verify that the Space selector dropdown lists all Spaces belonging to the user', () => {
space.clickOnSpaceSelector()
space.verifySpaceSelectorMenuVisible()
space.verifySpaceSelectorContainsSpaces([
staticSpaces.dashboardWithSafes.name,
staticSpaces.emptyGettingStarted.name,
])
})
})
})
/*
Safe Selector through Spaces empty dashboard: commented out; remove this block comment to restore.
// ===========================================
// Safe Selector
// ===========================================
describe('Safe Selector', () => {
it('Verify that the Safe selector shows all Safes in the current Space', () => {
space.verifySpaceDashboardWidgetVisible('Accounts')
space.verifySpaceDashboardAccountsWidgetRowCount(staticSpaces.dashboardWithSafes.accountsWidgetRowCount)
})
it('Verify that the Back to Space button is visible in the sidebar and returns the user to Space Home', () => {
space.verifySpaceDashboardWidgetVisible('Accounts')
space.clickAccountItemByIndex(0)
space.verifyUrlIncludesPath('/home')
space.verifyBackToSpaceButtonVisible()
space.clickBackToSpaceButton()
space.verifyUrlIncludesPath('/spaces')
})
})
// ===========================================
// Deep Links & Routing
// ===========================================
describe('Deep Links & Routing', () => {
it('Verify that a direct Safe URL loads without SIWE and without Space context', () => {
cy.visit('/home?safe=sep:0x1694CbDE1b30eEdd9f7A2b6C7e36A180F2a3a23C7')
cy.contains('Transactions').should('be.visible')
space.verifySafeUrlIncludesParam('sep:0x1694CbDE1b30eEdd9f7A2b6C7e36A180F2a3a23C7')
space.verifySpaceSidebarItemsNotVisible()
})
it('Verify that accessing the app without being logged in redirects to the welcome page', () => {
cy.clearAllCookies()
cy.clearAllLocalStorage()
space.visitSpaceDashboard(staticSpaces.dashboardWithSafes.uuid)
cy.contains('Welcome').should('be.visible')
space.verifyUrlIncludesPath('/welcome')
})
})
// ===========================================
// Disconnect
// ===========================================
describe('Disconnect', () => {
it('Verify that disconnect in the top bar clears session and routes user to the Welcome page', () => {
space.verifySpaceDashboardWidgetVisible('Accounts')
space.disconnectFromSpaceLevel()
cy.contains('Welcome').should('be.visible')
space.verifyUrlIncludesPath('/welcome')
})
})
describe('Spaces empty dashboard tests', () => {
beforeEach(() => {
wallet.connectSignerViaStorage(owner, constants.spacesUrl)
space.clickOnSignInBtn()
space.visitSpaceDashboard(staticSpaces.emptyGettingStarted.uuid)
})
describe('Empty State - Getting Started', () => {
it('Verify that the empty Space dashboard displays the Getting started page', () => {
cy.contains(space.gettingStartedLabel).should('be.visible')
cy.contains(space.addSafeAccountsLabel).should('be.visible')
})
it('Verify that the Accounts widget shows an empty state when no Safes are in the Space', () => {
cy.contains(space.gettingStartedLabel).should('be.visible')
cy.get(space.dashboardSafeList).should('not.exist')
})
it('Verify that clicking Add account opens the add accounts flow', () => {
cy.contains(space.gettingStartedLabel).should('be.visible')
cy.get(space.addAccountBtn).should('be.visible').click()
cy.contains(space.addAccountsModalLabel).should('be.visible')
})
it('Verify that clicking Import address book opens the import dialog', () => {
cy.contains(space.gettingStartedLabel).should('be.visible')
cy.get(space.importAddressBookBtn).should('be.visible').click()
cy.contains(space.importAddressBookLabel).should('be.visible')
})
it('Verify that clicking Add members opens the add member modal', () => {
cy.contains(space.gettingStartedLabel).should('be.visible')
cy.get(space.dashboardAddMemberBtn).should('be.visible').click()
cy.contains(space.inviteMemberLabel).should('be.visible')
})
it('Verify that clicking Learn more opens the Explore spaces info modal', () => {
cy.contains(space.gettingStartedLabel).should('be.visible')
cy.get(space.learnMoreBtn).should('be.visible').click()
cy.contains(space.exploreSpacesLabel).should('be.visible')
})
})
})
*/