html-reporter 8.2.0 → 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.
- package/CHANGELOG.md +10 -0
- package/README.md +44 -7
- package/lib/cli-commands/index.js +2 -1
- package/lib/cli-commands/remove-unused-screens/index.js +194 -0
- package/lib/cli-commands/remove-unused-screens/utils.js +159 -0
- package/lib/common-utils.js +52 -52
- package/lib/config/index.js +1 -1
- package/lib/constants/database.js +24 -4
- package/lib/db-utils/client.js +109 -0
- package/lib/db-utils/common.js +76 -0
- package/lib/db-utils/server.js +124 -0
- package/lib/gui/index.js +2 -1
- package/lib/gui/server.js +2 -1
- package/lib/gui/tool-runner/index.js +7 -7
- package/lib/gui/tool-runner/utils.js +7 -25
- package/lib/plugin-adapter.js +1 -1
- package/lib/plugin-api.js +17 -3
- package/lib/report-builder/static.js +1 -1
- package/lib/server-utils.js +1 -4
- package/lib/sqlite-adapter.js +3 -4
- package/lib/static/components/section/body/meta-info.js +1 -1
- package/lib/static/components/state/screenshot.js +1 -1
- package/lib/static/gui.min.js +19 -19
- package/lib/static/modules/actions.js +2 -3
- package/lib/static/modules/reducers/db.js +1 -1
- package/lib/static/modules/utils.js +0 -12
- package/lib/static/report.min.js +20 -20
- package/lib/test-adapter.js +2 -1
- package/lib/tests-tree-builder/static.js +13 -13
- package/package.json +6 -1
- package/lib/constants/file-names.js +0 -6
- package/lib/static/data.js +0 -611
- package/lib/static/databaseUrls.json +0 -1
- package/lib/static/modules/database-utils.js +0 -36
- package/lib/static/modules/sqlite.js +0 -152
- package/sqlite.db +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* eslint-env browser */
|
|
3
|
+
|
|
4
|
+
const {isEmpty} = require('lodash');
|
|
5
|
+
const commonSqliteUtils = require('./common');
|
|
6
|
+
const {fetchFile, normalizeUrls} = require('../common-utils');
|
|
7
|
+
|
|
8
|
+
const {DB_SUITES_TABLE_NAME, LOCAL_DATABASE_NAME} = require('../constants/database');
|
|
9
|
+
|
|
10
|
+
function fetchDataFromDatabases(dbJsonUrls) {
|
|
11
|
+
const loadDbJsonUrl = (dbJsonUrl) => fetchFile(dbJsonUrl);
|
|
12
|
+
const prepareUrls = (urls, baseUrl) => normalizeUrls(urls, baseUrl);
|
|
13
|
+
|
|
14
|
+
const formatData = (dbJsonUrl, jsonResponseStatus = 'unknown') => {
|
|
15
|
+
return {url: dbJsonUrl, status: jsonResponseStatus, data: null};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const loadDbUrl = async (dbUrl) => {
|
|
19
|
+
const {data, status} = await fetchFile(dbUrl, {responseType: 'arraybuffer'});
|
|
20
|
+
|
|
21
|
+
return {url: dbUrl, status, data};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return commonSqliteUtils.handleDatabases(dbJsonUrls, {loadDbJsonUrl, prepareUrls, formatData, loadDbUrl});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function mergeDatabases(dataForDbs) {
|
|
28
|
+
const SQL = await window.initSqlJs();
|
|
29
|
+
|
|
30
|
+
const fetchedDataArray = dataForDbs.map(data => new Uint8Array(data));
|
|
31
|
+
const connections = fetchedDataArray.map(data => new SQL.Database(data));
|
|
32
|
+
|
|
33
|
+
if (connections.length === 0) {
|
|
34
|
+
return null;
|
|
35
|
+
} else if (connections.length === 1) {
|
|
36
|
+
return connections[0];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const sumOfChunkSizes = fetchedDataArray.reduce((acc, data) => {
|
|
40
|
+
return acc + data.length;
|
|
41
|
+
}, 0);
|
|
42
|
+
|
|
43
|
+
const mergedDbConnection = new SQL.Database(undefined, sumOfChunkSizes);
|
|
44
|
+
const dbPaths = connections.map(db => db.filename);
|
|
45
|
+
|
|
46
|
+
commonSqliteUtils.mergeTables({db: mergedDbConnection, dbPaths, getExistingTables: (statement) => {
|
|
47
|
+
const tables = [];
|
|
48
|
+
|
|
49
|
+
while (statement.step()) {
|
|
50
|
+
tables.push(...statement.get());
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return tables;
|
|
54
|
+
}});
|
|
55
|
+
|
|
56
|
+
connections.forEach(db => db.close());
|
|
57
|
+
|
|
58
|
+
return mergedDbConnection;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function connectToDatabase(dbUrl) {
|
|
62
|
+
const mainDatabaseUrl = new URL(dbUrl);
|
|
63
|
+
const {data} = await fetchFile(mainDatabaseUrl.href, {
|
|
64
|
+
responseType: 'arraybuffer'
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const SQL = await window.initSqlJs();
|
|
68
|
+
return new SQL.Database(new Uint8Array(data));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function getMainDatabaseUrl() {
|
|
72
|
+
return new URL(LOCAL_DATABASE_NAME, window.location.href);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getSuitesTableRows(db) {
|
|
76
|
+
const databaseRows = getTableRows(db, DB_SUITES_TABLE_NAME);
|
|
77
|
+
|
|
78
|
+
if (isEmpty(databaseRows)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return databaseRows.values.sort(commonSqliteUtils.compareDatabaseRowsByTimestamp);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function getTableRows(db, tableName) {
|
|
86
|
+
const [databaseRows] = db.exec(commonSqliteUtils.selectAllQuery(tableName));
|
|
87
|
+
|
|
88
|
+
if (!databaseRows) {
|
|
89
|
+
console.warn(`Table "${tableName}" is empty`);
|
|
90
|
+
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return databaseRows;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function closeDatabase(db) {
|
|
98
|
+
db.close();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
module.exports = {
|
|
102
|
+
...commonSqliteUtils,
|
|
103
|
+
fetchDataFromDatabases,
|
|
104
|
+
mergeDatabases,
|
|
105
|
+
connectToDatabase,
|
|
106
|
+
getMainDatabaseUrl,
|
|
107
|
+
getSuitesTableRows,
|
|
108
|
+
closeDatabase
|
|
109
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const _ = require('lodash');
|
|
4
|
+
const {logger} = require('../common-utils');
|
|
5
|
+
const {DB_MAX_AVAILABLE_PAGE_SIZE, DB_SUITES_TABLE_NAME, SUITES_TABLE_COLUMNS, DB_COLUMN_INDEXES} = require('../constants/database');
|
|
6
|
+
|
|
7
|
+
exports.selectAllQuery = (tableName) => `SELECT * FROM ${tableName}`;
|
|
8
|
+
exports.selectAllSuitesQuery = () => exports.selectAllQuery(DB_SUITES_TABLE_NAME);
|
|
9
|
+
|
|
10
|
+
exports.createTablesQuery = () => [
|
|
11
|
+
createTableQuery(DB_SUITES_TABLE_NAME, SUITES_TABLE_COLUMNS)
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
exports.compareDatabaseRowsByTimestamp = (row1, row2) => {
|
|
15
|
+
return row1[DB_COLUMN_INDEXES.timestamp] - row2[DB_COLUMN_INDEXES.timestamp];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.handleDatabases = async (dbJsonUrls, opts = {}) => {
|
|
19
|
+
return _.flattenDeep(
|
|
20
|
+
await Promise.all(
|
|
21
|
+
dbJsonUrls.map(async dbJsonUrl => {
|
|
22
|
+
try {
|
|
23
|
+
const currentJsonResponse = await opts.loadDbJsonUrl(dbJsonUrl);
|
|
24
|
+
|
|
25
|
+
if (!currentJsonResponse.data) {
|
|
26
|
+
logger.warn(`Cannot get data from ${dbJsonUrl}`);
|
|
27
|
+
|
|
28
|
+
return opts.formatData ? opts.formatData(dbJsonUrl, currentJsonResponse.status) : [];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// JSON format declare at lib/static/modules/actions.js
|
|
32
|
+
const {dbUrls, jsonUrls} = currentJsonResponse.data;
|
|
33
|
+
|
|
34
|
+
// paths from databaseUrls.json may be relative or absolute
|
|
35
|
+
const preparedDbUrls = opts.prepareUrls(dbUrls, dbJsonUrl);
|
|
36
|
+
const preparedDbJsonUrls = opts.prepareUrls(jsonUrls, dbJsonUrl);
|
|
37
|
+
|
|
38
|
+
return await Promise.all([
|
|
39
|
+
exports.handleDatabases(preparedDbJsonUrls, opts),
|
|
40
|
+
...preparedDbUrls.map(dbUrl => opts.loadDbUrl(dbUrl, opts))
|
|
41
|
+
]);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
logger.warn(`Error while downloading databases from ${dbJsonUrl}`, e);
|
|
44
|
+
|
|
45
|
+
return opts.formatData ? opts.formatData(dbJsonUrl) : [];
|
|
46
|
+
}
|
|
47
|
+
}),
|
|
48
|
+
),
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
exports.mergeTables = ({db, dbPaths, getExistingTables = () => {}}) => {
|
|
53
|
+
db.prepare(`PRAGMA page_size = ${DB_MAX_AVAILABLE_PAGE_SIZE}`).run();
|
|
54
|
+
|
|
55
|
+
for (const dbPath of dbPaths) {
|
|
56
|
+
db.prepare(`ATTACH DATABASE '${dbPath}' AS attached`).run();
|
|
57
|
+
|
|
58
|
+
const getTablesStatement = db.prepare(`SELECT name FROM attached.sqlite_master WHERE type='table'`);
|
|
59
|
+
const tables = getExistingTables(getTablesStatement);
|
|
60
|
+
|
|
61
|
+
for (const tableName of tables) {
|
|
62
|
+
db.prepare(`CREATE TABLE IF NOT EXISTS ${tableName} AS SELECT * FROM attached.${tableName} LIMIT 0`).run();
|
|
63
|
+
db.prepare(`INSERT OR IGNORE INTO ${tableName} SELECT * FROM attached.${tableName}`).run();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
db.prepare(`DETACH attached`).run();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
function createTableQuery(tableName, columns) {
|
|
71
|
+
const formattedColumns = columns
|
|
72
|
+
.map(({name, type}) => `${name} ${type}`)
|
|
73
|
+
.join(', ');
|
|
74
|
+
|
|
75
|
+
return `CREATE TABLE IF NOT EXISTS ${tableName} (${formattedColumns})`;
|
|
76
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const crypto = require('crypto');
|
|
5
|
+
const axios = require('axios');
|
|
6
|
+
const fs = require('fs-extra');
|
|
7
|
+
const Database = require('better-sqlite3');
|
|
8
|
+
const chalk = require('chalk');
|
|
9
|
+
const NestedError = require('nested-error-stacks');
|
|
10
|
+
|
|
11
|
+
const StaticTestsTreeBuilder = require('../tests-tree-builder/static');
|
|
12
|
+
const commonSqliteUtils = require('./common');
|
|
13
|
+
const {isUrl, fetchFile, normalizeUrls, logger} = require('../common-utils');
|
|
14
|
+
|
|
15
|
+
const {DATABASE_URLS_JSON_NAME, LOCAL_DATABASE_NAME} = require('../constants/database');
|
|
16
|
+
|
|
17
|
+
function downloadDatabases(dbJsonUrls, opts) {
|
|
18
|
+
const loadDbJsonUrl = async (dbJsonUrl) => {
|
|
19
|
+
if (isUrl(dbJsonUrl)) {
|
|
20
|
+
return fetchFile(dbJsonUrl);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const data = await fs.readJSON(dbJsonUrl);
|
|
24
|
+
return {data};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const prepareUrls = (urls, baseUrl) => isUrl(baseUrl) ? normalizeUrls(urls, baseUrl) : urls;
|
|
28
|
+
const loadDbUrl = (dbUrl, opts) => downloadSingleDatabase(dbUrl, opts);
|
|
29
|
+
|
|
30
|
+
return commonSqliteUtils.handleDatabases(dbJsonUrls, {...opts, loadDbJsonUrl, prepareUrls, loadDbUrl});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function mergeDatabases(srcDbPaths, reportPath) {
|
|
34
|
+
try {
|
|
35
|
+
const mainDatabaseUrls = path.resolve(reportPath, DATABASE_URLS_JSON_NAME);
|
|
36
|
+
const mergedDbPath = path.resolve(reportPath, LOCAL_DATABASE_NAME);
|
|
37
|
+
const mergedDb = new Database(mergedDbPath);
|
|
38
|
+
|
|
39
|
+
commonSqliteUtils.mergeTables({db: mergedDb, dbPaths: srcDbPaths, getExistingTables: (statement) => {
|
|
40
|
+
return statement.all().map((table) => table.name);
|
|
41
|
+
}});
|
|
42
|
+
|
|
43
|
+
for (const dbPath of srcDbPaths) {
|
|
44
|
+
await fs.remove(dbPath);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
await rewriteDatabaseUrls([mergedDbPath], mainDatabaseUrls, reportPath);
|
|
48
|
+
|
|
49
|
+
mergedDb.close();
|
|
50
|
+
} catch (err) {
|
|
51
|
+
throw new NestedError('Error while merging databases', err);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getTestsTreeFromDatabase(dbPath) {
|
|
56
|
+
try {
|
|
57
|
+
const db = new Database(dbPath, {readonly: true, fileMustExist: true});
|
|
58
|
+
const testsTreeBuilder = StaticTestsTreeBuilder.create();
|
|
59
|
+
|
|
60
|
+
const suitesRows = db.prepare(commonSqliteUtils.selectAllSuitesQuery())
|
|
61
|
+
.raw()
|
|
62
|
+
.all()
|
|
63
|
+
.sort(commonSqliteUtils.compareDatabaseRowsByTimestamp);
|
|
64
|
+
const {tree} = testsTreeBuilder.build(suitesRows);
|
|
65
|
+
|
|
66
|
+
db.close();
|
|
67
|
+
|
|
68
|
+
return tree;
|
|
69
|
+
} catch (err) {
|
|
70
|
+
throw new NestedError('Error while getting data from database', err);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function downloadSingleDatabase(dbUrl, {pluginConfig} = {}) {
|
|
75
|
+
if (!isUrl(dbUrl)) {
|
|
76
|
+
return path.resolve(pluginConfig.path, dbUrl);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const dest = path.resolve(pluginConfig.path, getUniqueFileNameForLink(dbUrl));
|
|
80
|
+
|
|
81
|
+
logger.log(chalk.green(`Download ${dbUrl} to ${pluginConfig.path}`));
|
|
82
|
+
|
|
83
|
+
const response = await axios({
|
|
84
|
+
url: dbUrl,
|
|
85
|
+
responseType: 'stream'
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const writer = fs.createWriteStream(dest);
|
|
89
|
+
|
|
90
|
+
response.data.pipe(writer);
|
|
91
|
+
|
|
92
|
+
await new Promise((resolve, reject) => {
|
|
93
|
+
writer.on('finish', resolve);
|
|
94
|
+
writer.on('error', reject);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return dest;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function getUniqueFileNameForLink(link) {
|
|
101
|
+
const fileName = crypto
|
|
102
|
+
.createHash('sha256')
|
|
103
|
+
.update(link)
|
|
104
|
+
.digest('hex');
|
|
105
|
+
const fileExt = path.extname(new URL(link).pathname);
|
|
106
|
+
|
|
107
|
+
return `${fileName}${fileExt}`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function rewriteDatabaseUrls(dbPaths, mainDatabaseUrls, reportPath) {
|
|
111
|
+
const dbUrls = dbPaths.map(p => path.relative(reportPath, p));
|
|
112
|
+
|
|
113
|
+
await fs.writeJson(mainDatabaseUrls, {
|
|
114
|
+
dbUrls,
|
|
115
|
+
jsonUrls: []
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
module.exports = {
|
|
120
|
+
...commonSqliteUtils,
|
|
121
|
+
downloadDatabases,
|
|
122
|
+
mergeDatabases,
|
|
123
|
+
getTestsTreeFromDatabase
|
|
124
|
+
};
|
package/lib/gui/index.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
const chalk = require('chalk');
|
|
4
4
|
const opener = require('opener');
|
|
5
5
|
const server = require('./server');
|
|
6
|
-
const {logger
|
|
6
|
+
const {logger} = require('../common-utils');
|
|
7
|
+
const {logError} = require('../server-utils');
|
|
7
8
|
|
|
8
9
|
module.exports = (args) => {
|
|
9
10
|
server.start(args)
|
package/lib/gui/server.js
CHANGED
|
@@ -9,7 +9,8 @@ const {INTERNAL_SERVER_ERROR, OK} = require('http-codes');
|
|
|
9
9
|
|
|
10
10
|
const App = require('./app');
|
|
11
11
|
const {MAX_REQUEST_SIZE, KEEP_ALIVE_TIMEOUT, HEADERS_TIMEOUT} = require('./constants/server');
|
|
12
|
-
const {
|
|
12
|
+
const {initializeCustomGui, runCustomGuiAction} = require('../server-utils');
|
|
13
|
+
const {logger} = require('../common-utils');
|
|
13
14
|
const initPluginsRoutes = require('./routes/plugins');
|
|
14
15
|
|
|
15
16
|
exports.start = async ({paths, hermione, guiApi, configs}) => {
|
|
@@ -11,12 +11,12 @@ const Runner = require('./runner');
|
|
|
11
11
|
const subscribeOnToolEvents = require('./report-subscriber');
|
|
12
12
|
const GuiReportBuilder = require('../../report-builder/gui');
|
|
13
13
|
const EventSource = require('../event-source');
|
|
14
|
-
const
|
|
14
|
+
const {logger} = require('../../common-utils');
|
|
15
15
|
const reporterHelper = require('../../reporter-helpers');
|
|
16
16
|
const {UPDATED} = require('../../constants/test-statuses');
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const {
|
|
17
|
+
const {DATABASE_URLS_JSON_NAME, LOCAL_DATABASE_NAME} = require('../../constants/database');
|
|
18
|
+
const {formatId, getShortMD5, mkFullTitle, mergeDatabasesForReuse, filterByEqualDiffSizes} = require('./utils');
|
|
19
|
+
const {getTestsTreeFromDatabase} = require('../../db-utils/server');
|
|
20
20
|
|
|
21
21
|
const lookSameAsync = (img1, img2, opts) => {
|
|
22
22
|
return new Promise((resolve, reject) => {
|
|
@@ -237,13 +237,13 @@ module.exports = class ToolRunner {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
async _loadDataFromDatabase() {
|
|
240
|
-
const dbPath = path.resolve(this._reportPath,
|
|
240
|
+
const dbPath = path.resolve(this._reportPath, LOCAL_DATABASE_NAME);
|
|
241
241
|
|
|
242
242
|
if (await fs.pathExists(dbPath)) {
|
|
243
|
-
return
|
|
243
|
+
return getTestsTreeFromDatabase(dbPath);
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
logger.warn(chalk.yellow(`Nothing to reuse in ${this._reportPath}: can not load data from ${
|
|
246
|
+
logger.warn(chalk.yellow(`Nothing to reuse in ${this._reportPath}: can not load data from ${DATABASE_URLS_JSON_NAME}`));
|
|
247
247
|
|
|
248
248
|
return {};
|
|
249
249
|
}
|
|
@@ -6,12 +6,10 @@ const fs = require('fs-extra');
|
|
|
6
6
|
const chalk = require('chalk');
|
|
7
7
|
const crypto = require('crypto');
|
|
8
8
|
const Database = require('better-sqlite3');
|
|
9
|
-
const NestedError = require('nested-error-stacks');
|
|
10
9
|
|
|
11
|
-
const
|
|
12
|
-
const {
|
|
13
|
-
const
|
|
14
|
-
const {mergeTables, selectAllSuitesQuery, compareDatabaseRowsByTimestamp} = require('../../common-utils');
|
|
10
|
+
const {logger} = require('../../common-utils');
|
|
11
|
+
const {DATABASE_URLS_JSON_NAME, LOCAL_DATABASE_NAME} = require('../../constants/database');
|
|
12
|
+
const {mergeTables} = require('../../db-utils/server');
|
|
15
13
|
|
|
16
14
|
exports.formatId = (hash, browserId) => `${hash}/${browserId}`;
|
|
17
15
|
|
|
@@ -28,8 +26,8 @@ exports.mkFullTitle = ({suite, state}) => {
|
|
|
28
26
|
// 'databaseUrls.json' may contain many databases urls but html-reporter at gui mode can work with single databases file.
|
|
29
27
|
// all databases should be local files.
|
|
30
28
|
exports.mergeDatabasesForReuse = async (reportPath) => {
|
|
31
|
-
const dbUrlsJsonPath = path.resolve(reportPath,
|
|
32
|
-
const mergedDbPath = path.resolve(reportPath,
|
|
29
|
+
const dbUrlsJsonPath = path.resolve(reportPath, DATABASE_URLS_JSON_NAME);
|
|
30
|
+
const mergedDbPath = path.resolve(reportPath, LOCAL_DATABASE_NAME);
|
|
33
31
|
|
|
34
32
|
if (!await fs.pathExists(dbUrlsJsonPath)) {
|
|
35
33
|
return;
|
|
@@ -38,14 +36,14 @@ exports.mergeDatabasesForReuse = async (reportPath) => {
|
|
|
38
36
|
const {dbUrls = []} = await fs.readJson(dbUrlsJsonPath);
|
|
39
37
|
|
|
40
38
|
const dbPaths = dbUrls
|
|
41
|
-
.filter(u => u !==
|
|
39
|
+
.filter(u => u !== LOCAL_DATABASE_NAME)
|
|
42
40
|
.map(u => path.resolve(reportPath, u));
|
|
43
41
|
|
|
44
42
|
if (!dbPaths.length) {
|
|
45
43
|
return;
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
logger.warn(chalk.yellow(`Merge databases to ${
|
|
46
|
+
logger.warn(chalk.yellow(`Merge databases to ${LOCAL_DATABASE_NAME}`));
|
|
49
47
|
|
|
50
48
|
const mergedDatabase = new Database(mergedDbPath);
|
|
51
49
|
mergeTables({db: mergedDatabase, dbPaths, getExistingTables: (statement) => {
|
|
@@ -56,22 +54,6 @@ exports.mergeDatabasesForReuse = async (reportPath) => {
|
|
|
56
54
|
await Promise.all(dbPaths.map(p => fs.remove(p)));
|
|
57
55
|
};
|
|
58
56
|
|
|
59
|
-
exports.getDataFromDatabase = (dbPath) => {
|
|
60
|
-
try {
|
|
61
|
-
const db = new Database(dbPath, {readonly: true, fileMustExist: true});
|
|
62
|
-
const testsTreeBuilder = StaticTestsTreeBuilder.create();
|
|
63
|
-
|
|
64
|
-
const suitesRows = db.prepare(selectAllSuitesQuery()).raw().all().sort(compareDatabaseRowsByTimestamp);
|
|
65
|
-
const {tree} = testsTreeBuilder.build(suitesRows);
|
|
66
|
-
|
|
67
|
-
db.close();
|
|
68
|
-
|
|
69
|
-
return tree;
|
|
70
|
-
} catch (err) {
|
|
71
|
-
throw new NestedError('Error while getting data from database ', err);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
57
|
exports.filterByEqualDiffSizes = (imagesInfo, refDiffClusters) => {
|
|
76
58
|
if (_.isEmpty(refDiffClusters)) {
|
|
77
59
|
return [];
|
package/lib/plugin-adapter.js
CHANGED
package/lib/plugin-api.js
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
const AsyncEmitter = require('gemini-core').events.AsyncEmitter;
|
|
4
4
|
const pluginEvents = require('./constants/plugin-events');
|
|
5
|
+
const {downloadDatabases, mergeDatabases, getTestsTreeFromDatabase} = require('./db-utils/server');
|
|
5
6
|
|
|
6
7
|
module.exports = class HtmlReporter extends AsyncEmitter {
|
|
7
|
-
static create() {
|
|
8
|
-
return new this();
|
|
8
|
+
static create(config) {
|
|
9
|
+
return new this(config);
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
constructor() {
|
|
12
|
+
constructor(config) {
|
|
12
13
|
super();
|
|
13
14
|
|
|
15
|
+
this._config = config;
|
|
14
16
|
this._values = {
|
|
15
17
|
extraItems: {},
|
|
16
18
|
metaInfoExtenders: {},
|
|
@@ -58,4 +60,16 @@ module.exports = class HtmlReporter extends AsyncEmitter {
|
|
|
58
60
|
get values() {
|
|
59
61
|
return this._values;
|
|
60
62
|
}
|
|
63
|
+
|
|
64
|
+
downloadDatabases(...args) {
|
|
65
|
+
return downloadDatabases(...args);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
mergeDatabases(...args) {
|
|
69
|
+
return mergeDatabases(...args);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
getTestsTreeFromDatabase(...args) {
|
|
73
|
+
return getTestsTreeFromDatabase(...args);
|
|
74
|
+
}
|
|
61
75
|
};
|
|
@@ -5,7 +5,7 @@ const path = require('path');
|
|
|
5
5
|
const fs = require('fs-extra');
|
|
6
6
|
|
|
7
7
|
const {IDLE, RUNNING, SKIPPED, FAIL, ERROR, SUCCESS} = require('../constants/test-statuses');
|
|
8
|
-
const {LOCAL_DATABASE_NAME} = require('../constants/
|
|
8
|
+
const {LOCAL_DATABASE_NAME} = require('../constants/database');
|
|
9
9
|
const SqliteAdapter = require('../sqlite-adapter');
|
|
10
10
|
const TestAdapter = require('../test-adapter');
|
|
11
11
|
const {hasNoRefImageErrors} = require('../static/modules/utils');
|
package/lib/server-utils.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const url = require('url');
|
|
5
|
-
|
|
6
5
|
const chalk = require('chalk');
|
|
7
6
|
const _ = require('lodash');
|
|
8
7
|
const fs = require('fs-extra');
|
|
9
8
|
|
|
9
|
+
const {logger} = require('./common-utils');
|
|
10
10
|
const {ERROR, UPDATED, RUNNING, IDLE, SKIPPED} = require('./constants/test-statuses');
|
|
11
11
|
const {IMAGES_PATH} = require('./constants/paths');
|
|
12
12
|
const DATA_FILE_NAME = 'data.js';
|
|
@@ -59,8 +59,6 @@ function makeDirFor(destPath) {
|
|
|
59
59
|
return fs.mkdirs(path.dirname(destPath));
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const logger = _.pick(console, ['log', 'warn', 'error']);
|
|
63
|
-
|
|
64
62
|
function logPathToHtmlReport(pluginConfig) {
|
|
65
63
|
const reportPath = `file://${path.resolve(pluginConfig.path, 'index.html')}`;
|
|
66
64
|
|
|
@@ -272,7 +270,6 @@ module.exports = {
|
|
|
272
270
|
copyFileAsync,
|
|
273
271
|
makeDirFor,
|
|
274
272
|
|
|
275
|
-
logger,
|
|
276
273
|
logPathToHtmlReport,
|
|
277
274
|
logError,
|
|
278
275
|
|
package/lib/sqlite-adapter.js
CHANGED
|
@@ -6,9 +6,8 @@ const Database = require('better-sqlite3');
|
|
|
6
6
|
const NestedError = require('nested-error-stacks');
|
|
7
7
|
const debug = require('debug')('html-reporter:sqlite-adapter');
|
|
8
8
|
|
|
9
|
-
const {createTablesQuery
|
|
10
|
-
const {LOCAL_DATABASE_NAME, DATABASE_URLS_JSON_NAME} = require('./constants/
|
|
11
|
-
const {DB_SUITES_TABLE_NAME} = require('./constants/database');
|
|
9
|
+
const {createTablesQuery} = require('./db-utils/server');
|
|
10
|
+
const {DB_SUITES_TABLE_NAME, SUITES_TABLE_COLUMNS, LOCAL_DATABASE_NAME, DATABASE_URLS_JSON_NAME} = require('./constants/database');
|
|
12
11
|
|
|
13
12
|
module.exports = class SqliteAdapter {
|
|
14
13
|
static create(...args) {
|
|
@@ -95,7 +94,7 @@ module.exports = class SqliteAdapter {
|
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
_createValuesArray(testResult) {
|
|
98
|
-
return
|
|
97
|
+
return SUITES_TABLE_COLUMNS.reduce((acc, {name}) => {
|
|
99
98
|
const value = testResult[name];
|
|
100
99
|
if (value === undefined || value === null) {
|
|
101
100
|
acc.push(null);
|
|
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import {map, mapValues, isObject, omitBy, isEmpty} from 'lodash';
|
|
7
7
|
import * as actions from '../../../modules/actions';
|
|
8
8
|
import Details from '../../details';
|
|
9
|
-
import {isUrl} from '
|
|
9
|
+
import {isUrl} from '../../../../common-utils';
|
|
10
10
|
|
|
11
11
|
const mkLinkToUrl = (url, text = url) => {
|
|
12
12
|
return <a data-suite-view-link={url} className="section__icon_view-local" target="_blank" href={url}>{text}</a>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import React, {Component, Fragment} from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import DiffCircle from './diff-circle';
|
|
6
|
-
import {isUrl} from '
|
|
6
|
+
import {isUrl} from '../../../common-utils';
|
|
7
7
|
|
|
8
8
|
export default class Screenshot extends Component {
|
|
9
9
|
constructor(props) {
|