From e876117f379bb46f4c9ce810fc48f40754c3f3fb Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Sat, 26 Mar 2022 12:35:44 -0700 Subject: [PATCH 1/8] Separated stateful and stateless cypress test Run both groups in parallel Readded lost changes Readded package del and removed integration folder --- .github/workflows/ci.yml | 47 +++++++++++++++++-- .../{ => stateful}/deposit.test.ts | 0 .../integration/{ => stateful}/swap.test.ts | 0 .../{ => stateful}/withdrawal.test.ts | 0 .../{ => stateless}/accountDetail.test.ts | 0 .../{ => stateless}/advancedOption.test.ts | 0 .../integration/{ => stateless}/risk.test.ts | 0 .../{ => stateless}/topMenu.test.ts | 0 package-lock.json | 1 - package.json | 4 +- 10 files changed, 46 insertions(+), 6 deletions(-) rename cypress/integration/{ => stateful}/deposit.test.ts (100%) rename cypress/integration/{ => stateful}/swap.test.ts (100%) rename cypress/integration/{ => stateful}/withdrawal.test.ts (100%) rename cypress/integration/{ => stateless}/accountDetail.test.ts (100%) rename cypress/integration/{ => stateless}/advancedOption.test.ts (100%) rename cypress/integration/{ => stateless}/risk.test.ts (100%) rename cypress/integration/{ => stateless}/topMenu.test.ts (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c88bcf706..53753ef23 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: - run: npm test env: CI: true - + coverage: runs-on: ubuntu-latest steps: @@ -76,7 +76,46 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} - coverage-cypress: + coverage-cypress-stateless: + runs-on: ubuntu-latest + services: + saddle-contract: + image: saddlefinance/contracts:latest + ports: + - 8545:8545 + strategy: + fail-fast: false + matrix: + # run copies of the current job in parallel + containers: [1] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: 'UI Tests - Stateless' + uses: cypress-io/github-action@v2 + with: + install: true + start: npm run cy:coveragestateless + wait-on: 'http://localhost:3000' + wait-on-timeout: 120 + browser: chrome + spec: cypress/integration/stateless/* + - run: npx nyc report --reporter=text + - uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + - uses: actions/upload-artifact@v3 + if: failure() + with: + name: E2E Failures + path: | + cypress/screenshots/ + cypress/videos/ + env: + REACT_APP_NOTIFY_DAPP_ID: ${{ secrets.REACT_APP_NOTIFY_DAPP_ID }} + + coverage-cypress-stateful: env: REACT_APP_NOTIFY_DAPP_ID: ${{ secrets.REACT_APP_NOTIFY_DAPP_ID }} runs-on: ubuntu-latest @@ -94,7 +133,7 @@ jobs: # fix for forcing git to use https when pulling deps - run: 'git config --global --replace-all url."https://github.com/".insteadOf ssh://git@github.com/' - run: npm ci - - run: npm run cy:coverage + - run: npm run cy:coveragestateful env: CHOKIDAR_USEPOLLING: 1 - run: npx nyc report --reporter=text @@ -107,4 +146,4 @@ jobs: name: E2E Failures path: | cypress/screenshots/ - cypress/videos/ + cypress/videos/ \ No newline at end of file diff --git a/cypress/integration/deposit.test.ts b/cypress/integration/stateful/deposit.test.ts similarity index 100% rename from cypress/integration/deposit.test.ts rename to cypress/integration/stateful/deposit.test.ts diff --git a/cypress/integration/swap.test.ts b/cypress/integration/stateful/swap.test.ts similarity index 100% rename from cypress/integration/swap.test.ts rename to cypress/integration/stateful/swap.test.ts diff --git a/cypress/integration/withdrawal.test.ts b/cypress/integration/stateful/withdrawal.test.ts similarity index 100% rename from cypress/integration/withdrawal.test.ts rename to cypress/integration/stateful/withdrawal.test.ts diff --git a/cypress/integration/accountDetail.test.ts b/cypress/integration/stateless/accountDetail.test.ts similarity index 100% rename from cypress/integration/accountDetail.test.ts rename to cypress/integration/stateless/accountDetail.test.ts diff --git a/cypress/integration/advancedOption.test.ts b/cypress/integration/stateless/advancedOption.test.ts similarity index 100% rename from cypress/integration/advancedOption.test.ts rename to cypress/integration/stateless/advancedOption.test.ts diff --git a/cypress/integration/risk.test.ts b/cypress/integration/stateless/risk.test.ts similarity index 100% rename from cypress/integration/risk.test.ts rename to cypress/integration/stateless/risk.test.ts diff --git a/cypress/integration/topMenu.test.ts b/cypress/integration/stateless/topMenu.test.ts similarity index 100% rename from cypress/integration/topMenu.test.ts rename to cypress/integration/stateless/topMenu.test.ts diff --git a/package-lock.json b/package-lock.json index 4329ef508..846cba72a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,6 @@ "requires": true, "packages": { "": { - "name": "saddle-frontend", "version": "0.1.0", "hasInstallScript": true, "license": "MIT", diff --git a/package.json b/package.json index a0677ca92..7189fcef6 100644 --- a/package.json +++ b/package.json @@ -98,9 +98,11 @@ "build-storybook": "build-storybook -s public", "build": "REACT_APP_GIT_SHA=`git rev-parse --short HEAD` react-scripts build", "bundlemon": "bundlemon --subProject no-compression --defaultCompression none && bundlemon --subProject gzip-compression --defaultCompression gzip", - "cy:coverage": "start-test 3000 'cypress run'", + "cy:coverage": "start-test 3000 'cypress run --config video=false'", "cy:open": "cypress open", "cy:run": "cypress run", + "cy:coveragestateful": "start-test 3000 'cypress run --spec ./cypress/integration/stateful/*.test.ts'", + "cy:coveragestateless": "start-test 3000 'cypress run --spec ./cypress/integration/stateless/*.test.ts'", "cy:startopen": "start-test 3000 'cypress open'", "eject": "react-scripts eject", "lint:fix": "eslint --max-warnings=0 --ext ts,tsx --fix src/ && prettier --write 'src/**/*.{ts,tsx,scss}'", From e352059ca01ca3915886fcb7651f646b5684eac5 Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Tue, 29 Mar 2022 12:04:57 -0700 Subject: [PATCH 2/8] Removed matrix from stateless config Readded repo name to package-lock.json --- .github/workflows/ci.yml | 3 --- package-lock.json | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53753ef23..5e5347e20 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,9 +85,6 @@ jobs: - 8545:8545 strategy: fail-fast: false - matrix: - # run copies of the current job in parallel - containers: [1] steps: - name: Checkout uses: actions/checkout@v2 diff --git a/package-lock.json b/package-lock.json index 846cba72a..4329ef508 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "saddle-frontend", "version": "0.1.0", "hasInstallScript": true, "license": "MIT", From 6f9a8b92d91e8b1add93ba34ccb9c78559c39048 Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Tue, 29 Mar 2022 12:15:18 -0700 Subject: [PATCH 3/8] Fixed relative import path --- cypress/integration/stateless/advancedOption.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/integration/stateless/advancedOption.test.ts b/cypress/integration/stateless/advancedOption.test.ts index 40b250c8f..60e40fa64 100644 --- a/cypress/integration/stateless/advancedOption.test.ts +++ b/cypress/integration/stateless/advancedOption.test.ts @@ -1,4 +1,4 @@ -import { PoolName } from "../../src/constants" +import { PoolName } from "../../../src/constants" context("Advanced option test", () => { // have two seperate maps here since the naming convention is different throughout the page From 7f603c545d32d7760d2886b7dd26107809077ddb Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Tue, 29 Mar 2022 12:35:01 -0700 Subject: [PATCH 4/8] Update package.json scripts for cypress coverage Update relative paths Fixed syntax --- cypress/integration/stateful/deposit.test.ts | 2 +- cypress/integration/stateful/withdrawal.test.ts | 2 +- package.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cypress/integration/stateful/deposit.test.ts b/cypress/integration/stateful/deposit.test.ts index dfd91baf7..14e2d139f 100644 --- a/cypress/integration/stateful/deposit.test.ts +++ b/cypress/integration/stateful/deposit.test.ts @@ -1,4 +1,4 @@ -import { PoolName } from "../../src/constants" +import { PoolName } from "../../../src/constants" const poolTokens: { [key: string]: string[] } = { "BTC V2": ["WBTC", "RENBTC", "sBTC"], diff --git a/cypress/integration/stateful/withdrawal.test.ts b/cypress/integration/stateful/withdrawal.test.ts index ca02b4d1b..742a2707c 100644 --- a/cypress/integration/stateful/withdrawal.test.ts +++ b/cypress/integration/stateful/withdrawal.test.ts @@ -1,4 +1,4 @@ -import { PoolName } from "../../src/constants" +import { PoolName } from "../../../src/constants" // have two seperate maps here since the naming convention is different throughout the page const poolTokensFullName: { [key: string]: string[] } = { diff --git a/package.json b/package.json index 7189fcef6..175ebd5af 100644 --- a/package.json +++ b/package.json @@ -101,8 +101,8 @@ "cy:coverage": "start-test 3000 'cypress run --config video=false'", "cy:open": "cypress open", "cy:run": "cypress run", - "cy:coveragestateful": "start-test 3000 'cypress run --spec ./cypress/integration/stateful/*.test.ts'", - "cy:coveragestateless": "start-test 3000 'cypress run --spec ./cypress/integration/stateless/*.test.ts'", + "cy:coveragestateful": "start-test 3000 'cypress run --spec \"./cypress/integration/stateful/*.test.ts\"'", + "cy:coveragestateless": "start-test 3000 'cypress run --spec \"./cypress/integration/stateless/*.test.ts\"'", "cy:startopen": "start-test 3000 'cypress open'", "eject": "react-scripts eject", "lint:fix": "eslint --max-warnings=0 --ext ts,tsx --fix src/ && prettier --write 'src/**/*.{ts,tsx,scss}'", From 2b3b7beb1fb87749f20a26a993b23f31479a7560 Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Tue, 29 Mar 2022 13:36:54 -0700 Subject: [PATCH 5/8] Add nyc reporter config to html --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 175ebd5af..b89ceb90f 100644 --- a/package.json +++ b/package.json @@ -155,5 +155,8 @@ } } ] + }, + "nyc": { + "reporter": ["html"] } } From 74f07e625215fe0b2224ce8a4a16e1ba546b9ee3 Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Tue, 29 Mar 2022 13:49:52 -0700 Subject: [PATCH 6/8] Increase cypress command timeout --- cypress.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress.json b/cypress.json index 830c74a03..d698b60b5 100644 --- a/cypress.json +++ b/cypress.json @@ -9,6 +9,6 @@ "root": "#root" } }, - "defaultCommandTimeout": 30000, - "requestTimeout": 30000 + "defaultCommandTimeout": 40000, + "requestTimeout": 40000 } From 63ca65c035bbdf6cbe37509f30538fc72d1c40f6 Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Tue, 29 Mar 2022 14:05:20 -0700 Subject: [PATCH 7/8] Update timeouts --- .github/workflows/ci.yml | 6 +++--- cypress.json | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e5347e20..0715cd180 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,6 +77,8 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} coverage-cypress-stateless: + env: + REACT_APP_NOTIFY_DAPP_ID: ${{ secrets.REACT_APP_NOTIFY_DAPP_ID }} runs-on: ubuntu-latest services: saddle-contract: @@ -95,7 +97,7 @@ jobs: install: true start: npm run cy:coveragestateless wait-on: 'http://localhost:3000' - wait-on-timeout: 120 + wait-on-timeout: 240 browser: chrome spec: cypress/integration/stateless/* - run: npx nyc report --reporter=text @@ -109,8 +111,6 @@ jobs: path: | cypress/screenshots/ cypress/videos/ - env: - REACT_APP_NOTIFY_DAPP_ID: ${{ secrets.REACT_APP_NOTIFY_DAPP_ID }} coverage-cypress-stateful: env: diff --git a/cypress.json b/cypress.json index d698b60b5..372f45d05 100644 --- a/cypress.json +++ b/cypress.json @@ -9,6 +9,6 @@ "root": "#root" } }, - "defaultCommandTimeout": 40000, - "requestTimeout": 40000 + "defaultCommandTimeout": 60000, + "requestTimeout": 60000 } From e1f0bd0f2be1835204dbd02b4b0fa1873c0e767f Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Tue, 29 Mar 2022 18:06:33 -0700 Subject: [PATCH 8/8] Reduce cypress timeout to 30 secs Increased deposit wait for app to 5 secs --- cypress.json | 4 ++-- cypress/integration/stateful/deposit.test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cypress.json b/cypress.json index 372f45d05..830c74a03 100644 --- a/cypress.json +++ b/cypress.json @@ -9,6 +9,6 @@ "root": "#root" } }, - "defaultCommandTimeout": 60000, - "requestTimeout": 60000 + "defaultCommandTimeout": 30000, + "requestTimeout": 30000 } diff --git a/cypress/integration/stateful/deposit.test.ts b/cypress/integration/stateful/deposit.test.ts index 14e2d139f..3fe0293bc 100644 --- a/cypress/integration/stateful/deposit.test.ts +++ b/cypress/integration/stateful/deposit.test.ts @@ -9,7 +9,7 @@ context("Deposit Flow", () => { beforeEach(() => { const host = Cypress.env("DAPP_HOST") as string cy.visit(`${host}#/pools`) - cy.wait(3000) + cy.wait(5000) }) function testPoolDeposit(poolName: PoolName) { it(`successfully completes a deposit of all ${poolName} assets`, () => {