html-reporter 8.0.2 → 8.3.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +44 -7
  3. package/lib/cli-commands/index.js +2 -1
  4. package/lib/cli-commands/remove-unused-screens/index.js +194 -0
  5. package/lib/cli-commands/remove-unused-screens/utils.js +159 -0
  6. package/lib/common-utils.js +52 -52
  7. package/lib/config/index.js +1 -1
  8. package/lib/constants/database.js +24 -4
  9. package/lib/db-utils/client.js +109 -0
  10. package/lib/db-utils/common.js +76 -0
  11. package/lib/db-utils/server.js +124 -0
  12. package/lib/gui/index.js +2 -1
  13. package/lib/gui/server.js +2 -1
  14. package/lib/gui/tool-runner/index.js +7 -7
  15. package/lib/gui/tool-runner/utils.js +10 -27
  16. package/lib/plugin-adapter.js +1 -1
  17. package/lib/plugin-api.js +17 -3
  18. package/lib/report-builder/static.js +1 -1
  19. package/lib/server-utils.js +1 -4
  20. package/lib/sqlite-adapter.js +3 -4
  21. package/lib/static/components/bottom-progress-bar/index.js +38 -0
  22. package/lib/static/components/gui.js +2 -0
  23. package/lib/static/components/report.js +2 -0
  24. package/lib/static/components/section/body/meta-info.js +1 -1
  25. package/lib/static/components/state/screenshot.js +1 -1
  26. package/lib/static/components/suites.js +39 -5
  27. package/lib/static/gui.min.css +1 -1
  28. package/lib/static/gui.min.js +19 -19
  29. package/lib/static/modules/action-names.js +2 -1
  30. package/lib/static/modules/actions.js +3 -3
  31. package/lib/static/modules/default-state.js +4 -1
  32. package/lib/static/modules/reducers/bottom-progress-bar.js +16 -0
  33. package/lib/static/modules/reducers/db.js +1 -1
  34. package/lib/static/modules/reducers/index.js +3 -1
  35. package/lib/static/modules/utils.js +0 -12
  36. package/lib/static/report.min.css +1 -1
  37. package/lib/static/report.min.js +20 -20
  38. package/lib/static/styles.css +41 -0
  39. package/lib/test-adapter.js +2 -1
  40. package/lib/tests-tree-builder/static.js +13 -13
  41. package/package.json +6 -1
  42. package/lib/constants/file-names.js +0 -6
  43. package/lib/static/modules/database-utils.js +0 -36
  44. package/lib/static/modules/sqlite.js +0 -152
