html-reporter 8.4.1 → 8.4.4

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 CHANGED
@@ -2,6 +2,35 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ <a name="8.4.4"></a>
6
+ ## [8.4.4](https://github.com/gemini-testing/html-reporter/compare/v8.4.3...v8.4.4) (2022-04-29)
7
+
8
+
9
+
10
+ <a name="8.4.3"></a>
11
+ ## [8.4.3](https://github.com/gemini-testing/html-reporter/compare/v8.4.2...v8.4.3) (2022-04-26)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * **state:** hide control buttons ([0b7c79f](https://github.com/gemini-testing/html-reporter/commit/0b7c79f))
17
+ * **state-error:** hide error info for "AssertViewError" ([0711226](https://github.com/gemini-testing/html-reporter/commit/0711226))
18
+ * **static:** fix error when accept the screenshot ([06cfc61](https://github.com/gemini-testing/html-reporter/commit/06cfc61))
19
+
20
+
21
+
22
+ <a name="8.4.2"></a>
23
+ ## [8.4.2](https://github.com/gemini-testing/html-reporter/compare/v8.4.1...v8.4.2) (2022-03-31)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * **remove-unused-screens:** check if screens exist in fs ([edca7a2](https://github.com/gemini-testing/html-reporter/commit/edca7a2))
29
+ * **remove-unused-screens:** read tests silently ([a252bf3](https://github.com/gemini-testing/html-reporter/commit/a252bf3))
30
+ * **remove-unused-screens:** show user correct number of uniq tests read ([1024e58](https://github.com/gemini-testing/html-reporter/commit/1024e58))
31
+
32
+
33
+
5
34
  <a name="8.4.1"></a>
6
35
  ## [8.4.1](https://github.com/gemini-testing/html-reporter/compare/v8.4.0...v8.4.1) (2022-03-22)
7
36
 
package/hermione.js CHANGED
@@ -39,7 +39,7 @@ async function prepare(hermione, reportBuilder, pluginConfig) {
39
39
  }
40
40
 
41
41
  if (formattedResult.screenshot) {
42
- actions.push(formattedResult.saveBase64Screenshot(reportPath));
42
+ actions.push(formattedResult.saveErrorScreenshot(reportPath));
43
43
  }
44
44
 
45
45
  await Promise.all(actions);
@@ -13,6 +13,20 @@ const {getTestsFromFs, findScreens, askQuestion, identifyOutdatedScreens, identi
13
13
  const {DATABASE_URLS_JSON_NAME, LOCAL_DATABASE_NAME} = require('../../constants/database');
14
14
  const {logger} = require('../../common-utils');
15
15
 
16
+ // TODO: remove hack after add ability to add controllers from plugin in silent mode
17
+ function proxyHermione() {
18
+ const proxyHandler = {
19
+ get(target, prop) {
20
+ return prop in target ? target[prop] : new Proxy(() => {}, this);
21
+ },
22
+ apply() {
23
+ return new Proxy(() => {}, this);
24
+ }
25
+ };
26
+
27
+ global.hermione = new Proxy(global.hermione || {}, proxyHandler);
28
+ }
29
+
16
30
  module.exports = (program, pluginConfig, hermione) => {
17
31
  program
18
32
  .command(commandName)
@@ -22,6 +36,8 @@ module.exports = (program, pluginConfig, hermione) => {
22
36
  .on('--help', () => logger.log(getHelpMessage()))
23
37
  .action(async (options) => {
24
38
  try {
39
+ proxyHermione();
40
+
25
41
  const {pattern: userPatterns} = options;
26
42
 
27
43
  if (_.isEmpty(userPatterns)) {
@@ -35,7 +51,7 @@ module.exports = (program, pluginConfig, hermione) => {
35
51
  const fsTests = await getTestsFromFs(hermione);
36
52
  spinner.succeed();
37
53
 
38
- logger.log(`${chalk.green(Object.keys(fsTests.byId).length)} tests were read`);
54
+ logger.log(`${chalk.green(fsTests.count)} uniq tests were read in browsers: ${[...fsTests.browserIds].join(', ')}`);
39
55
 
40
56
  spinner.start(`Searching reference images on the file system by specified patterns:\n${userScreenPatterns.join('\n')}`);
41
57
  const foundScreenPaths = await findScreens(userScreenPatterns);
@@ -117,19 +133,38 @@ async function handleUnusedScreens(screenPaths, fsTests, opts = {}) {
117
133
  }
118
134
 
119
135
  async function handleScreens(allScreenPaths, screensToRemove, {spinner, cliOpts} = {}) {
120
- const screenPathsToRemoveLen = screensToRemove.paths.length;
136
+ const existentScreenPaths = await Promise.filter(screensToRemove.paths, async screenPath => {
137
+ try {
138
+ await fs.access(screenPath);
139
+ return true;
140
+ } catch (err) {
141
+ if (err.code === 'ENOENT') {
142
+ logger.warn(
143
+ chalk.red(
144
+ `Screen by path: "${screenPath}" is not found in your file system. ` +
145
+ 'Try to rebase your branch or download more recent report from CI.',
146
+ ),
147
+ );
148
+ return false;
149
+ }
150
+
151
+ throw err;
152
+ }
153
+ });
154
+
155
+ const screenPathsToRemoveLen = existentScreenPaths.length;
121
156
 
122
157
  logger.log(
123
158
  `Found ${chalk[screenPathsToRemoveLen > 0 ? 'red' : 'green'](screenPathsToRemoveLen)} ` +
124
159
  `${screensToRemove.type} reference images out of ${chalk.bold(allScreenPaths.length)}`
125
160
  );
126
161
 
127
- if (_.isEmpty(screensToRemove.paths)) {
162
+ if (_.isEmpty(existentScreenPaths)) {
128
163
  return;
129
164
  }
130
165
 
131
166
  spinner.start(`Calculating total size of ${screensToRemove.type} reference images`);
132
- const bytes = (await Promise.map(screensToRemove.paths, (screenPath) => fs.stat(screenPath))).reduce((acc, {size}) => acc + size, 0);
167
+ const bytes = (await Promise.map(existentScreenPaths, (screenPath) => fs.stat(screenPath))).reduce((acc, {size}) => acc + size, 0);
133
168
  spinner.succeed();
134
169
 
135
170
  logger.log(`Total size of ${screensToRemove.type} reference images = ${chalk.red(filesize(bytes))}`);
@@ -142,7 +177,7 @@ async function handleScreens(allScreenPaths, screensToRemove, {spinner, cliOpts}
142
177
  }, cliOpts);
143
178
 
144
179
  if (shouldShowList) {
145
- logger.log(`List of ${screensToRemove.type} reference images:\n${screensToRemove.paths.map((p) => chalk.red(p)).join('\n')}`);
180
+ logger.log(`List of ${screensToRemove.type} reference images:\n${existentScreenPaths.map((p) => chalk.red(p)).join('\n')}`);
146
181
  }
147
182
 
148
183
  const shouldRemove = await askQuestion({
@@ -157,7 +192,7 @@ async function handleScreens(allScreenPaths, screensToRemove, {spinner, cliOpts}
157
192
  }
158
193
 
159
194
  spinner.start(`Removing ${screensToRemove.type} reference images`);
160
- await removeScreens(screensToRemove.paths);
195
+ await removeScreens(existentScreenPaths);
161
196
  spinner.succeed();
162
197
 
163
198
  logger.log(`${chalk.green(screenPathsToRemoveLen)} reference images were removed`);
@@ -10,26 +10,34 @@ const inquirer = require('inquirer');
10
10
  const {SUCCESS} = require('../../constants/test-statuses');
11
11
 
12
12
  exports.getTestsFromFs = async (hermione) => {
13
- const testsTree = {
13
+ const tests = {
14
14
  byId: {},
15
- screenPatterns: []
15
+ screenPatterns: [],
16
+ count: 0,
17
+ browserIds: new Set()
16
18
  };
19
+ const uniqTests = new Set();
17
20
 
18
- const testCollection = await hermione.readTests();
21
+ const testCollection = await hermione.readTests([], {silent: true});
19
22
 
20
23
  testCollection.eachTest((test, browserId) => {
21
- const id = `${test.fullTitle()} ${browserId}`;
24
+ const fullTitle = test.fullTitle();
25
+ const id = `${fullTitle} ${browserId}`;
22
26
  const screenPattern = hermione.config.browsers[browserId].getScreenshotPath(test, '*');
23
27
 
24
- testsTree.byId[id] = {screenPattern, ...test};
28
+ tests.byId[id] = {screenPattern, ...test};
29
+ tests.browserIds.add(browserId);
30
+ uniqTests.add(fullTitle);
25
31
  });
26
32
 
27
- for (const test of Object.values(testsTree.byId)) {
33
+ tests.count = uniqTests.size;
34
+
35
+ for (const test of Object.values(tests.byId)) {
28
36
  test.screenPaths = (await fg(test.screenPattern)) || [];
29
- testsTree.screenPatterns.push(test.screenPattern);
37
+ tests.screenPatterns.push(test.screenPattern);
30
38
  }
31
39
 
32
- return testsTree;
40
+ return tests;
33
41
  };
34
42
 
35
43
  exports.findScreens = async (screenPatterns) => {
@@ -17,7 +17,7 @@ module.exports = (hermione, reportBuilder, client, reportPath) => {
17
17
  const actions = [formattedResult.saveTestImages(reportPath, workers)];
18
18
 
19
19
  if (formattedResult.screenshot) {
20
- actions.push(formattedResult.saveBase64Screenshot(reportPath));
20
+ actions.push(formattedResult.saveErrorScreenshot(reportPath));
21
21
  }
22
22
 
23
23
  if (formattedResult.errorDetails) {
@@ -70,6 +70,10 @@ class State extends Component {
70
70
  const isAcceptDisabled = !isAcceptable(node);
71
71
  const isFindSameDiffDisabled = !isFailStatus(node.status);
72
72
 
73
+ if (isAcceptDisabled && isFindSameDiffDisabled && isScreenshotAccepterDisabled) {
74
+ return null;
75
+ }
76
+
73
77
  return (
74
78
  <div className="state-controls">
75
79
  <ControlButton
@@ -8,7 +8,7 @@ import {isEmpty, map, isFunction} from 'lodash';
8
8
  import ReactHtmlParser from 'react-html-parser';
9
9
  import * as actions from '../../modules/actions';
10
10
  import Screenshot from './screenshot';
11
- import {isNoRefImageError} from '../../modules/utils';
11
+ import {isNoRefImageError, isAssertViewError} from '../../modules/utils';
12
12
  import ErrorDetails from './error-details';
13
13
  import Details from '../details';
14
14
  import {ERROR_TITLE_TEXT_LENGTH} from '../../../constants/errors';
@@ -94,6 +94,10 @@ class StateError extends Component {
94
94
  });
95
95
  }
96
96
 
97
+ _shouldDrawErrorInfo(error) {
98
+ return !isAssertViewError(error);
99
+ }
100
+
97
101
  render() {
98
102
  const {error, errorDetails} = this.props;
99
103
  const errorPattern = this._getErrorPattern();
@@ -104,7 +108,7 @@ class StateError extends Component {
104
108
 
105
109
  return (
106
110
  <div className="image-box__image image-box__image_single">
107
- <div className="error">{this._errorToElements(extendedError)}</div>
111
+ {this._shouldDrawErrorInfo(extendedError) && <div className="error">{this._errorToElements(extendedError)}</div>}
108
112
  {errorDetails && <ErrorDetails errorDetails={errorDetails} />}
109
113
  {this._drawImage()}
110
114
  </div>