From 4b523defb5bc2665dc3f66eb55c54638b710b01e Mon Sep 17 00:00:00 2001 From: Benjamin Haramboure <105707720+bharamboure-ledger@users.noreply.github.com> Date: Fri, 22 Nov 2024 11:35:18 +0100 Subject: [PATCH] DISABLE_TRANSACTION_BROADCAST logic moved to tests suites (#8385) * DISABLE_TRANSACTION_BROADCAST logic moved from github workflow to test suites --- .changeset/hot-cameras-fly.md | 5 + .../workflows/test-ui-e2e-only-desktop.yml | 16 - .../tests/fixtures/common.ts | 3 +- .../tests/specs/speculos/delegate.spec.ts | 241 +++---- .../tests/specs/speculos/send.tx.spec.ts | 625 +++++++++--------- .../tests/utils/githubUtils.ts | 3 + 6 files changed, 452 insertions(+), 441 deletions(-) create mode 100644 .changeset/hot-cameras-fly.md create mode 100644 apps/ledger-live-desktop/tests/utils/githubUtils.ts diff --git a/.changeset/hot-cameras-fly.md b/.changeset/hot-cameras-fly.md new file mode 100644 index 000000000000..af48f850ead9 --- /dev/null +++ b/.changeset/hot-cameras-fly.md @@ -0,0 +1,5 @@ +--- +"ledger-live-desktop": minor +--- + +broadcasting on e2e tests only on scheduled workflows on Monday diff --git a/.github/workflows/test-ui-e2e-only-desktop.yml b/.github/workflows/test-ui-e2e-only-desktop.yml index d800be14f6cd..8e6fd7839ed4 100644 --- a/.github/workflows/test-ui-e2e-only-desktop.yml +++ b/.github/workflows/test-ui-e2e-only-desktop.yml @@ -37,11 +37,6 @@ on: required: false type: string default: "B2CQA-2461" - enable_send_test: - description: Enable broadcast - required: false - type: boolean - default: false concurrency: group: ${{ github.workflow }}-${{ github.ref_name != 'develop' && github.ref || github.run_id }} @@ -61,7 +56,6 @@ jobs: CI_OS: "ubuntu-latest" PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 SPECULOS_IMAGE_TAG: ghcr.io/ledgerhq/speculos:0.11 - ENABLE_BROADCAST_TEST: ${{ inputs.enable_send_test }} runs-on: [ledger-live-4xlarge] strategy: fail-fast: false @@ -73,16 +67,6 @@ jobs: with: ref: ${{ inputs.ref || github.sha }} - - name: Setup broadcast environment variables - id: set-env - run: | - day=$(date +%u) - if [ $day -eq 1 ] || "$ENABLE_BROADCAST_TEST" = "1" ; then - echo "ENABLE_TRANSACTION_BROADCAST=1" >> $GITHUB_ENV - else - echo "DISABLE_TRANSACTION_BROADCAST=1" >> $GITHUB_ENV - fi - - name: Setup caches id: caches uses: LedgerHQ/ledger-live/tools/actions/composites/setup-caches@develop diff --git a/apps/ledger-live-desktop/tests/fixtures/common.ts b/apps/ledger-live-desktop/tests/fixtures/common.ts index c8e1ea39e646..abc8522a502d 100644 --- a/apps/ledger-live-desktop/tests/fixtures/common.ts +++ b/apps/ledger-live-desktop/tests/fixtures/common.ts @@ -152,8 +152,7 @@ export const test = base.extend({ FEATURE_FLAGS: JSON.stringify(featureFlags), MANAGER_DEV_MODE: IS_NOT_MOCK ? true : undefined, SPECULOS_API_PORT: IS_NOT_MOCK ? getEnv("SPECULOS_API_PORT")?.toString() : undefined, - DISABLE_TRANSACTION_BROADCAST: - process.env.ENABLE_TRANSACTION_BROADCAST == "1" || !IS_NOT_MOCK ? undefined : 1, + DISABLE_TRANSACTION_BROADCAST: !IS_NOT_MOCK ? undefined : 1, }, env, ); diff --git a/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts index d7258334afb2..58034272350e 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts @@ -4,6 +4,7 @@ import { Delegate } from "../../models/Delegate"; import { addTmsLink } from "tests/utils/allureUtils"; import { getDescription } from "../../utils/customJsonReporter"; import { commandCLI } from "tests/utils/cliUtils"; +import { isRunningInScheduledWorkflow } from "tests/utils/githubUtils"; const e2eDelegationAccounts = [ { @@ -47,17 +48,120 @@ const validators = [ }, ]; -for (const account of e2eDelegationAccounts) { - test.describe("Delegate", () => { +test.describe("Delegate flows", () => { + test.beforeAll(async () => { + process.env.ENABLE_TRANSACTION_BROADCAST = + new Date().getDay() === 1 && isRunningInScheduledWorkflow() ? "1" : "0"; + }); + for (const account of e2eDelegationAccounts) { + test.describe("Delegate", () => { + test.use({ + userdata: "skip-onboarding", + speculosApp: account.delegate.account.currency.speculosApp, + cliCommands: [ + { + command: commandCLI.liveData, + args: { + currency: account.delegate.account.currency.ticker, + index: account.delegate.account.index, + add: true, + appjson: "", + }, + }, + ], + }); + + test( + `[${account.delegate.account.currency.name}] Delegate`, + { + annotation: { + type: "TMS", + description: account.xrayTicket, + }, + }, + async ({ app }) => { + await addTmsLink(getDescription(test.info().annotations).split(", ")); + await app.layout.goToAccounts(); + await app.accounts.navigateToAccountByName(account.delegate.account.accountName); + + await app.account.clickBannerCTA(); + await app.delegate.verifyProvider(account.delegate.provider); + + await app.delegate.continueDelegate(); + await app.delegate.fillAmount(account.delegate.amount); + await app.modal.countinueSendAmount(); + + await app.speculos.signDelegationTransaction(account.delegate); + await app.delegate.clickViewDetailsButton(); + + await app.drawer.waitForDrawerToBeVisible(); + await app.delegateDrawer.transactionTypeIsVisible(); + await app.delegateDrawer.providerIsVisible(account.delegate); + await app.delegateDrawer.amountValueIsVisible(); + await app.drawer.close(); + + await app.layout.syncAccounts(); + await app.account.clickOnLastOperation(); + await app.delegateDrawer.expectDelegationInfos(account.delegate); + }, + ); + }); + } + + for (const validator of validators) { + test.describe("Select a validator", () => { + test.use({ + userdata: "skip-onboarding", + speculosApp: validator.delegate.account.currency.speculosApp, + cliCommands: [ + { + command: commandCLI.liveData, + args: { + currency: validator.delegate.account.currency.ticker, + index: validator.delegate.account.index, + add: true, + appjson: "", + }, + }, + ], + }); + + test( + `[${validator.delegate.account.currency.name}] - Select validator`, + { + annotation: { + type: "TMS", + description: validator.xrayTicket, + }, + }, + async ({ app }) => { + await addTmsLink(getDescription(test.info().annotations).split(", ")); + await app.layout.goToAccounts(); + await app.accounts.navigateToAccountByName(validator.delegate.account.accountName); + + await app.account.startStakingFlowFromMainStakeButton(); + await app.modal.continue(); + + await app.delegate.verifyProvider(validator.delegate.provider); + await app.delegate.openSearchProviderModal(); + await app.delegate.checkValidatorListIsVisible(); + await app.delegate.selectProvider(1); + }, + ); + }); + } + + test.describe("Staking flow from different entry point", () => { + const delegateAccount = new Delegate(Account.ATOM_1, "0.001", "Ledger"); test.use({ userdata: "skip-onboarding", - speculosApp: account.delegate.account.currency.speculosApp, + speculosApp: delegateAccount.account.currency.speculosApp, cliCommands: [ { command: commandCLI.liveData, args: { - currency: account.delegate.account.currency.ticker, - index: account.delegate.account.index, + currency: delegateAccount.account.currency.ticker, + index: delegateAccount.account.index, add: true, appjson: "", }, @@ -66,142 +170,45 @@ for (const account of e2eDelegationAccounts) { }); test( - `[${account.delegate.account.currency.name}] Delegate`, + "Staking flow from portfolio entry point", { annotation: { type: "TMS", - description: account.xrayTicket, + description: "B2CQA-2769", }, }, async ({ app }) => { await addTmsLink(getDescription(test.info().annotations).split(", ")); - await app.layout.goToAccounts(); - await app.accounts.navigateToAccountByName(account.delegate.account.accountName); + await app.layout.goToPortfolio(); + await app.portfolio.startStakeFlow(); - await app.account.clickBannerCTA(); - await app.delegate.verifyProvider(account.delegate.provider); + await app.assetDrawer.selectAsset(delegateAccount.account.currency); + await app.assetDrawer.selectAccountByIndex(delegateAccount.account); + await app.delegate.verifyProvider(delegateAccount.provider); await app.delegate.continueDelegate(); - await app.delegate.fillAmount(account.delegate.amount); - await app.modal.countinueSendAmount(); - - await app.speculos.signDelegationTransaction(account.delegate); - await app.delegate.clickViewDetailsButton(); - - await app.drawer.waitForDrawerToBeVisible(); - await app.delegateDrawer.transactionTypeIsVisible(); - await app.delegateDrawer.providerIsVisible(account.delegate); - await app.delegateDrawer.amountValueIsVisible(); - await app.drawer.close(); - - await app.layout.syncAccounts(); - await app.account.clickOnLastOperation(); - await app.delegateDrawer.expectDelegationInfos(account.delegate); }, ); - }); -} - -for (const validator of validators) { - test.describe("Select a validator", () => { - test.use({ - userdata: "skip-onboarding", - speculosApp: validator.delegate.account.currency.speculosApp, - cliCommands: [ - { - command: commandCLI.liveData, - args: { - currency: validator.delegate.account.currency.ticker, - index: validator.delegate.account.index, - add: true, - appjson: "", - }, - }, - ], - }); test( - `[${validator.delegate.account.currency.name}] - Select validator`, + "Staking flow from market entry point", { annotation: { type: "TMS", - description: validator.xrayTicket, + description: "B2CQA-2771", }, }, async ({ app }) => { await addTmsLink(getDescription(test.info().annotations).split(", ")); - await app.layout.goToAccounts(); - await app.accounts.navigateToAccountByName(validator.delegate.account.accountName); + await app.layout.goToMarket(); + await app.market.search(delegateAccount.account.currency.name); + await app.market.stakeButtonClick(delegateAccount.account.currency.ticker); - await app.account.startStakingFlowFromMainStakeButton(); - await app.modal.continue(); + await app.assetDrawer.selectAccountByIndex(delegateAccount.account); - await app.delegate.verifyProvider(validator.delegate.provider); - await app.delegate.openSearchProviderModal(); - await app.delegate.checkValidatorListIsVisible(); - await app.delegate.selectProvider(1); + await app.delegate.verifyProvider(delegateAccount.provider); + await app.delegate.continueDelegate(); }, ); }); -} - -test.describe("Staking flow from different entry point", () => { - const delegateAccount = new Delegate(Account.ATOM_1, "0.001", "Ledger"); - test.use({ - userdata: "skip-onboarding", - speculosApp: delegateAccount.account.currency.speculosApp, - cliCommands: [ - { - command: commandCLI.liveData, - args: { - currency: delegateAccount.account.currency.ticker, - index: delegateAccount.account.index, - add: true, - appjson: "", - }, - }, - ], - }); - - test( - "Staking flow from portfolio entry point", - { - annotation: { - type: "TMS", - description: "B2CQA-2769", - }, - }, - async ({ app }) => { - await addTmsLink(getDescription(test.info().annotations).split(", ")); - await app.layout.goToPortfolio(); - await app.portfolio.startStakeFlow(); - - await app.assetDrawer.selectAsset(delegateAccount.account.currency); - await app.assetDrawer.selectAccountByIndex(delegateAccount.account); - - await app.delegate.verifyProvider(delegateAccount.provider); - await app.delegate.continueDelegate(); - }, - ); - - test( - "Staking flow from market entry point", - { - annotation: { - type: "TMS", - description: "B2CQA-2771", - }, - }, - async ({ app }) => { - await addTmsLink(getDescription(test.info().annotations).split(", ")); - await app.layout.goToMarket(); - await app.market.search(delegateAccount.account.currency.name); - await app.market.stakeButtonClick(delegateAccount.account.currency.ticker); - - await app.assetDrawer.selectAccountByIndex(delegateAccount.account); - - await app.delegate.verifyProvider(delegateAccount.provider); - await app.delegate.continueDelegate(); - }, - ); }); diff --git a/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts index 817031fc9402..2d3895fdf204 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts @@ -5,6 +5,7 @@ import { Transaction, NFTTransaction } from "../../models/Transaction"; import { addTmsLink } from "tests/utils/allureUtils"; import { getDescription } from "../../utils/customJsonReporter"; import { commandCLI } from "tests/utils/cliUtils"; +import { isRunningInScheduledWorkflow } from "tests/utils/githubUtils"; //Warning 🚨: XRP Tests may fail due to API HTTP 429 issue - Jira: LIVE-14237 @@ -210,221 +211,187 @@ const tokenTransactionInvalid = [ }, ]; -//Warning 🚨: Test may fail due to the GetAppAndVersion issue - Jira: LIVE-12581 or insufficient funds +test.describe("Send flows", () => { + test.beforeAll(async () => { + process.env.ENABLE_TRANSACTION_BROADCAST = + new Date().getDay() === 1 && isRunningInScheduledWorkflow() ? "1" : "0"; + }); + //Warning 🚨: Test may fail due to the GetAppAndVersion issue - Jira: LIVE-12581 or insufficient funds + + for (const transaction of transactionE2E) { + test.describe("Send from 1 account to another", () => { + test.use({ + userdata: "skip-onboarding", + speculosApp: transaction.transaction.accountToDebit.currency.speculosApp, + cliCommands: [ + { + command: commandCLI.liveData, + args: { + currency: transaction.transaction.accountToCredit.currency.currencyId, + index: transaction.transaction.accountToCredit.index, + add: true, + appjson: "", + }, + }, + { + command: commandCLI.liveData, + args: { + currency: transaction.transaction.accountToDebit.currency.currencyId, + index: transaction.transaction.accountToDebit.index, + add: true, + appjson: "", + }, + }, + ], + }); -for (const transaction of transactionE2E) { - test.describe("Send from 1 account to another", () => { - test.use({ - userdata: "skip-onboarding", - speculosApp: transaction.transaction.accountToDebit.currency.speculosApp, - cliCommands: [ + test( + `Send from ${transaction.transaction.accountToDebit.accountName} to ${transaction.transaction.accountToCredit.accountName}`, { - command: commandCLI.liveData, - args: { - currency: transaction.transaction.accountToCredit.currency.currencyId, - index: transaction.transaction.accountToCredit.index, - add: true, - appjson: "", + annotation: { + type: "TMS", + description: transaction.xrayTicket, }, }, - { - command: commandCLI.liveData, - args: { - currency: transaction.transaction.accountToDebit.currency.currencyId, - index: transaction.transaction.accountToDebit.index, - add: true, - appjson: "", - }, + async ({ app }) => { + await addTmsLink(getDescription(test.info().annotations).split(", ")); + + await app.layout.goToAccounts(); + await app.accounts.navigateToAccountByName( + transaction.transaction.accountToDebit.accountName, + ); + + await app.account.clickSend(); + await app.send.craftTx(transaction.transaction); + await app.send.expectTxInfoValidity(transaction.transaction); + await app.send.clickContinueToDevice(); + + await app.speculos.signSendTransaction(transaction.transaction); + await app.send.expectTxSent(); + await app.account.navigateToViewDetails(); + await app.sendDrawer.addressValueIsVisible( + transaction.transaction.accountToCredit.address, + ); + await app.drawer.close(); + + await app.layout.goToAccounts(); + await app.accounts.clickSyncBtnForAccount( + transaction.transaction.accountToCredit.accountName, + ); + await app.accounts.navigateToAccountByName( + transaction.transaction.accountToCredit.accountName, + ); + await app.account.clickOnLastOperation(); + await app.sendDrawer.expectReceiverInfos(transaction.transaction); }, - ], + ); }); + } - test( - `Send from ${transaction.transaction.accountToDebit.accountName} to ${transaction.transaction.accountToCredit.accountName}`, - { - annotation: { - type: "TMS", - description: transaction.xrayTicket, - }, - }, - async ({ app }) => { - await addTmsLink(getDescription(test.info().annotations).split(", ")); - - await app.layout.goToAccounts(); - await app.accounts.navigateToAccountByName( - transaction.transaction.accountToDebit.accountName, - ); - - await app.account.clickSend(); - await app.send.craftTx(transaction.transaction); - await app.send.expectTxInfoValidity(transaction.transaction); - await app.send.clickContinueToDevice(); - - await app.speculos.signSendTransaction(transaction.transaction); - await app.send.expectTxSent(); - await app.account.navigateToViewDetails(); - await app.sendDrawer.addressValueIsVisible(transaction.transaction.accountToCredit.address); - await app.drawer.close(); + test.describe("Send token (subAccount) - invalid address input", () => { + const tokenTransactionInvalid = { + transaction: new Transaction(Account.ALGO_USDT_1, Account.ALGO_USDT_2, "0.1", Fee.MEDIUM), + expectedErrorMessage: "Recipient account has not opted in the selected ASA.", + }; - await app.layout.goToAccounts(); - await app.accounts.clickSyncBtnForAccount( - transaction.transaction.accountToCredit.accountName, - ); - await app.accounts.navigateToAccountByName( - transaction.transaction.accountToCredit.accountName, - ); - await app.account.clickOnLastOperation(); - await app.sendDrawer.expectReceiverInfos(transaction.transaction); - }, - ); - }); -} - -test.describe("Send token (subAccount) - invalid address input", () => { - const tokenTransactionInvalid = { - transaction: new Transaction(Account.ALGO_USDT_1, Account.ALGO_USDT_2, "0.1", Fee.MEDIUM), - expectedErrorMessage: "Recipient account has not opted in the selected ASA.", - }; - - test.use({ - userdata: "skip-onboarding", - speculosApp: tokenTransactionInvalid.transaction.accountToDebit.currency.speculosApp, - cliCommands: [ - { - command: commandCLI.liveData, - args: { - currency: tokenTransactionInvalid.transaction.accountToDebit.currency.currencyId, - index: tokenTransactionInvalid.transaction.accountToDebit.index, - add: true, - appjson: "", - }, - }, - ], - }); - - test( - `Send from ${tokenTransactionInvalid.transaction.accountToDebit.accountName} to ${tokenTransactionInvalid.transaction.accountToCredit.accountName} - invalid address input`, - { - annotation: { - type: "TMS", - description: "B2CQA-2702", - }, - }, - async ({ app }) => { - await app.layout.goToAccounts(); - await app.accounts.navigateToAccountByName( - tokenTransactionInvalid.transaction.accountToDebit.accountName, - ); - await app.account.navigateToTokenInAccount( - tokenTransactionInvalid.transaction.accountToDebit, - ); - await app.account.clickSend(); - await app.send.fillRecipient(tokenTransactionInvalid.transaction.accountToCredit.address); - await app.send.checkContinueButtonDisabled(); - await app.layout.checkErrorMessage(tokenTransactionInvalid.expectedErrorMessage); - }, - ); -}); - -for (const transaction of tokenTransactionInvalid) { - test.describe("Send token (subAccount) - invalid amount input", () => { test.use({ userdata: "skip-onboarding", - speculosApp: transaction.transaction.accountToDebit.currency.speculosApp, + speculosApp: tokenTransactionInvalid.transaction.accountToDebit.currency.speculosApp, cliCommands: [ { command: commandCLI.liveData, args: { - currency: transaction.transaction.accountToDebit.currency.currencyId, - index: transaction.transaction.accountToDebit.index, + currency: tokenTransactionInvalid.transaction.accountToDebit.currency.currencyId, + index: tokenTransactionInvalid.transaction.accountToDebit.index, add: true, appjson: "", }, }, ], }); + test( - `Send from ${transaction.transaction.accountToDebit.accountName} to ${transaction.transaction.accountToCredit.accountName} - invalid amount input`, + `Send from ${tokenTransactionInvalid.transaction.accountToDebit.accountName} to ${tokenTransactionInvalid.transaction.accountToCredit.accountName} - invalid address input`, { annotation: { type: "TMS", - description: transaction.xrayTicket, + description: "B2CQA-2702", }, }, async ({ app }) => { await app.layout.goToAccounts(); await app.accounts.navigateToAccountByName( - transaction.transaction.accountToDebit.accountName, + tokenTransactionInvalid.transaction.accountToDebit.accountName, + ); + await app.account.navigateToTokenInAccount( + tokenTransactionInvalid.transaction.accountToDebit, ); - await app.account.navigateToTokenInAccount(transaction.transaction.accountToDebit); await app.account.clickSend(); - await app.send.fillRecipient(transaction.transaction.accountToCredit.address); - await app.send.clickContinue(); - await app.send.fillAmount(transaction.transaction.amount); + await app.send.fillRecipient(tokenTransactionInvalid.transaction.accountToCredit.address); await app.send.checkContinueButtonDisabled(); - await app.layout.checkAmoutWarningMessage(transaction.expectedWarningMessage); + await app.layout.checkErrorMessage(tokenTransactionInvalid.expectedErrorMessage); }, ); }); -} - -test.describe("Send token (subAccount) - valid address & amount input", () => { - const tokenTransactionValid = new Transaction( - Account.ETH_USDT_1, - Account.ETH_USDT_2, - "1", - Fee.MEDIUM, - ); - test.use({ - userdata: "skip-onboarding", - speculosApp: tokenTransactionValid.accountToDebit.currency.speculosApp, - cliCommands: [ - { - command: commandCLI.liveData, - args: { - currency: tokenTransactionValid.accountToDebit.currency.currencyId, - index: tokenTransactionValid.accountToDebit.index, - add: true, - appjson: "", - }, - }, - ], - }); - test( - `Send from ${tokenTransactionValid.accountToDebit.accountName} to ${tokenTransactionValid.accountToCredit.accountName} - valid address & amount input`, - { - annotation: { - type: "TMS", - description: "B2CQA-2703, B2CQA-475", - }, - }, - async ({ app }) => { - await app.layout.goToAccounts(); - await app.accounts.navigateToAccountByName(tokenTransactionValid.accountToDebit.accountName); - await app.account.navigateToTokenInAccount(tokenTransactionValid.accountToDebit); - await app.account.clickSend(); - await app.send.fillRecipient(tokenTransactionValid.accountToCredit.address); - await app.send.checkContinueButtonEnable(); - await app.layout.checkInputErrorVisibibility("hidden"); - await app.send.clickContinue(); - await app.send.fillAmount(tokenTransactionValid.amount); - await app.send.checkContinueButtonEnable(); - }, - ); -}); + for (const transaction of tokenTransactionInvalid) { + test.describe("Send token (subAccount) - invalid amount input", () => { + test.use({ + userdata: "skip-onboarding", + speculosApp: transaction.transaction.accountToDebit.currency.speculosApp, + cliCommands: [ + { + command: commandCLI.liveData, + args: { + currency: transaction.transaction.accountToDebit.currency.currencyId, + index: transaction.transaction.accountToDebit.index, + add: true, + appjson: "", + }, + }, + ], + }); + test( + `Send from ${transaction.transaction.accountToDebit.accountName} to ${transaction.transaction.accountToCredit.accountName} - invalid amount input`, + { + annotation: { + type: "TMS", + description: transaction.xrayTicket, + }, + }, + async ({ app }) => { + await app.layout.goToAccounts(); + await app.accounts.navigateToAccountByName( + transaction.transaction.accountToDebit.accountName, + ); + await app.account.navigateToTokenInAccount(transaction.transaction.accountToDebit); + await app.account.clickSend(); + await app.send.fillRecipient(transaction.transaction.accountToCredit.address); + await app.send.clickContinue(); + await app.send.fillAmount(transaction.transaction.amount); + await app.send.checkContinueButtonDisabled(); + await app.layout.checkAmoutWarningMessage(transaction.expectedWarningMessage); + }, + ); + }); + } -for (const transaction of transactionsAmountInvalid) { - test.describe("Check invalid amount input error", () => { + test.describe("Send token (subAccount) - valid address & amount input", () => { + const tokenTransactionValid = new Transaction( + Account.ETH_USDT_1, + Account.ETH_USDT_2, + "1", + Fee.MEDIUM, + ); test.use({ userdata: "skip-onboarding", - speculosApp: transaction.transaction.accountToDebit.currency.speculosApp, + speculosApp: tokenTransactionValid.accountToDebit.currency.speculosApp, cliCommands: [ { command: commandCLI.liveData, args: { - currency: transaction.transaction.accountToDebit.currency.currencyId, - index: transaction.transaction.accountToDebit.index, + currency: tokenTransactionValid.accountToDebit.currency.currencyId, + index: tokenTransactionValid.accountToDebit.index, add: true, appjson: "", }, @@ -433,89 +400,90 @@ for (const transaction of transactionsAmountInvalid) { }); test( - `Check "${transaction.expectedErrorMessage}" for ${transaction.transaction.accountToDebit.currency.name} - invalid amount ${transaction.transaction.amount} input error`, + `Send from ${tokenTransactionValid.accountToDebit.accountName} to ${tokenTransactionValid.accountToCredit.accountName} - valid address & amount input`, { annotation: { type: "TMS", - description: transaction.xrayTicket, + description: "B2CQA-2703, B2CQA-475", }, }, async ({ app }) => { await app.layout.goToAccounts(); await app.accounts.navigateToAccountByName( - transaction.transaction.accountToDebit.accountName, + tokenTransactionValid.accountToDebit.accountName, ); - + await app.account.navigateToTokenInAccount(tokenTransactionValid.accountToDebit); await app.account.clickSend(); - await app.send.fillRecipient(transaction.transaction.accountToCredit.address); + await app.send.fillRecipient(tokenTransactionValid.accountToCredit.address); + await app.send.checkContinueButtonEnable(); + await app.layout.checkInputErrorVisibibility("hidden"); await app.send.clickContinue(); - await app.send.fillAmount(transaction.transaction.amount); - await app.send.checkContinueButtonDisabled(); - await app.layout.checkErrorMessage(transaction.expectedErrorMessage); + await app.send.fillAmount(tokenTransactionValid.amount); + await app.send.checkContinueButtonEnable(); }, ); }); -} - -test.describe("Verify send max user flow", () => { - const transactionInputValid = new Transaction( - Account.ETH_1, - Account.ETH_2, - "send max", - Fee.MEDIUM, - ); - - test.use({ - userdata: "skip-onboarding", - speculosApp: transactionInputValid.accountToDebit.currency.speculosApp, - cliCommands: [ - { - command: commandCLI.liveData, - args: { - currency: transactionInputValid.accountToDebit.currency.currencyId, - index: transactionInputValid.accountToDebit.index, - add: true, - appjson: "", + + for (const transaction of transactionsAmountInvalid) { + test.describe("Check invalid amount input error", () => { + test.use({ + userdata: "skip-onboarding", + speculosApp: transaction.transaction.accountToDebit.currency.speculosApp, + cliCommands: [ + { + command: commandCLI.liveData, + args: { + currency: transaction.transaction.accountToDebit.currency.currencyId, + index: transaction.transaction.accountToDebit.index, + add: true, + appjson: "", + }, + }, + ], + }); + + test( + `Check "${transaction.expectedErrorMessage}" for ${transaction.transaction.accountToDebit.currency.name} - invalid amount ${transaction.transaction.amount} input error`, + { + annotation: { + type: "TMS", + description: transaction.xrayTicket, + }, }, - }, - ], - }); + async ({ app }) => { + await app.layout.goToAccounts(); + await app.accounts.navigateToAccountByName( + transaction.transaction.accountToDebit.accountName, + ); + + await app.account.clickSend(); + await app.send.fillRecipient(transaction.transaction.accountToCredit.address); + await app.send.clickContinue(); + await app.send.fillAmount(transaction.transaction.amount); + await app.send.checkContinueButtonDisabled(); + await app.layout.checkErrorMessage(transaction.expectedErrorMessage); + }, + ); + }); + } - test( - `Check Valid amount input (${transactionInputValid.amount})`, - { - annotation: { - type: "TMS", - description: "B2CQA-473", - }, - }, - async ({ app }) => { - await addTmsLink(getDescription(test.info().annotations).split(", ")); - await app.layout.goToAccounts(); - await app.accounts.navigateToAccountByName(transactionInputValid.accountToDebit.accountName); - - await app.account.clickSend(); - await app.send.fillRecipient(transactionInputValid.accountToCredit.address); - await app.send.clickContinue(); - await app.send.fillAmount(transactionInputValid.amount); - await app.send.checkContinueButtonEnable(); - await app.layout.checkInputErrorVisibibility("hidden"); - }, - ); -}); + test.describe("Verify send max user flow", () => { + const transactionInputValid = new Transaction( + Account.ETH_1, + Account.ETH_2, + "send max", + Fee.MEDIUM, + ); -for (const transaction of transactionAddressValid) { - test.describe("Send funds step 1 (Recipient) - positive cases (Button enabled)", () => { test.use({ userdata: "skip-onboarding", - speculosApp: transaction.transaction.accountToDebit.currency.speculosApp, + speculosApp: transactionInputValid.accountToDebit.currency.speculosApp, cliCommands: [ { command: commandCLI.liveData, args: { - currency: transaction.transaction.accountToDebit.currency.currencyId, - index: transaction.transaction.accountToDebit.index, - scheme: transaction.transaction.accountToDebit.derivationMode, + currency: transactionInputValid.accountToDebit.currency.currencyId, + index: transactionInputValid.accountToDebit.index, add: true, appjson: "", }, @@ -524,119 +492,164 @@ for (const transaction of transactionAddressValid) { }); test( - `Check button enabled (${transaction.transaction.amount} from ${transaction.transaction.accountToDebit.accountName} to ${transaction.transaction.accountToCredit.accountName}) - valid address input (${transaction.transaction.accountToDebit.address})`, + `Check Valid amount input (${transactionInputValid.amount})`, { annotation: { type: "TMS", - description: transaction.xrayTicket, + description: "B2CQA-473", }, }, async ({ app }) => { await addTmsLink(getDescription(test.info().annotations).split(", ")); await app.layout.goToAccounts(); await app.accounts.navigateToAccountByName( - transaction.transaction.accountToDebit.accountName, + transactionInputValid.accountToDebit.accountName, ); await app.account.clickSend(); - await app.send.fillRecipientInfo(transaction.transaction); - await app.layout.checkInputWarningMessage(transaction.expectedWarningMessage); + await app.send.fillRecipient(transactionInputValid.accountToCredit.address); + await app.send.clickContinue(); + await app.send.fillAmount(transactionInputValid.amount); await app.send.checkContinueButtonEnable(); + await app.layout.checkInputErrorVisibibility("hidden"); }, ); }); -} -for (const transaction of transactionsAddressInvalid) { - test.describe("Send funds step 1 (Recipient) - negative cases (Button disabled)", () => { + for (const transaction of transactionAddressValid) { + test.describe("Send funds step 1 (Recipient) - positive cases (Button enabled)", () => { + test.use({ + userdata: "skip-onboarding", + speculosApp: transaction.transaction.accountToDebit.currency.speculosApp, + cliCommands: [ + { + command: commandCLI.liveData, + args: { + currency: transaction.transaction.accountToDebit.currency.currencyId, + index: transaction.transaction.accountToDebit.index, + scheme: transaction.transaction.accountToDebit.derivationMode, + add: true, + appjson: "", + }, + }, + ], + }); + + test( + `Check button enabled (${transaction.transaction.amount} from ${transaction.transaction.accountToDebit.accountName} to ${transaction.transaction.accountToCredit.accountName}) - valid address input (${transaction.transaction.accountToDebit.address})`, + { + annotation: { + type: "TMS", + description: transaction.xrayTicket, + }, + }, + async ({ app }) => { + await addTmsLink(getDescription(test.info().annotations).split(", ")); + await app.layout.goToAccounts(); + await app.accounts.navigateToAccountByName( + transaction.transaction.accountToDebit.accountName, + ); + + await app.account.clickSend(); + await app.send.fillRecipientInfo(transaction.transaction); + await app.layout.checkInputWarningMessage(transaction.expectedWarningMessage); + await app.send.checkContinueButtonEnable(); + }, + ); + }); + } + + for (const transaction of transactionsAddressInvalid) { + test.describe("Send funds step 1 (Recipient) - negative cases (Button disabled)", () => { + test.use({ + userdata: "skip-onboarding", + speculosApp: transaction.transaction.accountToDebit.currency.speculosApp, + cliCommands: [ + { + command: commandCLI.liveData, + args: { + currency: transaction.transaction.accountToDebit.currency.currencyId, + index: transaction.transaction.accountToDebit.index, + add: true, + appjson: "", + }, + }, + ], + }); + + test( + `Check "${transaction.expectedErrorMessage}" (from ${transaction.transaction.accountToDebit.accountName} to ${transaction.transaction.accountToCredit.accountName}) - invalid address input error`, + { + annotation: { + type: "TMS", + description: transaction.xrayTicket, + }, + }, + async ({ app }) => { + await addTmsLink(getDescription(test.info().annotations).split(", ")); + await app.layout.goToAccounts(); + await app.accounts.navigateToAccountByName( + transaction.transaction.accountToDebit.accountName, + ); + + await app.account.clickSend(); + await app.send.fillRecipientInfo(transaction.transaction); + await app.layout.checkErrorMessage(transaction.expectedErrorMessage); + await app.send.checkContinueButtonDisabled(); + }, + ); + }); + } + + test.describe("send NFT to ENS address", () => { + const transaction = new NFTTransaction(Account.ETH_1, Account.ETH_MC, "NY la muse", Fee.SLOW); + test.beforeAll(async () => { + process.env.DISABLE_TRANSACTION_BROADCAST = "true"; + }); + test.afterAll(async () => { + delete process.env.DISABLE_TRANSACTION_BROADCAST; + }); test.use({ userdata: "skip-onboarding", - speculosApp: transaction.transaction.accountToDebit.currency.speculosApp, cliCommands: [ { command: commandCLI.liveData, args: { - currency: transaction.transaction.accountToDebit.currency.currencyId, - index: transaction.transaction.accountToDebit.index, - add: true, + currency: transaction.accountToDebit.currency.currencyId, + index: transaction.accountToDebit.index, appjson: "", + add: true, }, }, ], + speculosApp: transaction.accountToDebit.currency.speculosApp, }); test( - `Check "${transaction.expectedErrorMessage}" (from ${transaction.transaction.accountToDebit.accountName} to ${transaction.transaction.accountToCredit.accountName}) - invalid address input error`, + "Send NFT to ENS address", { annotation: { type: "TMS", - description: transaction.xrayTicket, + description: "B2CQA-2203", }, }, async ({ app }) => { await addTmsLink(getDescription(test.info().annotations).split(", ")); await app.layout.goToAccounts(); - await app.accounts.navigateToAccountByName( - transaction.transaction.accountToDebit.accountName, - ); - - await app.account.clickSend(); - await app.send.fillRecipientInfo(transaction.transaction); - await app.layout.checkErrorMessage(transaction.expectedErrorMessage); - await app.send.checkContinueButtonDisabled(); + await app.accounts.navigateToAccountByName(transaction.accountToDebit.accountName); + await app.account.navigateToNFTGallery(); + await app.account.selectNFT(transaction.nftName); + await app.nftDrawer.expectNftNameIsVisible(transaction.nftName); + await app.nftDrawer.clickSend(); + await app.send.craftNFTTx(transaction); + await app.send.expectNFTTxInfoValidity(transaction); + await app.speculos.signSendNFTTransaction(transaction); + await app.send.expectTxSent(); + await app.account.navigateToViewDetails(); + await app.drawer.close(); + await app.account.navigateToNFTOperation(); + await app.sendDrawer.expectNftInfos(transaction); }, ); }); -} - -test.describe("send NFT to ENS address", () => { - const transaction = new NFTTransaction(Account.ETH_1, Account.ETH_MC, "NY la muse", Fee.SLOW); - test.beforeAll(async () => { - process.env.DISABLE_TRANSACTION_BROADCAST = "true"; - }); - test.afterAll(async () => { - delete process.env.DISABLE_TRANSACTION_BROADCAST; - }); - test.use({ - userdata: "skip-onboarding", - cliCommands: [ - { - command: commandCLI.liveData, - args: { - currency: transaction.accountToDebit.currency.currencyId, - index: transaction.accountToDebit.index, - appjson: "", - add: true, - }, - }, - ], - speculosApp: transaction.accountToDebit.currency.speculosApp, - }); - - test( - "Send NFT to ENS address", - { - annotation: { - type: "TMS", - description: "B2CQA-2203", - }, - }, - async ({ app }) => { - await addTmsLink(getDescription(test.info().annotations).split(", ")); - await app.layout.goToAccounts(); - await app.accounts.navigateToAccountByName(transaction.accountToDebit.accountName); - await app.account.navigateToNFTGallery(); - await app.account.selectNFT(transaction.nftName); - await app.nftDrawer.expectNftNameIsVisible(transaction.nftName); - await app.nftDrawer.clickSend(); - await app.send.craftNFTTx(transaction); - await app.send.expectNFTTxInfoValidity(transaction); - await app.speculos.signSendNFTTransaction(transaction); - await app.send.expectTxSent(); - await app.account.navigateToViewDetails(); - await app.drawer.close(); - await app.account.navigateToNFTOperation(); - await app.sendDrawer.expectNftInfos(transaction); - }, - ); }); diff --git a/apps/ledger-live-desktop/tests/utils/githubUtils.ts b/apps/ledger-live-desktop/tests/utils/githubUtils.ts new file mode 100644 index 000000000000..89703fe0bb56 --- /dev/null +++ b/apps/ledger-live-desktop/tests/utils/githubUtils.ts @@ -0,0 +1,3 @@ +export function isRunningInScheduledWorkflow(): boolean { + return process.env.GITHUB_ACTIONS === "true" && process.env.GITHUB_EVENT_NAME === "schedule"; +}