Skip to content

Commit cb4a49b

Browse files
committed
integration test: fix hash saving behaviour
1 parent 58c0efe commit cb4a49b

File tree

5 files changed

+70
-39
lines changed

5 files changed

+70
-39
lines changed

test/integration/integration.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ try {
152152
argv.browsers,
153153
argv.gui,
154154
argv.vizzu,
155-
argv.gui,
156155
argv.images,
157156
argv.hashes
158157
);

test/integration/modules/integration-test/test-case/test-case-result.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class TestCaseResult {
5757

5858
#createTestCaseResultPassed() {
5959
this.#testCaseObj.testSuiteResults.PASSED.push(this.#testCaseObj.testCase);
60-
this.#cnsl.log(("[ " + this.#testData.result.padEnd(this.#cnsl.getTestStatusPad(), " ") + " ] ").success + "[ " + String(++this.#testCaseObj.testSuiteResults.FINISHED).padEnd(this.#cnsl.getTestNumberPad(), " ") + " ] " + this.#testCaseObj.testCase);
60+
this.#cnsl.log(("[ " + this.#testData.result.padEnd(this.#cnsl.getTestStatusPad(), " ") + " ] ").success + "[ " + String(++this.#testCaseObj.testSuiteResults.FINISHED).padEnd(this.#cnsl.getTestNumberPad(), " ") + " ] " + path.relative(TestEnv.getTestSuitePath(), path.join(TestEnv.getWorkspacePath(), this.#testCaseObj.testCase)));
6161
if (this.#testCaseObj.createImages === "ALL") {
6262
this.#createImage(this.#testData, '-1new');
6363
}
@@ -66,7 +66,7 @@ class TestCaseResult {
6666

6767
#createTestCaseResultWarning() {
6868
this.#testCaseObj.testSuiteResults.WARNING.push(this.#testCaseObj.testCase);
69-
this.#cnsl.log(("[ " + this.#testData.result.padEnd(this.#cnsl.getTestStatusPad(), " ") + " ] " + "[ " + String(++this.#testCaseObj.testSuiteResults.FINISHED).padEnd(this.#cnsl.getTestNumberPad(), " ") + " ] " + "[ " + this.#testData.description + " ] ").warn + this.#testCaseObj.testCase);
69+
this.#cnsl.log(("[ " + this.#testData.result.padEnd(this.#cnsl.getTestStatusPad(), " ") + " ] " + "[ " + String(++this.#testCaseObj.testSuiteResults.FINISHED).padEnd(this.#cnsl.getTestNumberPad(), " ") + " ] " + "[ " + this.#testData.description + " ] ").warn + path.relative(TestEnv.getTestSuitePath(), path.join(TestEnv.getWorkspacePath(), this.#testCaseObj.testCase)));
7070
if (this.#testCaseObj.createImages !== "DISABLED") {
7171
this.#createImage(this.#testData, '-1new');
7272
}
@@ -114,7 +114,7 @@ class TestCaseResult {
114114

115115
#createTestCaseResultErrorMsg() {
116116
let errParts = this.#testData.description.split("http://127.0.0.1:" + String(this.#testCaseObj.workspaceHostServerPort)).join(path.resolve(TestEnv.getWorkspacePath())).split("\n");
117-
this.#cnsl.log(("[ " + this.#testData.result.padEnd(this.#cnsl.getTestStatusPad(), " ") + " ] " + "[ " + String(++this.#testCaseObj.testSuiteResults.FINISHED).padEnd(this.#cnsl.getTestNumberPad(), " ") + " ] " + "[ " + errParts[0] + " ] ").error + this.#testCaseObj.testCase);
117+
this.#cnsl.log(("[ " + this.#testData.result.padEnd(this.#cnsl.getTestStatusPad(), " ") + " ] " + "[ " + String(++this.#testCaseObj.testSuiteResults.FINISHED).padEnd(this.#cnsl.getTestNumberPad(), " ") + " ] " + "[ " + errParts[0] + " ] ").error + path.relative(TestEnv.getTestSuitePath(), path.join(TestEnv.getWorkspacePath(), this.#testCaseObj.testCase)));
118118
if (errParts.length > 1) {
119119
errParts.slice(1).forEach(item => {
120120
this.#cnsl.log("".padEnd(this.#cnsl.getTestStatusPad() + 7, " ") + item);

test/integration/modules/integration-test/test-case/test-case.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ class TestCase {
3737
static runTestCaseClient(testCaseObj, browserChrome, vizzuUrl) {
3838
return new Promise((resolve, reject) => {
3939
let refHash = [];
40-
let animStep = testCaseObj.animStep;
40+
let animStep = { step: testCaseObj.animStep, default: true };
4141
if (testCaseObj.testCase in testCaseObj.testCasesConfig.tests) {
4242
if ("animstep" in testCaseObj.testCasesConfig.tests[testCaseObj.testCase]) {
43-
animStep = testCaseObj.testCasesConfig.tests[testCaseObj.testCase]["animstep"].replace("%", "");
43+
animStep.step = testCaseObj.testCasesConfig.tests[testCaseObj.testCase]["animstep"].replace("%", "");
44+
animStep.default = false;
4445
}
4546
if ("refs" in testCaseObj.testCasesConfig.tests[testCaseObj.testCase]) {
4647
refHash = testCaseObj.testCasesConfig.tests[testCaseObj.testCase]["refs"];
@@ -54,12 +55,15 @@ class TestCase {
5455
+ "?testCasesPath=" + path.dirname(testCaseObj.testCase)
5556
+ "&testCase=" + path.basename(testCaseObj.testCase)
5657
+ "&vizzuUrl=" + vizzuUrl
57-
+ "&animStep=" + animStep
58+
+ "&animStep=" + animStep.step
5859
+ "&refHash=" + refHash.toString()
5960
+ "&createImages=" + testCaseObj.createImages)
6061
.then(() => {
6162
browserChrome.waitUntilTitleIs("Finished", testCaseObj.animTimeout).then(() => {
6263
browserChrome.executeScript("return testData").then(testData => {
64+
if (!animStep.default) {
65+
testData["animstep"] = animStep.step;
66+
}
6367
return resolve(testData);
6468
})
6569
}).catch(err => {

test/integration/modules/integration-test/test-suite-result.js

Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
const path = require("path");
2+
const fs = require("fs");
3+
4+
const TestEnv = require("../../modules/integration-test/test-env.js");
5+
16

27
class TestSuiteResult {
38

@@ -27,7 +32,7 @@ class TestSuiteResult {
2732

2833

2934
createTestSuiteResult() {
30-
//this.#createNewConfig();
35+
this.#createNewConfig();
3136
this.#testSuiteResults.TIME.END = Math.round(Date.now() / 1000);
3237
let duration = this.#testSuiteResults.TIME.END - this.#testSuiteResults.TIME.START;
3338
this.#cnsl.log("\n" + "duration:".padEnd(15, " ") + duration + "s");
@@ -44,54 +49,77 @@ class TestSuiteResult {
4449
this.#cnsl.log(("tests failed:".padEnd(15, " ") + this.#testSuiteResults.FAILED.length).error);
4550
process.exitCode = 1;
4651
this.#testSuiteResults.FAILED.forEach(testCase => {
47-
this.#cnsl.log("".padEnd(this.#cnsl.getTestStatusPad() + 5, " ") + testCase + " http://127.0.0.1:8080/test/integration/manual/?version=localhost&testCase=" + testCase);
52+
this.#cnsl.log("".padEnd(this.#cnsl.getTestStatusPad() + 5, " ") + path.relative(TestEnv.getTestSuitePath(), path.join(TestEnv.getWorkspacePath(), testCase)) + " http://127.0.0.1:8080/test/integration/manual/?version=localhost&testCase=" + testCase);
4853
});
4954
} else {
5055
this.#cnsl.log("tests failed:".padEnd(15, " ") + this.#testSuiteResults.FAILED.length);
5156
}
5257
}
5358

5459

55-
/*#createNewConfig() {
60+
#createNewConfig() {
5661
if (this.#createHashes !== "DISABLED") {
57-
if (this.#createHashes === "ALL" || (this.#createHashes === "FAILED" && (this.#testSuiteResults.FAILED.length !== 0 || this.#testSuiteResults.WARNING !== 0))) {
58-
let hashesPath = path.join(TestEnv.getTestSuiteResultsPath(), path.basename(this.#testCasesHashListPath));
59-
let rmReady = new Promise((resolve, reject) => {
60-
fs.rm(hashesPath, { force: true }, err => {
61-
if (err) {
62-
return reject(err);
63-
}
64-
return resolve();
65-
});
62+
if (this.#createHashes === "ALL" || (this.#createHashes === "FAILED" && (this.#testSuiteResults.FAILED.length !== 0 || this.#testSuiteResults.WARNING.length !== 0))) {
63+
let testCasesConfig = {};
64+
this.#testCasesConfig.suites.forEach(suite => {
65+
let suitePath = "/" + path.relative(TestEnv.getWorkspacePath(), suite.suite);
66+
testCasesConfig[suitePath] = { suite: suitePath, tmp: suite.config, test: {} };
6667
});
67-
let mkdirReady = new Promise((resolve, reject) => {
68-
fs.mkdir(TestEnv.getTestSuiteResultsPath(), { recursive: true }, err => {
69-
if (err) {
70-
return reject(err);
68+
for (const [key, value] of Object.entries(this.#testSuiteResults.RESULTS)) {
69+
if (this.#createHashes === "FAILED" && (!this.#testSuiteResults.FAILED.includes(key) && !this.#testSuiteResults.WARNING.includes(key))) {
70+
continue;
71+
}
72+
Object.keys(testCasesConfig).forEach(suite => {
73+
if (key.startsWith(suite)) {
74+
let testData = {};
75+
if(this.#testSuiteResults.RESULTS[key]["animstep"]) {
76+
testData["animstep"] = this.#testSuiteResults.RESULTS[key]["animstep"] + "%";
77+
}
78+
testData["refs"] = [this.#testSuiteResults.RESULTS[key]['hash']]
79+
testCasesConfig[suite].test[path.relative(suite, key)] = testData;
7180
}
72-
return resolve();
7381
});
74-
});
75-
Promise.all([rmReady, mkdirReady]).then(() => {
76-
let testCasesData = {};
77-
for (const [key, value] of Object.entries(this.#testSuiteResults.RESULTS)) {
78-
if (this.#cfgCreateHashes === "FAILED" && (!this.#testSuiteResults.FAILED.includes(key) && !this.#testSuiteResults.WARNING.includes(key))) {
79-
continue;
80-
}
81-
testCasesData[key] = { refs: [this.#testSuiteResults.RESULTS[key]['hash']] };
82+
}
83+
84+
for (const [key, value] of Object.entries(testCasesConfig)) {
85+
if (Object.keys(testCasesConfig[key].test).length === 0) {
86+
continue;
8287
}
83-
if (Object.keys(testCasesData).length !== 0) {
84-
testCasesData = JSON.stringify(testCasesData, null, 4);
85-
fs.writeFile(hashesPath, testCasesData, (err) => {
88+
let conFigPath = path.join(TestEnv.getTestSuiteResultsPath(),
89+
path.relative(TestEnv.getTestSuitePath(),
90+
path.join(TestEnv.getWorkspacePath(),
91+
key)),
92+
path.basename(value.tmp));
93+
let rmReady = new Promise((resolve, reject) => {
94+
fs.rm(conFigPath, { force: true }, err => {
95+
if (err) {
96+
return reject(err);
97+
}
98+
return resolve();
99+
});
100+
});
101+
let mkdirReady = new Promise((resolve, reject) => {
102+
fs.mkdir(path.dirname(conFigPath), { recursive: true }, err => {
103+
if (err) {
104+
return reject(err);
105+
}
106+
return resolve();
107+
});
108+
});
109+
Promise.all([rmReady, mkdirReady]).then(() => {
110+
let configData = value;
111+
delete configData.tmp;
112+
configData = JSON.stringify(configData, null, 4);
113+
fs.writeFile(conFigPath, configData, (err) => {
86114
if (err) {
87115
throw err;
88116
}
89117
});
90-
}
91-
});
118+
});
119+
}
92120
}
93121
}
94-
}*/
122+
}
95123
}
96124

97125

test/integration/test_cases/test_cases.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
},
3939
"basic_animations/coordsystems/circle_without_2_carte": {
4040
"refs": [
41-
"9070694"
41+
"9070693"
4242
]
4343
},
4444
"basic_animations/coordsystems/rectangle_carte_2_polar": {

0 commit comments

Comments
 (0)