diff --git a/.github/workflows/e2e-tests-dapp.yml b/.github/workflows/e2e-tests-dapp.yml new file mode 100644 index 0000000000..38cdb29c2a --- /dev/null +++ b/.github/workflows/e2e-tests-dapp.yml @@ -0,0 +1,162 @@ +name: E2E DApp tests + +on: + workflow_dispatch: + pull_request: + types: [opened, ready_for_review] + pull_request_review: + types: [submitted] + +jobs: + General: + if: github.event.review && (github.event.review.state == 'approved' || contains(github.event.review.body, '/check') || contains(github.event.review.body, '/dapp-general')) + runs-on: macos-14 + strategy: + matrix: + browser: ["chrome"] + fail-fast: false + + steps: + - uses: actions/checkout@v4 + + - name: distutils hack + run: brew install python-setuptools + + - name: Forcefully update the Chrome browser + if: matrix.browser=='chrome' + run: brew update && brew upgrade --cask google-chrome + + - name: Forcefully install Firefox for Developers browser + if: matrix.browser=='firefox' + run: | + brew update + brew tap homebrew/cask-versions && brew install --cask firefox-developer-edition + echo "FIREFOX_BIN=/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox-bin" >> $GITHUB_ENV + + - name: Read .nvmrc + id: nvm + run: echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_OUTPUT + + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: "${{ steps.nvm.outputs.NVMRC }}" + + - name: + Cache extension node modules + # https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows + uses: actions/cache@v4 + env: + cache-name: cache-yoroi-extension-node-modules + with: + # It is recommended to cache the NPM cache (~/.npm) instead of node_modules. + # https://github.com/actions/cache/blob/main/examples.md#node---npm + # But we put node version into the cache key and cache node_modules. + path: packages/yoroi-extension/node_modules + key: ${{ runner.os }}-build-${{ env.cache-name }}-node-${{ steps.nvm.outputs.NVMRC }}-${{ hashFiles('packages/yoroi-extension/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: npm install + run: | + . install-all.sh + + - name: Build the test mainnet version + working-directory: ./packages/yoroi-extension + run: npm run test:build:mainnet + + - name: Run tests + working-directory: ./packages/e2e-tests + env: + FIRST_SMOKE_TEST_WALLET: ${{ secrets.FIRST_SMOKE_TEST_WALLET }} + SECOND_STATIC_TEST_WALLET: ${{ secrets.SECOND_STATIC_TEST_WALLET }} + SECOND_SMOKE_TEST_WALLET: ${{ secrets.SECOND_SMOKE_TEST_WALLET }} + SECOND_SMOKE_TEST_WALLET_FF: ${{ secrets.SECOND_SMOKE_TEST_WALLET_FF }} + run: npm run test:${{ matrix.browser }}:dapp + + - name: Archive tests screenshots and logs + if: ${{ failure() }} + uses: actions/upload-artifact@v4 + with: + name: testRunsData_E2E_tests_${{ matrix.browser }} + path: | + ./packages/e2e-tests/mochawesome-report + ./packages/e2e-tests/testRunsData_${{ matrix.browser }} + + Failing: + if: github.event.review && contains(github.event.review.body, '/dapp-failing') + runs-on: macos-14 + strategy: + matrix: + browser: ['chrome'] + fail-fast: false + + steps: + - uses: actions/checkout@v4 + + - name: distutils hack + run: brew install python-setuptools + + - name: Forcefully update the Chrome browser + if: matrix.browser=='chrome' + run: brew update && brew upgrade --cask google-chrome + + - name: Forcefully install Firefox for Developers browser + if: matrix.browser=='firefox' + run: | + brew update + brew tap homebrew/cask-versions && brew install --cask firefox-developer-edition + echo "FIREFOX_BIN=/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox-bin" >> $GITHUB_ENV + + - name: Read .nvmrc + id: nvm + run: echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_OUTPUT + + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: '${{ steps.nvm.outputs.NVMRC }}' + + - name: Cache extension node modules + # https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows + uses: actions/cache@v4 + env: + cache-name: cache-yoroi-extension-node-modules + with: + # https://github.com/actions/cache/blob/main/examples.md#node---npm + # It is recommended to cache the NPM cache (~/.npm) instead of node_modules. + # But we put node version into the cache key and cache node_modules. + path: packages/yoroi-extension/node_modules + key: ${{ runner.os }}-build-${{ env.cache-name }}-node-${{ steps.nvm.outputs.NVMRC }}-${{ hashFiles('packages/yoroi-extension/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: npm install + run: | + . install-all.sh + + - name: Build the test mainnet version + working-directory: ./packages/yoroi-extension + run: npm run test:build:mainnet + + - name: Run tests + working-directory: ./packages/e2e-tests + env: + FIRST_SMOKE_TEST_WALLET: ${{ secrets.FIRST_SMOKE_TEST_WALLET }} + SECOND_STATIC_TEST_WALLET: ${{ secrets.SECOND_STATIC_TEST_WALLET }} + SECOND_SMOKE_TEST_WALLET: ${{ secrets.SECOND_SMOKE_TEST_WALLET }} + SECOND_SMOKE_TEST_WALLET_FF: ${{ secrets.SECOND_SMOKE_TEST_WALLET_FF }} + run: npm run test:${{ matrix.browser }}:dapp:bl + + - name: Archive tests screenshots and logs + if: ${{ failure() }} + uses: actions/upload-artifact@v4 + with: + name: testRunsData_E2E_tests_${{ matrix.browser }} + path: | + ./packages/e2e-tests/mochawesome-report + ./packages/e2e-tests/testRunsData_${{ matrix.browser }} diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests-ext.yml similarity index 90% rename from .github/workflows/e2e-tests.yml rename to .github/workflows/e2e-tests-ext.yml index 72a1251e2f..ac798239b2 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests-ext.yml @@ -1,19 +1,19 @@ -name: End-2-end tests +name: E2E Ext tests on: workflow_dispatch: pull_request: - types: [ opened, ready_for_review ] + types: [opened, ready_for_review] pull_request_review: - types: [ submitted ] + types: [submitted] jobs: - E2E_tests: - if: github.event.review && (github.event.review.state == 'approved' || contains(github.event.review.body, '/check') || contains(github.event.review.body, '/regression-check')) + General: + if: github.event.review && (github.event.review.state == 'approved' || contains(github.event.review.body, '/check') || contains(github.event.review.body, '/ext-general')) runs-on: macos-14 strategy: matrix: - browser: ['chrome'] + browser: ["chrome"] fail-fast: false steps: @@ -40,7 +40,7 @@ jobs: - name: Setup node uses: actions/setup-node@v4 with: - node-version: '${{ steps.nvm.outputs.NVMRC }}' + node-version: "${{ steps.nvm.outputs.NVMRC }}" - name: Cache extension node modules # https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows @@ -84,14 +84,14 @@ jobs: ./packages/e2e-tests/mochawesome-report ./packages/e2e-tests/testRunsData_${{ matrix.browser }} - E2E_dapp_tests: - if: github.event.review && (github.event.review.state == 'approved' || contains(github.event.review.body, '/check') || contains(github.event.review.body, '/dapp-check')) + Failing: + if: github.event.review && contains(github.event.review.body, '/ext-failing') runs-on: macos-14 strategy: matrix: - browser: ['chrome'] + browser: ["chrome"] fail-fast: false - + steps: - uses: actions/checkout@v4 @@ -116,7 +116,7 @@ jobs: - name: Setup node uses: actions/setup-node@v4 with: - node-version: '${{ steps.nvm.outputs.NVMRC }}' + node-version: "${{ steps.nvm.outputs.NVMRC }}" - name: Cache extension node modules # https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows @@ -137,7 +137,7 @@ jobs: - name: npm install run: | . install-all.sh - + - name: Build the test mainnet version working-directory: ./packages/yoroi-extension run: npm run test:build:mainnet @@ -149,7 +149,7 @@ jobs: SECOND_STATIC_TEST_WALLET: ${{ secrets.SECOND_STATIC_TEST_WALLET }} SECOND_SMOKE_TEST_WALLET: ${{ secrets.SECOND_SMOKE_TEST_WALLET }} SECOND_SMOKE_TEST_WALLET_FF: ${{ secrets.SECOND_SMOKE_TEST_WALLET_FF }} - run: npm run test:${{ matrix.browser }}:dapp + run: npm run test:${{ matrix.browser }}:bl - name: Archive tests screenshots and logs if: ${{ failure() }} @@ -158,4 +158,4 @@ jobs: name: testRunsData_E2E_tests_${{ matrix.browser }} path: | ./packages/e2e-tests/mochawesome-report - ./packages/e2e-tests/testRunsData_${{ matrix.browser }} \ No newline at end of file + ./packages/e2e-tests/testRunsData_${{ matrix.browser }} diff --git a/packages/e2e-tests/package.json b/packages/e2e-tests/package.json index 92a17cff9c..3a2d18e4e8 100644 --- a/packages/e2e-tests/package.json +++ b/packages/e2e-tests/package.json @@ -7,26 +7,33 @@ "config": { "hooksPath": "./utils/hooks.mjs", "testPathGeneral": "./test/*.test.js", + "testPathGeneralBl": "./test/blacklist/*.test.js", "testPathHW": "./test/hw/*.test.js", - "testPathDApp": "./test/dapp/*.test.js" + "testPathDApp": "./test/dapp/*.test.js", + "testPathDAppBl": "./test/blacklist/dapp/*.test.js" }, "scripts": { "test:clean:logs": "find . -type d -name \"testRunsData_*\" -exec rm -r {} +", "test:base:sequintel": "npm run test:clean:logs && mocha --require $npm_package_config_hooksPath $npm_package_config_testPathGeneral --reporter mochawesome", + "test:base:sequintel:bl": "npm run test:clean:logs && mocha --require $npm_package_config_hooksPath $npm_package_config_testPathGeneralBl --reporter mochawesome", "test:hw:base:sequintel": "npm run test:clean:logs && mocha --require $npm_package_config_hooksPath $npm_package_config_testPathHW --reporter mochawesome", "test:dapp:base:sequintel": "npm run test:clean:logs && mocha --require $npm_package_config_hooksPath $npm_package_config_testPathDApp --reporter mochawesome", + "test:dapp:base:sequintel:bl": "npm run test:clean:logs && mocha --require $npm_package_config_hooksPath $npm_package_config_testPathDAppBl --reporter mochawesome", "test:base:parallel": "npm run test:clean:logs && mocha --require $npm_package_config_hooksPath $npm_package_config_testPathGeneral --parallel --reporter mochawesome --require mochawesome/register", "test:base:one": "npm run test:clean:logs && mocha --require $npm_package_config_hooksPath $npm_package_config_testPathGeneral -g", "test:hw:base:one": "npm run test:clean:logs && mocha --require $npm_package_config_hooksPath $npm_package_config_testPathHW -g", "test:dapp:base:one": "npm run test:clean:logs && mocha --require $npm_package_config_hooksPath $npm_package_config_testPathDApp -g", "test:chrome": "env TARGETBROWSER=chrome npm run test:base:sequintel", + "test:chrome:bl": "env TARGETBROWSER=chrome npm run test:base:sequintel:bl", "test:chrome:hw": "env TARGETBROWSER=chrome npm run test:hw:base:sequintel", "test:chrome:dapp": "env TARGETBROWSER=chrome npm run test:dapp:base:sequintel", + "test:chrome:dapp:bl": "env TARGETBROWSER=chrome npm run test:dapp:base:sequintel:bl", "test:chrome:parallel": "env TARGETBROWSER=chrome npm run test:base:parallel", "test:chrome:one": "env TARGETBROWSER=chrome npm run test:base:one", "test:chrome:hw:one": "env TARGETBROWSER=chrome npm run test:hw:base:one", "test:chrome:dapp:one": "env TARGETBROWSER=chrome npm run test:dapp:base:one", "test:firefox": "env TARGETBROWSER=firefox npm run test:base:sequintel", + "test:firefox:bl": "env TARGETBROWSER=firefox npm run test:base:sequintel:bl", "test:firefox:hw": "env TARGETBROWSER=firefox npm run test:hw:base:sequintel", "test:firefox:dapp": "env TARGETBROWSER=firefox npm run test:dapp:base:sequintel", "test:firefox:parallel": "env TARGETBROWSER=firefox npm run test:base:parallel", diff --git a/packages/e2e-tests/pages/basepage.js b/packages/e2e-tests/pages/basepage.js index fe59a70ee0..cc6c5493c2 100644 --- a/packages/e2e-tests/pages/basepage.js +++ b/packages/e2e-tests/pages/basepage.js @@ -2,7 +2,13 @@ import { until, Key, logging } from 'selenium-webdriver'; import path from 'path'; import * as fs from 'node:fs'; import { promisify } from 'util'; -import { createTestRunDataDir, getByLocator, isFirefox, isChrome } from '../utils/utils.js'; +import { + createTestRunDataDir, + getByLocator, + getSnapshotObjectFromJSON, + isFirefox, + isChrome, +} from '../utils/utils.js'; import { getExtensionUrl } from '../utils/driverBootstrap.js'; import { defaultRepeatPeriod, @@ -10,7 +16,6 @@ import { halfSecond, oneSecond, } from '../helpers/timeConstants.js'; -import { getSnapshotObjectFromJSON } from '../utils/utils.js'; import { dbSnapshotsDir } from '../helpers/constants.js'; const writeFile = promisify(fs.writeFile); @@ -88,7 +93,8 @@ class BasePage { } async getText(locator) { this.logger.info(`BasePage::getText is called. Locator: ${JSON.stringify(locator)}`); - return await this.driver.findElement(getByLocator(locator)).getText(); + const locatorElem = await this.waitForElement(locator); + return await locatorElem.getText(); } async getCssValue(locator, cssStyleProperty) { this.logger.info( @@ -512,7 +518,7 @@ class BasePage { console.log('-----> Error happend:', event.target.result); }; const store = tx.objectStore(tableName); - const addRequest = store.put(valueItem); + store.put(valueItem); }; }, name, diff --git a/packages/e2e-tests/pages/walletCommonBase.page.js b/packages/e2e-tests/pages/walletCommonBase.page.js index ae519c9068..f0270b2bba 100644 --- a/packages/e2e-tests/pages/walletCommonBase.page.js +++ b/packages/e2e-tests/pages/walletCommonBase.page.js @@ -121,10 +121,11 @@ class WalletCommonBase extends BasePage { const rawNameAndPlateText = await this.getText(this.walletNameAndPlateNumberTextLocator); const [walletName, walletPlate] = rawNameAndPlateText.split('\n'); - await this.waitForElement(this.walletBalanceTextLocator); - const rawBalanceText = await this.getText(this.walletBalanceTextLocator); + const walletBalanceElem = await this.waitForElement(this.walletBalanceTextLocator); + const rawBalanceText = await walletBalanceElem.getText(); const adaBalance = Number(rawBalanceText.split(' ')[0]); + await this.waitForElement(this.walletFiatBalanceTextLocator); const rawFiatBalanceText = await this.getText(this.walletFiatBalanceTextLocator); const [fiatBalanceStr, fiatCurrency] = rawFiatBalanceText.split(' '); const fiatBalance = fiatBalanceStr === '-' ? 0 : Number(fiatBalanceStr); @@ -200,7 +201,8 @@ class WalletCommonBase extends BasePage { } async openChangeWalletModal() { this.logger.info(`WalletCommonBase::openChangeWalletModal is called`); - await this.click(this.selectedWalletButtonLocator); + const selectWalletBtnElem = await this.waitForElement(this.selectedWalletButtonLocator); + await selectWalletBtnElem.click(); await this.waitForElement(this.changeWalletDialogLocator); } async addNewWallet() { diff --git a/packages/e2e-tests/test/04_removingWallet.test.js b/packages/e2e-tests/test/04_removingWallet.test.js index 0d204990b4..36a00d6a17 100644 --- a/packages/e2e-tests/test/04_removingWallet.test.js +++ b/packages/e2e-tests/test/04_removingWallet.test.js @@ -1,11 +1,9 @@ import BasePage from '../pages/basepage.js'; import { customAfterEach } from '../utils/customHooks.js'; import TransactionsSubTab from '../pages/wallet/walletTab/walletTransactions.page.js'; -import { testWallet1 } from '../utils/testWallets.js'; import { expect } from 'chai'; import { getTestLogger } from '../utils/utils.js'; import { oneMinute } from '../helpers/timeConstants.js'; -import { restoreWallet } from '../helpers/restoreWalletHelper.js'; import SettingsTab from '../pages/wallet/settingsTab/settingsTab.page.js'; import WalletSubTab from '../pages/wallet/settingsTab/walletSubTab.page.js'; import AddNewWallet from '../pages/addNewWallet.page.js'; diff --git a/packages/e2e-tests/test/06_renamingWallet.test.js b/packages/e2e-tests/test/06_renamingWallet.test.js index cdbc7f52ec..85a5fd5621 100644 --- a/packages/e2e-tests/test/06_renamingWallet.test.js +++ b/packages/e2e-tests/test/06_renamingWallet.test.js @@ -4,7 +4,6 @@ import { testWallet1 } from '../utils/testWallets.js'; import { expect } from 'chai'; import { getTestLogger, walletNameShortener } from '../utils/utils.js'; import { oneMinute } from '../helpers/timeConstants.js'; -import { restoreWallet } from '../helpers/restoreWalletHelper.js'; import SettingsTab from '../pages/wallet/settingsTab/settingsTab.page.js'; import WalletSubTab from '../pages/wallet/settingsTab/walletSubTab.page.js'; import TransactionsSubTab from '../pages/wallet/walletTab/walletTransactions.page.js'; diff --git a/packages/e2e-tests/test/07_changingPassword.test.js b/packages/e2e-tests/test/07_changingPassword.test.js index 944ca90580..212df032c7 100644 --- a/packages/e2e-tests/test/07_changingPassword.test.js +++ b/packages/e2e-tests/test/07_changingPassword.test.js @@ -5,7 +5,6 @@ import { testWallet1 } from '../utils/testWallets.js'; import { expect } from 'chai'; import { getTestLogger } from '../utils/utils.js'; import { oneMinute } from '../helpers/timeConstants.js'; -import { restoreWallet } from '../helpers/restoreWalletHelper.js'; import SettingsTab from '../pages/wallet/settingsTab/settingsTab.page.js'; import WalletSubTab from '../pages/wallet/settingsTab/walletSubTab.page.js'; import { getPassword } from '../helpers/constants.js'; diff --git a/packages/e2e-tests/test/08_downloadingLogs.test.js b/packages/e2e-tests/test/08_downloadingLogs.test.js index 05b2fc0e0c..32bfbfb285 100644 --- a/packages/e2e-tests/test/08_downloadingLogs.test.js +++ b/packages/e2e-tests/test/08_downloadingLogs.test.js @@ -1,7 +1,6 @@ import BasePage from '../pages/basepage.js'; import { customAfterEach } from '../utils/customHooks.js'; import TransactionsSubTab from '../pages/wallet/walletTab/walletTransactions.page.js'; -import { testWallet1 } from '../utils/testWallets.js'; import { expect } from 'chai'; import { cleanDownloads, @@ -10,7 +9,6 @@ import { getTestLogger, } from '../utils/utils.js'; import { oneMinute } from '../helpers/timeConstants.js'; -import { restoreWallet } from '../helpers/restoreWalletHelper.js'; import SettingsTab from '../pages/wallet/settingsTab/settingsTab.page.js'; import SupportSubTab from '../pages/wallet/settingsTab/supportSubTab.page.js'; import driversPoolsManager from '../utils/driversPool.js'; diff --git a/packages/e2e-tests/test/09_exportTransactions.test.js b/packages/e2e-tests/test/09_exportTransactions.test.js index b00f8cc040..2ad1b05d3e 100644 --- a/packages/e2e-tests/test/09_exportTransactions.test.js +++ b/packages/e2e-tests/test/09_exportTransactions.test.js @@ -12,7 +12,6 @@ import { parseExportedCSV, } from '../utils/utils.js'; import { oneMinute } from '../helpers/timeConstants.js'; -import { restoreWallet } from '../helpers/restoreWalletHelper.js'; import driversPoolsManager from '../utils/driversPool.js'; import { compareExportedTxsAndDisplayedTxs } from '../helpers/customChecks.js'; import AddNewWallet from '../pages/addNewWallet.page.js'; diff --git a/packages/e2e-tests/test/10_exportTxsNegative.test.js b/packages/e2e-tests/test/10_exportTxsNegative.test.js index e1072aa831..9a6207c570 100644 --- a/packages/e2e-tests/test/10_exportTxsNegative.test.js +++ b/packages/e2e-tests/test/10_exportTxsNegative.test.js @@ -1,11 +1,9 @@ import BasePage from '../pages/basepage.js'; import { customAfterEach } from '../utils/customHooks.js'; import TransactionsSubTab from '../pages/wallet/walletTab/walletTransactions.page.js'; -import { testWallet1 } from '../utils/testWallets.js'; import { expect } from 'chai'; import { cleanDownloads, getTestLogger, getListOfDownloadedFiles } from '../utils/utils.js'; import { oneMinute } from '../helpers/timeConstants.js'; -import { restoreWallet } from '../helpers/restoreWalletHelper.js'; import driversPoolsManager from '../utils/driversPool.js'; import { Colors } from '../helpers/constants.js'; import AddNewWallet from '../pages/addNewWallet.page.js'; diff --git a/packages/e2e-tests/test/12_loadingAllTransactions.test.js b/packages/e2e-tests/test/12_loadingAllTransactions.test.js index 9d87b5aadd..08c219b2ca 100644 --- a/packages/e2e-tests/test/12_loadingAllTransactions.test.js +++ b/packages/e2e-tests/test/12_loadingAllTransactions.test.js @@ -11,7 +11,7 @@ import driversPoolsManager from '../utils/driversPool.js'; const testWallet = getSpendableWallet(); describe('Loading all txs', function () { - this.timeout(3 * oneMinute); + this.timeout(5 * oneMinute); let webdriver = null; let logger = null; diff --git a/packages/e2e-tests/test/18_changingLanguageSettings.test.js b/packages/e2e-tests/test/18_changingLanguageSettings.test.js index 34dea85eb6..5b96cdb16a 100644 --- a/packages/e2e-tests/test/18_changingLanguageSettings.test.js +++ b/packages/e2e-tests/test/18_changingLanguageSettings.test.js @@ -1,11 +1,9 @@ import BasePage from '../pages/basepage.js'; import { customAfterEach } from '../utils/customHooks.js'; import TransactionsSubTab from '../pages/wallet/walletTab/walletTransactions.page.js'; -import { testWallet1 } from '../utils/testWallets.js'; import { expect } from 'chai'; import { getTestLogger } from '../utils/utils.js'; import { oneMinute } from '../helpers/timeConstants.js'; -import { restoreWallet } from '../helpers/restoreWalletHelper.js'; import SettingsTab from '../pages/wallet/settingsTab/settingsTab.page.js'; import driversPoolsManager from '../utils/driversPool.js'; import GeneralSubTab from '../pages/wallet/settingsTab/generalSubTab.page.js'; diff --git a/packages/e2e-tests/test/19_changingFiat.test.js b/packages/e2e-tests/test/19_changingFiat.test.js index db564121da..f32c259603 100644 --- a/packages/e2e-tests/test/19_changingFiat.test.js +++ b/packages/e2e-tests/test/19_changingFiat.test.js @@ -1,21 +1,19 @@ import BasePage from '../pages/basepage.js'; import { customAfterEach } from '../utils/customHooks.js'; import TransactionsSubTab from '../pages/wallet/walletTab/walletTransactions.page.js'; -import { testWallet1 } from '../utils/testWallets.js'; import { expect } from 'chai'; -import { getTestLogger, roundUpCurrency } from '../utils/utils.js'; +import { diffIsLess1Perc, getCurrenciesPrices, getTestLogger, roundUpCurrency } from '../utils/utils.js'; import { oneMinute } from '../helpers/timeConstants.js'; -import { restoreWallet } from '../helpers/restoreWalletHelper.js'; import SettingsTab from '../pages/wallet/settingsTab/settingsTab.page.js'; import driversPoolsManager from '../utils/driversPool.js'; import GeneralSubTab from '../pages/wallet/settingsTab/generalSubTab.page.js'; import AddNewWallet from '../pages/addNewWallet.page.js'; -import axios from 'axios'; describe('Changing fiat currencies', function () { this.timeout(2 * oneMinute); let webdriver = null; let logger = null; + let prices = {}; before(function (done) { webdriver = driversPoolsManager.getDriverFromPool(); @@ -38,6 +36,7 @@ describe('Changing fiat currencies', function () { await transactionsPage.waitPrepareWalletBannerIsClosed(); const txPageIsDisplayed = await transactionsPage.isDisplayed(); expect(txPageIsDisplayed, 'The transactions page is not displayed').to.be.true; + prices = await getCurrenciesPrices(); }); for (const testDatum of testData) { @@ -62,13 +61,12 @@ describe('Changing fiat currencies', function () { expect(walletInfo.fiatBalance, 'Fiat balance is different').to.equal(0); } else { expect(walletInfo.fiatCurrency, 'Fiat currency is different').to.equal(testDatum); - const reqResponse = await axios.get('https://api.yoroiwallet.com/api/price/ADA/current'); - const prices = reqResponse.data.ticker.prices; const expectedFiatValue = roundUpCurrency( prices[testDatum] * walletInfo.balance, testDatum ); - expect(walletInfo.fiatBalance, 'Fiat balance is different').to.equal(expectedFiatValue); + const diffLess1Perc = diffIsLess1Perc(walletInfo.fiatBalance, expectedFiatValue); + expect(diffLess1Perc, 'Fiat difference is more than 1%').to.be.true; } }); }); diff --git a/packages/e2e-tests/test/20_changingCardanoExplorer.test.js b/packages/e2e-tests/test/20_changingCardanoExplorer.test.js index eb9eb3e259..eee0bacbc3 100644 --- a/packages/e2e-tests/test/20_changingCardanoExplorer.test.js +++ b/packages/e2e-tests/test/20_changingCardanoExplorer.test.js @@ -1,11 +1,9 @@ import BasePage from '../pages/basepage.js'; import { customAfterEach } from '../utils/customHooks.js'; import TransactionsSubTab from '../pages/wallet/walletTab/walletTransactions.page.js'; -import { testWallet1 } from '../utils/testWallets.js'; import { expect } from 'chai'; import { getTestLogger } from '../utils/utils.js'; import { oneMinute } from '../helpers/timeConstants.js'; -import { restoreWallet } from '../helpers/restoreWalletHelper.js'; import SettingsTab from '../pages/wallet/settingsTab/settingsTab.page.js'; import driversPoolsManager from '../utils/driversPool.js'; import BlockchainSubTab from '../pages/wallet/settingsTab/blockchainSubTab.page.js'; diff --git a/packages/e2e-tests/test/21_checkingTOS.test.js b/packages/e2e-tests/test/21_checkingTOS.test.js index 14ae58dd05..a586dbfe1d 100644 --- a/packages/e2e-tests/test/21_checkingTOS.test.js +++ b/packages/e2e-tests/test/21_checkingTOS.test.js @@ -1,11 +1,9 @@ import BasePage from '../pages/basepage.js'; import { customAfterEach } from '../utils/customHooks.js'; import TransactionsSubTab from '../pages/wallet/walletTab/walletTransactions.page.js'; -import { testWallet1 } from '../utils/testWallets.js'; import { expect } from 'chai'; import { getTestLogger } from '../utils/utils.js'; import { oneMinute } from '../helpers/timeConstants.js'; -import { restoreWallet } from '../helpers/restoreWalletHelper.js'; import SettingsTab from '../pages/wallet/settingsTab/settingsTab.page.js'; import driversPoolsManager from '../utils/driversPool.js'; import TermOfServiceAgreementSubTab from '../pages/wallet/settingsTab/tosSubTab.page.js'; diff --git a/packages/e2e-tests/test/22_addingMemo.test.js b/packages/e2e-tests/test/22_addingMemo.test.js index d71a61e091..78923393ad 100644 --- a/packages/e2e-tests/test/22_addingMemo.test.js +++ b/packages/e2e-tests/test/22_addingMemo.test.js @@ -3,9 +3,8 @@ import { customAfterEach } from '../utils/customHooks.js'; import TransactionsSubTab from '../pages/wallet/walletTab/walletTransactions.page.js'; import { testWallet1 } from '../utils/testWallets.js'; import { expect } from 'chai'; -import { getTestLogger, sleep } from '../utils/utils.js'; +import { getTestLogger } from '../utils/utils.js'; import { oneMinute } from '../helpers/timeConstants.js'; -import { restoreWallet } from '../helpers/restoreWalletHelper.js'; import driversPoolsManager from '../utils/driversPool.js'; import { getTestString } from '../helpers/constants.js'; import AddNewWallet from '../pages/addNewWallet.page.js'; diff --git a/packages/e2e-tests/test/23_editMemo.test.js b/packages/e2e-tests/test/23_editMemo.test.js index 26c41c27ef..18e3301de3 100644 --- a/packages/e2e-tests/test/23_editMemo.test.js +++ b/packages/e2e-tests/test/23_editMemo.test.js @@ -3,9 +3,8 @@ import { customAfterEach } from '../utils/customHooks.js'; import TransactionsSubTab from '../pages/wallet/walletTab/walletTransactions.page.js'; import { testWallet1 } from '../utils/testWallets.js'; import { expect } from 'chai'; -import { getTestLogger, sleep } from '../utils/utils.js'; +import { getTestLogger } from '../utils/utils.js'; import { oneMinute } from '../helpers/timeConstants.js'; -import { restoreWallet } from '../helpers/restoreWalletHelper.js'; import driversPoolsManager from '../utils/driversPool.js'; import { getTestString } from '../helpers/constants.js'; import AddNewWallet from '../pages/addNewWallet.page.js'; diff --git a/packages/e2e-tests/test/03_restoringWalletClearInputs.test.js b/packages/e2e-tests/test/blacklist/03_restoringWalletClearInputs.test.js similarity index 84% rename from packages/e2e-tests/test/03_restoringWalletClearInputs.test.js rename to packages/e2e-tests/test/blacklist/03_restoringWalletClearInputs.test.js index 7224348a06..db6ec57286 100644 --- a/packages/e2e-tests/test/03_restoringWalletClearInputs.test.js +++ b/packages/e2e-tests/test/blacklist/03_restoringWalletClearInputs.test.js @@ -1,16 +1,16 @@ -import BasePage from '../pages/basepage.js'; -import { customAfterEach } from '../utils/customHooks.js'; -import AddNewWallet from '../pages/addNewWallet.page.js'; -import RestoreWalletStepOne from '../pages/newWalletPages/restoreWalletSteps/restoreWalletStepOne.page.js'; -import RestoreWalletStepTwo from '../pages/newWalletPages/restoreWalletSteps/restoreWalletStepTwo.page.js'; -import WalletDetails from '../pages/newWalletPages/walletDetails.page.js'; -import TransactionsSubTab from '../pages/wallet/walletTab/walletTransactions.page.js'; -import { testWallet1, testWallet2 } from '../utils/testWallets.js'; -import { getPassword } from '../helpers/constants.js'; +import BasePage from '../../pages/basepage.js'; +import { customAfterEach } from '../../utils/customHooks.js'; +import AddNewWallet from '../../pages/addNewWallet.page.js'; +import RestoreWalletStepOne from '../../pages/newWalletPages/restoreWalletSteps/restoreWalletStepOne.page.js'; +import RestoreWalletStepTwo from '../../pages/newWalletPages/restoreWalletSteps/restoreWalletStepTwo.page.js'; +import WalletDetails from '../../pages/newWalletPages/walletDetails.page.js'; +import TransactionsSubTab from '../../pages/wallet/walletTab/walletTransactions.page.js'; +import { testWallet1, testWallet2 } from '../../utils/testWallets.js'; +import { getPassword } from '../../helpers/constants.js'; import { expect } from 'chai'; -import { getTestLogger } from '../utils/utils.js'; -import { oneMinute } from '../helpers/timeConstants.js'; -import driversPoolsManager from '../utils/driversPool.js'; +import { getTestLogger } from '../../utils/utils.js'; +import { oneMinute } from '../../helpers/timeConstants.js'; +import driversPoolsManager from '../../utils/driversPool.js'; // The test case is based on the issue https://emurgo.atlassian.net/browse/YOEXT-811 describe('Restoring 15-wallet, clear input and restore other 15-wallet', function () { diff --git a/packages/e2e-tests/test/15_calculatingBalanceOnReceiveAddrs.test.js b/packages/e2e-tests/test/blacklist/15_calculatingBalanceOnReceiveAddrs.test.js similarity index 73% rename from packages/e2e-tests/test/15_calculatingBalanceOnReceiveAddrs.test.js rename to packages/e2e-tests/test/blacklist/15_calculatingBalanceOnReceiveAddrs.test.js index 65ac3df1ef..8ec24c8f52 100644 --- a/packages/e2e-tests/test/15_calculatingBalanceOnReceiveAddrs.test.js +++ b/packages/e2e-tests/test/blacklist/15_calculatingBalanceOnReceiveAddrs.test.js @@ -1,14 +1,15 @@ import { expect } from 'chai'; -import BasePage from '../pages/basepage.js'; -import driversPoolsManager from '../utils/driversPool.js'; -import TransactionsSubTab from '../pages/wallet/walletTab/walletTransactions.page.js'; -import { customAfterEach } from '../utils/customHooks.js'; -import { getTestLogger } from '../utils/utils.js'; -import { oneMinute } from '../helpers/timeConstants.js'; -import { restoreWallet } from '../helpers/restoreWalletHelper.js'; -import { getSpendableWallet } from '../utils/testWallets.js'; -import ReceiveSubTab from '../pages/wallet/walletTab/receiveSubTab.page.js'; +import BasePage from '../../pages/basepage.js'; +import driversPoolsManager from '../../utils/driversPool.js'; +import TransactionsSubTab from '../../pages/wallet/walletTab/walletTransactions.page.js'; +import { customAfterEach } from '../../utils/customHooks.js'; +import { getTestLogger } from '../../utils/utils.js'; +import { oneMinute } from '../../helpers/timeConstants.js'; +import { restoreWallet } from '../../helpers/restoreWalletHelper.js'; +import { getSpendableWallet } from '../../utils/testWallets.js'; +import ReceiveSubTab from '../../pages/wallet/walletTab/receiveSubTab.page.js'; +// The test case is based on the issue https://emurgo.atlassian.net/browse/YOEXT-965 describe('Comparing balances on the top plate and on addresses', function () { this.timeout(2 * oneMinute); let webdriver = null; diff --git a/packages/e2e-tests/test/dapp/dAppGetCollateralErrorNotEnoughUtxo.test.js b/packages/e2e-tests/test/blacklist/dapp/dAppGetCollateralErrorNotEnoughUtxo.test.js similarity index 69% rename from packages/e2e-tests/test/dapp/dAppGetCollateralErrorNotEnoughUtxo.test.js rename to packages/e2e-tests/test/blacklist/dapp/dAppGetCollateralErrorNotEnoughUtxo.test.js index aace31ea87..9b644a5d54 100644 --- a/packages/e2e-tests/test/dapp/dAppGetCollateralErrorNotEnoughUtxo.test.js +++ b/packages/e2e-tests/test/blacklist/dapp/dAppGetCollateralErrorNotEnoughUtxo.test.js @@ -1,17 +1,18 @@ -import BasePage from '../../pages/basepage.js'; -import { customAfterEach } from '../../utils/customHooks.js'; +import BasePage from '../../../pages/basepage.js'; +import { customAfterEach } from '../../../utils/customHooks.js'; import { expect } from 'chai'; -import { getTestLogger } from '../../utils/utils.js'; -import { oneMinute } from '../../helpers/timeConstants.js'; -import { createWallet } from '../../helpers/restoreWalletHelper.js'; -import { WindowManager, mockDAppName } from '../../helpers/windowManager.js'; -import { getMockServer, mockDAppUrl } from '../../helpers/mock-dApp-webpage/mockServer.js'; -import { MockDAppWebpage } from '../../helpers/mock-dApp-webpage/mockedDApp.js'; -import { connectNonAuth } from '../../helpers/mock-dApp-webpage/dAppHelper.js'; -import { adaInLovelaces, getTestWalletName } from '../../helpers/constants.js'; -import { ApiErrorCode } from '../../helpers/mock-dApp-webpage/cip30Errors.js'; -import driversPoolsManager from '../../utils/driversPool.js'; +import { getTestLogger } from '../../../utils/utils.js'; +import { oneMinute } from '../../../helpers/timeConstants.js'; +import { createWallet } from '../../../helpers/restoreWalletHelper.js'; +import { WindowManager, mockDAppName } from '../../../helpers/windowManager.js'; +import { getMockServer, mockDAppUrl } from '../../../helpers/mock-dApp-webpage/mockServer.js'; +import { MockDAppWebpage } from '../../../helpers/mock-dApp-webpage/mockedDApp.js'; +import { connectNonAuth } from '../../../helpers/mock-dApp-webpage/dAppHelper.js'; +import { adaInLovelaces, getTestWalletName } from '../../../helpers/constants.js'; +import { ApiErrorCode } from '../../../helpers/mock-dApp-webpage/cip30Errors.js'; +import driversPoolsManager from '../../../utils/driversPool.js'; +// Issue https://emurgo.atlassian.net/browse/YOEXT-1191 describe('dApp, getCollateral, error, empty wallet, not auth', function () { const testWalletName = getTestWalletName(); let newTestWallet = { diff --git a/packages/e2e-tests/utils/utils.js b/packages/e2e-tests/utils/utils.js index df4e92fa13..691cceece1 100644 --- a/packages/e2e-tests/utils/utils.js +++ b/packages/e2e-tests/utils/utils.js @@ -1,9 +1,9 @@ import { By } from 'selenium-webdriver'; -import { dbSnapshotsDir, testRunDir } from '../helpers/constants.js'; -import { TargetBrowser } from '../helpers/constants.js'; +import { dbSnapshotsDir, TargetBrowser, testRunDir } from '../helpers/constants.js'; import * as fs from 'node:fs'; import path from 'path'; import pkg from 'simple-node-logger'; +import axios from 'axios'; const { createSimpleFileLogger } = pkg; export function getMethod(locatorMethod) { @@ -245,8 +245,24 @@ export const roundUpCurrency = (value, fiatCurrency) => { } }; -export const getSnapshotObjectFromJSON = (dbSnapshotName) => { +export const diffIsLess1Perc = (valueA, valueB) => { + const valueA1Perc = valueA * 0.01; + return valueB >= valueA - valueA1Perc && valueB <= valueA + valueA1Perc; +}; + +export const getSnapshotObjectFromJSON = dbSnapshotName => { const dbSnapshotPath = path.resolve(dbSnapshotsDir, dbSnapshotName); const fileContent = getFileContent(dbSnapshotPath); return JSON.parse(fileContent); -} +}; + +export const getCurrenciesPrices = async () => { + try { + const reqResponse = await axios.get( + 'https://iohk-mainnet.yoroiwallet.com/api/price/ADA/current' + ); + return reqResponse.data.ticker.prices; + } catch (error) { + throw new Error(`Error happen while getting currencies prices. Error: ${error}`); + } +};