Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Scan: Setup cypress with send testcase to scan #2676

Merged
merged 37 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
52aa823
:white_check_mark: Setup cypress with send testcase to scan
pzshine Sep 25, 2020
22a6e88
:loud_sound: Updated CHANGELOG file
pzshine Sep 25, 2020
188f0ff
:green_heart: Improved the test setup
pzshine Sep 28, 2020
32286c8
:white_check_mark: test again
pzshine Sep 28, 2020
0d25b33
:white_check_mark: Updated test config
pzshine Sep 28, 2020
96a610b
:white_check_mark: Test CI on github
pzshine Sep 30, 2020
fe97ba8
:white_check_mark: Tried to test with new config
pzshine Sep 30, 2020
d309aba
:white_check_mark: Updated github setting
pzshine Sep 30, 2020
71afc67
:green_heart: updated github setting
pzshine Sep 30, 2020
a421473
:green_heart: Test CI with new setup
pzshine Oct 1, 2020
23ad714
:green_heart: set up ci v1
pzshine Oct 1, 2020
f4425bb
:green_heart: Set up CI v2
pzshine Oct 1, 2020
be78b00
:green_heart: CI setup v3
pzshine Oct 1, 2020
4af3c89
:green_heart: Set CI v4
pzshine Oct 1, 2020
06a6a4c
:green_heart: set up CI v5
pzshine Oct 1, 2020
91a7f33
:green_heart: set up CI v6
pzshine Oct 1, 2020
b6ce895
:green_heart: set up CI v7
pzshine Oct 1, 2020
0917e68
:green_heart: test run v8
pzshine Oct 1, 2020
04a8adb
:green_heart: Set up CI v9
pzshine Oct 1, 2020
bbd5b6f
:green_heart: set up CI v10
pzshine Oct 1, 2020
cdb6a47
:green_heart: set up CI v11
pzshine Oct 1, 2020
9a66418
:green_heart: set up CI v12
pzshine Oct 1, 2020
59416d1
:green_heart: set up CI v13
pzshine Oct 1, 2020
5101e45
:green_heart: set up CI v13
pzshine Oct 1, 2020
d915d94
:green_heart: set up CI v14
pzshine Oct 1, 2020
d323344
:green_heart: set up CI v15
pzshine Oct 1, 2020
9bfcb50
:green_heart: set up CI v16
pzshine Oct 1, 2020
6c28219
:green_heart: set CI v17
pzshine Oct 1, 2020
98b26a3
:green_heart: set up CI v18
pzshine Oct 1, 2020
449d1f6
:green_heart: set up CI v19
pzshine Oct 1, 2020
9c752ab
:green_heart: run test again v19
pzshine Oct 1, 2020
22d43a1
:green_heart: Cleaned the CI setup
pzshine Oct 1, 2020
ff904c9
:recycle: Fixed by comments
pzshine Oct 2, 2020
cdddfb8
:white_check_mark: Updated cypress testcase
pzshine Oct 2, 2020
64b3ee2
:white_check_mark: run test again
pzshine Oct 2, 2020
1f33acd
Merge branch 'master' into cypress-setup
pzshine Oct 2, 2020
d32961d
:white_check_mark: Added get testtoken to the testcase
pzshine Oct 2, 2020
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
53 changes: 35 additions & 18 deletions .github/workflows/scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
1 change: 1 addition & 0 deletions CHANGELOG_UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions scan/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"baseUrl": "http://localhost:3000/",
"pluginsFile": false,
"fixturesFolder": false,
"defaultCommandTimeout": 10000
}
35 changes: 35 additions & 0 deletions scan/cypress/integration/send_action.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/// <reference types="cypress" />

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="sendToken"] > button').contains("Send").click();
cy.get('[id="recipientAddressInput"]')
.wait(1000)
.type("band1mrdmxkhtr3rgfzfgrkxy5pvjtvnm5qq0my5m0x")
.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"
);
});
});
pzshine marked this conversation as resolved.
Show resolved Hide resolved
25 changes: 25 additions & 0 deletions scan/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -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) => { ... })
20 changes: 20 additions & 0 deletions scan/cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -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')
16 changes: 13 additions & 3 deletions scan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand All @@ -71,5 +76,10 @@
".gif"
]
}
},
"jest": {
"testPathIgnorePatterns": [
"cypress"
]
}
}
2 changes: 2 additions & 0 deletions scan/src/components/EnhanceTxInput.re
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ let make =
~placeholder="",
~inputType="text",
~autoFocus=false,
~id,
) => {
let (status, setStatus) = React.useState(_ => Untouched);

Expand All @@ -101,6 +102,7 @@ let make =
<Text value=msg size=Text.Lg spacing={Text.Em(0.03)} nowrap=true block=true />
<div className={Styles.rightContainer(width)}>
<input
id
value={inputData.text}
className={Css.merge([Styles.input, code ? Styles.code : ""])}
placeholder
Expand Down
12 changes: 8 additions & 4 deletions scan/src/components/UserAccount.re
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module ConnectBtn = {
[@react.component]
let make = (~connect) => {
<div
id="connectButton"
className={Css.merge([
CssHelper.flexBox(~justify=`center, ~align=`center, ()),
CssHelper.clickable,
Expand Down Expand Up @@ -107,9 +108,11 @@ module FaucetBtn = {
module SendBtn = {
[@react.component]
let make = (~send) => {
<Button px=20 py=5 onClick={_ => {send()}}>
<Text value="Send" weight=Text.Medium nowrap=true block=true />
</Button>;
<div id="sendToken">
<Button px=20 py=5 onClick={_ => {send()}}>
<Text value="Send" weight=Text.Medium nowrap=true block=true />
</Button>
</div>;
};
};

Expand Down Expand Up @@ -156,13 +159,14 @@ let make = () => {
| Some({address}) =>
<div className={Css.merge([CssHelper.flexBox(~justify=`flexEnd, ()), Styles.container])}>
<div
id="userInfoButton"
className={Css.merge([CssHelper.flexBox(), CssHelper.clickable])}
onClick={_ => setShow(prev => !prev)}>
<div className=Styles.oval> <Icon name="fal fa-user" color=Colors.white /> </div>
<HSpacing size=Spacing.sm />
<Icon name="fas fa-caret-down" color=Colors.bandBlue />
</div>
<div className={Styles.profileCard(show)}>
<div className={Styles.profileCard(show)} id="addressWrapper">
<AddressRender address position=AddressRender.Text />
<VSpacing size={`px(16)} />
<div className=Styles.innerProfileCard>
Expand Down
3 changes: 2 additions & 1 deletion scan/src/components/modal/connect/ConnectWithMnemonic.re
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ let make = (~chainID) => {
<Text value="Enter Your Mnemonic" size=Text.Md weight=Text.Medium />
<VSpacing size=Spacing.sm />
<input
id="mnemonicInput"
autoFocus=true
value=mnemonic
className=Styles.inputBar
Expand All @@ -105,7 +106,7 @@ let make = (~chainID) => {
}
/>
<VSpacing size={`px(35)} />
<div className={CssHelper.flexBox(~justify=`flexEnd, ())}>
<div id="mnemonicConnectButton" className={CssHelper.flexBox(~justify=`flexEnd, ())}>
<Button px=20 py=8 onClick={_ => createMnemonic()}>
<Text value="Connect" weight=Text.Bold size=Text.Md color=Colors.white />
</Button>
Expand Down
1 change: 1 addition & 0 deletions scan/src/components/modal/submitTx/DelegateMsg.re
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ let make = (~address, ~validator, ~setMsgsOpt) => {
inputType="number"
code=true
autoFocus=true
id="delegateAmountInput"
/>;
| _ => <EnhanceTxInput.Loading msg="Delegate Amount (BAND)" width=300 />
}}
Expand Down
3 changes: 2 additions & 1 deletion scan/src/components/modal/submitTx/PreviewJsonStep.re
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ let make = (~rawTx, ~onBack, ~account: AccountContext.t) => {
</div>
<div
className=Styles.btn
id="broadcastButton"
onClick={_ => {
dispatchModal(DisableExit);
setState(_ => Signing);
Expand Down Expand Up @@ -192,7 +193,7 @@ let make = (~rawTx, ~onBack, ~account: AccountContext.t) => {
</div>
| Success(txHash) =>
<div className=Styles.resultContainer>
<div className=Styles.rFlex>
<div className=Styles.rFlex id="successMsgContainer">
<img src=Images.success2 className=Styles.resultIcon />
<HSpacing size=Spacing.md />
<Text value="Broadcast Transaction Success" weight=Text.Semibold />
Expand Down
1 change: 1 addition & 0 deletions scan/src/components/modal/submitTx/RedelegateMsg.re
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ let make = (~address, ~validator, ~setMsgsOpt) => {
inputType="number"
code=true
autoFocus=true
id="redelegateAmountInput"
/>;
| _ => <EnhanceTxInput.Loading msg="Amount (BAND)" width=300 />
}}
Expand Down
2 changes: 2 additions & 0 deletions scan/src/components/modal/submitTx/SendMsg.re
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -99,6 +100,7 @@ let make = (~address, ~receiver, ~setMsgsOpt) => {
| _ => true
}
}
id="sendAmountInput"
/>;
| _ => <EnhanceTxInput.Loading msg="Send Amount (BAND)" width=300 />
}}
Expand Down
2 changes: 2 additions & 0 deletions scan/src/components/modal/submitTx/SubmitTxModal.re
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ module SubmitTxStep = {
msg="Memo (optional)"
placeholder="Insert memo"
code=true
id="memoInput"
/>
<VSpacing size=Spacing.lg />
<VSpacing size=Spacing.md />
Expand All @@ -146,6 +147,7 @@ module SubmitTxStep = {
<VSpacing size=Spacing.lg />
<VSpacing size=Spacing.md />
<button
id="nextButton"
className=Styles.nextBtn
disabled={msgsOpt->Belt.Option.isNone}
onClick={_ => {
Expand Down
1 change: 1 addition & 0 deletions scan/src/components/modal/submitTx/UndelegateMsg.re
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ let make = (~address, ~validator, ~setMsgsOpt) => {
inputType="number"
code=true
autoFocus=true
id="undelegateAmountInput"
/>;
| _ => <EnhanceTxInput.Loading msg="Undelegate Amount (BAND)" width=300 />
}}
Expand Down
Loading