Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move failing tests to a separate workflow #3533

Merged
merged 17 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 152 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,82 @@ jobs:
path: |
./packages/e2e-tests/mochawesome-report
./packages/e2e-tests/testRunsData_${{ matrix.browser }}

E2E_tests_failing:
if: github.event.review && contains(github.event.review.body, '/regression-check')
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 }}: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 }}

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'))
Expand Down Expand Up @@ -151,6 +227,82 @@ jobs:
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 }}

E2E_dapp_tests_failing:
if: github.event.review && contains(github.event.review.body, '/dapp-check')
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
Expand Down
9 changes: 8 additions & 1 deletion packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 10 additions & 4 deletions packages/e2e-tests/pages/basepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ 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,
defaultWaitTimeout,
halfSecond,
oneSecond,
} from '../helpers/timeConstants.js';
import { getSnapshotObjectFromJSON } from '../utils/utils.js';
import { dbSnapshotsDir } from '../helpers/constants.js';

const writeFile = promisify(fs.writeFile);
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions packages/e2e-tests/pages/walletCommonBase.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 0 additions & 2 deletions packages/e2e-tests/test/04_removingWallet.test.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
1 change: 0 additions & 1 deletion packages/e2e-tests/test/06_renamingWallet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 0 additions & 1 deletion packages/e2e-tests/test/07_changingPassword.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 0 additions & 2 deletions packages/e2e-tests/test/08_downloadingLogs.test.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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';
Expand Down
1 change: 0 additions & 1 deletion packages/e2e-tests/test/09_exportTransactions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 0 additions & 2 deletions packages/e2e-tests/test/10_exportTxsNegative.test.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 0 additions & 2 deletions packages/e2e-tests/test/18_changingLanguageSettings.test.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
12 changes: 5 additions & 7 deletions packages/e2e-tests/test/19_changingFiat.test.js
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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) {
Expand All @@ -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://iohk-mainnet.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;
}
});
});
Expand Down
Loading
Loading