diff --git a/.github/workflows/scan.yaml b/.github/workflows/scan.yaml index c4c5bcb56a..8dde1c0c20 100644 --- a/.github/workflows/scan.yaml +++ b/.github/workflows/scan.yaml @@ -8,21 +8,38 @@ jobs: working-directory: ./scan steps: - - name: Code Checkout - uses: actions/checkout@v2 - - - name: Cache node_modules - id: scan-node-modules-cache - uses: actions/cache@v1 - with: - path: scan/node_modules - key: ${{ runner.OS }}-scan-test-${{ hashFiles('**/yarn.lock') }} - - - name: Run yarn - if: steps.scan-node-modules-cache.outputs.cache-hit != 'true' - run: yarn - working-directory: ${{env.working-directory}} - - - name: Run yarn test - run: yarn test - working-directory: ${{env.working-directory}} + - name: Code Checkout + uses: actions/checkout@v2 + + - name: Cache node_modules + id: scan-node-modules-cache + uses: actions/cache@v1 + with: + path: scan/node_modules + key: ${{ runner.OS }}-scan-test-${{ hashFiles('**/yarn.lock') }} + + - name: Yarn install deps with node_modules cache + run: | + yarn install --frozen-lockfile + if: steps.scan-node-modules-cache.outputs.cache-hit != 'true' + working-directory: ${{env.working-directory}} + + - name: Run yarn build + run: yarn build + env: + RPC_URL: "https://d3n.bandprotocol.com/rest" + GRAPHQL_URL: "wss://d3n.bandprotocol.com/v1/graphql" + NETWORK: "GUANYU38" + working-directory: ${{env.working-directory}} + + - name: Run install cypress + run: yarn cypress install + working-directory: ${{env.working-directory}} + + - name: Run yarn test + run: yarn test + working-directory: ${{env.working-directory}} + + - name: Run yarn integration-test + run: yarn integration-test + working-directory: ${{env.working-directory}} diff --git a/CHANGELOG_UNRELEASED.md b/CHANGELOG_UNRELEASED.md index 8d16e733d0..fd122d4f6d 100644 --- a/CHANGELOG_UNRELEASED.md +++ b/CHANGELOG_UNRELEASED.md @@ -29,6 +29,7 @@ - (impv) [\#2689](https://github.com/bandprotocol/bandchain/pull/2689) Styled the top part of account index page - (bugs) [\#2687](https://github.com/bandprotocol/bandchain/pull/2687) Fixed NaN number (Urgent) - (impv) [\#2684](https://github.com/bandprotocol/bandchain/pull/2684) Adjust validator voted from 250 to 100 +- (impv) [\#2676](https://github.com/bandprotocol/bandchain/pull/2676) Setup cypress to scan, added new sendToken testcase - (bugs) [\#2673](https://github.com/bandprotocol/bandchain/pull/2673) Fixed sorting on moniker with emoji - (impv) [\#2672](https://github.com/bandprotocol/bandchain/pull/2672) Hid the proposal desc from tx index page table - (impv) [\#2671](https://github.com/bandprotocol/bandchain/pull/2671) Adjusted tooltip width and added webapi diff --git a/scan/cypress.json b/scan/cypress.json new file mode 100644 index 0000000000..03bc9133b5 --- /dev/null +++ b/scan/cypress.json @@ -0,0 +1,6 @@ +{ + "baseUrl": "http://localhost:3000/", + "pluginsFile": false, + "fixturesFolder": false, + "defaultCommandTimeout": 10000 +} diff --git a/scan/cypress/integration/send_action.spec.js b/scan/cypress/integration/send_action.spec.js new file mode 100644 index 0000000000..25a38fd89a --- /dev/null +++ b/scan/cypress/integration/send_action.spec.js @@ -0,0 +1,36 @@ +/// + +describe("Login", () => { + beforeEach(() => { + cy.visit("/"); + }); + + it("Should have s address on account panel", () => { + cy.get('[id="connectButton"]').click(); + cy.get('[id="mnemonicInput"]').type("s"); + cy.get('[id="mnemonicConnectButton"] > button').click(); + cy.get('[id="userInfoButton"]').click(); + cy.get('[id="addressWrapper"] > a > span').should( + "contain", + "band1jrhuqrymzt4mnvgw8cvy3s9zhx3jj0dq30qpte" + ); + }); +}); + +describe("Send", () => { + it("Status should be Success", () => { + cy.get('[id="getFreeButton"] > button').click(); + cy.get('[id="sendToken"] > button').wait(500).contains("Send").click(); + cy.get('[id="recipientAddressInput"]') + .wait(1000) + .type("band1jrhuqrymzt4mnvgw8cvy3s9zhx3jj0dq30qpte") + .get('[id="sendAmountInput"]') + .type("2"); + cy.get('[id="nextButton"]').contains("Next").click(); + cy.get('[id="broadcastButton"]').click(); + cy.get('[id="successMsgContainer"] > span').should( + "contain", + "Broadcast Transaction Success" + ); + }); +}); diff --git a/scan/cypress/support/commands.js b/scan/cypress/support/commands.js new file mode 100644 index 0000000000..ca4d256f3e --- /dev/null +++ b/scan/cypress/support/commands.js @@ -0,0 +1,25 @@ +// *********************************************** +// This example commands.js shows you how to +// create various custom commands and overwrite +// existing commands. +// +// For more comprehensive examples of custom +// commands please read more here: +// https://on.cypress.io/custom-commands +// *********************************************** +// +// +// -- This is a parent command -- +// Cypress.Commands.add("login", (email, password) => { ... }) +// +// +// -- This is a child command -- +// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) +// +// +// -- This is a dual command -- +// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) +// +// +// -- This will overwrite an existing command -- +// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) diff --git a/scan/cypress/support/index.js b/scan/cypress/support/index.js new file mode 100644 index 0000000000..d68db96df2 --- /dev/null +++ b/scan/cypress/support/index.js @@ -0,0 +1,20 @@ +// *********************************************************** +// This example support/index.js is processed and +// loaded automatically before your test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/configuration +// *********************************************************** + +// Import commands.js using ES2015 syntax: +import './commands' + +// Alternatively you can use CommonJS syntax: +// require('./commands') diff --git a/scan/package.json b/scan/package.json index 6cac66c37a..285d740eb6 100644 --- a/scan/package.json +++ b/scan/package.json @@ -3,8 +3,10 @@ "scripts": { "build": "rm -rf dist/ && bsb -make-world && parcel build index.html --no-source-maps --no-cache", "start": "bsb -make-world -w", - "test:dev": "yarn jest --coverage", - "test": "yarn build && yarn test:dev" + "test": "yarn jest --coverage", + "cy:run": "cypress run", + "serve:build": "serve -s dist -l 3000", + "integration-test": "start-server-and-test 'yarn run serve:build' http://localhost:3000 cy:run" }, "dependencies": { "@apollo/react-hooks": "^3.1.5", @@ -53,12 +55,15 @@ "bs-platform": "^7.0.1", "bsb-js": "^1.1.7", "css-loader": "^4.3.0", + "cypress": "^5.2.0", "html-webpack-plugin": "^4.5.0", "parcel-bundler": "^1.12.4", "style-loader": "^1.2.1", "webpack": "^4.44.2", "webpack-cli": "^3.3.12", - "webpack-dev-server": "^3.11.0" + "webpack-dev-server": "^3.11.0", + "serve": "^11.3.0", + "start-server-and-test": "^1.11.0" }, "customDistStructure": { "config": { @@ -71,5 +76,10 @@ ".gif" ] } + }, + "jest": { + "testPathIgnorePatterns": [ + "cypress" + ] } } diff --git a/scan/src/components/EnhanceTxInput.re b/scan/src/components/EnhanceTxInput.re index 1c7cfdfeb6..129f02e678 100644 --- a/scan/src/components/EnhanceTxInput.re +++ b/scan/src/components/EnhanceTxInput.re @@ -85,6 +85,7 @@ let make = ~placeholder="", ~inputType="text", ~autoFocus=false, + ~id, ) => { let (status, setStatus) = React.useState(_ => Untouched); @@ -101,6 +102,7 @@ let make =
{
false); isRequest ? - : ; + :
+ +
; }; }; module SendBtn = { [@react.component] let make = (~send) => { - ; +
+ +
; }; }; @@ -120,7 +125,7 @@ module Balance = {
-
+
{ | Some({address}) =>
setShow(prev => !prev)}>
-
+
diff --git a/scan/src/components/modal/connect/ConnectWithMnemonic.re b/scan/src/components/modal/connect/ConnectWithMnemonic.re index c3184e6897..21b3ad035f 100644 --- a/scan/src/components/modal/connect/ConnectWithMnemonic.re +++ b/scan/src/components/modal/connect/ConnectWithMnemonic.re @@ -91,6 +91,7 @@ let make = (~chainID) => { { } /> -
+
diff --git a/scan/src/components/modal/submitTx/DelegateMsg.re b/scan/src/components/modal/submitTx/DelegateMsg.re index 1fd725f24e..2ed34767ab 100644 --- a/scan/src/components/modal/submitTx/DelegateMsg.re +++ b/scan/src/components/modal/submitTx/DelegateMsg.re @@ -94,6 +94,7 @@ let make = (~address, ~validator, ~setMsgsOpt) => { inputType="number" code=true autoFocus=true + id="delegateAmountInput" />; | _ => }} diff --git a/scan/src/components/modal/submitTx/PreviewJsonStep.re b/scan/src/components/modal/submitTx/PreviewJsonStep.re index efc1ec0ebb..c791ca1d04 100644 --- a/scan/src/components/modal/submitTx/PreviewJsonStep.re +++ b/scan/src/components/modal/submitTx/PreviewJsonStep.re @@ -131,6 +131,7 @@ let make = (~rawTx, ~onBack, ~account: AccountContext.t) => {
{ dispatchModal(DisableExit); setState(_ => Signing); @@ -192,7 +193,7 @@ let make = (~rawTx, ~onBack, ~account: AccountContext.t) => {
| Success(txHash) =>
-
+
diff --git a/scan/src/components/modal/submitTx/RedelegateMsg.re b/scan/src/components/modal/submitTx/RedelegateMsg.re index dbbd337dca..632bccef3f 100644 --- a/scan/src/components/modal/submitTx/RedelegateMsg.re +++ b/scan/src/components/modal/submitTx/RedelegateMsg.re @@ -197,6 +197,7 @@ let make = (~address, ~validator, ~setMsgsOpt) => { inputType="number" code=true autoFocus=true + id="redelegateAmountInput" />; | _ => }} diff --git a/scan/src/components/modal/submitTx/SendMsg.re b/scan/src/components/modal/submitTx/SendMsg.re index e0914b5b03..031b61cdd2 100644 --- a/scan/src/components/modal/submitTx/SendMsg.re +++ b/scan/src/components/modal/submitTx/SendMsg.re @@ -69,6 +69,7 @@ let make = (~address, ~receiver, ~setMsgsOpt) => { parse=Parse.address msg="Recipient Address" code=true + id="recipientAddressInput" placeholder="Insert recipient address" autoFocus={ switch (toAddress.text) { @@ -99,6 +100,7 @@ let make = (~address, ~receiver, ~setMsgsOpt) => { | _ => true } } + id="sendAmountInput" />; | _ => }} diff --git a/scan/src/components/modal/submitTx/SubmitTxModal.re b/scan/src/components/modal/submitTx/SubmitTxModal.re index c480cefb72..1ad88dfa3b 100644 --- a/scan/src/components/modal/submitTx/SubmitTxModal.re +++ b/scan/src/components/modal/submitTx/SubmitTxModal.re @@ -130,6 +130,7 @@ module SubmitTxStep = { msg="Memo (optional)" placeholder="Insert memo" code=true + id="memoInput" /> @@ -146,6 +147,7 @@ module SubmitTxStep = {