Skip to content

Commit

Permalink
Update workflows. Add test ids
Browse files Browse the repository at this point in the history
  • Loading branch information
mike10ca committed Nov 19, 2023
1 parent cdaae40 commit 5a43ee6
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 33 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/ondemand.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Regression on demand tests

on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
e2e:
runs-on: ubuntu-20.04
name: Cypress Regression on demand tests
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4, 5]
steps:
- uses: actions/checkout@v3

- uses: ./.github/workflows/yarn

- name: Install Cypress
run: |
./node_modules/.bin/cypress install
- uses: ./.github/workflows/build
with:
secrets: ${{ toJSON(secrets) }}
e2e_mnemonic: ${{ secrets.NEXT_PUBLIC_CYPRESS_MNEMONIC }}

- name: Serve
run: yarn serve &

- uses: cypress-io/github-action@v4
with:
parallel: true
spec: cypress/e2e/**/*.cy.js
browser: chrome
record: true
config: baseUrl=http://localhost:8080
group: 'Regression on demand tests'
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 6 additions & 3 deletions .github/workflows/regression.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: regression
name: Regression tests

on:
workflow_dispatch:
pull_request:
branches:
- 'release**'
- 'release/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -35,7 +38,7 @@ jobs:
- uses: cypress-io/github-action@v4
with:
parallel: true
spec: cypress/e2e/regression/*.cy.js
spec: cypress/e2e/**/*.cy.js
browser: chrome
record: true
config: baseUrl=http://localhost:8080
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml → .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: e2e
name: Smoke tests

on:
pull_request:
Expand Down
7 changes: 6 additions & 1 deletion cypress/e2e/pages/create_wallet.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const safeCreationStatusInfo = '[data-testid="safe-status-info"]'
const startUsingSafeBtn = '[data-testid="start-using-safe-btn"]'
const sponsorIcon = '[data-testid="sponsor-icon"]'
const networkFeeSection = '[data-tetid="network-fee-section"]'
const nextBtn = '[data-testid="next-btn"]'
const backBtn = '[data-testid="back-btn"]'

const sponsorStr = 'Your account is sponsored by Goerli'
const safeCreationProcessing = 'Transaction is being executed'
Expand All @@ -32,6 +34,9 @@ export const walletName = 'test1-sepolia-safe'
export const defaltSepoliaPlaceholder = 'Sepolia Safe'
const welcomeToSafeStr = 'Welcome to Safe'

export function clickOnBackBtn() {
cy.get(backBtn).should('be.enabled').click()
}
export function verifySafeIsBeingCreated() {
cy.get(safeCreationStatusInfo).should('have.text', safeCreationProcessing)
}
Expand Down Expand Up @@ -128,7 +133,7 @@ export function selectNetwork(network, regex = false) {
}

export function clickOnNextBtn() {
cy.contains('button', 'Next').click()
cy.get(nextBtn).should('be.enabled').click()
}

