Skip to content

Commit

Permalink
Tests: Add cypress tests (#4772)
Browse files Browse the repository at this point in the history
  • Loading branch information
mike10ca authored Jan 14, 2025
1 parent 676314e commit 38c8489
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 18 deletions.
3 changes: 3 additions & 0 deletions apps/web/cypress/e2e/pages/create_tx.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const toggleUntrustedBtn = '[data-testid="toggle-untrusted"]'
const simulateTxBtn = '[data-testid="simulate-btn"]'
const simulateSuccess = '[data-testid="simulation-success-msg"]'
const signBtn = '[data-testid="sign-btn"]'
export const altImgDai = 'img[alt="DAI"]'
export const altImgCow = 'img[alt="COW"]'
export const altImgSwaps = 'svg[alt="Swap order"]'

const viewTransactionBtn = 'View transaction'
const transactionDetailsTitle = 'Transaction details'
Expand Down
2 changes: 1 addition & 1 deletion apps/web/cypress/e2e/pages/create_wallet.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export function clearWalletName() {
}

export function openNetworkSelector() {
cy.get(expandMoreIcon).parents('div').eq(1).click()
cy.get('header').find(expandMoreIcon).parent().click()
}
export function selectNetwork(network) {
cy.wait(1000)
Expand Down
22 changes: 8 additions & 14 deletions apps/web/cypress/e2e/prodhealthcheck/swaps_history_2.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import * as constants from '../../support/constants.js'
import * as main from '../pages/main.page.js'
import * as create_tx from '../pages/create_tx.pages.js'
import * as swaps_data from '../../fixtures/swaps_data.json'
import * as data from '../../fixtures/txhistory_data_data.json'
import * as swaps from '../pages/swaps.pages.js'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'
import { acceptCookies2 } from '../pages/main.page.js'

let staticSafes = []

const swapsHistory = swaps_data.type.history
const typeGeneral = data.type.general

describe('[PROD] Swaps history tests 2', () => {
before(async () => {
Expand Down Expand Up @@ -45,21 +47,13 @@ describe('[PROD] Swaps history tests 2', () => {
staticSafes.SEP_STATIC_SAFE_1 +
swaps.swapTxs.safeAppSwapOrder,
)
const dai = swaps.createRegex(swapsHistory.forAtLeastFullDai, 'DAI')
const eq = swaps.createRegex(swapsHistory.DAIeqCOW, 'COW')
acceptCookies2()
main.verifyValuesDoNotExist('div', [
swapsHistory.actionApproveG,
swapsHistory.actionDepositG,
swapsHistory.amount,
swapsHistory.executionPrice,
swapsHistory.surplus,
swapsHistory.expiry,
swapsHistory.oderId,
swapsHistory.status,
swapsHistory.forAtLeast,
swapsHistory.forAtMost,
])
main.verifyValuesDoNotExist(create_tx.transactionItem, [swapsHistory.title, swapsHistory.cow, swapsHistory.dai])
main.verifyValuesExist(create_tx.transactionItem, [swapsHistory.actionPreSignatureG])
main.verifyValuesExist(create_tx.transactionItem, [swapsHistory.title])
create_tx.verifySummaryByName(swapsHistory.title, null, [typeGeneral.statusOk])
main.verifyElementsExist([create_tx.altImgDai, create_tx.altImgCow], create_tx.altImgSwaps)
create_tx.verifyExpandedDetails([swapsHistory.sell10Cow, dai, eq, swapsHistory.dai, swapsHistory.filled])
},
)
})
3 changes: 2 additions & 1 deletion apps/web/cypress/e2e/regression/swaps_history_2.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ describe('Swaps history tests 2', () => {
})

// Added to prod
it(
// Unskip after the decoding bug is fixed on staging
it.skip(
'Verify no decoding if tx was created using CowSwap safe-app in the history',
{ defaultCommandTimeout: 30000 },
() => {
Expand Down
26 changes: 26 additions & 0 deletions apps/web/cypress/e2e/regression/tx_history_5.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as constants from '../../support/constants.js'
import * as createTx from '../pages/create_tx.pages.js'
import * as data from '../../fixtures/txhistory_data_data.json'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'
import * as main from '../pages/main.page.js'

let staticSafes = []

const typeSend = data.type.send
const typeGeneral = data.type.general

const safe = 'sep:0x8f4A19C85b39032A37f7a6dCc65234f966F72551'
const txbuilder =
'&id=multisig_0x8f4A19C85b39032A37f7a6dCc65234f966F72551_0x97d4c1b3149853c0d8ca71bd700faae628f0a833bdb4bd9c6b14c171117703d4'

describe('Safe app tx history tests', () => {
before(async () => {
staticSafes = await getSafes(CATEGORIES.static)
})

it('Verify tx builder has icon and app name', () => {
cy.visit(constants.transactionUrl + safe + txbuilder)
createTx.verifySummaryByName(typeSend.txBuilderTitle, null, [typeGeneral.statusOk], typeSend.txBuilderAltImage)
main.verifyValuesExist(createTx.transactionItem, [typeSend.txBuilderTitle])
})
})
4 changes: 3 additions & 1 deletion apps/web/cypress/fixtures/swaps_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"oderId": "Order ID",
"status": "Status",
"sellFull": "Sell 1 COW",
"sell10Cow": "Sell 10 COW",
"sell": "Sell",
"oneCOW": "1 COW",
"forAtLeast": "for at least",
Expand All @@ -59,7 +60,8 @@
"safeAppTitile": "CowSwap",
"title": "Swap order",
"multiSend": "multiSend",
"multiSendCallOnly1_3_0": "Safe: MultiSendCallOnly 1.3.0"
"multiSendCallOnly1_3_0": "Safe: MultiSendCallOnly 1.3.0",
"altImage": "Swap order"
}
}
}
4 changes: 3 additions & 1 deletion apps/web/cypress/fixtures/txhistory_data_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@
"recipientAddress": "sep:0x06373d5e45AD31BD354CeBfA8dB4eD2c75B8708e",
"transactionHash": "0x6a59...6a98",
"altImage": "Sent",
"altToken": "ETH"
"altToken": "ETH",
"txBuilderTitle": "Transaction Builder",
"txBuilderAltImage": "Transaction Builder"
},
"onchainRejection": {
"title": "On-chain rejection",
Expand Down

0 comments on commit 38c8489

Please sign in to comment.