@brightspace-ui/testing 1.20.0 → 1.21.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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@brightspace-ui/testing",
3
3
  "description": "Utilities for testing front-end components and applications",
4
4
  "type": "module",
5
- "version": "1.20.0",
5
+ "version": "1.21.0",
6
6
  "repository": "https://github.com/BrightspaceUI/testing.git",
7
7
  "scripts": {
8
8
  "lint": "npm run lint:eslint && npm run lint:style",
@@ -121,7 +121,7 @@ class App extends LitElement {
121
121
  constructor() {
122
122
  super();
123
123
  this._filterBrowsers = data.browsers.map(b => b.name);
124
- this._filterStatus = data.numFailed > 0 ? FILTER_STATUS.FAILED : FILTER_STATUS.ALL;
124
+ this._filterStatus = data.numFailed > 0 ? FILTER_STATUS.FAILED : (data.numByteDiff > 0 ? FILTER_STATUS.BYTEDIFF : FILTER_STATUS.ALL);
125
125
  this._fullMode = FULL_MODE.GOLDEN.value;
126
126
  this._layout = LAYOUTS.SPLIT.value;
127
127
  this._overlay = true;
@@ -146,7 +146,10 @@ class App extends LitElement {
146
146
  }
147
147
  if (searchParams.has('status')) {
148
148
  let filterStatus = searchParams.get('status');
149
- if (filterStatus === FILTER_STATUS.FAILED && data.numFailed === 0) filterStatus = FILTER_STATUS.ALL;
149
+ if (filterStatus === FILTER_STATUS.FAILED && data.numFailed === 0 ||
150
+ filterStatus === FILTER_STATUS.BYTEDIFF && data.numByteDiff === 0) {
151
+ filterStatus = FILTER_STATUS.ALL;
152
+ }
150
153
  this._filterStatus = filterStatus;
151
154
  }
152
155
  if (searchParams.has('browsers')) {
@@ -198,7 +201,8 @@ class App extends LitElement {
198
201
 
199
202
  const statusFilters = [
200
203
  { name: FILTER_STATUS.FAILED, count: data.numFailed },
201
- { name: FILTER_STATUS.PASSED, count: data.numTests - data.numFailed },
204
+ { name: FILTER_STATUS.BYTEDIFF, count: data.numByteDiff },
205
+ { name: FILTER_STATUS.PASSED, count: data.numTests - data.numFailed - data.numByteDiff },
202
206
  { name: FILTER_STATUS.ALL, count: data.numTests }
203
207
  ];
204
208
 
@@ -434,7 +438,8 @@ class App extends LitElement {
434
438
  if (this._filterBrowsers.includes(r.name) &&
435
439
  (this._filterStatus === FILTER_STATUS.ALL ||
436
440
  r.passed && this._filterStatus === FILTER_STATUS.PASSED ||
437
- !r.passed && this._filterStatus === FILTER_STATUS.FAILED)) numStatusMatch++;
441
+ r.bytediff && this._filterStatus === FILTER_STATUS.BYTEDIFF ||
442
+ !r.bytediff && !r.passed && this._filterStatus === FILTER_STATUS.FAILED)) numStatusMatch++;
438
443
  });
439
444
  if (numStatusMatch > 0) {
440
445
  if (lookingForNextTest) {
@@ -77,7 +77,8 @@ export const COMMON_STYLE = css`
77
77
  export const FILTER_STATUS = {
78
78
  ALL: 'All',
79
79
  PASSED: 'Passed',
80
- FAILED: 'Failed'
80
+ FAILED: 'Failed',
81
+ BYTEDIFF: 'Byte Diff'
81
82
  };
82
83
 
83
84
  export const FULL_MODE = {
@@ -175,7 +175,7 @@ function renderResult(resultData, options) {
175
175
  let newPart;
176
176
  if (resultData.passed) {
177
177
  newPart = html`<div class="result-graphic padding">${ICON_TADA}<p>Hooray! No changes here.</p></div>`;
178
- } else if (!resultData.info.diff && resultData.info.pixelsDiff === 0) {
178
+ } else if (resultData.bytediff) {
179
179
  newPart = html`<div class="result-graphic padding">${ICON_BYTES}
180
180
  <p>No pixels have changed, but the bytes are different.</p>
181
181
  <p class="details">
@@ -27,6 +27,7 @@ function createData(rootDir, updateGoldens, sessions) {
27
27
  const prevBrowser = metadata.browsers?.find(b => b.name === browserName);
28
28
  browsers.set(browserName, {
29
29
  name: browserName,
30
+ numByteDiff: 0,
30
31
  numFailed: 0,
31
32
  version: parseInt(s.browser.browser.version()),
32
33
  previousVersion: prevBrowser?.version
@@ -36,14 +37,14 @@ function createData(rootDir, updateGoldens, sessions) {
36
37
 
37
38
  const fileName = s.testFile.substring(rootDir.length + 1);
38
39
  if (!files.has(fileName)) {
39
- files.set(fileName, { name: fileName, numFailed: 0, tests: new Map() });
40
+ files.set(fileName, { name: fileName, numByteDiff: 0, numFailed: 0, tests: new Map() });
40
41
  }
41
42
  const fileData = files.get(fileName);
42
43
  flattenResults(s, browserData, fileData);
43
44
 
44
45
  });
45
46
 
46
- let numTests = 0, numFailed = 0;
47
+ let numTests = 0, numFailed = 0, numByteDiff = 0;
47
48
  files.forEach(f => {
48
49
  numTests += f.tests.size;
49
50
  f.tests.forEach(t => {
@@ -51,6 +52,10 @@ function createData(rootDir, updateGoldens, sessions) {
51
52
  f.numFailed++;
52
53
  numFailed++;
53
54
  }
55
+ if (t.numByteDiff > 0) {
56
+ f.numByteDiff++;
57
+ numByteDiff++;
58
+ }
54
59
  });
55
60
  });
56
61
 
@@ -61,7 +66,7 @@ function createData(rootDir, updateGoldens, sessions) {
61
66
  writeFileSync(metadataPath, `${JSON.stringify(metadata, undefined, '\t')}\n`);
62
67
  }
63
68
 
64
- return { browsers, files, numFailed, numTests };
69
+ return { browsers, files, numByteDiff, numFailed, numTests };
65
70
 
66
71
  }
67
72
 
@@ -79,20 +84,28 @@ function flattenResults(session, browserData, fileData) {
79
84
  if (!fileData.tests.has(testName)) {
80
85
  fileData.tests.set(testName, {
81
86
  name: testName,
87
+ numByteDiff: 0,
82
88
  numFailed: 0,
83
89
  results: []
84
90
  });
85
91
  }
86
92
  const testData = fileData.tests.get(testName);
93
+ const bytediff = !t.passed && !info.diff && info.pixelsDiff === 0;
87
94
  if (!t.passed) {
88
- browserData.numFailed++;
89
- testData.numFailed++;
95
+ if (bytediff) {
96
+ browserData.numByteDiff++;
97
+ testData.numByteDiff++;
98
+ } else {
99
+ browserData.numFailed++;
100
+ testData.numFailed++;
101
+ }
90
102
  }
91
103
  testData.results.push({
92
104
  name: browserData.name,
93
105
  duration: t.duration,
94
106
  error: t.error?.message,
95
107
  passed: t.passed,
108
+ bytediff,
96
109
  info: info
97
110
  });
98
111
  });