@baseline-ui/test-utils 0.62.0 → 1.0.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/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import * as _playwright_test from '@playwright/test';
1
+ import * as playwright_test from 'playwright/test';
2
2
  import { Page, Locator, FrameLocator } from '@playwright/test';
3
3
  import { SinonSpy } from 'sinon';
4
4
 
@@ -29,57 +29,57 @@ interface ToBeAccessibleOptions {
29
29
  attachmentName?: string;
30
30
  }
31
31
 
32
- declare const expect: _playwright_test.Expect<{
33
- toBeWithinDelta(this: _playwright_test.ExpectMatcherState, received: number, expected: number, delta: number): {
32
+ declare const expect: playwright_test.Expect<{
33
+ toBeWithinDelta(this: playwright_test.ExpectMatcherState, received: number, expected: number, delta: number): {
34
34
  message: () => string;
35
35
  pass: true;
36
36
  } | {
37
37
  message: () => string;
38
38
  pass: false;
39
39
  };
40
- toBeCalledOnce(this: _playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
40
+ toBeCalledOnce(this: playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
41
41
  message: () => string;
42
42
  pass: true;
43
43
  } | {
44
44
  message: () => string;
45
45
  pass: false;
46
46
  }>;
47
- toBeCalledTwice(this: _playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
47
+ toBeCalledTwice(this: playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
48
48
  message: () => string;
49
49
  pass: true;
50
50
  } | {
51
51
  message: () => string;
52
52
  pass: false;
53
53
  }>;
54
- toBeCalledThrice(this: _playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
54
+ toBeCalledThrice(this: playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
55
55
  message: () => string;
56
56
  pass: true;
57
57
  } | {
58
58
  message: () => string;
59
59
  pass: false;
60
60
  }>;
61
- toBeCalledWith(this: _playwright_test.ExpectMatcherState, fn: SinonSpy, ...args: unknown[]): Promise<{
61
+ toBeCalledWith(this: playwright_test.ExpectMatcherState, fn: SinonSpy, ...args: unknown[]): Promise<{
62
62
  message: () => string;
63
63
  pass: true;
64
64
  } | {
65
65
  message: () => string;
66
66
  pass: false;
67
67
  }>;
68
- toBeCalledWithExactly(this: _playwright_test.ExpectMatcherState, fn: SinonSpy, ...args: unknown[]): Promise<{
68
+ toBeCalledWithExactly(this: playwright_test.ExpectMatcherState, fn: SinonSpy, ...args: unknown[]): Promise<{
69
69
  message: () => string;
70
70
  pass: true;
71
71
  } | {
72
72
  message: () => string;
73
73
  pass: false;
74
74
  }>;
75
- toBeCalled(this: _playwright_test.ExpectMatcherState, fn: SinonSpy): {
75
+ toBeCalled(this: playwright_test.ExpectMatcherState, fn: SinonSpy): {
76
76
  message: () => string;
77
77
  pass: true;
78
78
  } | {
79
79
  message: () => string;
80
80
  pass: false;
81
81
  };
82
- toBeCalledTimes(this: _playwright_test.ExpectMatcherState, fn: SinonSpy, times: number): Promise<{
82
+ toBeCalledTimes(this: playwright_test.ExpectMatcherState, fn: SinonSpy, times: number): Promise<{
83
83
  message: () => string;
84
84
  pass: true;
85
85
  } | {
@@ -95,7 +95,7 @@ declare const expect: _playwright_test.Expect<{
95
95
  message: () => string;
96
96
  pass: false;
97
97
  }>;
98
- toMatchClassTree(this: _playwright_test.ExpectMatcherState, locator: Locator, snapshotName?: string, options?: {
98
+ toMatchClassTree(this: playwright_test.ExpectMatcherState, locator: Locator, snapshotName?: string, options?: {
99
99
  prefix?: string | string[];
100
100
  ignoreHashed?: boolean;
101
101
  }): Promise<{
@@ -139,6 +139,128 @@ interface BaseTesterOptions {
139
139
  */
140
140
  type DisclosureOpenWith = "click" | "Space" | "Enter" | "ArrowDown" | "ArrowUp";
141
141
 
142
+ /**
143
+ * Options for {@link editorTester}. The Editor has no single disclosure
144
+ * trigger, so instead of `trigger` it accepts `root` — the `.BaselineUI-Editor`
145
+ * container every other locator is scoped to. Pass it when more than one
146
+ * Editor is mounted in the same frame.
147
+ */
148
+ interface EditorTesterOptions {
149
+ frame: Frame;
150
+ /**
151
+ * The Editor root element. Defaults to `frame.locator(".BaselineUI-Editor")`.
152
+ */
153
+ root?: Locator;
154
+ }
155
+ /**
156
+ * Driver for an `<Editor>` in Playwright component tests. Construct with
157
+ * {@link editorTester} (or `testers(frame).editor()`).
158
+ *
159
+ * Works for both modes of the component: in rich text mode `textbox` resolves
160
+ * to the contenteditable area, in plain/minimal mode to the `<textarea>` —
161
+ * both expose `role="textbox"`, so no mode flag is needed. Rich-text-only
162
+ * surface (toolbar buttons, link popover, mention dropdown, help dialog)
163
+ * simply won't match when `enableRichText` is off.
164
+ */
165
+ interface EditorTester {
166
+ readonly root: Locator;
167
+ /**
168
+ * The editing area: the rich text contenteditable or the plain-mode
169
+ * textarea (both have `role="textbox"`).
170
+ */
171
+ readonly textbox: Locator;
172
+ /**
173
+ * The rich text placeholder overlay, attached only while the document is
174
+ * empty. (In plain mode the placeholder is a `<textarea>` attribute —
175
+ * assert on `textbox` instead.)
176
+ */
177
+ readonly placeholder: Locator;
178
+ readonly toolbar: Locator;
179
+ readonly boldButton: Locator;
180
+ readonly italicButton: Locator;
181
+ readonly underlineButton: Locator;
182
+ readonly fontColorButton: Locator;
183
+ readonly backgroundColorButton: Locator;
184
+ /**
185
+ * Opens the font color picker popover if it isn't already open.
186
+ * Idempotent — keys off `aria-expanded` on the trigger.
187
+ */
188
+ openFontColorPicker: (how?: DisclosureOpenWith) => Promise<void>;
189
+ openBackgroundColorPicker: (how?: DisclosureOpenWith) => Promise<void>;
190
+ readonly addLinkButton: Locator;
191
+ readonly linkDialog: Locator;
192
+ readonly linkInput: Locator;
193
+ readonly linkAddButton: Locator;
194
+ /** The "Edit Link" button in show mode (caret inside an existing link). */
195
+ readonly linkEditButton: Locator;
196
+ readonly linkRemoveButton: Locator;
197
+ readonly linkCancelButton: Locator;
198
+ readonly linkSaveButton: Locator;
199
+ openLinkDialog: (how?: DisclosureOpenWith) => Promise<void>;
200
+ readonly saveButton: Locator;
201
+ /** The cancel button (rendered only when `onCancel` is provided). */
202
+ readonly cancelButton: Locator;
203
+ /**
204
+ * The footer mention button (rendered only with rich text +
205
+ * `mentionableUsers`).
206
+ */
207
+ readonly mentionButton: Locator;
208
+ readonly helpButton: Locator;
209
+ /** The keyboard shortcuts help dialog (a modal, portalled to the body). */
210
+ readonly helpDialog: Locator;
211
+ readonly helpDialogCloseButton: Locator;
212
+ openHelpDialog: () => Promise<void>;
213
+ /**
214
+ * The inline mention combobox input, attached only while a mention flow is
215
+ * active (after "@" or {@link startMention}).
216
+ */
217
+ readonly mentionInput: Locator;
218
+ /** The mention suggestion listbox (portalled outside the editor root). */
219
+ readonly mentionListbox: Locator;
220
+ mentionOption: (name: string | RegExp) => Locator;
221
+ /**
222
+ * Starts a mention flow via the footer mention button if one isn't already
223
+ * active. Idempotent — bails when the mention input is visible.
224
+ */
225
+ startMention: () => Promise<void>;
226
+ }
227
+
228
+ /**
229
+ * Options for {@link fileUploaderTester}. The root is always resolved from the
230
+ * stable `data-testid="file-uploader"`; `trigger` overrides the upload
231
+ * button (the focusable element that opens the native file picker) for the
232
+ * rare case a consumer renders a custom one.
233
+ *
234
+ * `variant` mirrors the component's `variant` prop and only affects how the
235
+ * upload `button` is resolved: in the `dropzone` variant the whole drop area is
236
+ * the focusable trigger (`data-testid="file-uploader-dropzone"`, `role="button"`),
237
+ * while the `button` variant renders a single `role="button"` inside the root.
238
+ */
239
+ interface FileUploaderTesterOptions extends BaseTesterOptions {
240
+ variant?: "dropzone" | "button";
241
+ }
242
+ /**
243
+ * Driver for a `<FileUploader>` in Playwright component tests. Construct with
244
+ * {@link fileUploaderTester} (or `testers(frame).fileUploader()`).
245
+ */
246
+ interface FileUploaderTester {
247
+ /** The uploader root element — scopes every other locator. */
248
+ readonly root: Locator;
249
+ /** The upload trigger button that opens the native file picker. */
250
+ readonly button: Locator;
251
+ /** The hidden native file input. Prefer {@link upload} to set files on it. */
252
+ readonly input: Locator;
253
+ /**
254
+ * The drop area (dropzone variant only). Use with `locator.drop({ files })`
255
+ * to simulate a drag-and-drop. Not attached in the `button` variant.
256
+ */
257
+ readonly dropzone: Locator;
258
+ /** The error alert. Only attached while `errorMessage` is set. */
259
+ readonly errorMessage: Locator;
260
+ /** Sets files on the hidden input — the way a user picks files. */
261
+ upload: (files: Parameters<Locator["setInputFiles"]>[0]) => Promise<void>;
262
+ }
263
+
142
264
  /**
143
265
  * Options for {@link selectTester}. Defaults the trigger to
144
266
  * `frame.getByTestId("select-button")` (the convention for both single- and
@@ -272,6 +394,8 @@ interface SelectTesterFactoryFor<O extends {
272
394
  }
273
395
 
274
396
  type BoundSelectOptions = Omit<SelectTesterOptions, "frame">;
397
+ type BoundEditorOptions = Omit<EditorTesterOptions, "frame">;
398
+ type BoundFileUploaderOptions = Omit<FileUploaderTesterOptions, "frame">;
275
399
  /**
276
400
  * The frame-bound tester factory. Methods are flat — one per component — so
277
401
  * IDE autocomplete on `t.` lists the full surface in one place. Variants of a
@@ -283,6 +407,8 @@ type BoundSelectOptions = Omit<SelectTesterOptions, "frame">;
283
407
  */
284
408
  interface Testers {
285
409
  select: SelectTesterFactoryFor<BoundSelectOptions>;
410
+ editor: (options?: BoundEditorOptions) => EditorTester;
411
+ fileUploader: (options?: BoundFileUploaderOptions) => FileUploaderTester;
286
412
  }
287
413
  /**
288
414
  * Build a frame-bound tester factory. Construct once per test and pick the
@@ -300,4 +426,4 @@ interface Testers {
300
426
  */
301
427
  declare function testers(frame: Frame): Testers;
302
428
 
303
- export { type AutocompleteTester, DEFAULT_CRITICAL_INCOMPLETE_RULES, DEFAULT_DISABLED_RULES, DEFAULT_WCAG_TAGS, type Frame, type MultiSelectTester, type SelectTester, type Testers, type ToBeAccessibleOptions, expect, testers };
429
+ export { type AutocompleteTester, DEFAULT_CRITICAL_INCOMPLETE_RULES, DEFAULT_DISABLED_RULES, DEFAULT_WCAG_TAGS, type EditorTester, type FileUploaderTester, type Frame, type MultiSelectTester, type SelectTester, type Testers, type ToBeAccessibleOptions, expect, testers };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as _playwright_test from '@playwright/test';
1
+ import * as playwright_test from 'playwright/test';
2
2
  import { Page, Locator, FrameLocator } from '@playwright/test';
3
3
  import { SinonSpy } from 'sinon';
4
4
 
@@ -29,57 +29,57 @@ interface ToBeAccessibleOptions {
29
29
  attachmentName?: string;
30
30
  }
31
31
 
32
- declare const expect: _playwright_test.Expect<{
33
- toBeWithinDelta(this: _playwright_test.ExpectMatcherState, received: number, expected: number, delta: number): {
32
+ declare const expect: playwright_test.Expect<{
33
+ toBeWithinDelta(this: playwright_test.ExpectMatcherState, received: number, expected: number, delta: number): {
34
34
  message: () => string;
35
35
  pass: true;
36
36
  } | {
37
37
  message: () => string;
38
38
  pass: false;
39
39
  };
40
- toBeCalledOnce(this: _playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
40
+ toBeCalledOnce(this: playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
41
41
  message: () => string;
42
42
  pass: true;
43
43
  } | {
44
44
  message: () => string;
45
45
  pass: false;
46
46
  }>;
47
- toBeCalledTwice(this: _playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
47
+ toBeCalledTwice(this: playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
48
48
  message: () => string;
49
49
  pass: true;
50
50
  } | {
51
51
  message: () => string;
52
52
  pass: false;
53
53
  }>;
54
- toBeCalledThrice(this: _playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
54
+ toBeCalledThrice(this: playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
55
55
  message: () => string;
56
56
  pass: true;
57
57
  } | {
58
58
  message: () => string;
59
59
  pass: false;
60
60
  }>;
61
- toBeCalledWith(this: _playwright_test.ExpectMatcherState, fn: SinonSpy, ...args: unknown[]): Promise<{
61
+ toBeCalledWith(this: playwright_test.ExpectMatcherState, fn: SinonSpy, ...args: unknown[]): Promise<{
62
62
  message: () => string;
63
63
  pass: true;
64
64
  } | {
65
65
  message: () => string;
66
66
  pass: false;
67
67
  }>;
68
- toBeCalledWithExactly(this: _playwright_test.ExpectMatcherState, fn: SinonSpy, ...args: unknown[]): Promise<{
68
+ toBeCalledWithExactly(this: playwright_test.ExpectMatcherState, fn: SinonSpy, ...args: unknown[]): Promise<{
69
69
  message: () => string;
70
70
  pass: true;
71
71
  } | {
72
72
  message: () => string;
73
73
  pass: false;
74
74
  }>;
75
- toBeCalled(this: _playwright_test.ExpectMatcherState, fn: SinonSpy): {
75
+ toBeCalled(this: playwright_test.ExpectMatcherState, fn: SinonSpy): {
76
76
  message: () => string;
77
77
  pass: true;
78
78
  } | {
79
79
  message: () => string;
80
80
  pass: false;
81
81
  };
82
- toBeCalledTimes(this: _playwright_test.ExpectMatcherState, fn: SinonSpy, times: number): Promise<{
82
+ toBeCalledTimes(this: playwright_test.ExpectMatcherState, fn: SinonSpy, times: number): Promise<{
83
83
  message: () => string;
84
84
  pass: true;
85
85
  } | {
@@ -95,7 +95,7 @@ declare const expect: _playwright_test.Expect<{
95
95
  message: () => string;
96
96
  pass: false;
97
97
  }>;
98
- toMatchClassTree(this: _playwright_test.ExpectMatcherState, locator: Locator, snapshotName?: string, options?: {
98
+ toMatchClassTree(this: playwright_test.ExpectMatcherState, locator: Locator, snapshotName?: string, options?: {
99
99
  prefix?: string | string[];
100
100
  ignoreHashed?: boolean;
101
101
  }): Promise<{
@@ -139,6 +139,128 @@ interface BaseTesterOptions {
139
139
  */
140
140
  type DisclosureOpenWith = "click" | "Space" | "Enter" | "ArrowDown" | "ArrowUp";
141
141
 
142
+ /**
143
+ * Options for {@link editorTester}. The Editor has no single disclosure
144
+ * trigger, so instead of `trigger` it accepts `root` — the `.BaselineUI-Editor`
145
+ * container every other locator is scoped to. Pass it when more than one
146
+ * Editor is mounted in the same frame.
147
+ */
148
+ interface EditorTesterOptions {
149
+ frame: Frame;
150
+ /**
151
+ * The Editor root element. Defaults to `frame.locator(".BaselineUI-Editor")`.
152
+ */
153
+ root?: Locator;
154
+ }
155
+ /**
156
+ * Driver for an `<Editor>` in Playwright component tests. Construct with
157
+ * {@link editorTester} (or `testers(frame).editor()`).
158
+ *
159
+ * Works for both modes of the component: in rich text mode `textbox` resolves
160
+ * to the contenteditable area, in plain/minimal mode to the `<textarea>` —
161
+ * both expose `role="textbox"`, so no mode flag is needed. Rich-text-only
162
+ * surface (toolbar buttons, link popover, mention dropdown, help dialog)
163
+ * simply won't match when `enableRichText` is off.
164
+ */
165
+ interface EditorTester {
166
+ readonly root: Locator;
167
+ /**
168
+ * The editing area: the rich text contenteditable or the plain-mode
169
+ * textarea (both have `role="textbox"`).
170
+ */
171
+ readonly textbox: Locator;
172
+ /**
173
+ * The rich text placeholder overlay, attached only while the document is
174
+ * empty. (In plain mode the placeholder is a `<textarea>` attribute —
175
+ * assert on `textbox` instead.)
176
+ */
177
+ readonly placeholder: Locator;
178
+ readonly toolbar: Locator;
179
+ readonly boldButton: Locator;
180
+ readonly italicButton: Locator;
181
+ readonly underlineButton: Locator;
182
+ readonly fontColorButton: Locator;
183
+ readonly backgroundColorButton: Locator;
184
+ /**
185
+ * Opens the font color picker popover if it isn't already open.
186
+ * Idempotent — keys off `aria-expanded` on the trigger.
187
+ */
188
+ openFontColorPicker: (how?: DisclosureOpenWith) => Promise<void>;
189
+ openBackgroundColorPicker: (how?: DisclosureOpenWith) => Promise<void>;
190
+ readonly addLinkButton: Locator;
191
+ readonly linkDialog: Locator;
192
+ readonly linkInput: Locator;
193
+ readonly linkAddButton: Locator;
194
+ /** The "Edit Link" button in show mode (caret inside an existing link). */
195
+ readonly linkEditButton: Locator;
196
+ readonly linkRemoveButton: Locator;
197
+ readonly linkCancelButton: Locator;
198
+ readonly linkSaveButton: Locator;
199
+ openLinkDialog: (how?: DisclosureOpenWith) => Promise<void>;
200
+ readonly saveButton: Locator;
201
+ /** The cancel button (rendered only when `onCancel` is provided). */
202
+ readonly cancelButton: Locator;
203
+ /**
204
+ * The footer mention button (rendered only with rich text +
205
+ * `mentionableUsers`).
206
+ */
207
+ readonly mentionButton: Locator;
208
+ readonly helpButton: Locator;
209
+ /** The keyboard shortcuts help dialog (a modal, portalled to the body). */
210
+ readonly helpDialog: Locator;
211
+ readonly helpDialogCloseButton: Locator;
212
+ openHelpDialog: () => Promise<void>;
213
+ /**
214
+ * The inline mention combobox input, attached only while a mention flow is
215
+ * active (after "@" or {@link startMention}).
216
+ */
217
+ readonly mentionInput: Locator;
218
+ /** The mention suggestion listbox (portalled outside the editor root). */
219
+ readonly mentionListbox: Locator;
220
+ mentionOption: (name: string | RegExp) => Locator;
221
+ /**
222
+ * Starts a mention flow via the footer mention button if one isn't already
223
+ * active. Idempotent — bails when the mention input is visible.
224
+ */
225
+ startMention: () => Promise<void>;
226
+ }
227
+
228
+ /**
229
+ * Options for {@link fileUploaderTester}. The root is always resolved from the
230
+ * stable `data-testid="file-uploader"`; `trigger` overrides the upload
231
+ * button (the focusable element that opens the native file picker) for the
232
+ * rare case a consumer renders a custom one.
233
+ *
234
+ * `variant` mirrors the component's `variant` prop and only affects how the
235
+ * upload `button` is resolved: in the `dropzone` variant the whole drop area is
236
+ * the focusable trigger (`data-testid="file-uploader-dropzone"`, `role="button"`),
237
+ * while the `button` variant renders a single `role="button"` inside the root.
238
+ */
239
+ interface FileUploaderTesterOptions extends BaseTesterOptions {
240
+ variant?: "dropzone" | "button";
241
+ }
242
+ /**
243
+ * Driver for a `<FileUploader>` in Playwright component tests. Construct with
244
+ * {@link fileUploaderTester} (or `testers(frame).fileUploader()`).
245
+ */
246
+ interface FileUploaderTester {
247
+ /** The uploader root element — scopes every other locator. */
248
+ readonly root: Locator;
249
+ /** The upload trigger button that opens the native file picker. */
250
+ readonly button: Locator;
251
+ /** The hidden native file input. Prefer {@link upload} to set files on it. */
252
+ readonly input: Locator;
253
+ /**
254
+ * The drop area (dropzone variant only). Use with `locator.drop({ files })`
255
+ * to simulate a drag-and-drop. Not attached in the `button` variant.
256
+ */
257
+ readonly dropzone: Locator;
258
+ /** The error alert. Only attached while `errorMessage` is set. */
259
+ readonly errorMessage: Locator;
260
+ /** Sets files on the hidden input — the way a user picks files. */
261
+ upload: (files: Parameters<Locator["setInputFiles"]>[0]) => Promise<void>;
262
+ }
263
+
142
264
  /**
143
265
  * Options for {@link selectTester}. Defaults the trigger to
144
266
  * `frame.getByTestId("select-button")` (the convention for both single- and
@@ -272,6 +394,8 @@ interface SelectTesterFactoryFor<O extends {
272
394
  }
273
395
 
274
396
  type BoundSelectOptions = Omit<SelectTesterOptions, "frame">;
397
+ type BoundEditorOptions = Omit<EditorTesterOptions, "frame">;
398
+ type BoundFileUploaderOptions = Omit<FileUploaderTesterOptions, "frame">;
275
399
  /**
276
400
  * The frame-bound tester factory. Methods are flat — one per component — so
277
401
  * IDE autocomplete on `t.` lists the full surface in one place. Variants of a
@@ -283,6 +407,8 @@ type BoundSelectOptions = Omit<SelectTesterOptions, "frame">;
283
407
  */
284
408
  interface Testers {
285
409
  select: SelectTesterFactoryFor<BoundSelectOptions>;
410
+ editor: (options?: BoundEditorOptions) => EditorTester;
411
+ fileUploader: (options?: BoundFileUploaderOptions) => FileUploaderTester;
286
412
  }
287
413
  /**
288
414
  * Build a frame-bound tester factory. Construct once per test and pick the
@@ -300,4 +426,4 @@ interface Testers {
300
426
  */
301
427
  declare function testers(frame: Frame): Testers;
302
428
 
303
- export { type AutocompleteTester, DEFAULT_CRITICAL_INCOMPLETE_RULES, DEFAULT_DISABLED_RULES, DEFAULT_WCAG_TAGS, type Frame, type MultiSelectTester, type SelectTester, type Testers, type ToBeAccessibleOptions, expect, testers };
429
+ export { type AutocompleteTester, DEFAULT_CRITICAL_INCOMPLETE_RULES, DEFAULT_DISABLED_RULES, DEFAULT_WCAG_TAGS, type EditorTester, type FileUploaderTester, type Frame, type MultiSelectTester, type SelectTester, type Testers, type ToBeAccessibleOptions, expect, testers };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var test=require('@playwright/test'),$=require('axe-core'),promises=require('fs/promises'),R=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var $__default=/*#__PURE__*/_interopDefault($);var R__default=/*#__PURE__*/_interopDefault(R);/**
1
+ 'use strict';var test=require('@playwright/test'),_=require('axe-core'),promises=require('fs/promises'),C=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ___default=/*#__PURE__*/_interopDefault(_);var C__default=/*#__PURE__*/_interopDefault(C);/**
2
2
  * Copyright (c) 2023-2024 PSPDFKit GmbH. All rights reserved.
3
3
  *
4
4
  * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
@@ -7,15 +7,15 @@
7
7
  * This notice may not be removed from this file.
8
8
  *
9
9
  */
10
- var b=["wcag2a","wcag2aa","wcag21a","wcag21aa","best-practice"],S=["landmark-one-main","page-has-heading-one","region","aria-allowed-role","duplicate-id","scrollable-region-focusable"],A=["aria-valid-attr-value","aria-valid-attr","aria-required-attr"];function O(e,t={}){let{prefix:s="BaselineUI-",ignoreHashed:n=false}=t,o=Array.isArray(s)?s:[s];function r(c){return c.split(/[-_]/).some(a=>a.length>=5&&/^[a-z\d]+$/.test(a)&&/[a-z]/.test(a)&&/\d/.test(a))}function l(c){return [...c.classList].filter(a=>o.some(d=>a.startsWith(d))&&(!n||!r(a)))}function u(c,a=false){let d=[],w=c.shadowRoot?c.shadowRoot.children:c.children;for(let h of w){let y=a||h.getAttribute("aria-hidden")==="true",x=l(h),T=u(h,y);x.length>0?d.push({classes:x,children:T,hidden:y}):d.push(...T);}return d}function f(c,a="",d=false){let w=[];for(let h=0;h<c.length;h++){let y=c[h],x=h===c.length-1,T=d?"":x?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",P=d?"":a+(x?" ":"\u2502 "),D=y.classes.join(", ");w.push(a+T+D+(y.hidden?" [aria-hidden]":""),...f(y.children,P));}return w}let p=l(e),i=u(e);return p.length===0&&i.length===0?"":p.length>0?f([{classes:p,children:i,hidden:false}],"",true).join(`
11
- `):f(i,"",true).join(`
12
- `)}var g=e=>{if(e instanceof Error)return e.message;if(typeof e=="string")return e;if(e==null)return "unknown error";try{return JSON.stringify(e)}catch{return "unstringifiable error"}},U=async e=>{let t=typeof e.goto=="function",s=!t&&typeof e.owner=="function";if(t||s)return e.locator("body");let n=e;return await n.first().evaluate(r=>r.tagName?.toLowerCase()==="iframe").catch(()=>false)?n.contentFrame().locator("body"):n},N=async e=>{await e.first().evaluate((t,s)=>{if(window.axe)return;let o=document.createElement("script");o.textContent=s,document.head.append(o);},$__default.default.source);},j=["document-title","html-has-lang","html-lang-valid","html-xml-lang-mismatch"],M=(e,t=[])=>{let s=new Set([...S,...t,...e.disableRules??[]]);return {runOnly:{type:"tag",values:[...e.tags??b]},rules:Object.fromEntries([...s].map(n=>[n,{enabled:false}]))}},F=e=>{if(e!==void 0)return typeof e=="string"?[e]:[...e]},W=async(e,t,s)=>{let n=await e.count();if(n===0)throw new Error("toBeAccessible: locator resolved to zero elements; nothing to scan.");await N(e);let o=F(t.include),r=F(t.exclude);return n===1?await e.evaluate(async(l,u)=>{let f=window,p={include:[l,...u.userInclude??[]],exclude:u.userExclude??[]};return await f.axe.run(p,u.runOptions)},{userInclude:o,userExclude:r,runOptions:s}):await e.evaluateAll(async(l,u)=>{let f=window,p={include:[...l,...u.userInclude??[]],exclude:u.userExclude??[]};return await f.axe.run(p,u.runOptions)},{userInclude:o,userExclude:r,runOptions:s})},L="BaselineUI-";function E(e){return e.replaceAll(/\W+/g,"-").replaceAll(/^-|-$/g,"")}function H(e){return Array.isArray(e)?e.length===1&&e[0]===L:e===L}function G(e){return (Array.isArray(e)?e:[e]).join("+")}function V(e,t,s,n,o){let r=t.slice(1).map(l=>E(l));return s&&r.push(E(s)),n!==void 0&&!H(n)&&r.push(E(G(n))),o&&r.push("ignoreHashed"),R__default.default.join(e,`${r.join("--")}.txt`)}var z=test.expect.extend({toBeWithinDelta(e,t,s){return Math.abs(e-t)<=s?{message:()=>`expected ${e} not to be within ${s} of ${t}`,pass:true}:{message:()=>`expected ${e} to be within ${s} of ${t}`,pass:false}},async toBeCalledOnce(e){try{return await test.expect.poll(()=>e.callCount).toBe(1),{message:()=>"Expected function to be called once.",pass:!0}}catch(t){return {message:()=>g(t),pass:false}}},async toBeCalledTwice(e){try{return await test.expect.poll(()=>e.callCount).toBe(2),{message:()=>"Expected function to be called twice.",pass:!0}}catch(t){return {message:()=>g(t),pass:false}}},async toBeCalledThrice(e){try{return await test.expect.poll(()=>e.callCount).toBe(3),{message:()=>"Expected function to be called thrice.",pass:!0}}catch(t){return {message:()=>g(t),pass:false}}},async toBeCalledWith(e,...t){try{return await test.expect(()=>{for(let[s,n]of t.entries())test.expect(e.lastCall?.args?.[s]).toStrictEqual(n);}).toPass(),{message:()=>`Expected function to be called with ${t.join(", ")}.`,pass:!0}}catch(s){return {message:()=>g(s),pass:false}}},async toBeCalledWithExactly(e,...t){try{return await test.expect.poll(()=>e.lastCall?.args).toStrictEqual(t),{message:()=>`Expected function to be called with exactly ${t.join(", ")}.`,pass:!0}}catch(s){return {message:()=>g(s),pass:false}}},toBeCalled(e){try{return test.expect(e.called).toBeTruthy(),{message:()=>"Expected function to be called.",pass:!0}}catch(t){return {message:()=>g(t),pass:false}}},async toBeCalledTimes(e,t){try{return await test.expect.poll(()=>e.callCount).toBe(t),{message:()=>`Expected function to be called ${t} times.`,pass:!0}}catch(s){return {message:()=>g(s),pass:false}}},async toBeAccessible(e,t={}){let s=await U(e),n=await s.first().evaluate(i=>{let c=i.ownerDocument?.defaultView;return c!==null&&c!==window.top}).catch(()=>false),o=M(t,n?j:[]),r,l=async()=>{let i=await W(s,t,o),c=t.treatIncompleteAsViolationIds??A,a=[...i.violations,...i.incomplete.filter(d=>c.includes(d.id))];return r={result:i,violations:a},a},u;try{if(t.timeout&&t.timeout>0){let i=test.expect.poll(l,{timeout:t.timeout});await(this.isNot?i.not.toHaveLength(0):i.toHaveLength(0));}else await l();}catch(i){u=i;}if(!r)throw new Error(`toBeAccessible: axe scan never completed.
13
- ${g(u)}`);if(r.violations.length===0)return {message:()=>"Expected accessibility violations but found none.",pass:true};this.isNot||await test.test.info().attach(t.attachmentName??"accessibility-scan-results",{body:JSON.stringify(r.result,null,2),contentType:"application/json"});let f=r.violations.map(i=>{let c=i.nodes.map(a=>Array.isArray(a.target)?a.target.join(" "):String(a.target)).join(`
14
- `);return ` \u2022 [${i.id}] ${i.help}
10
+ var w=["wcag2a","wcag2aa","wcag21a","wcag21aa","best-practice"],L=["landmark-one-main","page-has-heading-one","region","aria-allowed-role","duplicate-id","scrollable-region-focusable"],E=["aria-valid-attr-value","aria-valid-attr","aria-required-attr"];function A(e,o={}){let{prefix:t="BaselineUI-",ignoreHashed:n=false}=o,r=Array.isArray(t)?t:[t];function s(c){return c.split(/[-_]/).some(i=>i.length>=5&&/^[a-z\d]+$/.test(i)&&/[a-z]/.test(i)&&/\d/.test(i))}function l(c){return [...c.classList].filter(i=>r.some(g=>i.startsWith(g))&&(!n||!s(i)))}function u(c,i=false){let g=[],b=c.shadowRoot?c.shadowRoot.children:c.children;for(let f of b){let h=i||f.getAttribute("aria-hidden")==="true",B=l(f),x=u(f,h);B.length>0?g.push({classes:B,children:x,hidden:h}):g.push(...x);}return g}function d(c,i="",g=false){let b=[];for(let f=0;f<c.length;f++){let h=c[f],B=f===c.length-1,x=g?"":B?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",P=g?"":i+(B?" ":"\u2502 "),U=h.classes.join(", ");b.push(i+x+U+(h.hidden?" [aria-hidden]":""),...d(h.children,P));}return b}let p=l(e),a=u(e);return p.length===0&&a.length===0?"":p.length>0?d([{classes:p,children:a,hidden:false}],"",true).join(`
11
+ `):d(a,"",true).join(`
12
+ `)}var y=e=>{if(e instanceof Error)return e.message;if(typeof e=="string")return e;if(e==null)return "unknown error";try{return JSON.stringify(e)}catch{return "unstringifiable error"}},j=async e=>{let o=typeof e.goto=="function",t=!o&&typeof e.owner=="function";if(o||t)return e.locator("body");let n=e;return await n.first().evaluate(s=>s.tagName?.toLowerCase()==="iframe").catch(()=>false)?n.contentFrame().locator("body"):n},M=async e=>{await e.first().evaluate((o,t)=>{if(window.axe)return;let r=document.createElement("script");r.textContent=t,document.head.append(r);},___default.default.source);},W=["document-title","html-has-lang","html-lang-valid","html-xml-lang-mismatch"],z=(e,o=[])=>{let t=new Set([...L,...o,...e.disableRules??[]]);return {runOnly:{type:"tag",values:[...e.tags??w]},rules:Object.fromEntries([...t].map(n=>[n,{enabled:false}]))}},F=e=>{if(e!==void 0)return typeof e=="string"?[e]:[...e]},H=async(e,o,t)=>{let n=await e.count();if(n===0)throw new Error("toBeAccessible: locator resolved to zero elements; nothing to scan.");await M(e);let r=F(o.include),s=F(o.exclude);return n===1?await e.evaluate(async(l,u)=>{let d=window,p={include:[l,...u.userInclude??[]],exclude:u.userExclude??[]};return await d.axe.run(p,u.runOptions)},{userInclude:r,userExclude:s,runOptions:t}):await e.evaluateAll(async(l,u)=>{let d=window,p={include:[...l,...u.userInclude??[]],exclude:u.userExclude??[]};return await d.axe.run(p,u.runOptions)},{userInclude:r,userExclude:s,runOptions:t})},O="BaselineUI-";function S(e){return e.replaceAll(/\W+/g,"-").replaceAll(/^-|-$/g,"")}function V(e){return Array.isArray(e)?e.length===1&&e[0]===O:e===O}function G(e){return (Array.isArray(e)?e:[e]).join("+")}function q(e,o,t,n,r){let s=o.slice(1).map(l=>S(l));return t&&s.push(S(t)),n!==void 0&&!V(n)&&s.push(S(G(n))),r&&s.push("ignoreHashed"),C__default.default.join(e,`${s.join("--")}.txt`)}var J=test.expect.extend({toBeWithinDelta(e,o,t){return Math.abs(e-o)<=t?{message:()=>`expected ${e} not to be within ${t} of ${o}`,pass:true}:{message:()=>`expected ${e} to be within ${t} of ${o}`,pass:false}},async toBeCalledOnce(e){try{return await test.expect.poll(()=>e.callCount).toBe(1),{message:()=>"Expected function to be called once.",pass:!0}}catch(o){return {message:()=>y(o),pass:false}}},async toBeCalledTwice(e){try{return await test.expect.poll(()=>e.callCount).toBe(2),{message:()=>"Expected function to be called twice.",pass:!0}}catch(o){return {message:()=>y(o),pass:false}}},async toBeCalledThrice(e){try{return await test.expect.poll(()=>e.callCount).toBe(3),{message:()=>"Expected function to be called thrice.",pass:!0}}catch(o){return {message:()=>y(o),pass:false}}},async toBeCalledWith(e,...o){try{return await test.expect(()=>{for(let[t,n]of o.entries())test.expect(e.lastCall?.args?.[t]).toStrictEqual(n);}).toPass(),{message:()=>`Expected function to be called with ${o.join(", ")}.`,pass:!0}}catch(t){return {message:()=>y(t),pass:false}}},async toBeCalledWithExactly(e,...o){try{return await test.expect.poll(()=>e.lastCall?.args).toStrictEqual(o),{message:()=>`Expected function to be called with exactly ${o.join(", ")}.`,pass:!0}}catch(t){return {message:()=>y(t),pass:false}}},toBeCalled(e){try{return test.expect(e.called).toBeTruthy(),{message:()=>"Expected function to be called.",pass:!0}}catch(o){return {message:()=>y(o),pass:false}}},async toBeCalledTimes(e,o){try{return await test.expect.poll(()=>e.callCount).toBe(o),{message:()=>`Expected function to be called ${o} times.`,pass:!0}}catch(t){return {message:()=>y(t),pass:false}}},async toBeAccessible(e,o={}){let t=await j(e),n=await t.first().evaluate(a=>{let c=a.ownerDocument?.defaultView;return c!==null&&c!==window.top}).catch(()=>false),r=z(o,n?W:[]),s,l=async()=>{let a=await H(t,o,r),c=o.treatIncompleteAsViolationIds??E,i=[...a.violations,...a.incomplete.filter(g=>c.includes(g.id))];return s={result:a,violations:i},i},u;try{if(o.timeout&&o.timeout>0){let a=test.expect.poll(l,{timeout:o.timeout});await(this.isNot?a.not.toHaveLength(0):a.toHaveLength(0));}else await l();}catch(a){u=a;}if(!s)throw new Error(`toBeAccessible: axe scan never completed.
13
+ ${y(u)}`);if(s.violations.length===0)return {message:()=>"Expected accessibility violations but found none.",pass:true};this.isNot||await test.test.info().attach(o.attachmentName??"accessibility-scan-results",{body:JSON.stringify(s.result,null,2),contentType:"application/json"});let d=s.violations.map(a=>{let c=a.nodes.map(i=>Array.isArray(i.target)?i.target.join(" "):String(i.target)).join(`
14
+ `);return ` \u2022 [${a.id}] ${a.help}
15
15
  ${c}
16
- ${i.helpUrl??""}`}).join(`
17
- `),p=r.violations.length;return {message:()=>`Found ${p} accessibility violation${p===1?"":"s"}:
18
- ${f}`,pass:false}},async toMatchClassTree(e,t,s={}){let{prefix:n=L,ignoreHashed:o=false}=s,r=await e.evaluate(O,{prefix:n,ignoreHashed:o});if(!r){let l=Array.isArray(n)?n.map(u=>`${u}*`).join(" / "):`${n}*`;return {message:()=>`No ${l} classes found in the DOM tree.`,pass:false}}try{let l=`${r}
19
- `,u=test.test.info();if(u.config.ignoreSnapshots)return {message:()=>"Class tree snapshot check skipped.",pass:!0};let p=V(u.project.snapshotDir,u.titlePath,t,n,o),i=u.config.updateSnapshots;await promises.mkdir(R__default.default.dirname(p),{recursive:!0});let c;try{c=await promises.readFile(p,"utf8");}catch(a){if(a.code==="ENOENT"&&i!=="none")return await promises.writeFile(p,l),{message:()=>"Class tree snapshot created.",pass:!0};throw a}if(c!==l){if(i==="all"||i==="changed")return await promises.writeFile(p,l),{message:()=>"Class tree snapshot updated.",pass:!0};try{test.expect(l).toBe(c);}catch(a){return {message:()=>`Class tree snapshot mismatch at ${p}
16
+ ${a.helpUrl??""}`}).join(`
17
+ `),p=s.violations.length;return {message:()=>`Found ${p} accessibility violation${p===1?"":"s"}:
18
+ ${d}`,pass:false}},async toMatchClassTree(e,o,t={}){let{prefix:n=O,ignoreHashed:r=false}=t,s=await e.evaluate(A,{prefix:n,ignoreHashed:r});if(!s){let l=Array.isArray(n)?n.map(u=>`${u}*`).join(" / "):`${n}*`;return {message:()=>`No ${l} classes found in the DOM tree.`,pass:false}}try{let l=`${s}
19
+ `,u=test.test.info();if(u.config.ignoreSnapshots)return {message:()=>"Class tree snapshot check skipped.",pass:!0};let p=q(u.project.snapshotDir,u.titlePath,o,n,r),a=u.config.updateSnapshots;await promises.mkdir(C__default.default.dirname(p),{recursive:!0});let c;try{c=await promises.readFile(p,"utf8");}catch(i){if(i.code==="ENOENT"&&a!=="none")return await promises.writeFile(p,l),{message:()=>"Class tree snapshot created.",pass:!0};throw i}if(c!==l){if(a==="all"||a==="changed")return await promises.writeFile(p,l),{message:()=>"Class tree snapshot updated.",pass:!0};try{test.expect(l).toBe(c);}catch(i){return {message:()=>`Class tree snapshot mismatch at ${p}
20
20
 
21
- ${a.message}`,pass:!1}}}return {message:()=>"Class tree matched snapshot.",pass:!0}}catch(l){return {message:()=>g(l),pass:false}}}});function I(e){let t=async()=>{if(await e.getAttribute("aria-expanded")!==null)return e;let o=e.locator("[aria-expanded]").first();return await o.count()>0?o:e},s=async()=>await(await t()).getAttribute("aria-expanded")==="true";return {isOpen:s,open:async(o="click")=>{if(await s())return;if(o==="click"){await e.click();return}await(await t()).press(o);}}}var _=(e=>{let s=q(e);return e.multiple&&(s=J(s,e.frame)),e.autocomplete&&(s=K(s,e.frame)),s});function q({frame:e,trigger:t}){let s=t??e.getByTestId("select-button"),n=r=>e.getByRole("option",{name:r}),{open:o}=I(s);return {trigger:s,listbox:e.getByRole("listbox"),option:n,open:o,async selectOption(r){await o(),await n(r).click();}}}function J(e,t){return {...e,selectAllButton:t.getByTestId("select-all-button"),clearButton:t.getByTestId("select-clear-button"),tag:s=>e.trigger.getByRole("row",{name:s}),removeTagButton:s=>e.trigger.getByRole("row",{name:s}).getByRole("button")}}function K(e,t){let s=t.getByRole("searchbox");return {...e,searchbox:s,async filter(n){await s.fill(n);}}}function X(e){return {select:((t={})=>_({frame:e,...t}))}}exports.DEFAULT_CRITICAL_INCOMPLETE_RULES=A;exports.DEFAULT_DISABLED_RULES=S;exports.DEFAULT_WCAG_TAGS=b;exports.expect=z;exports.testers=X;
21
+ ${i.message}`,pass:!1}}}return {message:()=>"Class tree matched snapshot.",pass:!0}}catch(l){return {message:()=>y(l),pass:false}}}});function T(e){let o=async()=>{if(await e.getAttribute("aria-expanded")!==null)return e;let r=e.locator("[aria-expanded]").first();return await r.count()>0?r:e},t=async()=>await(await o()).getAttribute("aria-expanded")==="true";return {isOpen:t,open:async(r="click")=>{if(await t())return;if(r==="click"){await e.click();return}await(await o()).press(r);}}}function R({frame:e,root:o}){let t=o??e.locator(".BaselineUI-Editor"),n=t.getByTestId("editor-font-color-button"),r=t.getByTestId("editor-background-color-button"),s=t.getByTestId("editor-add-link-button"),l=t.getByTestId("editor-help-button"),u=t.getByTestId("editor-mention-button"),d=t.getByRole("combobox"),p=e.getByTestId("editor-mention-listbox"),a=e.getByTestId("editor-help-dialog-close-button"),c=e.getByRole("dialog").filter({has:a}),i=e.getByRole("dialog").filter({has:e.getByTestId(/^editor-link-/)});return {root:t,textbox:t.getByRole("textbox"),placeholder:t.getByTestId("editor-placeholder"),toolbar:t.getByRole("toolbar"),boldButton:t.getByTestId("editor-bold-button"),italicButton:t.getByTestId("editor-italic-button"),underlineButton:t.getByTestId("editor-underline-button"),fontColorButton:n,backgroundColorButton:r,openFontColorPicker:T(n).open,openBackgroundColorPicker:T(r).open,addLinkButton:s,linkDialog:i,linkInput:e.getByTestId("editor-link-input"),linkAddButton:e.getByTestId("editor-link-add-button"),linkEditButton:e.getByTestId("editor-link-edit-button"),linkRemoveButton:e.getByTestId("editor-link-remove-button"),linkCancelButton:e.getByTestId("editor-link-cancel-button"),linkSaveButton:e.getByTestId("editor-link-save-button"),openLinkDialog:T(s).open,saveButton:t.getByTestId("editor-save-button"),cancelButton:t.getByTestId("editor-cancel-button"),mentionButton:u,helpButton:l,helpDialog:c,helpDialogCloseButton:a,async openHelpDialog(){await c.isVisible()||await l.click();},mentionInput:d,mentionListbox:p,mentionOption:g=>p.getByRole("option",{name:g}),async startMention(){await d.isVisible()||await u.click();}}}function D({frame:e,trigger:o,variant:t="dropzone"}){let n=e.getByTestId("file-uploader"),r=n.locator('input[type="file"]'),s=o??(t==="button"?n.getByRole("button"):e.getByTestId("file-uploader-dropzone"));return {root:n,button:s,input:r,dropzone:e.getByTestId("file-uploader-dropzone"),errorMessage:n.getByRole("alert"),async upload(l){await r.setInputFiles(l);}}}var v=(e=>{let t=K(e);return e.multiple&&(t=X(t,e.frame)),e.autocomplete&&(t=Q(t,e.frame)),t});function K({frame:e,trigger:o}){let t=o??e.getByTestId("select-button"),n=s=>e.getByRole("option",{name:s}),{open:r}=T(t);return {trigger:t,listbox:e.getByRole("listbox"),option:n,open:r,async selectOption(s){await r(),await n(s).click();}}}function X(e,o){return {...e,selectAllButton:o.getByTestId("select-all-button"),clearButton:o.getByTestId("select-clear-button"),tag:t=>e.trigger.getByRole("row",{name:t}),removeTagButton:t=>e.trigger.getByRole("row",{name:t}).getByRole("button")}}function Q(e,o){let t=o.getByRole("searchbox");return {...e,searchbox:t,async filter(n){await t.fill(n);}}}function Y(e){return {select:((o={})=>v({frame:e,...o})),editor:(o={})=>R({frame:e,...o}),fileUploader:(o={})=>D({frame:e,...o})}}exports.DEFAULT_CRITICAL_INCOMPLETE_RULES=E;exports.DEFAULT_DISABLED_RULES=L;exports.DEFAULT_WCAG_TAGS=w;exports.expect=J;exports.testers=Y;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import {expect,test}from'@playwright/test';import $ from'axe-core';import {mkdir,readFile,writeFile}from'fs/promises';import R from'path';/**
1
+ import {expect,test}from'@playwright/test';import _ from'axe-core';import {mkdir,readFile,writeFile}from'fs/promises';import C from'path';/**
2
2
  * Copyright (c) 2023-2024 PSPDFKit GmbH. All rights reserved.
3
3
  *
4
4
  * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
@@ -7,15 +7,15 @@ import {expect,test}from'@playwright/test';import $ from'axe-core';import {mkdir
7
7
  * This notice may not be removed from this file.
8
8
  *
9
9
  */
10
- var b=["wcag2a","wcag2aa","wcag21a","wcag21aa","best-practice"],S=["landmark-one-main","page-has-heading-one","region","aria-allowed-role","duplicate-id","scrollable-region-focusable"],A=["aria-valid-attr-value","aria-valid-attr","aria-required-attr"];function O(e,t={}){let{prefix:s="BaselineUI-",ignoreHashed:n=false}=t,o=Array.isArray(s)?s:[s];function r(c){return c.split(/[-_]/).some(a=>a.length>=5&&/^[a-z\d]+$/.test(a)&&/[a-z]/.test(a)&&/\d/.test(a))}function l(c){return [...c.classList].filter(a=>o.some(d=>a.startsWith(d))&&(!n||!r(a)))}function u(c,a=false){let d=[],w=c.shadowRoot?c.shadowRoot.children:c.children;for(let h of w){let y=a||h.getAttribute("aria-hidden")==="true",x=l(h),T=u(h,y);x.length>0?d.push({classes:x,children:T,hidden:y}):d.push(...T);}return d}function f(c,a="",d=false){let w=[];for(let h=0;h<c.length;h++){let y=c[h],x=h===c.length-1,T=d?"":x?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",P=d?"":a+(x?" ":"\u2502 "),D=y.classes.join(", ");w.push(a+T+D+(y.hidden?" [aria-hidden]":""),...f(y.children,P));}return w}let p=l(e),i=u(e);return p.length===0&&i.length===0?"":p.length>0?f([{classes:p,children:i,hidden:false}],"",true).join(`
11
- `):f(i,"",true).join(`
12
- `)}var g=e=>{if(e instanceof Error)return e.message;if(typeof e=="string")return e;if(e==null)return "unknown error";try{return JSON.stringify(e)}catch{return "unstringifiable error"}},U=async e=>{let t=typeof e.goto=="function",s=!t&&typeof e.owner=="function";if(t||s)return e.locator("body");let n=e;return await n.first().evaluate(r=>r.tagName?.toLowerCase()==="iframe").catch(()=>false)?n.contentFrame().locator("body"):n},N=async e=>{await e.first().evaluate((t,s)=>{if(window.axe)return;let o=document.createElement("script");o.textContent=s,document.head.append(o);},$.source);},j=["document-title","html-has-lang","html-lang-valid","html-xml-lang-mismatch"],M=(e,t=[])=>{let s=new Set([...S,...t,...e.disableRules??[]]);return {runOnly:{type:"tag",values:[...e.tags??b]},rules:Object.fromEntries([...s].map(n=>[n,{enabled:false}]))}},F=e=>{if(e!==void 0)return typeof e=="string"?[e]:[...e]},W=async(e,t,s)=>{let n=await e.count();if(n===0)throw new Error("toBeAccessible: locator resolved to zero elements; nothing to scan.");await N(e);let o=F(t.include),r=F(t.exclude);return n===1?await e.evaluate(async(l,u)=>{let f=window,p={include:[l,...u.userInclude??[]],exclude:u.userExclude??[]};return await f.axe.run(p,u.runOptions)},{userInclude:o,userExclude:r,runOptions:s}):await e.evaluateAll(async(l,u)=>{let f=window,p={include:[...l,...u.userInclude??[]],exclude:u.userExclude??[]};return await f.axe.run(p,u.runOptions)},{userInclude:o,userExclude:r,runOptions:s})},L="BaselineUI-";function E(e){return e.replaceAll(/\W+/g,"-").replaceAll(/^-|-$/g,"")}function H(e){return Array.isArray(e)?e.length===1&&e[0]===L:e===L}function G(e){return (Array.isArray(e)?e:[e]).join("+")}function V(e,t,s,n,o){let r=t.slice(1).map(l=>E(l));return s&&r.push(E(s)),n!==void 0&&!H(n)&&r.push(E(G(n))),o&&r.push("ignoreHashed"),R.join(e,`${r.join("--")}.txt`)}var z=expect.extend({toBeWithinDelta(e,t,s){return Math.abs(e-t)<=s?{message:()=>`expected ${e} not to be within ${s} of ${t}`,pass:true}:{message:()=>`expected ${e} to be within ${s} of ${t}`,pass:false}},async toBeCalledOnce(e){try{return await expect.poll(()=>e.callCount).toBe(1),{message:()=>"Expected function to be called once.",pass:!0}}catch(t){return {message:()=>g(t),pass:false}}},async toBeCalledTwice(e){try{return await expect.poll(()=>e.callCount).toBe(2),{message:()=>"Expected function to be called twice.",pass:!0}}catch(t){return {message:()=>g(t),pass:false}}},async toBeCalledThrice(e){try{return await expect.poll(()=>e.callCount).toBe(3),{message:()=>"Expected function to be called thrice.",pass:!0}}catch(t){return {message:()=>g(t),pass:false}}},async toBeCalledWith(e,...t){try{return await expect(()=>{for(let[s,n]of t.entries())expect(e.lastCall?.args?.[s]).toStrictEqual(n);}).toPass(),{message:()=>`Expected function to be called with ${t.join(", ")}.`,pass:!0}}catch(s){return {message:()=>g(s),pass:false}}},async toBeCalledWithExactly(e,...t){try{return await expect.poll(()=>e.lastCall?.args).toStrictEqual(t),{message:()=>`Expected function to be called with exactly ${t.join(", ")}.`,pass:!0}}catch(s){return {message:()=>g(s),pass:false}}},toBeCalled(e){try{return expect(e.called).toBeTruthy(),{message:()=>"Expected function to be called.",pass:!0}}catch(t){return {message:()=>g(t),pass:false}}},async toBeCalledTimes(e,t){try{return await expect.poll(()=>e.callCount).toBe(t),{message:()=>`Expected function to be called ${t} times.`,pass:!0}}catch(s){return {message:()=>g(s),pass:false}}},async toBeAccessible(e,t={}){let s=await U(e),n=await s.first().evaluate(i=>{let c=i.ownerDocument?.defaultView;return c!==null&&c!==window.top}).catch(()=>false),o=M(t,n?j:[]),r,l=async()=>{let i=await W(s,t,o),c=t.treatIncompleteAsViolationIds??A,a=[...i.violations,...i.incomplete.filter(d=>c.includes(d.id))];return r={result:i,violations:a},a},u;try{if(t.timeout&&t.timeout>0){let i=expect.poll(l,{timeout:t.timeout});await(this.isNot?i.not.toHaveLength(0):i.toHaveLength(0));}else await l();}catch(i){u=i;}if(!r)throw new Error(`toBeAccessible: axe scan never completed.
13
- ${g(u)}`);if(r.violations.length===0)return {message:()=>"Expected accessibility violations but found none.",pass:true};this.isNot||await test.info().attach(t.attachmentName??"accessibility-scan-results",{body:JSON.stringify(r.result,null,2),contentType:"application/json"});let f=r.violations.map(i=>{let c=i.nodes.map(a=>Array.isArray(a.target)?a.target.join(" "):String(a.target)).join(`
14
- `);return ` \u2022 [${i.id}] ${i.help}
10
+ var w=["wcag2a","wcag2aa","wcag21a","wcag21aa","best-practice"],L=["landmark-one-main","page-has-heading-one","region","aria-allowed-role","duplicate-id","scrollable-region-focusable"],E=["aria-valid-attr-value","aria-valid-attr","aria-required-attr"];function A(e,o={}){let{prefix:t="BaselineUI-",ignoreHashed:n=false}=o,r=Array.isArray(t)?t:[t];function s(c){return c.split(/[-_]/).some(i=>i.length>=5&&/^[a-z\d]+$/.test(i)&&/[a-z]/.test(i)&&/\d/.test(i))}function l(c){return [...c.classList].filter(i=>r.some(g=>i.startsWith(g))&&(!n||!s(i)))}function u(c,i=false){let g=[],b=c.shadowRoot?c.shadowRoot.children:c.children;for(let f of b){let h=i||f.getAttribute("aria-hidden")==="true",B=l(f),x=u(f,h);B.length>0?g.push({classes:B,children:x,hidden:h}):g.push(...x);}return g}function d(c,i="",g=false){let b=[];for(let f=0;f<c.length;f++){let h=c[f],B=f===c.length-1,x=g?"":B?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",P=g?"":i+(B?" ":"\u2502 "),U=h.classes.join(", ");b.push(i+x+U+(h.hidden?" [aria-hidden]":""),...d(h.children,P));}return b}let p=l(e),a=u(e);return p.length===0&&a.length===0?"":p.length>0?d([{classes:p,children:a,hidden:false}],"",true).join(`
11
+ `):d(a,"",true).join(`
12
+ `)}var y=e=>{if(e instanceof Error)return e.message;if(typeof e=="string")return e;if(e==null)return "unknown error";try{return JSON.stringify(e)}catch{return "unstringifiable error"}},j=async e=>{let o=typeof e.goto=="function",t=!o&&typeof e.owner=="function";if(o||t)return e.locator("body");let n=e;return await n.first().evaluate(s=>s.tagName?.toLowerCase()==="iframe").catch(()=>false)?n.contentFrame().locator("body"):n},M=async e=>{await e.first().evaluate((o,t)=>{if(window.axe)return;let r=document.createElement("script");r.textContent=t,document.head.append(r);},_.source);},W=["document-title","html-has-lang","html-lang-valid","html-xml-lang-mismatch"],z=(e,o=[])=>{let t=new Set([...L,...o,...e.disableRules??[]]);return {runOnly:{type:"tag",values:[...e.tags??w]},rules:Object.fromEntries([...t].map(n=>[n,{enabled:false}]))}},F=e=>{if(e!==void 0)return typeof e=="string"?[e]:[...e]},H=async(e,o,t)=>{let n=await e.count();if(n===0)throw new Error("toBeAccessible: locator resolved to zero elements; nothing to scan.");await M(e);let r=F(o.include),s=F(o.exclude);return n===1?await e.evaluate(async(l,u)=>{let d=window,p={include:[l,...u.userInclude??[]],exclude:u.userExclude??[]};return await d.axe.run(p,u.runOptions)},{userInclude:r,userExclude:s,runOptions:t}):await e.evaluateAll(async(l,u)=>{let d=window,p={include:[...l,...u.userInclude??[]],exclude:u.userExclude??[]};return await d.axe.run(p,u.runOptions)},{userInclude:r,userExclude:s,runOptions:t})},O="BaselineUI-";function S(e){return e.replaceAll(/\W+/g,"-").replaceAll(/^-|-$/g,"")}function V(e){return Array.isArray(e)?e.length===1&&e[0]===O:e===O}function G(e){return (Array.isArray(e)?e:[e]).join("+")}function q(e,o,t,n,r){let s=o.slice(1).map(l=>S(l));return t&&s.push(S(t)),n!==void 0&&!V(n)&&s.push(S(G(n))),r&&s.push("ignoreHashed"),C.join(e,`${s.join("--")}.txt`)}var J=expect.extend({toBeWithinDelta(e,o,t){return Math.abs(e-o)<=t?{message:()=>`expected ${e} not to be within ${t} of ${o}`,pass:true}:{message:()=>`expected ${e} to be within ${t} of ${o}`,pass:false}},async toBeCalledOnce(e){try{return await expect.poll(()=>e.callCount).toBe(1),{message:()=>"Expected function to be called once.",pass:!0}}catch(o){return {message:()=>y(o),pass:false}}},async toBeCalledTwice(e){try{return await expect.poll(()=>e.callCount).toBe(2),{message:()=>"Expected function to be called twice.",pass:!0}}catch(o){return {message:()=>y(o),pass:false}}},async toBeCalledThrice(e){try{return await expect.poll(()=>e.callCount).toBe(3),{message:()=>"Expected function to be called thrice.",pass:!0}}catch(o){return {message:()=>y(o),pass:false}}},async toBeCalledWith(e,...o){try{return await expect(()=>{for(let[t,n]of o.entries())expect(e.lastCall?.args?.[t]).toStrictEqual(n);}).toPass(),{message:()=>`Expected function to be called with ${o.join(", ")}.`,pass:!0}}catch(t){return {message:()=>y(t),pass:false}}},async toBeCalledWithExactly(e,...o){try{return await expect.poll(()=>e.lastCall?.args).toStrictEqual(o),{message:()=>`Expected function to be called with exactly ${o.join(", ")}.`,pass:!0}}catch(t){return {message:()=>y(t),pass:false}}},toBeCalled(e){try{return expect(e.called).toBeTruthy(),{message:()=>"Expected function to be called.",pass:!0}}catch(o){return {message:()=>y(o),pass:false}}},async toBeCalledTimes(e,o){try{return await expect.poll(()=>e.callCount).toBe(o),{message:()=>`Expected function to be called ${o} times.`,pass:!0}}catch(t){return {message:()=>y(t),pass:false}}},async toBeAccessible(e,o={}){let t=await j(e),n=await t.first().evaluate(a=>{let c=a.ownerDocument?.defaultView;return c!==null&&c!==window.top}).catch(()=>false),r=z(o,n?W:[]),s,l=async()=>{let a=await H(t,o,r),c=o.treatIncompleteAsViolationIds??E,i=[...a.violations,...a.incomplete.filter(g=>c.includes(g.id))];return s={result:a,violations:i},i},u;try{if(o.timeout&&o.timeout>0){let a=expect.poll(l,{timeout:o.timeout});await(this.isNot?a.not.toHaveLength(0):a.toHaveLength(0));}else await l();}catch(a){u=a;}if(!s)throw new Error(`toBeAccessible: axe scan never completed.
13
+ ${y(u)}`);if(s.violations.length===0)return {message:()=>"Expected accessibility violations but found none.",pass:true};this.isNot||await test.info().attach(o.attachmentName??"accessibility-scan-results",{body:JSON.stringify(s.result,null,2),contentType:"application/json"});let d=s.violations.map(a=>{let c=a.nodes.map(i=>Array.isArray(i.target)?i.target.join(" "):String(i.target)).join(`
14
+ `);return ` \u2022 [${a.id}] ${a.help}
15
15
  ${c}
16
- ${i.helpUrl??""}`}).join(`
17
- `),p=r.violations.length;return {message:()=>`Found ${p} accessibility violation${p===1?"":"s"}:
18
- ${f}`,pass:false}},async toMatchClassTree(e,t,s={}){let{prefix:n=L,ignoreHashed:o=false}=s,r=await e.evaluate(O,{prefix:n,ignoreHashed:o});if(!r){let l=Array.isArray(n)?n.map(u=>`${u}*`).join(" / "):`${n}*`;return {message:()=>`No ${l} classes found in the DOM tree.`,pass:false}}try{let l=`${r}
19
- `,u=test.info();if(u.config.ignoreSnapshots)return {message:()=>"Class tree snapshot check skipped.",pass:!0};let p=V(u.project.snapshotDir,u.titlePath,t,n,o),i=u.config.updateSnapshots;await mkdir(R.dirname(p),{recursive:!0});let c;try{c=await readFile(p,"utf8");}catch(a){if(a.code==="ENOENT"&&i!=="none")return await writeFile(p,l),{message:()=>"Class tree snapshot created.",pass:!0};throw a}if(c!==l){if(i==="all"||i==="changed")return await writeFile(p,l),{message:()=>"Class tree snapshot updated.",pass:!0};try{expect(l).toBe(c);}catch(a){return {message:()=>`Class tree snapshot mismatch at ${p}
16
+ ${a.helpUrl??""}`}).join(`
17
+ `),p=s.violations.length;return {message:()=>`Found ${p} accessibility violation${p===1?"":"s"}:
18
+ ${d}`,pass:false}},async toMatchClassTree(e,o,t={}){let{prefix:n=O,ignoreHashed:r=false}=t,s=await e.evaluate(A,{prefix:n,ignoreHashed:r});if(!s){let l=Array.isArray(n)?n.map(u=>`${u}*`).join(" / "):`${n}*`;return {message:()=>`No ${l} classes found in the DOM tree.`,pass:false}}try{let l=`${s}
19
+ `,u=test.info();if(u.config.ignoreSnapshots)return {message:()=>"Class tree snapshot check skipped.",pass:!0};let p=q(u.project.snapshotDir,u.titlePath,o,n,r),a=u.config.updateSnapshots;await mkdir(C.dirname(p),{recursive:!0});let c;try{c=await readFile(p,"utf8");}catch(i){if(i.code==="ENOENT"&&a!=="none")return await writeFile(p,l),{message:()=>"Class tree snapshot created.",pass:!0};throw i}if(c!==l){if(a==="all"||a==="changed")return await writeFile(p,l),{message:()=>"Class tree snapshot updated.",pass:!0};try{expect(l).toBe(c);}catch(i){return {message:()=>`Class tree snapshot mismatch at ${p}
20
20
 
21
- ${a.message}`,pass:!1}}}return {message:()=>"Class tree matched snapshot.",pass:!0}}catch(l){return {message:()=>g(l),pass:false}}}});function I(e){let t=async()=>{if(await e.getAttribute("aria-expanded")!==null)return e;let o=e.locator("[aria-expanded]").first();return await o.count()>0?o:e},s=async()=>await(await t()).getAttribute("aria-expanded")==="true";return {isOpen:s,open:async(o="click")=>{if(await s())return;if(o==="click"){await e.click();return}await(await t()).press(o);}}}var _=(e=>{let s=q(e);return e.multiple&&(s=J(s,e.frame)),e.autocomplete&&(s=K(s,e.frame)),s});function q({frame:e,trigger:t}){let s=t??e.getByTestId("select-button"),n=r=>e.getByRole("option",{name:r}),{open:o}=I(s);return {trigger:s,listbox:e.getByRole("listbox"),option:n,open:o,async selectOption(r){await o(),await n(r).click();}}}function J(e,t){return {...e,selectAllButton:t.getByTestId("select-all-button"),clearButton:t.getByTestId("select-clear-button"),tag:s=>e.trigger.getByRole("row",{name:s}),removeTagButton:s=>e.trigger.getByRole("row",{name:s}).getByRole("button")}}function K(e,t){let s=t.getByRole("searchbox");return {...e,searchbox:s,async filter(n){await s.fill(n);}}}function X(e){return {select:((t={})=>_({frame:e,...t}))}}export{A as DEFAULT_CRITICAL_INCOMPLETE_RULES,S as DEFAULT_DISABLED_RULES,b as DEFAULT_WCAG_TAGS,z as expect,X as testers};
21
+ ${i.message}`,pass:!1}}}return {message:()=>"Class tree matched snapshot.",pass:!0}}catch(l){return {message:()=>y(l),pass:false}}}});function T(e){let o=async()=>{if(await e.getAttribute("aria-expanded")!==null)return e;let r=e.locator("[aria-expanded]").first();return await r.count()>0?r:e},t=async()=>await(await o()).getAttribute("aria-expanded")==="true";return {isOpen:t,open:async(r="click")=>{if(await t())return;if(r==="click"){await e.click();return}await(await o()).press(r);}}}function R({frame:e,root:o}){let t=o??e.locator(".BaselineUI-Editor"),n=t.getByTestId("editor-font-color-button"),r=t.getByTestId("editor-background-color-button"),s=t.getByTestId("editor-add-link-button"),l=t.getByTestId("editor-help-button"),u=t.getByTestId("editor-mention-button"),d=t.getByRole("combobox"),p=e.getByTestId("editor-mention-listbox"),a=e.getByTestId("editor-help-dialog-close-button"),c=e.getByRole("dialog").filter({has:a}),i=e.getByRole("dialog").filter({has:e.getByTestId(/^editor-link-/)});return {root:t,textbox:t.getByRole("textbox"),placeholder:t.getByTestId("editor-placeholder"),toolbar:t.getByRole("toolbar"),boldButton:t.getByTestId("editor-bold-button"),italicButton:t.getByTestId("editor-italic-button"),underlineButton:t.getByTestId("editor-underline-button"),fontColorButton:n,backgroundColorButton:r,openFontColorPicker:T(n).open,openBackgroundColorPicker:T(r).open,addLinkButton:s,linkDialog:i,linkInput:e.getByTestId("editor-link-input"),linkAddButton:e.getByTestId("editor-link-add-button"),linkEditButton:e.getByTestId("editor-link-edit-button"),linkRemoveButton:e.getByTestId("editor-link-remove-button"),linkCancelButton:e.getByTestId("editor-link-cancel-button"),linkSaveButton:e.getByTestId("editor-link-save-button"),openLinkDialog:T(s).open,saveButton:t.getByTestId("editor-save-button"),cancelButton:t.getByTestId("editor-cancel-button"),mentionButton:u,helpButton:l,helpDialog:c,helpDialogCloseButton:a,async openHelpDialog(){await c.isVisible()||await l.click();},mentionInput:d,mentionListbox:p,mentionOption:g=>p.getByRole("option",{name:g}),async startMention(){await d.isVisible()||await u.click();}}}function D({frame:e,trigger:o,variant:t="dropzone"}){let n=e.getByTestId("file-uploader"),r=n.locator('input[type="file"]'),s=o??(t==="button"?n.getByRole("button"):e.getByTestId("file-uploader-dropzone"));return {root:n,button:s,input:r,dropzone:e.getByTestId("file-uploader-dropzone"),errorMessage:n.getByRole("alert"),async upload(l){await r.setInputFiles(l);}}}var v=(e=>{let t=K(e);return e.multiple&&(t=X(t,e.frame)),e.autocomplete&&(t=Q(t,e.frame)),t});function K({frame:e,trigger:o}){let t=o??e.getByTestId("select-button"),n=s=>e.getByRole("option",{name:s}),{open:r}=T(t);return {trigger:t,listbox:e.getByRole("listbox"),option:n,open:r,async selectOption(s){await r(),await n(s).click();}}}function X(e,o){return {...e,selectAllButton:o.getByTestId("select-all-button"),clearButton:o.getByTestId("select-clear-button"),tag:t=>e.trigger.getByRole("row",{name:t}),removeTagButton:t=>e.trigger.getByRole("row",{name:t}).getByRole("button")}}function Q(e,o){let t=o.getByRole("searchbox");return {...e,searchbox:t,async filter(n){await t.fill(n);}}}function Y(e){return {select:((o={})=>v({frame:e,...o})),editor:(o={})=>R({frame:e,...o}),fileUploader:(o={})=>D({frame:e,...o})}}export{E as DEFAULT_CRITICAL_INCOMPLETE_RULES,L as DEFAULT_DISABLED_RULES,w as DEFAULT_WCAG_TAGS,J as expect,Y as testers};