Skip to content

Commit b105d15

Browse files
authored
Merge pull request #264 from veghdev/integrationtest_doc
Integration test more detailed documentation
2 parents 278a2fe + cb3e1f2 commit b105d15

File tree

3 files changed

+95
-51
lines changed

3 files changed

+95
-51
lines changed

test/integration/man.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@ const yargs = require("yargs");
33
const Manual = require("./modules/manual/manual.js");
44

55
try {
6+
var usage = `
7+
Usage: $0 [tests] [options]
8+
9+
This program allows for the manual testing of Vizzu. The program provides the following options:
10+
11+
Select Vizzu version in the first column to use for playing animations on the left canvas.
12+
Select Vizzu version in the second column to use for playing animations on the right canvas.
13+
This enables comparison between the two versions and helps identify any differences.
14+
15+
Select a test case in the third column to play.
16+
The animation of the selected test case will be displayed using the chosen Vizzu versions.
17+
`;
18+
619
var argv = yargs
720
.usage("Usage: $0 [tests] [options]")
821

@@ -20,9 +33,8 @@ try {
2033
.nargs("c", 1)
2134
.describe(
2235
"c",
23-
"Change the list of config file's path of the test cases" +
24-
"\n(relative or absolute path where the repo folder is the root)" +
25-
"\n"
36+
"Change the list of configuration files' path of the test cases" +
37+
"\n(relative or absolute path where the repo folder is the root)"
2638
)
2739
.default("c", [
2840
"/test/integration/test_cases/test_cases.json",

test/integration/test.js

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,28 @@ const catchError = (err) => {
1818
};
1919

2020
try {
21+
22+
var usage = `
23+
Usage: $0 [tests] [options]
24+
25+
The integration test aims to comprehensively test the Vizzu library by executing animations represented as a promise chain of animate function calls.
26+
Each test case follows predefined animation steps and calculates a hash based on the generated canvas image data for each step.
27+
The test validation compares the calculated hash values with the expected values stored for each test case.
28+
29+
The test offers the ability to generate and save images for every canvas image data, as well as create reference and difference images.
30+
This allows for detailed analysis and comparison of the test output.
31+
32+
During testing, two types of warnings may occur.
33+
Firstly, if a test case lacks a stored reference hash, a warning is issued.
34+
Secondly, if a test case produces a different hash compared to the stored reference, but the reference Vizzu library also generates the same hash,
35+
it indicates that the difference is likely caused by environmental factors such as the operating system or the browser.
36+
37+
Please note that the test require Chrome, ChromeDriver and Selenium Webdriver to be properly configured and available.
38+
`;
39+
2140
var argv = yargs
2241

23-
.usage(
24-
"Usage: $0 [tests] [options]" +
25-
"\n\nThe objective of the integration test is to E2E test the Vizzu library." +
26-
"\nThe test cases are animations, each animation consists of an animate function call promise chain." +
27-
"\nThe test animations run in Chrome using ChromeDriver and Selenium Webdriver." +
28-
"\nA test case seeks through each animate function calls with a predefined animation step." +
29-
"\nA hash is calculated on every created canvas image data for each animation step." +
30-
"\nA test validates a hash calculated from the created hash list during each test case."
31-
)
42+
.usage(usage)
3243

3344
.help("h")
3445
.alias("h", "help")
@@ -43,9 +54,8 @@ try {
4354
.nargs("c", 1)
4455
.describe(
4556
"c",
46-
"Change the list of config file's path of the test cases" +
47-
"\n(relative or absolute path where the repo folder is the root)" +
48-
"\n"
57+
"Change the list of configuration files' path of the test cases" +
58+
"\n(relative or absolute path where the repo folder is the root)"
4959
)
5060
.default("c", [
5161
"/test/integration/test_cases/test_cases.json",
@@ -55,7 +65,7 @@ try {
5565
.choices("Werror", ["noref", "sameref"])
5666
.describe(
5767
"Werror",
58-
"Select warnings to be treated as errors" +
68+
"Select warnings to be treated as errors during the test execution" +
5969
'\n- "noref": Test cases without reference hashes' +
6070
'\n- "sameref": Test cases that produce the same hashes with the reference Vizzu'
6171
)
@@ -69,7 +79,7 @@ try {
6979
.choices("images", ["ALL", "FAILED", "DISABLED"])
7080
.describe(
7181
"images",
72-
"Change report images saving behavior" +
82+
"Change the saving behavior of images, which are captured from every test steps" +
7383
'\n- "ALL": Create images for every test' +
7484
'\n- "FAILED": Create images for failed/warning tests only' +
7585
'\n- "DISABLED": Do not create images'
@@ -79,7 +89,7 @@ try {
7989
.choices("hashes", ["ALL", "FAILED", "DISABLED"])
8090
.describe(
8191
"hashes",
82-
"Change report hashes saving behavior" +
92+
"Change the saving behavior of hashes, which are unique identifiers calculated for each test case" +
8393
'\n- "ALL": Write hashes into the report file for every test' +
8494
'\n- "FAILED": Write hashes into the report file for failed/warning tests only' +
8595
'\n- "DISABLED": Do not create report file'
@@ -89,7 +99,7 @@ try {
8999
.boolean("nologs")
90100
.describe(
91101
"nologs",
92-
"\n Do not save browser and console log into file" + "\n"
102+
"Disable the saving of browser and console logs into a log file"
93103
)
94104
.default("nologs", false)
95105

@@ -99,16 +109,15 @@ try {
99109
"vizzu",
100110
"Change Vizzu url" +
101111
"\n(can be forced to use vizzu.js or vizzu.min.js if its given)" +
102-
'\n\n- "head": select the last stable Vizzu from the main branch' +
112+
'\n\n- "head": specify "head" to select the last stable version of Vizzu from the main branch' +
103113
"\n(default: vizzu.min.js)" +
104114
"\n\n- [sha]: select Vizzu with a short commit number" +
105115
"\n(default: vizzu.min.js)" +
106116
"\n\n- [version]: select Vizzu with a version number" +
107117
"\n(vizzu.min.js only)" +
108118
"\n\n- path: select Vizzu from the local file system" +
109119
"\n(relative or absolute path where the repo folder is the root)" +
110-
"\n(default: vizzu.js)" +
111-
"\n"
120+
"\n(default: vizzu.js)"
112121
)
113122
.default("vizzu", "/example/lib/vizzu.js")
114123

@@ -118,32 +127,31 @@ try {
118127
"vizzu-ref",
119128
"Change reference Vizzu url" +
120129
"\n(can be forced to use vizzu.js or vizzu.min.js if its given)" +
121-
'\n\n- "head": select the last stable Vizzu from the main branch' +
130+
'\n\n- "head": specify "head" to select the last stable version of Vizzu from the main branch' +
122131
"\n(default: vizzu.min.js)" +
123132
"\n\n- [sha]: select Vizzu with a short commit number" +
124133
"\n(default: vizzu.min.js)" +
125134
"\n\n- [version]: select Vizzu with a version number" +
126135
"\n(vizzu.min.js only)" +
127136
"\n\n- path: select Vizzu from the local file system" +
128137
"\n(relative or absolute path where the repo folder is the root)" +
129-
"\n(default: vizzu.js)" +
130-
"\n"
138+
"\n(default: vizzu.js)"
131139
)
132140
.default("vizzu-ref", "head")
133141

134142
.boolean("g")
135143
.alias("g", "gui")
136-
.describe("g", "Use browser with graphical user interface" + "\n")
144+
.describe("g", "Use browser with graphical user interface")
137145
.default("g", false)
138146

139147
.number("b")
140148
.alias("b", "browsers")
141-
.describe("b", "Change number of parallel browser windows" + "\n")
149+
.describe("b", "Change number of parallel browser windows")
142150
.default("b", 6)
143151

144152
.boolean("d")
145153
.alias("d", "delete")
146-
.describe("d", "Delete test report folder" + "\n")
154+
.describe("d", "Delete test report folder")
147155
.default("d", false)
148156

149157
.example([
@@ -166,17 +174,17 @@ try {
166174
"Select test cases with glob pattern",
167175
],
168176
])
169-
.example(
170-
"$0 -g",
171-
"Run all tests and use browser with graphical user interface"
172-
)
173177
.example([
174178
[
175-
"$0 -vizzu head",
179+
"$0 --vizzu head",
176180
"Run all tests with the latest stable Vizzu from the main branch",
177181
],
178182
[
179-
"$0 -vizzu [sha]/vizzu.js",
183+
"$0 --vizzu [x.y.z]",
184+
"Run all tests and select Vizzu with a version number",
185+
],
186+
[
187+
"$0 --vizzu [sha]/vizzu.js",
180188
"Run all tests and select Vizzu with a short commit number" +
181189
"\nand use vizzu.js instead of the default vizzu.min.js",
182190
],

test/test.md

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,53 +39,77 @@ npm test -- -t <test name>
3939

4040
# Integration testing
4141

42-
## Install all test dependencies on Ubuntu 20.04
43-
44-
Add Node.js to the repository list:
42+
For information on how integration testing works and what options it has, please see the program help:
4543

4644
```
47-
wget --quiet -O - https://deb.nodesource.com/setup_18.x | sudo bash
45+
cd test/integration
46+
node test.js --help
4847
```
4948

50-
Install test dependencies:
49+
## Test environment
50+
51+
It is recommended to use `Ubuntu 22.04` and setup the test environment with the steps below.
52+
53+
Install package dependencies:
5154

5255
```
5356
sudo apt-get update
54-
sudo apt-get install nodejs fonts-roboto fonts-noto-cjk gnupg wget curl unzip
57+
sudo apt-get install fonts-roboto fonts-noto-cjk gnupg wget curl unzip
5558
```
5659

57-
Install or update latest chrome and chromedriver:
60+
It is recommended to use `Node.js 18`.
61+
Install `nvm` and `Node.js 18`:
5862

5963
```
60-
npm run chrome
64+
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
65+
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
66+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
67+
68+
nvm install 18
69+
nvm use default 18
70+
71+
node --version
6172
```
6273

63-
## Testing the project
74+
Note: We use the latest `Chrome` and `Chromedriver` to keep our library up to date.
75+
Install (or update) the latest `Chrome` and `Chromedriver`:
76+
77+
```
78+
npm run chrome
79+
```
6480

65-
### Install NPM dependencies:
81+
Install `npm` package dependencies:
6682

6783
```
6884
cd test/integration
6985
npm install # npm update
7086
```
7187

72-
### Run all tests
88+
## Run all test cases
7389

7490
```
7591
cd test/integration
7692
node test.js
77-
# For more information run: node test.js -h
7893
```
7994

80-
#### Manual testing
95+
For more options please see the program help.
96+
97+
```
98+
node test.js --help
99+
```
81100

82-
Test cases can be viewed using different versions of vizzu using the manual checker.\
83-
Note: select version of Vizzu on the left (where HEAD is the latest stable)\
84-
Note: select test case on the right
101+
## Manual testing
102+
103+
Test cases can be viewed using different versions of vizzu using the manual checker.
85104

86105
```
87106
cd test/integration
88107
node man.js
89108
# Press CTRL and click on the URL to open it in the default browser
90-
# For more information run: node man.js -h
91109
```
110+
111+
For more options please see the program help.
112+
113+
```
114+
node man.js --help
115+
```

0 commit comments

Comments
 (0)