@brightspace-ui/testing 1.39.1 → 1.40.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.39.1",
5
+ "version": "1.40.0",
6
6
  "repository": "https://github.com/BrightspaceUI/testing.git",
7
7
  "scripts": {
8
8
  "lint": "npm run lint:eslint && npm run lint:style",
@@ -53,7 +53,7 @@
53
53
  "@web/test-runner-playwright": "^0.11",
54
54
  "command-line-args": "^6",
55
55
  "command-line-usage": "^7",
56
- "d2l-test-reporting": "^4",
56
+ "d2l-test-reporting": "^5",
57
57
  "glob": "^13",
58
58
  "lit": "^2 || ^3",
59
59
  "pixelmatch": "^7",
@@ -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,29 +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
- testInfo.byteSizeDiff = testInfo.byteSizeDiff || info.byteSizeDiff;
24
25
  }
25
- const tests = testInfoMap.get(this.key) || {};
26
- testInfoMap.set(this.key, { ...tests, [alt]: testInfo });
27
26
  }
28
27
  }
29
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),
@@ -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, {
@@ -119,6 +119,7 @@ function flattenResults(session, browserData, fileData) {
119
119
  error: t.error?.message,
120
120
  passed,
121
121
  bytediff: info.byteSizeDiff,
122
+ slowDuration: allTestInfo.slowDuration,
122
123
  info: info
123
124
  });
124
125
  }