@brightspace-ui/testing 1.37.2 → 1.38.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/README.md CHANGED
@@ -343,6 +343,8 @@ class SlowElem extends LitElement {
343
343
  }
344
344
  ```
345
345
 
346
+ The [`LoadingCompleteMixin` in `@brightspace-ui/core`](https://github.com/BrightspaceUI/core/tree/main/mixins/loading-complete) has been added to make implementing this even simpler.
347
+
346
348
  To bypass waiting for `getLoadingComplete()`, set the `awaitLoadingComplete` configuration option to `false`:
347
349
 
348
350
  ```javascript
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.37.2",
5
+ "version": "1.38.0",
6
6
  "repository": "https://github.com/BrightspaceUI/testing.git",
7
7
  "scripts": {
8
8
  "lint": "npm run lint:eslint && npm run lint:style",
@@ -23,13 +23,14 @@
23
23
  "author": "D2L Corporation",
24
24
  "license": "Apache-2.0",
25
25
  "devDependencies": {
26
- "@brightspace-ui/stylelint-config": "^1",
26
+ "@brightspace-ui/stylelint-config": "^2",
27
27
  "chai": "^6",
28
28
  "eslint": "^9",
29
- "eslint-config-brightspace": "^2.0.0",
29
+ "eslint-config-brightspace": "^2",
30
+ "globals": "^17",
30
31
  "mocha": "^11",
31
32
  "sinon": "^21",
32
- "globals": "^17"
33
+ "stylelint": "^17"
33
34
  },
34
35
  "exports": {
35
36
  ".": "./src/browser/index.js"
@@ -82,13 +82,14 @@ async function waitForElem(elem, awaitLoadingComplete = true) {
82
82
  *
83
83
  * @param {*} element
84
84
  * @param {{
85
- * awaitLoadingComplete: boolean,
86
- * lang: string,
85
+ * awaitLoadingComplete: boolean,
86
+ * colorMode: string,
87
+ * lang: string,
87
88
  * mathjax: {renderLatex: boolean},
88
89
  * rtl: boolean,
89
90
  * pagePadding: boolean,
90
91
  * media: string,
91
- * viewport: { height: number, width: number }
92
+ * viewport: { height: number, width: number }
92
93
  * }} opts
93
94
  */
94
95
  export async function fixture(element, opts = {}) {
@@ -4,6 +4,7 @@ import { nextFrame } from '@open-wc/testing';
4
4
 
5
5
  const DEFAULT_PAGE_PADDING = true,
6
6
  DEFAULT_LANG = 'en',
7
+ DEFAULT_COLOR_MODE = undefined,
7
8
  DEFAULT_MATHJAX_RENDER_LATEX = false,
8
9
  DEFAULT_MEDIA = 'screen',
9
10
  DEFAULT_VIEWPORT = {
@@ -18,6 +19,7 @@ let
18
19
  currentMathjaxRenderLatex = DEFAULT_MATHJAX_RENDER_LATEX,
19
20
  currentMedia = DEFAULT_MEDIA,
20
21
  currentRtl = false,
22
+ currentColorMode = DEFAULT_COLOR_MODE,
21
23
  currentViewportHeight = 0,
22
24
  currentViewportWidth = 0,
23
25
  shouldResetMouse = false;
@@ -47,6 +49,7 @@ export async function reset(opts = {}) {
47
49
  lang: DEFAULT_LANG,
48
50
  mathjax: {},
49
51
  rtl: !!opts.lang?.startsWith('ar'),
52
+ colorMode: DEFAULT_COLOR_MODE,
50
53
  pagePadding: DEFAULT_PAGE_PADDING,
51
54
  media: DEFAULT_MEDIA
52
55
  };
@@ -89,6 +92,17 @@ export async function reset(opts = {}) {
89
92
  currentRtl = opts.rtl;
90
93
  }
91
94
 
95
+ if (opts.colorMode !== currentColorMode) {
96
+ const colorMode = ['light', 'dark'].includes(opts.colorMode) ? opts.colorMode : DEFAULT_COLOR_MODE;
97
+ if (!colorMode) {
98
+ document.documentElement.removeAttribute('data-color-mode');
99
+ } else {
100
+ document.documentElement.setAttribute('data-color-mode', colorMode);
101
+ }
102
+ awaitNextFrame = true;
103
+ currentColorMode = colorMode;
104
+ }
105
+
92
106
  opts.lang ??= '';
93
107
  if (documentLocaleSettings.language !== opts.lang) {
94
108
  document.documentElement.lang = opts.lang;
@@ -89,6 +89,9 @@ export class WTRConfig {
89
89
  --d2l-inline-start: left;
90
90
  --d2l-length-factor: 1;
91
91
  --d2l-mirror-transform: none;
92
+ --d2l-theme-background-color-base: #ffffff;
93
+ --d2l-theme-text-color-static-standard: #202122;
94
+ font-size: 20px;
92
95
  }
93
96
 
94
97
  html[dir="rtl"] * {
@@ -101,6 +104,11 @@ export class WTRConfig {
101
104
  --d2l-mirror-transform: scale(-1, 1);
102
105
  }
103
106
 
107
+ html[data-color-mode="dark"] {
108
+ --d2l-theme-background-color-base: #161718;
109
+ --d2l-theme-text-color-static-standard: #cdd5dc;
110
+ }
111
+
104
112
  @font-face {
105
113
  font-family: 'Lato';
106
114
  font-style: normal;
@@ -114,12 +122,9 @@ export class WTRConfig {
114
122
  src: url(${FONT_ASSETS}Lato-700.woff2) format('woff2');
115
123
  }
116
124
 
117
- html {
118
- font-size: 20px;
119
- }
120
125
  body {
121
- background-color: #ffffff;
122
- color: var(--d2l-color-ferrite, #202122);
126
+ background-color: var(--d2l-theme-background-color-base);
127
+ color: var(--d2l-theme-text-color-static-standard);
123
128
  font-family: 'Lato', sans-serif;
124
129
  letter-spacing: 0.01rem;
125
130
  font-size: 0.95rem;