Skip to content

Commit

Permalink
BE-666 Add steps how to run e2e test for GUI to README
Browse files Browse the repository at this point in the history
Added README.md under client/test directory
Relocated some files related to e2e test

Change-Id: I48652606e900bcf3efd99b5f27be41e2ee3cc3e4
Signed-off-by: Atsushi Neki <atsushin@fast.au.fujitsu.com>
  • Loading branch information
nekia committed Jun 24, 2019
1 parent 23398dd commit fe002ce
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 10 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@
"timeago",
"timeline",
"tls",
"tooltip",
"txcount",
"txid",
"txhash",
Expand Down
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ Hyperledger Explorer is a simple, powerful, easy-to-use, well maintained, open s
- [14.0 Hyperledger Explorer Swagger](#Hyperledger-Explorer-Swagger)
- [15.0 Logs](#Logs)
- [16.0 Troubleshooting](#Troubleshooting)
- [17.0 License](#License)
- [17.0 Testing](#Testing)
- [18.0 License](#License)



Expand Down Expand Up @@ -548,9 +549,25 @@ To push the container to your registry, run:
- Please visit the [TROUBLESHOOT.md](TROUBLESHOOT.md) to view the Troubleshooting TechNotes for Hyperledger Explorer.


<a name="Testing" />

# 17.0 Testing <!-- do not remove this comment, ensure there is a blank line before each heading -->

* Unit test

* End-to-End test

* For REST API

- Please visit the [README.md](./app/platform/fabric/e2e-test/README.md) to view the End-To-End Testing TechNotes for Hyperledger Explorer REST API.

* For GUI

- Please visit the [README.md](./client/test/E2E-TEST-README.md) to view the End-To-End Testing TechNotes for Hyperledger Explorer GUI.


<a name="License" />

# 17.0 License <!-- do not remove this comment, ensure there is a blank line before each heading -->
# 18.0 License <!-- do not remove this comment, ensure there is a blank line before each heading -->

Hyperledger Explorer Project source code is released under the Apache 2.0 license. The README.md, CONTRIBUTING.md files, and files in the "images", "__snapshots__" folders are licensed under the Creative Commons Attribution 4.0 International License. You may obtain a copy of the license, titled CC-BY-4.0, at http://creativecommons.org/licenses/by/4.0/.
65 changes: 65 additions & 0 deletions client/test/E2E-TEST-README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

<!-- (SPDX-License-Identifier: CC-BY-4.0) --> <!-- Ensure there is a newline before, and after, this line -->

# How to run e2e test

## Pull fabric images and tools

```
$ cd /some/where/blockchain-explorer
$ npm run e2e-test-setup-tool:ci
```

## Build Explorer / Explorer-DB image

```
$ cd /some/where/blockchain-explorer
$ npm run e2e-test-setup-img
```

## Setup environment

Bring up the fabric network and start Explorer service on it

```
$ cd /some/where/blockchain-explorer
$ npm run e2e-gui-test-setup
```

## Run test scenarios

```
# cd /some/where/blockchain-explorer
$ npm run e2e-gui-test-setup-env
$ npm run e2e-gui-test-run
```

# Tips

# Project Structure

Scenario files are intended to locate in `/client/test/specs` folder.
Overall project structure is as follows:

```
client/test/
+-- docker-compose.yaml // Definition for Selenium Hub/Browser container service
+-- e2e-setup.sh // Bring up fabric network and explorer
+-- wdio.conf.js // webdriverIO configuration
+-- specs/ // Test scenarios
+-- dashboard.js // dashboard rendering scenarios
+-- ...
```

Mainly we'll update `client/test/specs/*.js` to cover more scenarios.

# Link

* https://webdriver.io/docs/api.html
* https://github.com/SeleniumHQ/docker-selenium
2 changes: 1 addition & 1 deletion client/e2e-setup.sh → client/test/e2e-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#


ROOTDIR="$(cd "$(dirname "$0")"/.. && pwd)"
ROOTDIR="$(cd "$(dirname "$0")"/../.. && pwd)"
export CORE_PEER_NETWORKID=e2egui
export COMPOSE_PROJECT_NAME=$CORE_PEER_NETWORKID
export NETWORK_PROFILE=first-network
Expand Down
10 changes: 6 additions & 4 deletions client/test/dashboard.js → client/test/specs/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

/* eslint-disable no-unused-expressions */

require('chai').should();
var expect = require('chai').expect;

Expand All @@ -21,7 +23,7 @@ describe('Explorer dashboard', () => {
});

describe('statistics', () => {
it('shoud have a metrics', () => {
it('should have a metrics', () => {
browser.setTimeout({
timeouts: 100000
});
Expand All @@ -43,7 +45,7 @@ describe('Explorer dashboard', () => {
txNum.should.be.equal('5');

// Num. of Nodes
var nodeNum = browser
nodeNum = browser
.$(
'#root > div > div > div > div > div:nth-child(1) > div > div > div:nth-child(3) > div > div:nth-child(2) > h1'
)
Expand Down Expand Up @@ -107,11 +109,11 @@ describe('Explorer dashboard', () => {
);
path.click();

var tooltip = browser.$(
tooltip = browser.$(
'#root > div > div > div > div > div:nth-child(2) > div:nth-child(2) > div > div > div > div.recharts-tooltip-wrapper.recharts-tooltip-wrapper-right.recharts-tooltip-wrapper-bottom > div > ul > li > span.recharts-tooltip-item-name'
);

var displayTooltip = tooltip.isExisting();
displayTooltip = tooltip.isExisting();
expect(displayTooltip).to.be.true;
console.log(tooltip.getText());
});
Expand Down
2 changes: 1 addition & 1 deletion client/wdio.conf.js → client/test/wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports.config = {
// NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
// directory is where your package.json resides, so `wdio` will be called from there.
//
specs: ['./test/**/*.js'],
specs: ['./test/specs/**/*.js'],
// Patterns to exclude.
exclude: [
// 'path/to/excluded/files'
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@
"e2e-test": "run-s e2e-test-check-tool e2e-test-check-img e2e-test-setup-env e2e-test-setup-img e2e-test-run",
"e2e-test-sanitycheck:ci": "cross-env PATH=$PATH:$PWD/bin run-s e2e-test-setup-tool:ci e2e-test-check-tool e2e-test-check-img e2e-test-setup-env e2e-test-setup-img e2e-test-run-sanitycheck",
"e2e-gui-test-setup-env": "cd client; npm install",
"e2e-gui-test-setup": "./client/e2e-setup.sh",
"e2e-gui-test-run": "cd client; npx wdio",
"e2e-gui-test-setup": "./client/test/e2e-setup.sh",
"e2e-gui-test-run": "cd client; npx wdio ./test/wdio.conf.js",
"e2e-gui-test": "run-s e2e-gui-test-setup e2e-gui-test-run",
"e2e-gui-test:ci": "cross-env PATH=$PATH:$PWD/bin run-s e2e-test-setup-tool:ci e2e-test-check-tool e2e-test-setup-img e2e-gui-test-setup-env e2e-gui-test-setup e2e-gui-test-run"
}
Expand Down

0 comments on commit fe002ce

Please sign in to comment.