From 52aa8232b6145fe97907ff7fb7731951fef537df Mon Sep 17 00:00:00 2001 From: pzshine Date: Fri, 25 Sep 2020 19:39:17 +0700 Subject: [PATCH 01/36] :white_check_mark: Setup cypress with send testcase to scan --- scan/cypress.json | 6 + scan/cypress/integration/send_action.spec.js | 35 ++ scan/cypress/support/commands.js | 25 + scan/cypress/support/index.js | 20 + scan/package.json | 4 +- scan/src/components/UserAccount.re | 12 +- .../modal/connect/ConnectWithMnemonic.re | 3 +- .../modal/submitTx/PreviewJsonStep.re | 3 +- .../modal/submitTx/SubmitTxModal.re | 1 + scan/yarn.lock | 537 +++++++++++++++++- 10 files changed, 630 insertions(+), 16 deletions(-) create mode 100644 scan/cypress.json create mode 100644 scan/cypress/integration/send_action.spec.js create mode 100644 scan/cypress/support/commands.js create mode 100644 scan/cypress/support/index.js diff --git a/scan/cypress.json b/scan/cypress.json new file mode 100644 index 0000000000..b3cfa8bdb1 --- /dev/null +++ b/scan/cypress.json @@ -0,0 +1,6 @@ +{ + "baseUrl": "http://localhost:1234/", + "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..2d53ab9e69 --- /dev/null +++ b/scan/cypress/integration/send_action.spec.js @@ -0,0 +1,35 @@ +/// + +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"]').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="sendToken"]').contains("Send").click(); + cy.get('[placeholder="Insert recipient address"]') + .wait(1000) + .type("band1mrdmxkhtr3rgfzfgrkxy5pvjtvnm5qq0my5m0x") + .get('[placeholder="Insert send amount"]') + .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..7a6fdceccb 100644 --- a/scan/package.json +++ b/scan/package.json @@ -4,7 +4,8 @@ "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 build && yarn test:dev", + "integration-test": "cypress open" }, "dependencies": { "@apollo/react-hooks": "^3.1.5", @@ -53,6 +54,7 @@ "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", diff --git a/scan/src/components/UserAccount.re b/scan/src/components/UserAccount.re index 7dedf08a5a..657faa1caf 100644 --- a/scan/src/components/UserAccount.re +++ b/scan/src/components/UserAccount.re @@ -44,6 +44,7 @@ module ConnectBtn = { [@react.component] let make = (~connect) => {
{ - ; +
+ +
; }; }; @@ -156,6 +159,7 @@ let make = () => { | Some({address}) =>
setShow(prev => !prev)}>
@@ -163,7 +167,7 @@ let make = () => {
- +
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/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/SubmitTxModal.re b/scan/src/components/modal/submitTx/SubmitTxModal.re index c480cefb72..32a2586904 100644 --- a/scan/src/components/modal/submitTx/SubmitTxModal.re +++ b/scan/src/components/modal/submitTx/SubmitTxModal.re @@ -146,6 +146,7 @@ module SubmitTxStep = { ; + :
+ +
; }; }; @@ -123,7 +125,7 @@ module Balance = {
-
+