Skip to content

Commit

Permalink
Tests: Tests improvements (#4318)
Browse files Browse the repository at this point in the history
* Prevent failing step 

* Hide beamer before all tests

* Update workflow
  • Loading branch information
mike10ca authored Oct 7, 2024
1 parent da41027 commit d8ada9c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_STAGING=
NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_PRODUCTION=

# Cypress wallet private keys
CYPRESS_WALLET_CREDENTIALS=
CYPRESS_WALLET_CREDENTIALS=

# Beamer keys for e2e tests
BEAMER_DATA_E2E=
1 change: 1 addition & 0 deletions .github/workflows/cypress/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ runs:
GITHUB_TOKEN: ${{ fromJSON(inputs.secrets).GITHUB_TOKEN }}
CYPRESS_PROJECT_ID: ${{ inputs.project_id }}
CYPRESS_WALLET_CREDENTIALS: ${{ fromJSON(inputs.secrets).CYPRESS_WALLET_CREDENTIALS }}
BEAMER_DATA_E2E: ${{ fromJSON(inputs.secrets).BEAMER_DATA_E2E }}
6 changes: 4 additions & 2 deletions .github/workflows/e2e-ondemand.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ jobs:
if: always()
run: |
pip install trcli
trcli -y \
if ! trcli -y \
-h https://gno.testrail.io/ \
--project "Safe- Web App" \
--username ${{ secrets.TESTRAIL_USERNAME }} \
--password ${{ secrets.TESTRAIL_PASSWORD }} \
parse_junit \
--title "Automated Tests, branch: ${GITHUB_REF_NAME}" \
--run-description ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} \
-f "reports/junit-report.xml"
-f "reports/junit-report.xml"; then
echo -e "\e[41;32mTestRail upload failed. Pipeline will continue, please check the upload process.\e[0m"
fi
3 changes: 1 addition & 2 deletions cypress/e2e/pages/batches.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ function executeTransaction() {
}

function addToBatchButton() {
cy.wait(1000)
cy.get('button').contains(addToBatchBtn).scrollIntoView().should('not.be.disabled').click()
cy.get('button').contains(addToBatchBtn).click()
}

export function openBatchtransactionsModal() {
Expand Down
10 changes: 10 additions & 0 deletions cypress/e2e/safe-apps/drain_account.spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ import * as safeapps from '../pages/safeapps.pages'
import * as navigation from '../pages/navigation.page'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'
import * as ls from '../../support/localstorage_data.js'
import * as wallet from '../../support/utils/wallet.js'

let safeAppSafes = []
let iframeSelector

const walletCredentials = JSON.parse(Cypress.env('CYPRESS_WALLET_CREDENTIALS'))
const signer = walletCredentials.OWNER_4_PRIVATE_KEY

describe('Drain Account tests', () => {
before(async () => {
safeAppSafes = await getSafes(CATEGORIES.safeapps)
Expand All @@ -34,15 +38,19 @@ describe('Drain Account tests', () => {
})

it('Verify drain can be created', () => {
wallet.connectSigner(signer)
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.recipientStr).type(safeAppSafes.SEP_SAFEAPP_SAFE_2)
getBody().findAllByText(safeapps.transferEverythingStr).click()
})
cy.findByRole('button', { name: safeapps.testTransfer1 })
cy.findByRole('button', { name: safeapps.nativeTransfer2 })
navigation.clickOnWalletExpandMoreIcon()
navigation.clickOnDisconnectBtn()
})

it('Verify partial drain can be created', () => {
wallet.connectSigner(signer)
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.selectAllRowsChbxStr).click()
getBody().findAllByLabelText(safeapps.selectRowChbxStr).eq(1).click()
Expand All @@ -52,6 +60,8 @@ describe('Drain Account tests', () => {
})
cy.findByRole('button', { name: safeapps.testTransfer2 })
cy.findByRole('button', { name: safeapps.nativeTransfer1 })
navigation.clickOnWalletExpandMoreIcon()
navigation.clickOnDisconnectBtn()
})

// TODO: ENS does not resolve
Expand Down
10 changes: 10 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import './safe-apps-commands'
const { addCompareSnapshotCommand } = require('cypress-visual-regression/dist/command')
addCompareSnapshotCommand()

const beamer = JSON.parse(Cypress.env('BEAMER_DATA_E2E'))
const productID = beamer.PRODUCT_ID

before(() => {
Cypress.on('uncaught:exception', (err, runnable) => {
return false
Expand All @@ -48,4 +51,11 @@ before(() => {
beforeEach(() => {
cy.setupInterceptors()
cy.clearAllSessionStorage()
cy.window().then((window) => {
const getDate = () => new Date().toISOString()
const beamerKey1 = `_BEAMER_FIRST_VISIT_${productID}`
const beamerKey2 = `_BEAMER_BOOSTED_ANNOUNCEMENT_DATE_${productID}`
window.localStorage.setItem(beamerKey1, getDate())
window.localStorage.setItem(beamerKey2, getDate())
})
})

0 comments on commit d8ada9c

Please sign in to comment.