From 07eb9eb9a299075e367ae6227530dfd55e1560ae Mon Sep 17 00:00:00 2001 From: eddie <66155195+just-toby@users.noreply.github.com> Date: Thu, 6 Jul 2023 14:01:13 -0700 Subject: [PATCH] fix: combine userState with default injected wallet in cypress setup (#6849) * fix: combine userState with default injected wallet in cypress setup * fix: unconnected state in two tests * fix: update name --- cypress/e2e/landing.test.ts | 4 ++-- cypress/e2e/wallet-connection/connect.test.ts | 3 ++- cypress/support/commands.ts | 2 +- cypress/utils/user-state.ts | 2 ++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/landing.test.ts b/cypress/e2e/landing.test.ts index df7fa9e43b..acdcd02a35 100644 --- a/cypress/e2e/landing.test.ts +++ b/cypress/e2e/landing.test.ts @@ -1,9 +1,9 @@ import { getTestSelector } from '../utils' -import { CONNECTED_WALLET_USER_STATE } from '../utils/user-state' +import { CONNECTED_WALLET_USER_STATE, DISCONNECTED_WALLET_USER_STATE } from '../utils/user-state' describe('Landing Page', () => { it('shows landing page when no user state exists', () => { - cy.visit('/', { userState: {} }) + cy.visit('/', { userState: DISCONNECTED_WALLET_USER_STATE }) cy.get(getTestSelector('landing-page')) cy.screenshot() }) diff --git a/cypress/e2e/wallet-connection/connect.test.ts b/cypress/e2e/wallet-connection/connect.test.ts index ace3d6b185..7e5e4a22fd 100644 --- a/cypress/e2e/wallet-connection/connect.test.ts +++ b/cypress/e2e/wallet-connection/connect.test.ts @@ -1,4 +1,5 @@ import { getTestSelector } from '../../utils' +import { DISCONNECTED_WALLET_USER_STATE } from '../../utils/user-state' describe('disconnect wallet', () => { it('should clear state', () => { @@ -27,7 +28,7 @@ describe('disconnect wallet', () => { describe('connect wallet', () => { it('should load state', () => { - cy.visit('/swap', { ethereum: 'hardhat', userState: {} }) + cy.visit('/swap', { ethereum: 'hardhat', userState: DISCONNECTED_WALLET_USER_STATE }) // Connect the wallet cy.get(getTestSelector('navbar-connect-wallet')).contains('Connect').click() diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 63ec3b47a6..99c75f5403 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -58,7 +58,7 @@ Cypress.Commands.overwrite( // Set initial user state. win.localStorage.setItem( 'redux_localstorage_simple_user', // storage key for the user reducer using 'redux-localstorage-simple' - JSON.stringify(options?.userState ?? CONNECTED_WALLET_USER_STATE) + JSON.stringify({ ...CONNECTED_WALLET_USER_STATE, ...(options?.userState ?? {}) }) ) // Set feature flags, if configured. diff --git a/cypress/utils/user-state.ts b/cypress/utils/user-state.ts index 1e44e9bf6b..0b4b54c1d6 100644 --- a/cypress/utils/user-state.ts +++ b/cypress/utils/user-state.ts @@ -1,3 +1,5 @@ import { UserState } from '../../src/state/user/reducer' export const CONNECTED_WALLET_USER_STATE: Partial = { selectedWallet: 'INJECTED' } + +export const DISCONNECTED_WALLET_USER_STATE: Partial = { selectedWallet: undefined }