Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
test: pass execution environment to Cypress (#3963)
Browse files Browse the repository at this point in the history
* tests: pass execution environment to cypress

* test: use a css selector to target a substring instead of the whole url

* fix: cypress-io/github-action syntax
  • Loading branch information
DiogoSoaress authored Jun 13, 2022
1 parent c49db48 commit 097d070
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,5 @@ jobs:
browser: chrome
record: false
config: baseUrl=https://pr${{ github.event.number }}--safereact.review-safe.gnosisdev.com/app/
env:
CYPRESS_ENV: ${{ env.REACT_APP_ENV}}
27 changes: 10 additions & 17 deletions cypress/integration/smoke/dashboard.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Dashboard', () => {

it('should display the dashboard title', () => {
cy.contains('main h1', 'Dashboard')
})
})

it('should display the overview widget', () => {
cy.contains('main p', SAFE).should('exist')
Expand All @@ -20,9 +20,10 @@ describe('Dashboard', () => {
})

it('should display the mobile banner', () => {
const appStoreLink = 'https://apps.apple.com/app/apple-store/id1515759131?pt=119497694&ct=Web%20App%20Dashboard&mt=8'
const appStoreLink =
'https://apps.apple.com/app/apple-store/id1515759131?pt=119497694&ct=Web%20App%20Dashboard&mt=8'
cy.get(`a[href="${appStoreLink}"]`).should('exist')

cy.get('button[aria-label="Close mobile banner"]').click()
cy.contains('button', 'Already use it!')
cy.contains('button', 'Not interested').click()
Expand All @@ -34,16 +35,10 @@ describe('Dashboard', () => {
cy.contains('main', 'This Safe has no queued transactions').should('not.exist')

// Queued txns
cy.contains(
`main a[href="/app/${SAFE}/transactions/queue"]`,
'0' + 'addOwnerWithThreshold' + '1/1'
).should('exist')

cy.contains(
`main a[href="/app/${SAFE}/transactions/queue"]`,
'2' + 'Send' + '-0.001 USDC' + '1/1'
).should('exist')

cy.contains(`main a[href="/app/${SAFE}/transactions/queue"]`, '0' + 'addOwnerWithThreshold' + '1/1').should('exist')

cy.contains(`main a[href="/app/${SAFE}/transactions/queue"]`, '2' + 'Send' + '-0.001 USDC' + '1/1').should('exist')

cy.contains(`a[href="/app/${SAFE}/transactions/queue"]`, 'View All')
})

Expand All @@ -52,13 +47,11 @@ describe('Dashboard', () => {

// Tx Builder app
cy.contains('main p', 'Use Transaction Builder')
cy.get(`a[href="/app/${SAFE}/apps?appUrl=https://safe-apps.dev.gnosisdev.com/tx-builder"]`)
.should('exist')
cy.get(`a[href*='/tx-builder']`).should('exist')

// WalletConnect app
cy.contains('main p', 'Use WalletConnect')
cy.get(`a[href="/app/${SAFE}/apps?appUrl=https://safe-apps.dev.gnosisdev.com/wallet-connect"]`)
.should('exist')
cy.get(`a[href*='/wallet-connect']`).should('exist')

// Featured apps have a Safe-specific link
cy.get(`main a[href^="/app/${SAFE}/apps?appUrl=http"]`).should('have.length', 2)
Expand Down
5 changes: 3 additions & 2 deletions scripts/cypress.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const DEPLOYMENTS = {
}

const command = `cypress ${process.argv[2]}`
const env = process.argv?.[3]
// To accept 'prod' or 'production' as an argument
let env = process.argv?.[3] === 'production' ? 'prod' : process.argv?.[3]

exec(env ? `${command} --config baseUrl=${DEPLOYMENTS[env]}` : command)
exec(env ? `${command} --config baseUrl=${DEPLOYMENTS[env]} --env CYPRESS_ENV=${env}` : command)

0 comments on commit 097d070

Please sign in to comment.