html-reporter 7.3.1 → 7.4.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.
@@ -3,6 +3,7 @@
3
3
  export default {
4
4
  INIT_GUI_REPORT: 'INIT_GUI_REPORT',
5
5
  INIT_STATIC_REPORT: 'INIT_STATIC_REPORT',
6
+ FIN_GUI_REPORT: 'FIN_GUI_REPORT',
6
7
  FIN_STATIC_REPORT: 'FIN_STATIC_REPORT',
7
8
  RUN_ALL_TESTS: 'RUN_ALL_TESTS',
8
9
  RUN_FAILED_TESTS: 'RUN_FAILED_TESTS',
@@ -5,8 +5,9 @@ import StaticTestsTreeBuilder from '../../tests-tree-builder/static';
5
5
  import actionNames from './action-names';
6
6
  import {types as modalTypes} from '../components/modals';
7
7
  import {QUEUED} from '../../constants/test-statuses';
8
+ import {LOCAL_DATABASE_NAME} from '../../constants/file-names';
8
9
  import {getHttpErrorMessage} from './utils';
9
- import {fetchDatabases, mergeDatabases} from './sqlite';
10
+ import {fetchDatabases, mergeDatabases, connectToDatabase} from './sqlite';
10
11
  import {getSuitesTableRows} from './database-utils';
11
12
  import {setFilteredBrowsers} from './query-params';
12
13
  import plugins from './plugins';
@@ -22,11 +23,14 @@ export const initGuiReport = () => {
22
23
  try {
23
24
  const appState = await axios.get('/init');
24
25
 
26
+ const mainDatabaseUrl = new URL(LOCAL_DATABASE_NAME, window.location.href);
27
+ const db = await connectToDatabase(mainDatabaseUrl.href);
28
+
25
29
  await plugins.loadAll(appState.data.config);
26
30
 
27
31
  dispatch({
28
32
  type: actionNames.INIT_GUI_REPORT,
29
- payload: appState.data
33
+ payload: {...appState.data, db}
30
34
  });
31
35
 
32
36
  const {customGuiError} = appState.data;
@@ -80,6 +84,7 @@ export const initStaticReport = () => {
80
84
  };
81
85
  };
82
86
 
87
+ export const finGuiReport = () => ({type: actionNames.FIN_GUI_REPORT});
83
88
  export const finStaticReport = () => ({type: actionNames.FIN_STATIC_REPORT});
84
89
 
85
90
  const runTests = ({tests = [], action = {}} = {}) => {
@@ -3,12 +3,14 @@ import actionNames from '../action-names';
3
3
 
4
4
  export default (state, action) => {
5
5
  switch (action.type) {
6
- case actionNames.INIT_STATIC_REPORT: {
6
+ case actionNames.INIT_STATIC_REPORT:
7
+ case actionNames.INIT_GUI_REPORT: {
7
8
  const {db} = action.payload;
8
9
  return {...state, db};
9
10
  }
10
11
 
11
- case actionNames.FIN_STATIC_REPORT: {
12
+ case actionNames.FIN_STATIC_REPORT:
13
+ case actionNames.FIN_GUI_REPORT: {
12
14
  closeDatabase(state.db);
13
15
 
14
16
  return state;
@@ -2,7 +2,7 @@
2
2
 
3
3
  import axios from 'axios';
4
4
  import {flattenDeep} from 'lodash';
5
- import {mergeTablesQueries} from '../../common-utils';
5
+ import {mergeTables} from '../../common-utils';
6
6
 
7
7
  function isRelativeUrl(url) {
8
8
  try {
@@ -114,28 +114,33 @@ async function mergeDatabases(dataForDbs) {
114
114
  const mergedDbConnection = new SQL.Database(undefined, sumOfChunkSizes);
115
115
  const dbPaths = connections.map(db => db.filename);
116
116
 
117
- for (const query of mergeTablesQueries(dbPaths)) {
118
- try {
119
- mergedDbConnection.run(query);
120
- } catch (err) {
121
- // TODO: To be able to work with files that have been created before
122
- // TODO: Remove in next versions
123
- if (/no such table/.test(err)) {
124
- console.warn(err);
125
-
126
- continue;
127
- }
117
+ mergeTables({db: mergedDbConnection, dbPaths, getExistingTables: (statement) => {
118
+ const tables = [];
128
119
 
129
- throw err;
120
+ while (statement.step()) {
121
+ tables.push(...statement.get());
130
122
  }
131
- }
123
+
124
+ return tables;
125
+ }});
132
126
 
133
127
  connections.forEach(db => db.close());
134
128
 
135
129
  return mergedDbConnection;
136
130
  }
137
131
 
132
+ async function connectToDatabase(dbUrl) {
133
+ const mainDatabaseUrl = new URL(dbUrl);
134
+ const {data} = await fetchFile(mainDatabaseUrl.href, {
135
+ responseType: 'arraybuffer'
136
+ });
137
+
138
+ const SQL = await window.initSqlJs();
139
+ return new SQL.Database(new Uint8Array(data));
140
+ }
141
+
138
142
  module.exports = {
139
143
  fetchDatabases,
140
- mergeDatabases
144
+ mergeDatabases,
145
+ connectToDatabase
141
146
  };