From 38c8489c77cf0646c7646a8beae18e2c370183a4 Mon Sep 17 00:00:00 2001 From: Michael <30682308+mike10ca@users.noreply.github.com> Date: Tue, 14 Jan 2025 15:54:46 +0100 Subject: [PATCH] Tests: Add cypress tests (#4772) --- apps/web/cypress/e2e/pages/create_tx.pages.js | 3 +++ .../cypress/e2e/pages/create_wallet.pages.js | 2 +- .../e2e/prodhealthcheck/swaps_history_2.cy.js | 22 ++++++---------- .../e2e/regression/swaps_history_2.cy.js | 3 ++- .../cypress/e2e/regression/tx_history_5.cy.js | 26 +++++++++++++++++++ apps/web/cypress/fixtures/swaps_data.json | 4 ++- .../cypress/fixtures/txhistory_data_data.json | 4 ++- 7 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 apps/web/cypress/e2e/regression/tx_history_5.cy.js diff --git a/apps/web/cypress/e2e/pages/create_tx.pages.js b/apps/web/cypress/e2e/pages/create_tx.pages.js index 0c93b61164..cf4d95ba1c 100644 --- a/apps/web/cypress/e2e/pages/create_tx.pages.js +++ b/apps/web/cypress/e2e/pages/create_tx.pages.js @@ -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' diff --git a/apps/web/cypress/e2e/pages/create_wallet.pages.js b/apps/web/cypress/e2e/pages/create_wallet.pages.js index 8f6af31a64..0404133313 100644 --- a/apps/web/cypress/e2e/pages/create_wallet.pages.js +++ b/apps/web/cypress/e2e/pages/create_wallet.pages.js @@ -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) diff --git a/apps/web/cypress/e2e/prodhealthcheck/swaps_history_2.cy.js b/apps/web/cypress/e2e/prodhealthcheck/swaps_history_2.cy.js index a89e3f8134..5b4649afd0 100644 --- a/apps/web/cypress/e2e/prodhealthcheck/swaps_history_2.cy.js +++ b/apps/web/cypress/e2e/prodhealthcheck/swaps_history_2.cy.js @@ -2,6 +2,7 @@ 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' @@ -9,6 +10,7 @@ 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 () => { @@ -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]) }, ) }) diff --git a/apps/web/cypress/e2e/regression/swaps_history_2.cy.js b/apps/web/cypress/e2e/regression/swaps_history_2.cy.js index 76e2aa75a9..a850acc294 100644 --- a/apps/web/cypress/e2e/regression/swaps_history_2.cy.js +++ b/apps/web/cypress/e2e/regression/swaps_history_2.cy.js @@ -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 }, () => { diff --git a/apps/web/cypress/e2e/regression/tx_history_5.cy.js b/apps/web/cypress/e2e/regression/tx_history_5.cy.js new file mode 100644 index 0000000000..8675a52082 --- /dev/null +++ b/apps/web/cypress/e2e/regression/tx_history_5.cy.js @@ -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]) + }) +}) diff --git a/apps/web/cypress/fixtures/swaps_data.json b/apps/web/cypress/fixtures/swaps_data.json index 20efadf8a3..7949896443 100644 --- a/apps/web/cypress/fixtures/swaps_data.json +++ b/apps/web/cypress/fixtures/swaps_data.json @@ -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", @@ -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" } } } diff --git a/apps/web/cypress/fixtures/txhistory_data_data.json b/apps/web/cypress/fixtures/txhistory_data_data.json index 076a31500f..9bdab8a0ed 100644 --- a/apps/web/cypress/fixtures/txhistory_data_data.json +++ b/apps/web/cypress/fixtures/txhistory_data_data.json @@ -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",