html-reporter 9.8.2 → 9.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/lib/common-utils.js +5 -0
- package/lib/constants/diff-modes.js +5 -0
- package/lib/gui/app.js +4 -0
- package/lib/gui/server.js +7 -1
- package/lib/gui/tool-runner/index.js +43 -3
- package/lib/gui/tool-runner/utils.js +0 -5
- package/lib/local-images-saver.js +1 -1
- package/lib/report-builder/gui.js +53 -2
- package/lib/report-builder/static.js +4 -0
- package/lib/reporter-helpers.js +26 -2
- package/lib/server-utils.js +16 -2
- package/lib/sqlite-adapter.js +40 -12
- package/lib/static/components/controls/selects/index.styl +1 -1
- package/lib/static/components/modals/screenshot-accepter/header.js +17 -0
- package/lib/static/components/modals/screenshot-accepter/index.js +67 -4
- package/lib/static/components/section/body/history/index.js +1 -1
- package/lib/static/components/state/index.js +33 -6
- package/lib/static/components/state/screenshot/resized.js +3 -3
- package/lib/static/components/state/state-fail/index.js +111 -92
- package/lib/static/components/state/state-fail/index.styl +1 -1
- package/lib/static/components/state/state-fail/useFitImages.js +63 -0
- package/lib/static/gui.min.css +1 -1
- package/lib/static/gui.min.js +29 -25
- package/lib/static/hooks/useElementSize.js +2 -2
- package/lib/static/hooks/useWindowSize.js +3 -3
- package/lib/static/modules/action-names.js +2 -0
- package/lib/static/modules/actions.js +25 -1
- package/lib/static/modules/middlewares/metrika.js +1 -0
- package/lib/static/modules/reducers/tree/index.js +49 -2
- package/lib/static/modules/reducers/tree/nodes/browsers.js +11 -0
- package/lib/static/modules/reducers/tree/nodes/images.js +9 -0
- package/lib/static/modules/reducers/tree/nodes/results.js +14 -0
- package/lib/static/modules/reducers/tree/nodes/suites.js +23 -1
- package/lib/static/modules/reducers/view.js +3 -0
- package/lib/static/modules/utils.js +11 -1
- package/lib/static/report.min.css +1 -1
- package/lib/static/report.min.js +29 -25
- package/lib/test-adapter.js +60 -24
- package/lib/tests-tree-builder/gui.js +68 -0
- package/package.json +1 -1
package/lib/test-adapter.js
CHANGED
|
@@ -12,8 +12,8 @@ const {getSuitePath} = require('./plugin-utils').getHermioneUtils();
|
|
|
12
12
|
const {getCommandsHistory} = require('./history-utils');
|
|
13
13
|
const {SUCCESS, FAIL, ERROR, UPDATED} = require('./constants/test-statuses');
|
|
14
14
|
const {ERROR_DETAILS_PATH} = require('./constants/paths');
|
|
15
|
+
const {logger, getShortMD5} = require('./common-utils');
|
|
15
16
|
const utils = require('./server-utils');
|
|
16
|
-
const {logger} = require('./common-utils');
|
|
17
17
|
|
|
18
18
|
const globalCacheAllImages = new Map();
|
|
19
19
|
const globalCacheExpectedPaths = new Map();
|
|
@@ -39,7 +39,7 @@ module.exports = class TestAdapter {
|
|
|
39
39
|
this._errors = this._hermione.errors;
|
|
40
40
|
this._suite = SuiteAdapter.create(this._testResult);
|
|
41
41
|
this._imagesSaver = this._hermione.htmlReporter.imagesSaver;
|
|
42
|
-
this._testId =
|
|
42
|
+
this._testId = this._mkTestId();
|
|
43
43
|
this._errorDetails = undefined;
|
|
44
44
|
this._timestamp = this._testResult.timestamp;
|
|
45
45
|
|
|
@@ -79,7 +79,7 @@ module.exports = class TestAdapter {
|
|
|
79
79
|
return globalCacheAllImages.get(imgPath) || imgPath;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
_getLastImageInfoFromDb(stateName) {
|
|
83
83
|
const browserName = this._testResult.browserId;
|
|
84
84
|
const suitePath = getSuitePath(this._testResult);
|
|
85
85
|
const suitePathString = JSON.stringify(suitePath);
|
|
@@ -95,34 +95,35 @@ module.exports = class TestAdapter {
|
|
|
95
95
|
return imagesInfo.find(info => info.stateName === stateName);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
const {id, browserId} = this._testResult;
|
|
100
|
-
// TODO: remove toString after publish major version
|
|
101
|
-
return [id.toString(), browserId, stateName].join('/');
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
_getExpectedPath(stateName, status) {
|
|
98
|
+
_getExpectedPath(stateName, status, cacheExpectedPaths) {
|
|
105
99
|
const key = this._getExpectedKey(stateName);
|
|
106
100
|
|
|
107
101
|
if (status === UPDATED) {
|
|
108
102
|
const expectedPath = utils.getReferencePath(this, stateName);
|
|
109
|
-
|
|
103
|
+
cacheExpectedPaths.set(key, expectedPath);
|
|
110
104
|
|
|
111
|
-
return expectedPath;
|
|
105
|
+
return {path: expectedPath, reused: false};
|
|
112
106
|
}
|
|
113
107
|
|
|
114
|
-
if (
|
|
115
|
-
return
|
|
108
|
+
if (cacheExpectedPaths.has(key)) {
|
|
109
|
+
return {path: cacheExpectedPaths.get(key), reused: true};
|
|
116
110
|
}
|
|
117
111
|
|
|
118
|
-
const imageInfo = this.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
112
|
+
const imageInfo = this._getLastImageInfoFromDb(stateName);
|
|
113
|
+
|
|
114
|
+
if (imageInfo && imageInfo.expectedImg) {
|
|
115
|
+
const expectedPath = imageInfo.expectedImg.path;
|
|
122
116
|
|
|
123
|
-
|
|
117
|
+
cacheExpectedPaths.set(key, expectedPath);
|
|
118
|
+
|
|
119
|
+
return {path: expectedPath, reused: true};
|
|
120
|
+
}
|
|
124
121
|
|
|
125
|
-
|
|
122
|
+
const expectedPath = utils.getReferencePath(this, stateName);
|
|
123
|
+
|
|
124
|
+
cacheExpectedPaths.set(key, expectedPath);
|
|
125
|
+
|
|
126
|
+
return {path: expectedPath, reused: false};
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
getImagesFor(status, stateName) {
|
|
@@ -130,7 +131,7 @@ module.exports = class TestAdapter {
|
|
|
130
131
|
const currImg = this.getCurrImg(stateName);
|
|
131
132
|
const errImg = this.getErrImg();
|
|
132
133
|
|
|
133
|
-
const refPath = this._getExpectedPath(stateName, status);
|
|
134
|
+
const {path: refPath} = this._getExpectedPath(stateName, status, globalCacheExpectedPaths);
|
|
134
135
|
const currPath = utils.getCurrentPath(this, stateName);
|
|
135
136
|
const diffPath = utils.getDiffPath(this, stateName);
|
|
136
137
|
|
|
@@ -373,10 +374,10 @@ module.exports = class TestAdapter {
|
|
|
373
374
|
await fs.writeFile(detailsFilePath, detailsData);
|
|
374
375
|
}
|
|
375
376
|
|
|
376
|
-
async saveTestImages(reportPath, workers) {
|
|
377
|
+
async saveTestImages(reportPath, workers, cacheExpectedPaths = globalCacheExpectedPaths) {
|
|
377
378
|
const result = await Promise.all(this.assertViewResults.map(async (assertResult) => {
|
|
378
379
|
const {stateName} = assertResult;
|
|
379
|
-
const destRefPath = this._getExpectedPath(stateName);
|
|
380
|
+
const {path: destRefPath, reused: reusedReference} = this._getExpectedPath(stateName, undefined, cacheExpectedPaths);
|
|
380
381
|
const srcRefPath = this.getRefImg(stateName).path;
|
|
381
382
|
|
|
382
383
|
const destCurrPath = utils.getCurrentPath(this, stateName);
|
|
@@ -396,8 +397,11 @@ module.exports = class TestAdapter {
|
|
|
396
397
|
actions.push(
|
|
397
398
|
this._saveImg(srcCurrPath, destCurrPath, reportPath),
|
|
398
399
|
this._saveImg(srcDiffPath, dstCurrPath, reportPath),
|
|
399
|
-
this._saveImg(srcRefPath, destRefPath, reportPath)
|
|
400
400
|
);
|
|
401
|
+
|
|
402
|
+
if (!reusedReference) {
|
|
403
|
+
actions.push(this._saveImg(srcRefPath, destRefPath, reportPath));
|
|
404
|
+
}
|
|
401
405
|
}
|
|
402
406
|
|
|
403
407
|
if (this.isNoRefImageError(assertResult)) {
|
|
@@ -421,6 +425,38 @@ module.exports = class TestAdapter {
|
|
|
421
425
|
return result;
|
|
422
426
|
}
|
|
423
427
|
|
|
428
|
+
updateCacheExpectedPath(stateName, expectedPath) {
|
|
429
|
+
const key = this._getExpectedKey(stateName);
|
|
430
|
+
|
|
431
|
+
if (expectedPath) {
|
|
432
|
+
globalCacheExpectedPaths.set(key, expectedPath);
|
|
433
|
+
} else {
|
|
434
|
+
globalCacheExpectedPaths.delete(key);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
decreaseAttemptNumber() {
|
|
439
|
+
const testId = this._mkTestId();
|
|
440
|
+
const currentTestAttempt = testsAttempts.get(testId);
|
|
441
|
+
const previousTestAttempt = currentTestAttempt - 1;
|
|
442
|
+
|
|
443
|
+
if (previousTestAttempt) {
|
|
444
|
+
testsAttempts.set(testId, previousTestAttempt);
|
|
445
|
+
} else {
|
|
446
|
+
testsAttempts.delete(testId);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
_mkTestId() {
|
|
451
|
+
return this._testResult.fullTitle() + '.' + this._testResult.browserId;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
_getExpectedKey(stateName) {
|
|
455
|
+
const shortTestId = getShortMD5(this._mkTestId());
|
|
456
|
+
|
|
457
|
+
return shortTestId + '#' + stateName;
|
|
458
|
+
}
|
|
459
|
+
|
|
424
460
|
//parallelize and cache of 'looks-same.createDiff' (because it is very slow)
|
|
425
461
|
async _saveDiffInWorker(imageDiffError, destPath, workers, cacheDiffImages = globalCacheDiffImages) {
|
|
426
462
|
await utils.makeDirFor(destPath);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const _ = require('lodash');
|
|
4
4
|
const BaseTestsTreeBuilder = require('./base');
|
|
5
5
|
const {UPDATED} = require('../constants/test-statuses');
|
|
6
|
+
const {isUpdatedStatus} = require('../common-utils');
|
|
6
7
|
|
|
7
8
|
module.exports = class GuiTestsTreeBuilder extends BaseTestsTreeBuilder {
|
|
8
9
|
getLastResult(formattedResult) {
|
|
@@ -83,10 +84,77 @@ module.exports = class GuiTestsTreeBuilder extends BaseTestsTreeBuilder {
|
|
|
83
84
|
});
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
getResultDataToUnacceptImage(resultId, stateName) {
|
|
88
|
+
const imageId = this._tree.results.byId[resultId].imageIds.find(imageId => {
|
|
89
|
+
return this._tree.images.byId[imageId].stateName === stateName;
|
|
90
|
+
});
|
|
91
|
+
const image = this._tree.images.byId[imageId];
|
|
92
|
+
const result = this._tree.results.byId[image.parentId];
|
|
93
|
+
const browser = this._tree.browsers.byId[result.parentId];
|
|
94
|
+
|
|
95
|
+
const previousResultId = browser.resultIds.find((_, ind, resultIds) => resultIds[ind + 1] === result.id);
|
|
96
|
+
const previousResult = previousResultId ? this._tree.results.byId[previousResultId] : null;
|
|
97
|
+
|
|
98
|
+
const previousImageId = previousResult
|
|
99
|
+
? previousResult.imageIds.find(imageId => this._tree.images.byId[imageId].stateName === image.stateName)
|
|
100
|
+
: null;
|
|
101
|
+
const previousImage = previousImageId
|
|
102
|
+
? this._tree.images.byId[previousImageId]
|
|
103
|
+
: null;
|
|
104
|
+
|
|
105
|
+
const countUpdated = result.imageIds.reduce((acc, currImageId) => {
|
|
106
|
+
return acc + isUpdatedStatus(this._tree.images.byId[currImageId].status);
|
|
107
|
+
}, 0);
|
|
108
|
+
const shouldRemoveResult = isUpdatedStatus(image.status) && countUpdated === 1;
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
imageId,
|
|
112
|
+
status: image.status,
|
|
113
|
+
timestamp: result.timestamp,
|
|
114
|
+
previousImage,
|
|
115
|
+
previousImageId,
|
|
116
|
+
shouldRemoveResult
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
86
120
|
reuseTestsTree(testsTree) {
|
|
87
121
|
this._tree.browsers.allIds.forEach((browserId) => this._reuseBrowser(testsTree, browserId));
|
|
88
122
|
}
|
|
89
123
|
|
|
124
|
+
updateImageInfo(imageId, imageInfo) {
|
|
125
|
+
const currentImage = this._tree.images.byId[imageId];
|
|
126
|
+
const updatedImage = {
|
|
127
|
+
...imageInfo,
|
|
128
|
+
id: currentImage.id,
|
|
129
|
+
parentId: currentImage.parentId
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
this._tree.images.byId[imageId] = updatedImage;
|
|
133
|
+
|
|
134
|
+
return updatedImage;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
removeTestResult(resultId) {
|
|
138
|
+
const result = this._tree.results.byId[resultId];
|
|
139
|
+
|
|
140
|
+
this._removeImagesById(result.imageIds);
|
|
141
|
+
|
|
142
|
+
this._tree.browsers.byId[result.parentId].resultIds =
|
|
143
|
+
this._tree.browsers.byId[result.parentId].resultIds.filter(id => id !== resultId);
|
|
144
|
+
|
|
145
|
+
this._tree.results.allIds = this._tree.results.allIds.filter(id => id !== resultId);
|
|
146
|
+
|
|
147
|
+
delete this._tree.results.byId[resultId];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
_removeImagesById(imageIds) {
|
|
151
|
+
this._tree.images.allIds = this._tree.images.allIds.filter(id => !imageIds.includes(id));
|
|
152
|
+
|
|
153
|
+
imageIds.forEach(imageId => {
|
|
154
|
+
delete this._tree.images.byId[imageId];
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
90
158
|
_reuseBrowser(testsTree, browserId) {
|
|
91
159
|
const reuseBrowser = testsTree.browsers.byId[browserId];
|
|
92
160
|
|
package/package.json
CHANGED