html-reporter 7.3.0 → 7.6.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,9 +3,11 @@
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',
10
+ STOP_TESTS: 'STOP_TESTS',
9
11
  RETRY_SUITE: 'RETRY_SUITE',
10
12
  RETRY_TEST: 'RETRY_TEST',
11
13
  SUITE_BEGIN: 'SUITE_BEGIN',
@@ -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 = {}} = {}) => {
@@ -134,6 +139,15 @@ export const acceptTest = (imageId) => {
134
139
  return acceptOpened([imageId], actionNames.ACCEPT_SCREENSHOT);
135
140
  };
136
141
 
142
+ export const stopTests = () => async dispatch => {
143
+ try {
144
+ await axios.post('/stop');
145
+ dispatch({type: actionNames.STOP_TESTS});
146
+ } catch (e) {
147
+ console.error(`Error while stopping tests: {e}`);
148
+ }
149
+ };
150
+
137
151
  export const suiteBegin = (suite) => ({type: actionNames.SUITE_BEGIN, payload: suite});
138
152
  export const testBegin = (test) => ({type: actionNames.TEST_BEGIN, payload: test});
139
153
  export const testResult = (result) => ({type: actionNames.TEST_RESULT, payload: result});
@@ -8,6 +8,7 @@ export default Object.assign(defaults, {
8
8
  gui: true,
9
9
  running: false,
10
10
  processing: false,
11
+ stopping: false,
11
12
  autoRun: false,
12
13
  skips: [],
13
14
  browsers: [],
@@ -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;
@@ -22,6 +22,7 @@ import skips from './skips';
22
22
  import view from './view';
23
23
  import plugins from './plugins';
24
24
  import groupedErrors from './grouped-errors';
25
+ import stopping from './stopping';
25
26
 
26
27
  // The order of specifying reducers is important.
27
28
  // At the top specify reducers that does not depend on other state fields.
@@ -31,6 +32,7 @@ export default reduceReducers(
31
32
  notifications,
32
33
  running,
33
34
  processing,
35
+ stopping,
34
36
  loading,
35
37
  gui,
36
38
  date,
@@ -0,0 +1,16 @@
1
+ import actionNames from '../action-names';
2
+
3
+ export default (state = {}, action) => {
4
+ switch (action.type) {
5
+ case actionNames.STOP_TESTS: {
6
+ return {...state, stopping: true};
7
+ }
8
+
9
+ case actionNames.TESTS_END: {
10
+ return {...state, stopping: false};
11
+ }
12
+
13
+ default:
14
+ return state;
15
+ }
16
+ };
@@ -61,10 +61,7 @@ export function calcSuitesShowness(tree, suiteIds) {
61
61
  });
62
62
 
63
63
  const changeParentSuiteCb = (parentSuite) => {
64
- const shouldBeShown = parentSuite.suiteIds
65
- .some((suiteId) => tree.suites.stateById[suiteId].shouldBeShown);
66
-
67
- changeSuiteState(tree, parentSuite.id, {shouldBeShown});
64
+ changeSuiteState(tree, parentSuite.id, {shouldBeShown: shouldSuiteBeShown(parentSuite, tree)});
68
65
  };
69
66
 
70
67
  calcParentSuitesState(youngestSuites, tree, changeParentSuiteCb);
@@ -96,10 +93,7 @@ export function calcSuitesOpenness(tree, expand, suiteIds) {
96
93
  });
97
94
 
98
95
  const changeParentSuiteCb = (parentSuite) => {
99
- const shouldBeOpened = parentSuite.suiteIds
100
- .some((suiteId) => tree.suites.stateById[suiteId].shouldBeOpened);
101
-
102
- changeSuiteState(tree, parentSuite.id, {shouldBeOpened});
96
+ changeSuiteState(tree, parentSuite.id, {shouldBeOpened: shouldSuiteBeOpened(parentSuite, tree)});
103
97
  };
104
98
 
105
99
  calcParentSuitesState(youngestSuites, tree, changeParentSuiteCb);
@@ -142,7 +136,10 @@ function sortSuitesByNesting(suites) {
142
136
 
143
137
  function getYoungestSuites(tree) {
144
138
  return tree.suites.allIds
145
- .filter((suiteId) => !_.isEmpty(tree.suites.byId[suiteId].browserIds))
139
+ .filter((suiteId) => {
140
+ const suite = tree.suites.byId[suiteId];
141
+ return _.isEmpty(suite.suiteIds) && !_.isEmpty(suite.browserIds);
142
+ })
146
143
  .map((suiteId) => tree.suites.byId[suiteId]);
147
144
  }
148
145
 
@@ -158,6 +155,19 @@ function calcSuiteOpenness(suite, expand, tree) {
158
155
  return shouldNodeBeOpened(expand, {errorsCb, retriesCb});
159
156
  }
160
157
 
158
+ function shouldSuiteBeShown(suite, tree) {
159
+ return shouldSuiteBe(suite, tree, 'shouldBeShown');
160
+ }
161
+
162
+ function shouldSuiteBeOpened(suite, tree) {
163
+ return shouldSuiteBe(suite, tree, 'shouldBeOpened');
164
+ }
165
+
166
+ function shouldSuiteBe(suite, tree, field) {
167
+ return (suite.suiteIds || []).some((suiteId) => tree.suites.stateById[suiteId][field])
168
+ || (suite.browserIds || []).some((browserId) => tree.browsers.stateById[browserId][field]);
169
+ }
170
+
161
171
  function updateParentSuitesStatus(tree, suitesIds = [], filteredBrowsers) {
162
172
  if (!suitesIds || !suitesIds.length) {
163
173
  return;
@@ -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
  };