@@ -883,3 +883,44 @@ a:active {
883
883
  .ui.loader {
884
884
  z-index: 50;
885
885
  }
886
+
887
+ .bottom-progress-bar {
888
+ position: fixed;
889
+ width: 100%;
890
+ bottom: 0;
891
+ line-height: 1em;
892
+ z-index: 999;
893
+ }
894
+
895
+ .bottom-progress-bar:hover .bottom-progress-bar__progress-container {
896
+ height: 15px;
897
+ }
898
+
899
+ .bottom-progress-bar__progress-container {
900
+ height: 3px;
901
+ background: #938965;
902
+ box-shadow: 0 0 6px -3px #848484;
903
+ transition: height .2s ease;
904
+ }
905
+
906
+ .bottom-progress-bar__progress-bar {
907
+ background-color: #ffcc00;
908
+ text-align: center;
909
+ height: 100%;
910
+ }
911
+
912
+ .bottom-progress-bar__counter {
913
+ position: absolute;
914
+ width: 100%;
915
+ text-align: center;
916
+ bottom: 0;
917
+ color: #382f0d;
918
+ font-size: 10px;
919
+ opacity: 0;
920
+
921
+ transition: opacity .1s ease;
922
+ }
923
+
924
+ .bottom-progress-bar:hover .bottom-progress-bar__counter {
925
+ opacity: 1;
926
+ }
@@ -13,6 +13,7 @@ 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
15
  const utils = require('./server-utils');
16
+ const {logger} = require('./common-utils');
16
17
 
17
18
  const globalCacheAllImages = new Map();
18
19
 
@@ -125,7 +126,7 @@ module.exports = class TestAdapter {
125
126
 
126
127
  async saveBase64Screenshot(reportPath) {
127
128
  if (!this.screenshot.base64) {
128
- utils.logger.warn('Cannot save screenshot on reject');
129
+ logger.warn('Cannot save screenshot on reject');
129
130
 
130
131
  return Promise.resolve();
131
132
  }
@@ -2,9 +2,9 @@
2
2
 
3
3
  const _ = require('lodash');
4
4
  const BaseTestsTreeBuilder = require('./base');
5
- const {dbColumnIndexes} = require('../common-utils');
6
5
  const testStatus = require('../constants/test-statuses');
7
6
  const {versions: browserVersions} = require('../constants/browser');
7
+ const {DB_COLUMN_INDEXES} = require('../constants/database');
8
8
 
9
9
  module.exports = class StaticTestsTreeBuilder extends BaseTestsTreeBuilder {
10
10
  constructor() {
@@ -25,8 +25,8 @@ module.exports = class StaticTestsTreeBuilder extends BaseTestsTreeBuilder {
25
25
  const browsers = {};
26
26
 
27
27
  for (const row of rows) {
28
- const testPath = JSON.parse(row[dbColumnIndexes.suitePath]);
29
- const browserName = row[dbColumnIndexes.name];
28
+ const testPath = JSON.parse(row[DB_COLUMN_INDEXES.suitePath]);
29
+ const browserName = row[DB_COLUMN_INDEXES.name];
30
30
 
31
31
  const testId = this._buildId(testPath);
32
32
  const browserId = this._buildId(testId, browserName);
@@ -151,16 +151,16 @@ function initStats() {
151
151
 
152
152
  function mkTestResult(row, data = {}) {
153
153
  return {
154
- description: row[dbColumnIndexes.description],
155
- imagesInfo: JSON.parse(row[dbColumnIndexes.imagesInfo]),
156
- metaInfo: JSON.parse(row[dbColumnIndexes.metaInfo]),
157
- multipleTabs: Boolean(row[dbColumnIndexes.multipleTabs]),
158
- name: row[dbColumnIndexes.name],
159
- screenshot: Boolean(row[dbColumnIndexes.screenshot]),
160
- status: row[dbColumnIndexes.status],
161
- suiteUrl: row[dbColumnIndexes.suiteUrl],
162
- skipReason: row[dbColumnIndexes.skipReason],
163
- error: JSON.parse(row[dbColumnIndexes.error]),
154
+ description: row[DB_COLUMN_INDEXES.description],
155
+ imagesInfo: JSON.parse(row[DB_COLUMN_INDEXES.imagesInfo]),
156
+ metaInfo: JSON.parse(row[DB_COLUMN_INDEXES.metaInfo]),
157
+ multipleTabs: Boolean(row[DB_COLUMN_INDEXES.multipleTabs]),
158
+ name: row[DB_COLUMN_INDEXES.name],
159
+ screenshot: Boolean(row[DB_COLUMN_INDEXES.screenshot]),
160
+ status: row[DB_COLUMN_INDEXES.status],
161
+ suiteUrl: row[DB_COLUMN_INDEXES.suiteUrl],
162
+ skipReason: row[DB_COLUMN_INDEXES.skipReason],
163
+ error: JSON.parse(row[DB_COLUMN_INDEXES.error]),
164
164
  ...data
165
165
  };
166
166
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-reporter",
3
- "version": "8.0.2",
3
+ "version": "8.3.0",
4
4
  "description": "Plugin for hermione which is intended to aggregate the results of tests running into html report",
5
5
  "scripts": {
6
6
  "coverage": "nyc npm run test-unit",
@@ -51,16 +51,20 @@
51
51
  "chalk": "^1.1.3",
52
52
  "debug": "^4.1.1",
53
53
  "express": "^4.16.2",
54
+ "filesize": "^8.0.6",
54
55
  "fs-extra": "^7.0.1",
55
56
  "gemini-configparser": "^1.0.0",
56
57
  "gemini-core": "^6.3.2",
57
58
  "http-codes": "1.0.0",
58
59
  "immer": "^7.0.7",
60
+ "inquirer": "^8.2.0",
59
61
  "json-stringify-safe": "^5.0.1",
60
62
  "lodash": "^4.17.4",
61
63
  "looks-same": "^7.1.1",
64
+ "micromatch": "^4.0.4",
62
65
  "nested-error-stacks": "^2.1.0",
63
66
  "opener": "^1.4.3",
67
+ "ora": "^5.4.1",
64
68
  "p-queue": "^5.0.0",
65
69
  "qs": "^6.9.1",
66
70
  "react-hotkeys": "^2.0.0",
@@ -79,6 +83,7 @@
79
83
  "web-vitals": "^1.1.2"
80
84
  },
81
85
  "devDependencies": {
86
+ "@gemini-testing/commander": "^2.15.3",
82
87
  "app-module-path": "^2.2.0",
83
88
  "babel-core": "^6.26.0",
84
89
  "babel-eslint": "^8.0.1",
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- LOCAL_DATABASE_NAME: 'sqlite.db',
5
- DATABASE_URLS_JSON_NAME: 'databaseUrls.json'
6
- };
@@ -1,36 +0,0 @@
1
- 'use strict';
2
-
3
- const {isEmpty} = require('lodash');
4
- const {selectAllQuery, compareDatabaseRowsByTimestamp} = require('../../common-utils');
5
- const {DB_SUITES_TABLE_NAME} = require('../../constants/database');
6
-
7
- function getSuitesTableRows(db) {
8
- const databaseRows = getTableRows(db, DB_SUITES_TABLE_NAME);
9
-
10
- if (isEmpty(databaseRows)) {
11
- return;
12
- }
13
-
14
- return databaseRows.values.sort(compareDatabaseRowsByTimestamp);
15
- }
16
-
17
- function getTableRows(db, tableName) {
18
- const [databaseRows] = db.exec(selectAllQuery(tableName));
19
-
20
- if (!databaseRows) {
21
- console.warn(`Table "${tableName}" is empty`);
22
-
23
- return [];
24
- }
25
-
26
- return databaseRows;
27
- }
28
-
29
- function closeDatabase(db) {
30
- db.close();
31
- }
32
-
33
- module.exports = {
34
- getSuitesTableRows,
35
- closeDatabase
36
- };
@@ -1,152 +0,0 @@
1
- 'use strict';
2
-
3
- import axios from 'axios';
4
- import {flattenDeep} from 'lodash';
5
- import {mergeTables} from '../../common-utils';
6
- import {LOCAL_DATABASE_NAME} from '../../constants/file-names';
7
-
8
- function isRelativeUrl(url) {
9
- try {
10
- // eslint-disable-next-line no-new
11
- new URL(url);
12
-
13
- return false;
14
- } catch (e) {
15
- return true;
16
- }
17
- }
18
-
19
- function normalizeUrls(urls = [], baseUrl) {
20
- const baseUrlsSearch = new URL(baseUrl).search;
21
-
22
- return urls.map(url => {
23
- try {
24
- const newUrl = new URL(url, baseUrl);
25
-
26
- // URL's parameters can specify directory at file server
27
- if (isRelativeUrl(url) && !newUrl.search) {
28
- newUrl.search = baseUrlsSearch;
29
- }
30
-
31
- return newUrl.href;
32
- } catch (e) {
33
- console.warn(`Can not normalize url '${url} for base url '${baseUrl}'`, e);
34
-
35
- return url;
36
- }
37
- });
38
- }
39
-
40
- async function fetchFile(url, options) {
41
- try {
42
- const {data, status} = await axios.get(url, options);
43
-
44
- return {data, status};
45
- } catch (e) {
46
- console.warn(`Error while fetching ${url}`, e);
47
-
48
- // 'unknown' for request blocked by CORS policy
49
- const status = e.response ? e.response.status : 'unknown';
50
-
51
- return {data: null, status};
52
- }
53
- }
54
-
55
- // recursive fetch databaseUrls.json and databases
56
- async function fetchDatabases(currentJsonsUrls) {
57
- return flattenDeep(
58
- await Promise.all(
59
- currentJsonsUrls.map(async currentJsonUrl => {
60
- try {
61
- const currentJsonResponse = await fetchFile(currentJsonUrl);
62
-
63
- if (!currentJsonResponse.data) {
64
- return {
65
- url: currentJsonUrl,
66
- status: currentJsonResponse.status,
67
- data: null
68
- };
69
- }
70
-
71
- // JSON format declare at lib/static/modules/actions.js
72
- const {dbUrls, jsonUrls} = currentJsonResponse.data;
73
-
74
- // paths from databaseUrls.json may be relative or absolute
75
- const normalizedDbUrls = normalizeUrls(dbUrls, currentJsonUrl);
76
- const normalizedJsonUrls = normalizeUrls(jsonUrls, currentJsonUrl);
77
-
78
- return await Promise.all([
79
- fetchDatabases(normalizedJsonUrls),
80
-
81
- ...normalizedDbUrls.map(async databaseUrl => {
82
- const {data, status} = await fetchFile(databaseUrl, {
83
- responseType: 'arraybuffer'
84
- });
85
-
86
- return {url: databaseUrl, status, data};
87
- })
88
- ]);
89
- } catch (e) {
90
- console.warn(`Error while fetching databases from ${currentJsonUrl}`, e);
91
-
92
- return {url: currentJsonUrl, status: 'unknown', data: null};
93
- }
94
- }),
95
- ),
96
- );
97
- }
98
-
99
- async function mergeDatabases(dataForDbs) {
100
- const SQL = await window.initSqlJs();
101
-
102
- const fetchedDataArray = dataForDbs.map(data => new Uint8Array(data));
103
- const connections = fetchedDataArray.map(data => new SQL.Database(data));
104
-
105
- if (connections.length === 0) {
106
- return null;
107
- } else if (connections.length === 1) {
108
- return connections[0];
109
- }
110
-
111
- const sumOfChunkSizes = fetchedDataArray.reduce((acc, data) => {
112
- return acc + data.length;
113
- }, 0);
114
-
115
- const mergedDbConnection = new SQL.Database(undefined, sumOfChunkSizes);
116
- const dbPaths = connections.map(db => db.filename);
117
-
118
- mergeTables({db: mergedDbConnection, dbPaths, getExistingTables: (statement) => {
119
- const tables = [];
120
-
121
- while (statement.step()) {
122
- tables.push(...statement.get());
123
- }
124
-
125
- return tables;
126
- }});
127
-
128
- connections.forEach(db => db.close());
129
-
130
- return mergedDbConnection;
131
- }
132
-
133
- async function connectToDatabase(dbUrl) {
134
- const mainDatabaseUrl = new URL(dbUrl);
135
- const {data} = await fetchFile(mainDatabaseUrl.href, {
136
- responseType: 'arraybuffer'
137
- });
138
-
139
- const SQL = await window.initSqlJs();
140
- return new SQL.Database(new Uint8Array(data));
141
- }
142
-
143
- function getMainDatabaseUrl() {
144
- return new URL(LOCAL_DATABASE_NAME, window.location.href);
145
- }
146
-
147
- module.exports = {
148
- fetchDatabases,
149
- mergeDatabases,
150
- connectToDatabase,
151
- getMainDatabaseUrl
152
- };