@brightspace-ui/testing 1.39.0 → 1.39.2

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.39.0",
5
+ "version": "1.39.2",
6
6
  "repository": "https://github.com/BrightspaceUI/testing.git",
7
7
  "scripts": {
8
8
  "lint": "npm run lint:eslint && npm run lint:style",
@@ -234,9 +234,9 @@ export function renderBrowserResults(browser, tests, options) {
234
234
  let status = STATUS_TYPE.NORMAL;
235
235
  if (resultData.info) {
236
236
  status = STATUS_TYPE.WARNING;
237
- if (resultData.duration > resultData.info.slowDuration) {
237
+ if (resultData.duration > resultData.slowDuration) {
238
238
  status = STATUS_TYPE.ERROR;
239
- } else if (resultData.duration < (resultData.info.slowDuration / 2)) {
239
+ } else if (resultData.duration < (resultData.slowDuration / 2)) {
240
240
  status = STATUS_TYPE.NORMAL;
241
241
  }
242
242
  }
@@ -1,28 +1,28 @@
1
1
  const testInfoMap = new Map();
2
2
 
3
3
  export class TestInfoManager {
4
- constructor(session, fullTitle) {
4
+ constructor(session, fullTitle, slowDuration) {
5
5
  this.key = `${session.browser.name.toLowerCase()}|${session.testFile}|${fullTitle}`;
6
+ if (!testInfoMap.has(this.key)) testInfoMap.set(this.key, { slowDuration, tests: {} });
6
7
  }
7
8
  get() {
8
9
  return testInfoMap.get(this.key);
9
10
  }
10
11
 
11
12
  set(testInfo, alt = 'default') {
12
- if (testInfoMap.has(this.key)) {
13
- const info = this.get()?.[alt] || {};
14
- testInfo.slowDuration = info.slowDuration;
13
+ const tests = this.get().tests;
15
14
 
16
- if (info.golden || testInfo.golden) {
17
- testInfo.golden = { ...info.golden, ...testInfo.golden };
15
+ if (!(alt in tests)) {
16
+ tests[alt] = testInfo;
17
+ } else {
18
+ const info = tests[alt];
19
+ for (const prop in testInfo) {
20
+ if ((prop === 'golden' || prop === 'new') && prop in info) {
21
+ info[prop] = { ...info[prop], ...testInfo[prop] };
22
+ }
23
+ else info[prop] = testInfo[prop];
18
24
  }
19
- if (info.new || testInfo.new) {
20
- testInfo.new = { ...info.new, ...testInfo.new };
21
- }
22
- testInfo.diff = testInfo.diff || info.diff;
23
25
  }
24
- const tests = testInfoMap.get(this.key) || {};
25
- testInfoMap.set(this.key, { ...tests, [alt]: testInfo });
26
26
  }
27
27
  }
28
28
 
@@ -185,7 +185,7 @@ export function visualDiff({ updateGoldens = false, runSubset = false } = {}) {
185
185
  await clearAllDirs(updateGoldens, join(rootDir, PATHS.VDIFF_ROOT));
186
186
  },
187
187
  async executeCommand({ command, payload, session }) {
188
- const infoManager = new TestInfoManager(session, payload.name);
188
+ const infoManager = new TestInfoManager(session, payload.name, payload.slowDuration);
189
189
 
190
190
  if (session.browser.type !== 'playwright') {
191
191
  throw new Error('Visual-diff is only supported for browser type Playwright.');
@@ -249,7 +249,6 @@ export function visualDiff({ updateGoldens = false, runSubset = false } = {}) {
249
249
 
250
250
  const screenshotImage = PNG.sync.read(screenshotFileBuffers[alt]);
251
251
  infoManager.set({
252
- slowDuration: payload.slowDuration,
253
252
  new: {
254
253
  height: screenshotImage.height,
255
254
  path: screenshotFileName.substring(rootLength),
@@ -303,7 +302,8 @@ export function visualDiff({ updateGoldens = false, runSubset = false } = {}) {
303
302
  new: {
304
303
  byteSize: screenshotSize
305
304
  },
306
- pixelsDiff
305
+ pixelsDiff,
306
+ byteSizeDiff: true
307
307
  }, alt);
308
308
  return { pass: false, message: 'Image diff is clean but the images do not have the same bytes.' };
309
309
  }
@@ -92,8 +92,8 @@ function flattenResults(session, browserData, fileData) {
92
92
  // tests missing info but with no error were skipped via grep, so exclude them
93
93
  if (!allTestInfo && !t.error) return;
94
94
 
95
- for (const test in allTestInfo) {
96
- const info = allTestInfo[test];
95
+ for (const test in allTestInfo.tests) {
96
+ const info = allTestInfo.tests[test];
97
97
  if (test !== 'default') testName = `${prefix}${t.name} (${test})`;
98
98
  if (!fileData.tests.has(testName)) {
99
99
  fileData.tests.set(testName, {
@@ -104,9 +104,9 @@ function flattenResults(session, browserData, fileData) {
104
104
  });
105
105
  }
106
106
  const testData = fileData.tests.get(testName);
107
- const bytediff = !t.passed && info?.diff === undefined && info?.pixelsDiff === 0;
108
- if (!t.passed) {
109
- if (bytediff) {
107
+ const passed = !!(info.golden) && !(info.pixelsDiff) && !(info.byteSizeDiff);
108
+ if (!passed) {
109
+ if (info.byteSizeDiff) {
110
110
  browserData.numByteDiff++;
111
111
  testData.numByteDiff++;
112
112
  }
@@ -117,8 +117,9 @@ function flattenResults(session, browserData, fileData) {
117
117
  name: browserData.name,
118
118
  duration: t.duration,
119
119
  error: t.error?.message,
120
- passed: t.passed,
121
- bytediff,
120
+ passed,
121
+ bytediff: info.byteSizeDiff,
122
+ slowDuration: allTestInfo.slowDuration,
122
123
  info: info
123
124
  });
124
125
  }