Skip to content

Commit

Permalink
Feat/fe rollup prod checks (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
MariuszSzpyt authored May 27, 2024
1 parent 19d1588 commit 5116a58
Show file tree
Hide file tree
Showing 8 changed files with 518 additions and 6 deletions.
192 changes: 192 additions & 0 deletions .github/workflows/gasp-prod-smoke-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
name: GASP UI prod smoke tests

on:
workflow_dispatch:
schedule:
- cron: "30 7 * * *"
jobs:
setup-report:
name: setup testmo report
runs-on: ubuntu-latest
outputs:
testmo-run-id: ${{ steps.setTestRun.outputs.testmo-run-id }}

steps:
- name: Install testmo
run: yarn global add @testmo/testmo-cli

- name: Add extra params
run: |
testmo automation:resources:add-field --name git --type string \
--value ${GITHUB_SHA:0:7} --resources resources.json
RUN_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
testmo automation:resources:add-link --name build \
--url $RUN_URL --resources resources.json
- name: Create test run
run: |
testmo automation:run:create \
--instance https://mangata-finance.testmo.net \
--project-id 2 \
--name "FE GASP prod smoke test run" \
--resources resources.json \
--source "gasp-prod-e2e-job" > testmo-run-id.txt
ID=$(cat testmo-run-id.txt)
echo "testmo-run-id=$ID" >> $GITHUB_OUTPUT
echo "ID=$ID" >> $GITHUB_ENV
env:
TESTMO_URL: ${{ secrets.TESTMO_URL }}
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
id: setTestRun

e2e-tm:
name: Run UI tests
needs: [setup-report]
strategy:
fail-fast: false
matrix:
command: ["first"]
runs-on: ubuntu-latest
env:
API_URL: "wss://collator-01-ws-rollup-testnet.mangata.online"
UI_URL: https://holesky.gasp.xyz/
TEST_SUDO_NAME: ${{ secrets.DEV_SUDO_NAME }}
MNEMONIC_META: ${{ secrets.MNEMONIC_PROD_META }}
PRIVKEY_META: ${{ secrets.PRIVKEY_PROD_META }}
TEST_SCRIPT: "test-gasp-prod"
NODE_ENV: test
SELENIUM_REMOTE_URL: http://localhost:4444/wd/hub

steps:
- name: Start Selenoid Server
uses: Xotabu4/selenoid-github-action@v2
with:
selenoid-start-arguments: |
--args "-timeout 300s" --browsers 'chrome:110.0;chrome:112.0;chrome:114.0'
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
- name: Install testmo
run: yarn global add @testmo/testmo-cli

- name: Install dependencies with Yarn
run: yarn
- name: Tsc code quality check
run: yarn tsc-lint
- name: ESLint code quality check
run: yarn eslint
- name: installed packages
run: yarn list

- name: is selenoid started?
run: curl http://localhost:4444/status

- name: Run tests
run: yarn test-gasp-prod-${{ matrix.command }}

- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: JEST UI Tests ${{ matrix.command }} # Name of the check run which will be created
path: reports/*.xml # Path to test results
reporter: jest-junit # Format of test results

- name: Install testmo
run: yarn global add @testmo/testmo-cli

- name: Submit results to the testmo-run
if: always()
run: |
testmo automation:run:submit-thread \
--instance https://mangata-finance.testmo.net \
--run-id ${{needs.setup-report.outputs.testmo-run-id}} \
--results reports/*.xml
env:
TESTMO_URL: ${{ secrets.TESTMO_URL }}
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
continue-on-error: true

- name: Sleep for 5 seconds
run: sleep 10s #close buffers of videos.

- name: Copy video files to reports folder
if: success() || failure()
run: "cp ~/.aerokube/selenoid/* -r reports/artifacts/"

- name: Create reports zip
uses: vimtor/action-zip@v1
if: success() || failure()
with:
files: reports/
dest: reports.zip

- name: Archive report files
uses: actions/upload-artifact@v2
if: success() || failure()
with:
name: ReportData ${{ matrix.command }}
path: reports.zip

- name: Archive report files
uses: actions/upload-artifact@v2
if: success() || failure()
with:
name: TestReport ${{ matrix.command }}
path: reports/html-report/report.html

test-complete:
needs: [setup-report, e2e-tm]
if: always()
runs-on: ubuntu-latest

steps:
- name: Install testmo
run: yarn global add @testmo/testmo-cli

- name: Complete test run
run: |
npx testmo automation:run:complete \
--instance https://mangata-finance.testmo.net \
--run-id ${{needs.setup-report.outputs.testmo-run-id}} \
env:
TESTMO_URL: ${{ secrets.TESTMO_URL }}
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
continue-on-error: true

slack-notify-ok:
needs: [e2e-tm, setup-report]
if: success()
runs-on: ubuntu-latest

steps:
- name: Slack Notification - OK
if: success()
uses: bryannice/[email protected]
env:
SLACK_INCOMING_WEBHOOK: ${{ secrets.STG_SLACK_WEBHOOK }}
SLACK_TITLE: "PROD GASP smoke UI tests - results - OK"
SLACK_COLOR: "#00ff11"
SLACK_MESSAGE: "Test succeed in [ ${{ env.TEST_SCRIPT }} ]
testmo report: https://mangata-finance.testmo.net/automation/runs/view/${{needs.setup-report.outputs.testmo-run-id}}"
GITHUB_REF: "https://mangata-finance.github.io/mangata-e2e/${{ github.run_number }}"

slack-notify-nook:
needs: [e2e-tm]
if: failure()
runs-on: ubuntu-latest

steps:
- name: Slack Notification - Error
uses: bryannice/[email protected]
env:
SLACK_INCOMING_WEBHOOK: ${{ secrets.STG_SLACK_WEBHOOK }}
SLACK_TITLE: "PROD GASP smoke UI tests - results - NOOK"
SLACK_COLOR: "#ff0011"
SLACK_MESSAGE: "Test failures [ ${{ env.TEST_SCRIPT }} ]
testmo report: https://mangata-finance.testmo.net/automation/runs/view/${{needs.setup-report.outputs.testmo-run-id}}"
GITHUB_REF: "https://mangata-finance.github.io/mangata-e2e/${{ github.run_number }}"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
"test-microapps-chops-fifth": "export CHOPSTICK_UI=true ; rm nonce.db ; rm sudo.lock; node --experimental-specifier-resolution=node --loader ts-node/esm --experimental-vm-modules node_modules/jest/bin/jest.js --verbose --runInBand --ci --group=microappsStaking",
"test-microapps-prod-first": "export CHOPSTICK_UI=true ; rm nonce.db ; rm sudo.lock; node --experimental-specifier-resolution=node --loader ts-node/esm --experimental-vm-modules node_modules/jest/bin/jest.js --verbose --runInBand --ci --group=microappsProdDeposit --group=microappsProdSwap --group=microappsProdWallet --group=microappsProdWithdraw --group=microappsProdStaking --group=microappsProdPools",
"test-gasp-ui": "export CHOPSTICK_UI=true ; rm nonce.db ; rm sudo.lock; node --experimental-specifier-resolution=node --loader ts-node/esm --experimental-vm-modules node_modules/jest/bin/jest.js --verbose --runInBand --ci --group=rollupDeposit --group=rollupWallet --group=rollupWithdraw",
"test-gasp-prod-first": "export CHOPSTICK_UI=true ; rm nonce.db ; rm sudo.lock; node --experimental-specifier-resolution=node --loader ts-node/esm --experimental-vm-modules node_modules/jest/bin/jest.js --verbose --runInBand --ci --group=rollupWithdrawProd --group=rollupDepositProd",
"cliTool": "node --experimental-specifier-resolution=node --loader ts-node/esm --experimental-vm-modules cliTool/index.ts --runInBand",
"runtimeUpgrade": " jest --verbose --ci --group=upgradeRuntime --runInBand --forceExit"
},
Expand Down
2 changes: 1 addition & 1 deletion reports/artifacts/readme.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
This folder will contain screenshots for Github actions artifacts
- This folder will contain screenshots for Github actions artifacts
117 changes: 117 additions & 0 deletions test/rollup-test/rollup-prod.deposit.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
*
* @group rollupDepositProd
*/
import { jest } from "@jest/globals";
import { WebDriver } from "selenium-webdriver";
import { getApi, initApi } from "../../utils/api";
import { DriverBuilder } from "../../utils/frontend/utils/Driver";
import {
acceptNetworkSwitchInNewWindow,
addExtraLogs,
importMetamaskExtension,
uiStringToNumber,
} from "../../utils/frontend/utils/Helper";
import "dotenv/config";
import {
connectWallet,
setupPage,
setupPageWithState,
waitForActionNotification,
} from "../../utils/frontend/rollup-utils/Handlers";
import { WalletWrapper } from "../../utils/frontend/rollup-pages/WalletWrapper";
import {
DepositActionType,
DepositModal,
} from "../../utils/frontend/rollup-utils/DepositModal";
import { TransactionType } from "../../utils/frontend/rollup-pages/NotificationToast";

jest.spyOn(console, "log").mockImplementation(jest.fn());

jest.setTimeout(1500000);
let driver: WebDriver;

let acc_addr = "";
let acc_addr_short = "";
const GETH_ASSET_NAME = "GETH";

describe("Gasp Prod UI deposit tests", () => {
beforeAll(async () => {
try {
getApi();
} catch (e) {
await initApi();
}

driver = await DriverBuilder.getInstance();
acc_addr = await importMetamaskExtension(driver, true);
acc_addr_short = acc_addr.slice(-4).toLowerCase();

await setupPage(driver);
await connectWallet(driver, "Metamask", acc_addr_short);
});

test("User can deposit GETH", async () => {
await setupPageWithState(driver, acc_addr_short);

const walletWrapper = new WalletWrapper(driver);
await walletWrapper.openWalletConnectionInfo();
const tokensAmountBefore =
await walletWrapper.getMyTokensRowAmount(GETH_ASSET_NAME);
await walletWrapper.openDeposit();
const depositModal = new DepositModal(driver);
const isModalVisible = await depositModal.isModalVisible();
expect(isModalVisible).toBeTruthy();

await depositModal.openChainList();
await depositModal.selectChain("Ethereum");
await depositModal.openTokensList();
await depositModal.waitForTokenListElementsVisible(GETH_ASSET_NAME);
await depositModal.selectToken(GETH_ASSET_NAME);

const randomNum = Math.floor(Math.random() * 99) + 1;
await depositModal.enterValue("1." + randomNum.toString());

await depositModal.waitForContinueState(true, 60000);
const isOriginFeeDisplayed = await depositModal.isOriginFeeDisplayed();
expect(isOriginFeeDisplayed).toBeTruthy();

const isNetworkButtonEnabled = await depositModal.isNetworkButtonEnabled();
expect(isNetworkButtonEnabled).toBeTruthy();

await depositModal.clickDepositButtonByText(DepositActionType.Network);
await acceptNetworkSwitchInNewWindow(driver);

await depositModal.clickDepositButtonByText(DepositActionType.Approve);
await waitForActionNotification(driver, TransactionType.ApproveContract);

await depositModal.clickDepositButtonByText(DepositActionType.Deposit);
await waitForActionNotification(driver, TransactionType.Deposit);
await depositModal.clickDepositButtonByText(DepositActionType.Done);

await walletWrapper.waitTokenAmountChange(
GETH_ASSET_NAME,
tokensAmountBefore,
);
const tokensAmountAfter =
await walletWrapper.getMyTokensRowAmount(GETH_ASSET_NAME);
expect(await uiStringToNumber(tokensAmountAfter)).toBeGreaterThan(
await uiStringToNumber(tokensAmountBefore),
);
});

afterEach(async () => {
const session = await driver.getSession();
await addExtraLogs(
driver,
expect.getState().currentTestName + " - " + session.getId(),
);
});

afterAll(async () => {
const api = getApi();
await api.disconnect();
await driver.quit();
DriverBuilder.destroy();
});
});
Loading

0 comments on commit 5116a58

Please sign in to comment.