Skip to content

Commit

Permalink
fix: Extend e2e test, preserve query params when navigating the user
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan committed Oct 26, 2023
1 parent 609e9e3 commit 6ee7cd8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
5 changes: 5 additions & 0 deletions cypress/e2e/pages/create_wallet.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const thresholdInput = 'input[name="threshold"]'
export const removeOwnerBtn = 'button[aria-label="Remove owner"]'
const connectingContainer = 'div[class*="connecting-container"]'
const createNewSafeBtn = 'span[data-track="create-safe: Continue to creation"]'
const connectWalletBtn = 'Connect wallet'

const changeNetworkWarningStr = 'Change your wallet network'
const safeAccountSetupStr = 'Safe Account setup'
Expand Down Expand Up @@ -49,6 +50,10 @@ export function clickOnCreateNewSafeBtn() {
cy.get(createNewSafeBtn).click().wait(1000)
}

export function clickOnConnectWalletAndCreateBtn() {
cy.contains('[data-testid="welcome-login"]', connectWalletBtn).click().wait(1000)
}

export function typeWalletName(name) {
cy.get(nameInput).type(name).should('have.value', name)
}
Expand Down
18 changes: 10 additions & 8 deletions cypress/e2e/smoke/create_safe_simple.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ describe('Create Safe tests', () => {
main.acceptCookies()
})

it('C55742: Verify a Wallet can be connected', () => {
/** TODO: Update this for the new safe creation flow
* e.g. connect and observe being navigated to the create safe page
* disconnect and observe being on the welcome page again
*/
it.only('C55742: Verify a Wallet can be connected', () => {
createwallet.clickOnCreateNewSafeBtn()
owner.clickOnWalletExpandMoreIcon()
owner.clickOnDisconnectBtn()
cy.url().should('include', constants.welcomeUrl)
createwallet.clickOnConnectWalletAndCreateBtn()
createwallet.connectWallet()
cy.url().should('include', constants.createNewSafeSepoliaUrl)
})

it('C55743: Verify Next button is disabled until switching to network is done', () => {
it.only('C55743: Verify Next button is disabled until switching to network is done', () => {
owner.waitForConnectionStatus()
createwallet.selectNetwork(constants.networks.ethereum)
createwallet.checkNetworkChangeWarningMsg()
Expand All @@ -30,12 +32,12 @@ describe('Create Safe tests', () => {
createwallet.verifyNextBtnIsEnabled()
})

it('C32378: Verify that a new Wallet has default name related to the selected network', () => {
it.only('C32378: Verify that a new Wallet has default name related to the selected network', () => {
owner.waitForConnectionStatus()
createwallet.verifyDefaultWalletName(createwallet.defaltSepoliaPlaceholder)
})

it('C4790: Verify error message is displayed if wallet name input exceeds 50 characters', () => {
it.only('C4790: Verify error message is displayed if wallet name input exceeds 50 characters', () => {
owner.waitForConnectionStatus()
createwallet.typeWalletName(main.generateRandomString(51))
owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.exceedChars)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('useSyncSafeCreationStep', () => {
renderHook(() => useSyncSafeCreationStep(mockSetStep))

expect(mockSetStep).not.toHaveBeenCalled()
expect(mockPushRoute).toHaveBeenCalledWith(AppRoutes.welcome)
expect(mockPushRoute).toHaveBeenCalledWith({ pathname: AppRoutes.welcome, query: undefined })
})

it('should go to the fourth step if there is a pending safe', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/new-safe/create/useSyncSafeCreationStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const useSyncSafeCreationStep = (setStep: StepRenderProps<NewSafeFormData>['setS

// Jump to connect wallet step if there is no wallet and no pending Safe
if (!wallet) {
router.push(AppRoutes.welcome)
router.push({ pathname: AppRoutes.welcome, query: router.query })
}

// Jump to choose name and network step if the wallet is connected to the wrong chain and there is no pending Safe
Expand Down
4 changes: 2 additions & 2 deletions src/components/welcome/WelcomeLogin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ const WelcomeLogin = () => {

const continueToCreation = () => {
trackEvent(CREATE_SAFE_EVENTS.OPEN_SAFE_CREATION)
router.push(AppRoutes.newSafe.create)
router.push({ pathname: AppRoutes.newSafe.create, query: router.query })
}

return (
<Paper className={css.loginCard}>
<Paper className={css.loginCard} data-testid="welcome-login">
<Box className={css.loginContent}>
<SvgIcon component={SafeLogo} inheritViewBox sx={{ height: '24px', width: '80px' }} />
<Typography variant="h6" mt={6} fontWeight={700}>
Expand Down

0 comments on commit 6ee7cd8

Please sign in to comment.