export function verifyOwnerName(name, index) {
Expand Down
6 changes: 6 additions & 0 deletions cypress/e2e/pages/main.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ export function waitForTrnsactionHistoryToComplete() {
cy.intercept('GET', constants.transactionHistoryEndpoint).as('History')
cy.wait('@History')
}

export function waitForSafeListRequestToComplete() {
cy.intercept('GET', constants.safeListEndpoint).as('Safes')
cy.wait('@Safes')
}

export function acceptCookies(index = 0) {
cy.wait(1000)

Expand Down
23 changes: 12 additions & 11 deletions cypress/e2e/regression/create_safe_simple.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as owner from '../pages/owners.pages'
describe('Safe creation tests', () => {
beforeEach(() => {
cy.visit(constants.welcomeUrl + '?chain=sep')
main.waitForSafeListRequestToComplete()
cy.clearLocalStorage()
main.acceptCookies()
})
Expand Down Expand Up @@ -41,7 +42,7 @@ describe('Safe creation tests', () => {
it('Verify current connected account is shown as default owner', () => {
owner.waitForConnectionStatus()
createwallet.clickOnCreateNewSafeBtn()
owner.clickOnNextBtn()
createwallet.clickOnNextBtn()
owner.verifyExistingOwnerAddress(0, constants.DEFAULT_OWNER_ADDRESS)
})

Expand All @@ -65,26 +66,26 @@ describe('Safe creation tests', () => {
const ownerName = 'David'
owner.waitForConnectionStatus()
createwallet.clickOnCreateNewSafeBtn()
owner.clickOnNextBtn()
createwallet.clickOnNextBtn()
createwallet.clickOnAddNewOwnerBtn()
createwallet.typeOwnerName(ownerName, 1)
createwallet.typeOwnerAddress(constants.SEPOLIA_OWNER_2, 1)
owner.clickOnBackBtn()
createwallet.clickOnBackBtn()
createwallet.clearWalletName()
createwallet.typeWalletName(createwallet.walletName)
owner.clickOnNextBtn()
owner.clickOnNextBtn()
createwallet.clickOnNextBtn()
createwallet.clickOnNextBtn()
createwallet.verifySafeNameInSummaryStep(createwallet.walletName)
createwallet.verifyOwnerNameInSummaryStep(ownerName)
createwallet.verifyOwnerAddressInSummaryStep(constants.DEFAULT_OWNER_ADDRESS)
createwallet.verifyOwnerAddressInSummaryStep(constants.DEFAULT_OWNER_ADDRESS)
createwallet.verifyThresholdStringInSummaryStep(1, 2)
createwallet.verifyNetworkInSummaryStep(constants.networks.sepolia)
owner.clickOnBackBtn()
owner.clickOnBackBtn()
createwallet.clickOnBackBtn()
createwallet.clickOnBackBtn()
cy.wait(1000)
owner.clickOnNextBtn()
owner.clickOnNextBtn()
createwallet.clickOnNextBtn()
createwallet.clickOnNextBtn()
createwallet.verifySafeNameInSummaryStep(createwallet.walletName)
createwallet.verifyOwnerNameInSummaryStep(ownerName)
createwallet.verifyOwnerAddressInSummaryStep(constants.DEFAULT_OWNER_ADDRESS)
Expand All @@ -97,15 +98,15 @@ describe('Safe creation tests', () => {
it('Verify tip is displayed on right side for threshold 1/1', () => {
owner.waitForConnectionStatus()
createwallet.clickOnCreateNewSafeBtn()
owner.clickOnNextBtn()
createwallet.clickOnNextBtn()
createwallet.verifyPolicy1_1()
})

// TODO: Check unit tests
it('Verify address input validation rules', () => {
owner.waitForConnectionStatus()
createwallet.clickOnCreateNewSafeBtn()
owner.clickOnNextBtn()
createwallet.clickOnNextBtn()
createwallet.clickOnAddNewOwnerBtn()
createwallet.typeOwnerAddress(main.generateRandomString(10), 1)
owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.invalidFormat)
Expand Down
12 changes: 4 additions & 8 deletions cypress/e2e/regression/remove_owner.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,36 @@ import * as owner from '../pages/owners.pages'

describe('Remove Owners tests', () => {
beforeEach(() => {
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_1)
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_3)
main.waitForTrnsactionHistoryToComplete()
cy.clearLocalStorage()
main.acceptCookies()
owner.waitForConnectionStatus()
cy.contains(owner.safeAccountNonceStr, { timeout: 10000 })
})

it('Verify that "Remove" icon is visible', () => {
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_3)
owner.verifyRemoveBtnIsEnabled().should('have.length', 2)
})

it('Verify Tooltip displays correct message for Non-Owner', () => {
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_4)
main.waitForTrnsactionHistoryToComplete()
owner.waitForConnectionStatus()
owner.verifyRemoveBtnIsDisabled()
})

it('Verify Tooltip displays correct message for disconnected user', () => {
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_3)
owner.waitForConnectionStatus()
owner.clickOnWalletExpandMoreIcon()
owner.clickOnDisconnectBtn()
owner.verifyRemoveBtnIsDisabled()
})

it('Verify owner removal form can be opened', () => {
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_3)
owner.waitForConnectionStatus()
owner.openRemoveOwnerWindow(1)
})

it('Verify threshold input displays the upper limit as the current safe number of owners minus one', () => {
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_3)
owner.waitForConnectionStatus()
owner.openRemoveOwnerWindow(1)
owner.verifyThresholdLimit(1, 1)
owner.getThresholdOptions().should('have.length', 1)
Expand Down
5 changes: 3 additions & 2 deletions cypress/e2e/smoke/create_safe_simple.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as owner from '../pages/owners.pages'
describe('[SMOKE] Safe creation tests', () => {
beforeEach(() => {
cy.visit(constants.welcomeUrl + '?chain=sep')
main.waitForSafeListRequestToComplete()
cy.clearLocalStorage()
main.acceptCookies()
})
Expand All @@ -26,7 +27,7 @@ describe('[SMOKE] Safe creation tests', () => {
it('[SMOKE] Verify Add and Remove Owner Row works as expected', () => {
owner.waitForConnectionStatus()
createwallet.clickOnCreateNewSafeBtn()
owner.clickOnNextBtn()
createwallet.clickOnNextBtn()
createwallet.clickOnAddNewOwnerBtn()
owner.verifyNumberOfOwners(2)
owner.verifyExistingOwnerAddress(1, '')
Expand All @@ -40,7 +41,7 @@ describe('[SMOKE] Safe creation tests', () => {
it('[SMOKE] Verify Threshold Setup', () => {
owner.waitForConnectionStatus()
createwallet.clickOnCreateNewSafeBtn()
owner.clickOnNextBtn()
createwallet.clickOnNextBtn()
createwallet.clickOnAddNewOwnerBtn()
createwallet.clickOnAddNewOwnerBtn()
owner.verifyNumberOfOwners(3)
Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/smoke/remove_owner.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as constants from '../../support/constants'
import * as main from '../../e2e/pages/main.page'
import * as owner from '../pages/owners.pages'
import * as createwallet from '../pages/create_wallet.pages'

describe('[SMOKE] Remove Owners tests', () => {
beforeEach(() => {
Expand All @@ -15,7 +16,7 @@ describe('[SMOKE] Remove Owners tests', () => {
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_3)
owner.waitForConnectionStatus()
owner.openRemoveOwnerWindow(1)
owner.clickOnNextBtn()
createwallet.clickOnNextBtn()
owner.verifyOwnerDeletionWindowDisplayed()
})
})
1 change: 1 addition & 0 deletions cypress/support/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const validAppUrl = 'https://my-valid-custom-app.com'
export const proposeEndpoint = '/**/propose'
export const appsEndpoint = '/**/safe-apps'
export const transactionHistoryEndpoint = '**/history'
export const safeListEndpoint = '**/safes'

export const mainSideMenuOptions = {
home: 'Home',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ const OwnerPolicyStep = ({
<Divider />
<Box className={layoutCss.row}>
<Box display="flex" flexDirection="row" justifyContent="space-between" gap={3}>
<Button variant="outlined" size="small" onClick={handleBack} startIcon={<ArrowBackIcon fontSize="small" />}>
<Button data-testid="back-btn" variant="outlined" size="small" onClick={handleBack} startIcon={<ArrowBackIcon fontSize="small" />}>

Check failure on line 173 in src/components/new-safe/create/steps/OwnerPolicyStep/index.tsx

View workflow job for this annotation

GitHub Actions / ESLint Results

prettier/prettier

Replace `·data-testid="back-btn"·variant="outlined"·size="small"·onClick={handleBack}·startIcon={<ArrowBackIcon·fontSize="small"·/>}` with `⏎··············data-testid="back-btn"⏎··············variant="outlined"⏎··············size="small"⏎··············onClick={handleBack}⏎··············startIcon={<ArrowBackIcon·fontSize="small"·/>}⏎············`
Back
</Button>
<Button type="submit" variant="contained" size="stretched" disabled={isDisabled}>
<Button data-testid="next-btn" type="submit" variant="contained" size="stretched" disabled={isDisabled}>
Next
</Button>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion src/components/new-safe/create/steps/ReviewStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ const ReviewStep = ({ data, onSubmit, onBack, setStep }: StepRenderProps<NewSafe
<Box className={layoutCss.row}>
<Box display="flex" flexDirection="row" justifyContent="space-between" gap={3}>
<Button
data-testid="review-step-back-btn"
data-testid="back-btn"
variant="outlined"
size="small"
onClick={handleBack}
Expand Down
4 changes: 2 additions & 2 deletions src/components/new-safe/create/steps/SetNameStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ function SetNameStep({
<Divider />
<Box className={layoutCss.row}>
<Box display="flex" flexDirection="row" justifyContent="space-between" gap={3}>
<Button variant="outlined" onClick={onCancel} size="small">
<Button data-testid="cancel-btn" variant="outlined" onClick={onCancel} size="small">
Cancel
</Button>
<Button type="submit" variant="contained" size="stretched" disabled={isDisabled}>
<Button data-testid="next-btn" type="submit" variant="contained" size="stretched" disabled={isDisabled}>
Next
</Button>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion src/components/tx-flow/flows/RemoveOwner/SetThreshold.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const SetThreshold = ({
<Divider className={commonCss.nestedDivider} />

<CardActions>
<Button variant="contained" type="submit">
<Button data-testid="next-btn" variant="contained" type="submit">
Next
</Button>
</CardActions>
Expand Down

0 comments on commit 5a43ee6

Please sign in to comment.