Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Create safe e2e test #1500

Merged
merged 11 commits into from
Jan 9, 2023
5 changes: 5 additions & 0 deletions .github/workflows/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ inputs:
description: 'Production build flag'
required: false

e2e_mnemonic:
description: 'Mnemonic for the E2E tests'
required: false

runs:
using: 'composite'
steps:
Expand All @@ -30,3 +34,4 @@ runs:
NEXT_PUBLIC_TENDERLY_PROJECT_NAME: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_TENDERLY_PROJECT_NAME }}
NEXT_PUBLIC_TENDERLY_SIMULATE_ENDPOINT_URL: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_TENDERLY_SIMULATE_ENDPOINT_URL }}
NEXT_PUBLIC_WC_BRIDGE: ${{ fromJSON(inputs.secrets).NEXT_PUBLIC_WC_BRIDGE }}
NEXT_PUBLIC_CYPRESS_MNEMONIC: ${{ inputs.e2e_mnemonic }}
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
- uses: ./.github/workflows/build
with:
secrets: ${{ toJSON(secrets) }}
e2e_mnemonic: ${{ secrets.NEXT_PUBLIC_CYPRESS_MNEMONIC }}

- name: Serve
run: yarn serve &
Expand All @@ -36,4 +37,3 @@ jobs:
config: baseUrl=http://localhost:8080
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
CYPRESS_MNEMONIC: ${{ secrets.NEXT_PUBLIC_CYPRESS_MNEMONIC }}
2 changes: 1 addition & 1 deletion .github/workflows/safe-apps-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- uses: ./.github/workflows/build
with:
secrets: ${{ toJSON(secrets) }}
e2e_mnemonic: ${{ secrets.NEXT_PUBLIC_CYPRESS_MNEMONIC }}

- name: Serve
run: yarn serve &
Expand All @@ -38,4 +39,3 @@ jobs:
env:
CYPRESS_PROJECT_ID: okn21k
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_SAFE_APPS_RECORD_KEY }}
CYPRESS_MNEMONIC: ${{ secrets.NEXT_PUBLIC_CYPRESS_MNEMONIC }}
4 changes: 0 additions & 4 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ export default defineConfig({
projectId: 'exhdra',
trashAssetsBeforeRuns: true,

env: {
CYPRESS_MNEMONIC: process.env.CYPRESS_MNEMONIC,
},

retries: {
runMode: 2,
openMode: 0,
Expand Down
14 changes: 3 additions & 11 deletions cypress/e2e/create_safe.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,16 @@ describe('Create Safe', () => {
cy.contains('button', 'Accept all').click()

// Ensure wallet is connected to correct chain via header
cy.contains('E2E Wallet @ Rinkeby')
cy.contains('E2E Wallet @ Görli')

cy.contains('Create new Safe').click()

// Connect wallet & select network
cy.contains('Continue').click()

// Name
cy.wait(1000) // Wait for form default values to populate
cy.contains('button', 'Continue').click()
cy.contains('button', 'Next').click()

// Owners and confirmations
cy.wait(1000) // Wait for form default values to populate
cy.contains('button', 'Continue').click()

// Review
cy.wait(1000) // Not sure why without this ends with "Transaction underpriced"
cy.contains('button', 'Create').click()
cy.contains('Your Safe was successfully created!', { timeout: 60000 })
cy.contains('button', 'Next').click()
})
})
60 changes: 60 additions & 0 deletions cypress/e2e/smoke/create_safe_form.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const DEFAULT_OWNER_ADDRESS = '0xC16Db0251654C0a72E91B190d81eAD367d2C6fED'
const OWNER_ADDRESS = '0xE297437d6b53890cbf004e401F3acc67c8b39665'

describe('Create Safe form', () => {
before(() => {
localStorage.setItem('SAFE_v2__lastWallet', JSON.stringify('E2E Wallet'))
})
it('should navigate to the form', () => {
//cy.connectE2EWallet()

cy.visit('/welcome')

// Close cookie banner
cy.contains('button', 'Accept all').click()

// Ensure wallet is connected to correct chain via header
cy.contains('E2E Wallet @ Görli')

cy.contains('Create new Safe').click()
})

it('should allow setting a name', () => {
// Name input should have a placeholder ending in 'goerli-safe'
cy.get('input[name="name"]')
.should('have.attr', 'placeholder')
.should('match', /g(ö|oe)rli-safe/)

// Input a custom name
cy.get('input[name="name"]').type('Test safe name').should('have.value', 'Test safe name')

cy.contains('button', 'Next').click()
})

it('should display a default owner and threshold', () => {
// Default owner
cy.get('input[name="owners.0.address"]').should('have.value', DEFAULT_OWNER_ADDRESS)
cy.get('input[name="owners.0.name"]').type('Test Owner Name').should('have.value', 'Test Owner Name')

// Default threshold
cy.get('input[name="threshold"]').should('have.value', 1)

// Add new owner
cy.contains('button', 'Add new owner').click()
cy.get('input[name="owners.1.address"]').should('exist')
cy.get('input[name="owners.1.address"]').type(OWNER_ADDRESS)

// Update threshold
cy.get('input[name="threshold"]').parent().click()
cy.contains('li', '2').click()

cy.contains('button', 'Next').click()
})

it('should display summary on review page', () => {
cy.contains('Test safe name')
cy.contains(OWNER_ADDRESS)
cy.contains(DEFAULT_OWNER_ADDRESS)
cy.contains('2 out of 2')
})
})