@ember-joinery/test-support 0.0.0-stage → 1.1.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/CHANGELOG.md +574 -0
- package/LICENSE.md +9 -0
- package/NOTICE +532 -0
- package/README.md +356 -2
- package/addon-main.cjs +4 -0
- package/dist/-private/checkable.d.ts +21 -0
- package/dist/-private/checkable.d.ts.map +1 -0
- package/dist/-private/checkable.js +80 -0
- package/dist/-private/control.d.ts +18 -0
- package/dist/-private/control.d.ts.map +1 -0
- package/dist/-private/control.js +55 -0
- package/dist/-private/menu.d.ts +145 -0
- package/dist/-private/menu.d.ts.map +1 -0
- package/dist/-private/menu.js +322 -0
- package/dist/-private/overlay.d.ts +9 -0
- package/dist/-private/overlay.d.ts.map +1 -0
- package/dist/-private/overlay.js +39 -0
- package/dist/-private/showing.d.ts +7 -0
- package/dist/-private/showing.d.ts.map +1 -0
- package/dist/-private/showing.js +10 -0
- package/dist/-private/size.d.ts +10 -0
- package/dist/-private/size.d.ts.map +1 -0
- package/dist/-private/size.js +24 -0
- package/dist/-private/tree.d.ts +34 -0
- package/dist/-private/tree.d.ts.map +1 -0
- package/dist/-private/tree.js +80 -0
- package/dist/accordion.d.ts +62 -0
- package/dist/accordion.d.ts.map +1 -0
- package/dist/accordion.js +112 -0
- package/dist/alert-dialog.d.ts +24 -0
- package/dist/alert-dialog.d.ts.map +1 -0
- package/dist/alert-dialog.js +37 -0
- package/dist/alert.d.ts +27 -0
- package/dist/alert.d.ts.map +1 -0
- package/dist/alert.js +43 -0
- package/dist/app-shell.d.ts +43 -0
- package/dist/app-shell.d.ts.map +1 -0
- package/dist/app-shell.js +78 -0
- package/dist/aspect-ratio.d.ts +21 -0
- package/dist/aspect-ratio.d.ts.map +1 -0
- package/dist/aspect-ratio.js +30 -0
- package/dist/attachment.d.ts +86 -0
- package/dist/attachment.d.ts.map +1 -0
- package/dist/attachment.js +156 -0
- package/dist/avatar.d.ts +65 -0
- package/dist/avatar.d.ts.map +1 -0
- package/dist/avatar.js +106 -0
- package/dist/badge.d.ts +29 -0
- package/dist/badge.d.ts.map +1 -0
- package/dist/badge.js +49 -0
- package/dist/breadcrumb.d.ts +36 -0
- package/dist/breadcrumb.d.ts.map +1 -0
- package/dist/breadcrumb.js +80 -0
- package/dist/bubble.d.ts +56 -0
- package/dist/bubble.d.ts.map +1 -0
- package/dist/bubble.js +94 -0
- package/dist/button-group.d.ts +34 -0
- package/dist/button-group.d.ts.map +1 -0
- package/dist/button-group.js +62 -0
- package/dist/button.d.ts +37 -0
- package/dist/button.d.ts.map +1 -0
- package/dist/button.js +77 -0
- package/dist/calendar.d.ts +115 -0
- package/dist/calendar.d.ts.map +1 -0
- package/dist/calendar.js +276 -0
- package/dist/card.d.ts +31 -0
- package/dist/card.d.ts.map +1 -0
- package/dist/card.js +49 -0
- package/dist/checkbox.d.ts +46 -0
- package/dist/checkbox.d.ts.map +1 -0
- package/dist/checkbox.js +84 -0
- package/dist/child.d.ts +29 -0
- package/dist/child.d.ts.map +1 -0
- package/dist/child.js +27 -0
- package/dist/collapsible.d.ts +44 -0
- package/dist/collapsible.d.ts.map +1 -0
- package/dist/collapsible.js +83 -0
- package/dist/color-scheme.d.ts +44 -0
- package/dist/color-scheme.d.ts.map +1 -0
- package/dist/color-scheme.js +123 -0
- package/dist/combobox.d.ts +114 -0
- package/dist/combobox.d.ts.map +1 -0
- package/dist/combobox.js +293 -0
- package/dist/command.d.ts +92 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/command.js +183 -0
- package/dist/context-menu.d.ts +37 -0
- package/dist/context-menu.d.ts.map +1 -0
- package/dist/context-menu.js +59 -0
- package/dist/date-picker.d.ts +48 -0
- package/dist/date-picker.d.ts.map +1 -0
- package/dist/date-picker.js +136 -0
- package/dist/dialog.d.ts +64 -0
- package/dist/dialog.d.ts.map +1 -0
- package/dist/dialog.js +142 -0
- package/dist/drawer.d.ts +63 -0
- package/dist/drawer.d.ts.map +1 -0
- package/dist/drawer.js +136 -0
- package/dist/dropdown-menu.d.ts +35 -0
- package/dist/dropdown-menu.d.ts.map +1 -0
- package/dist/dropdown-menu.js +49 -0
- package/dist/empty.d.ts +29 -0
- package/dist/empty.d.ts.map +1 -0
- package/dist/empty.js +47 -0
- package/dist/field.d.ts +86 -0
- package/dist/field.d.ts.map +1 -0
- package/dist/field.js +150 -0
- package/dist/file-drop.d.ts +74 -0
- package/dist/file-drop.d.ts.map +1 -0
- package/dist/file-drop.js +137 -0
- package/dist/focus.d.ts +54 -0
- package/dist/focus.d.ts.map +1 -0
- package/dist/focus.js +174 -0
- package/dist/harness.d.ts +90 -0
- package/dist/harness.d.ts.map +1 -0
- package/dist/harness.js +189 -0
- package/dist/heading.d.ts +16 -0
- package/dist/heading.d.ts.map +1 -0
- package/dist/heading.js +19 -0
- package/dist/hero.d.ts +21 -0
- package/dist/hero.d.ts.map +1 -0
- package/dist/hero.js +28 -0
- package/dist/hover-card.d.ts +46 -0
- package/dist/hover-card.d.ts.map +1 -0
- package/dist/hover-card.js +85 -0
- package/dist/icon.d.ts +10 -0
- package/dist/icon.d.ts.map +1 -0
- package/dist/icon.js +13 -0
- package/dist/index.d.ts +98 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +99 -0
- package/dist/input-group.d.ts +55 -0
- package/dist/input-group.d.ts.map +1 -0
- package/dist/input-group.js +103 -0
- package/dist/input-otp.d.ts +103 -0
- package/dist/input-otp.d.ts.map +1 -0
- package/dist/input-otp.js +293 -0
- package/dist/input.d.ts +53 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/input.js +90 -0
- package/dist/inspector.d.ts +47 -0
- package/dist/inspector.d.ts.map +1 -0
- package/dist/inspector.js +97 -0
- package/dist/item.d.ts +63 -0
- package/dist/item.d.ts.map +1 -0
- package/dist/item.js +104 -0
- package/dist/kbd.d.ts +28 -0
- package/dist/kbd.d.ts.map +1 -0
- package/dist/kbd.js +36 -0
- package/dist/keys.d.ts +20 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +32 -0
- package/dist/label.d.ts +24 -0
- package/dist/label.d.ts.map +1 -0
- package/dist/label.js +39 -0
- package/dist/layers.d.ts +42 -0
- package/dist/layers.d.ts.map +1 -0
- package/dist/layers.js +70 -0
- package/dist/link.d.ts +44 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +60 -0
- package/dist/marker.d.ts +42 -0
- package/dist/marker.d.ts.map +1 -0
- package/dist/marker.js +73 -0
- package/dist/menubar.d.ts +76 -0
- package/dist/menubar.d.ts.map +1 -0
- package/dist/menubar.js +139 -0
- package/dist/message-scroller.d.ts +101 -0
- package/dist/message-scroller.d.ts.map +1 -0
- package/dist/message-scroller.js +215 -0
- package/dist/message.d.ts +48 -0
- package/dist/message.d.ts.map +1 -0
- package/dist/message.js +72 -0
- package/dist/native-form.d.ts +44 -0
- package/dist/native-form.d.ts.map +1 -0
- package/dist/native-form.js +111 -0
- package/dist/native-select.d.ts +56 -0
- package/dist/native-select.d.ts.map +1 -0
- package/dist/native-select.js +100 -0
- package/dist/navigation-bar.d.ts +30 -0
- package/dist/navigation-bar.d.ts.map +1 -0
- package/dist/navigation-bar.js +52 -0
- package/dist/navigation-menu.d.ts +97 -0
- package/dist/navigation-menu.d.ts.map +1 -0
- package/dist/navigation-menu.js +207 -0
- package/dist/navigation-stack.d.ts +36 -0
- package/dist/navigation-stack.d.ts.map +1 -0
- package/dist/navigation-stack.js +67 -0
- package/dist/observers.d.ts +21 -0
- package/dist/observers.d.ts.map +1 -0
- package/dist/observers.js +34 -0
- package/dist/page.d.ts +38 -0
- package/dist/page.d.ts.map +1 -0
- package/dist/page.js +68 -0
- package/dist/pagination.d.ts +39 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +71 -0
- package/dist/pointer.d.ts +38 -0
- package/dist/pointer.d.ts.map +1 -0
- package/dist/pointer.js +82 -0
- package/dist/popover.d.ts +50 -0
- package/dist/popover.d.ts.map +1 -0
- package/dist/popover.js +90 -0
- package/dist/progress.d.ts +38 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +81 -0
- package/dist/pull-to-refresh.d.ts +40 -0
- package/dist/pull-to-refresh.d.ts.map +1 -0
- package/dist/pull-to-refresh.js +65 -0
- package/dist/questionnaire.d.ts +117 -0
- package/dist/questionnaire.d.ts.map +1 -0
- package/dist/questionnaire.js +240 -0
- package/dist/radio-group.d.ts +53 -0
- package/dist/radio-group.d.ts.map +1 -0
- package/dist/radio-group.js +95 -0
- package/dist/rating.d.ts +67 -0
- package/dist/rating.d.ts.map +1 -0
- package/dist/rating.js +160 -0
- package/dist/resizable.d.ts +76 -0
- package/dist/resizable.d.ts.map +1 -0
- package/dist/resizable.js +138 -0
- package/dist/routing.d.ts +36 -0
- package/dist/routing.d.ts.map +1 -0
- package/dist/routing.js +50 -0
- package/dist/roving-focus.d.ts +38 -0
- package/dist/roving-focus.d.ts.map +1 -0
- package/dist/roving-focus.js +60 -0
- package/dist/scroll-area.d.ts +58 -0
- package/dist/scroll-area.d.ts.map +1 -0
- package/dist/scroll-area.js +153 -0
- package/dist/scroller.d.ts +41 -0
- package/dist/scroller.d.ts.map +1 -0
- package/dist/scroller.js +65 -0
- package/dist/select.d.ts +98 -0
- package/dist/select.d.ts.map +1 -0
- package/dist/select.js +203 -0
- package/dist/selectors.d.ts +44 -0
- package/dist/selectors.d.ts.map +1 -0
- package/dist/selectors.js +63 -0
- package/dist/send-pointer.d.ts +17 -0
- package/dist/send-pointer.d.ts.map +1 -0
- package/dist/send-pointer.js +35 -0
- package/dist/separator.d.ts +26 -0
- package/dist/separator.d.ts.map +1 -0
- package/dist/separator.js +40 -0
- package/dist/shadowed.d.ts +55 -0
- package/dist/shadowed.d.ts.map +1 -0
- package/dist/shadowed.js +97 -0
- package/dist/sheet.d.ts +14 -0
- package/dist/sheet.d.ts.map +1 -0
- package/dist/sheet.js +15 -0
- package/dist/sidebar.d.ts +159 -0
- package/dist/sidebar.d.ts.map +1 -0
- package/dist/sidebar.js +299 -0
- package/dist/skeleton.d.ts +18 -0
- package/dist/skeleton.d.ts.map +1 -0
- package/dist/skeleton.js +25 -0
- package/dist/slider.d.ts +66 -0
- package/dist/slider.d.ts.map +1 -0
- package/dist/slider.js +155 -0
- package/dist/spinner.d.ts +10 -0
- package/dist/spinner.d.ts.map +1 -0
- package/dist/spinner.js +13 -0
- package/dist/split-view.d.ts +77 -0
- package/dist/split-view.d.ts.map +1 -0
- package/dist/split-view.js +145 -0
- package/dist/status-bar.d.ts +25 -0
- package/dist/status-bar.d.ts.map +1 -0
- package/dist/status-bar.js +42 -0
- package/dist/sticky-footer.d.ts +33 -0
- package/dist/sticky-footer.d.ts.map +1 -0
- package/dist/sticky-footer.js +65 -0
- package/dist/switch.d.ts +44 -0
- package/dist/switch.d.ts.map +1 -0
- package/dist/switch.js +77 -0
- package/dist/tab-bar.d.ts +38 -0
- package/dist/tab-bar.d.ts.map +1 -0
- package/dist/tab-bar.js +78 -0
- package/dist/table.d.ts +41 -0
- package/dist/table.d.ts.map +1 -0
- package/dist/table.js +100 -0
- package/dist/tabs.d.ts +66 -0
- package/dist/tabs.d.ts.map +1 -0
- package/dist/tabs.js +149 -0
- package/dist/test-hooks.d.ts +9 -0
- package/dist/test-hooks.d.ts.map +1 -0
- package/dist/test-hooks.js +1 -0
- package/dist/textarea.d.ts +47 -0
- package/dist/textarea.d.ts.map +1 -0
- package/dist/textarea.js +78 -0
- package/dist/title-bar.d.ts +43 -0
- package/dist/title-bar.d.ts.map +1 -0
- package/dist/title-bar.js +74 -0
- package/dist/toaster.d.ts +172 -0
- package/dist/toaster.d.ts.map +1 -0
- package/dist/toaster.js +307 -0
- package/dist/toggle-group.d.ts +51 -0
- package/dist/toggle-group.d.ts.map +1 -0
- package/dist/toggle-group.js +97 -0
- package/dist/toggle.d.ts +21 -0
- package/dist/toggle.d.ts.map +1 -0
- package/dist/toggle.js +26 -0
- package/dist/toolbar.d.ts +40 -0
- package/dist/toolbar.d.ts.map +1 -0
- package/dist/toolbar.js +67 -0
- package/dist/tooltip.d.ts +48 -0
- package/dist/tooltip.d.ts.map +1 -0
- package/dist/tooltip.js +91 -0
- package/dist/trace.d.ts +118 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/trace.js +196 -0
- package/dist/translator.d.ts +34 -0
- package/dist/translator.d.ts.map +1 -0
- package/dist/translator.js +75 -0
- package/dist/window-frame.d.ts +40 -0
- package/dist/window-frame.d.ts.map +1 -0
- package/dist/window-frame.js +66 -0
- package/dist/zoetrope.d.ts +51 -0
- package/dist/zoetrope.d.ts.map +1 -0
- package/dist/zoetrope.js +94 -0
- package/package.json +68 -3
package/dist/toggle.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ButtonHarness } from "./button.js";
|
|
2
|
+
/**
|
|
3
|
+
* Drives a `<Toggle>` from `@ember-joinery/ember`, the primitives' `Toggle`, or an element made
|
|
4
|
+
* a toggle with `asToggle`. It is a button (every `ButtonHarness` member works: `variant` is
|
|
5
|
+
* `default` or `outline`, `size` `default`, `sm` or `lg`), whose pressed state is read from
|
|
6
|
+
* `aria-pressed`.
|
|
7
|
+
*
|
|
8
|
+
* const bold = new ToggleHarness('bold') // <Toggle @name="bold">
|
|
9
|
+
* await bold.toggle()
|
|
10
|
+
* assert.true(bold.isPressed)
|
|
11
|
+
*/
|
|
12
|
+
export class ToggleHarness extends ButtonHarness {
|
|
13
|
+
static component = 'toggle';
|
|
14
|
+
/** Whether it is pressed (`aria-pressed="true"`). */
|
|
15
|
+
get isPressed() {
|
|
16
|
+
return this.element.getAttribute('aria-pressed') === 'true';
|
|
17
|
+
}
|
|
18
|
+
/** Radix's `data-state`: `on` or `off`. */
|
|
19
|
+
get state() {
|
|
20
|
+
return this.element.getAttribute('data-state');
|
|
21
|
+
}
|
|
22
|
+
/** Presses it, as a click does: on becomes off, and off on. */
|
|
23
|
+
async toggle() {
|
|
24
|
+
await this.click();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
import { type KeyModifiers } from './focus.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Drives a `<Toolbar>` from `@ember-joinery/ember`: its controls (each element with the
|
|
5
|
+
* toolbar's `item` modifier), which one Tab stops on, and the keys that move between them.
|
|
6
|
+
*
|
|
7
|
+
* const toolbar = new ToolbarHarness('format') // <Toolbar @name="format">
|
|
8
|
+
* assert.deepEqual(toolbar.labels, ['Bold', 'Italic', 'Share'])
|
|
9
|
+
* await toolbar.focus()
|
|
10
|
+
* await toolbar.press('ArrowRight')
|
|
11
|
+
* assert.strictEqual(toolbar.focusedLabel, 'Italic')
|
|
12
|
+
*/
|
|
13
|
+
export declare class ToolbarHarness extends Harness {
|
|
14
|
+
static component: string;
|
|
15
|
+
/** Its accessible name: `aria-label` or `aria-labelledby`. */
|
|
16
|
+
get label(): string;
|
|
17
|
+
/** Its orientation (`aria-orientation`): `horizontal` or `vertical`. */
|
|
18
|
+
get orientation(): string | null;
|
|
19
|
+
/** Its `@size`: `sm`, `default` or `lg`. */
|
|
20
|
+
get size(): string | null;
|
|
21
|
+
/** Its controls, in order: every element with the toolbar's `item` modifier. */
|
|
22
|
+
get controls(): HTMLElement[];
|
|
23
|
+
/** Each control's accessible name, in order. */
|
|
24
|
+
get labels(): string[];
|
|
25
|
+
/** The control Tab enters the toolbar on, or `null` before any has had focus. */
|
|
26
|
+
get tabStop(): HTMLElement | null;
|
|
27
|
+
/** The control with focus, or `null`. */
|
|
28
|
+
get focused(): HTMLElement | null;
|
|
29
|
+
/** The accessible name of the control with focus, or `''`. */
|
|
30
|
+
get focusedLabel(): string;
|
|
31
|
+
/** Its groups, in order. */
|
|
32
|
+
get groups(): HTMLElement[];
|
|
33
|
+
/** Its separators, in order. */
|
|
34
|
+
get separators(): HTMLElement[];
|
|
35
|
+
/** Focuses the toolbar as Tab does: the control last focused, or the first. */
|
|
36
|
+
focus(): Promise<void>;
|
|
37
|
+
/** Presses a key on the focused control: an arrow, Home or End moves focus. */
|
|
38
|
+
press(key: string, modifiers?: KeyModifiers): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=toolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbar.d.ts","sourceRoot":"","sources":["../src/toolbar.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,YAAY,CAAA;AAGxD;;;;;;;;;GASG;AACH,qBAAa,cAAe,SAAQ,OAAO;IACzC,OAAgB,SAAS,SAAY;IAErC,8DAA8D;IAC9D,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,wEAAwE;IACxE,IAAI,WAAW,IAAI,MAAM,GAAG,IAAI,CAE/B;IAED,4CAA4C;IAC5C,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAExB;IAED,gFAAgF;IAChF,IAAI,QAAQ,IAAI,WAAW,EAAE,CAI5B;IAED,gDAAgD;IAChD,IAAI,MAAM,IAAI,MAAM,EAAE,CAErB;IAED,iFAAiF;IACjF,IAAI,OAAO,IAAI,WAAW,GAAG,IAAI,CAEhC;IAED,yCAAyC;IACzC,IAAI,OAAO,IAAI,WAAW,GAAG,IAAI,CAGhC;IAED,8DAA8D;IAC9D,IAAI,YAAY,IAAI,MAAM,CAGzB;IAED,4BAA4B;IAC5B,IAAI,MAAM,IAAI,WAAW,EAAE,CAE1B;IAED,gCAAgC;IAChC,IAAI,UAAU,IAAI,WAAW,EAAE,CAE9B;IAED,+EAA+E;IACzE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,+EAA+E;IACzE,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;CAGtE"}
|
package/dist/toolbar.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { focus } from '@ember/test-helpers';
|
|
2
|
+
import { Harness } from "./harness.js";
|
|
3
|
+
import { pressKey } from "./focus.js";
|
|
4
|
+
import { accessibleName } from "./-private/checkable.js";
|
|
5
|
+
/**
|
|
6
|
+
* Drives a `<Toolbar>` from `@ember-joinery/ember`: its controls (each element with the
|
|
7
|
+
* toolbar's `item` modifier), which one Tab stops on, and the keys that move between them.
|
|
8
|
+
*
|
|
9
|
+
* const toolbar = new ToolbarHarness('format') // <Toolbar @name="format">
|
|
10
|
+
* assert.deepEqual(toolbar.labels, ['Bold', 'Italic', 'Share'])
|
|
11
|
+
* await toolbar.focus()
|
|
12
|
+
* await toolbar.press('ArrowRight')
|
|
13
|
+
* assert.strictEqual(toolbar.focusedLabel, 'Italic')
|
|
14
|
+
*/
|
|
15
|
+
export class ToolbarHarness extends Harness {
|
|
16
|
+
static component = 'toolbar';
|
|
17
|
+
/** Its accessible name: `aria-label` or `aria-labelledby`. */
|
|
18
|
+
get label() {
|
|
19
|
+
return accessibleName(this.element);
|
|
20
|
+
}
|
|
21
|
+
/** Its orientation (`aria-orientation`): `horizontal` or `vertical`. */
|
|
22
|
+
get orientation() {
|
|
23
|
+
return this.element.getAttribute('aria-orientation');
|
|
24
|
+
}
|
|
25
|
+
/** Its `@size`: `sm`, `default` or `lg`. */
|
|
26
|
+
get size() {
|
|
27
|
+
return this.element.getAttribute('data-size');
|
|
28
|
+
}
|
|
29
|
+
/** Its controls, in order: every element with the toolbar's `item` modifier. */
|
|
30
|
+
get controls() {
|
|
31
|
+
return [...this.element.querySelectorAll('[tabindex]')].filter(control => control !== this.element);
|
|
32
|
+
}
|
|
33
|
+
/** Each control's accessible name, in order. */
|
|
34
|
+
get labels() {
|
|
35
|
+
return this.controls.map(control => accessibleName(control));
|
|
36
|
+
}
|
|
37
|
+
/** The control Tab enters the toolbar on, or `null` before any has had focus. */
|
|
38
|
+
get tabStop() {
|
|
39
|
+
return this.controls.find(control => control.getAttribute('tabindex') === '0') ?? null;
|
|
40
|
+
}
|
|
41
|
+
/** The control with focus, or `null`. */
|
|
42
|
+
get focused() {
|
|
43
|
+
const active = this.element.ownerDocument.activeElement;
|
|
44
|
+
return this.controls.find(control => control === active) ?? null;
|
|
45
|
+
}
|
|
46
|
+
/** The accessible name of the control with focus, or `''`. */
|
|
47
|
+
get focusedLabel() {
|
|
48
|
+
const focused = this.focused;
|
|
49
|
+
return focused ? accessibleName(focused) : '';
|
|
50
|
+
}
|
|
51
|
+
/** Its groups, in order. */
|
|
52
|
+
get groups() {
|
|
53
|
+
return this.parts('group');
|
|
54
|
+
}
|
|
55
|
+
/** Its separators, in order. */
|
|
56
|
+
get separators() {
|
|
57
|
+
return this.parts('separator');
|
|
58
|
+
}
|
|
59
|
+
/** Focuses the toolbar as Tab does: the control last focused, or the first. */
|
|
60
|
+
async focus() {
|
|
61
|
+
await focus(this.tabStop ?? this.controls[0]);
|
|
62
|
+
}
|
|
63
|
+
/** Presses a key on the focused control: an arrow, Home or End moves focus. */
|
|
64
|
+
async press(key, modifiers = {}) {
|
|
65
|
+
await pressKey(key, modifiers);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
import { type HoverOptions } from './pointer.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Drives a `<Tooltip>` from `@ember-joinery/ember` or `@ember-joinery/primitives/tooltip`. It
|
|
5
|
+
* reads the state from the trigger's `data-state` and what the trigger's `aria-describedby`
|
|
6
|
+
* names, and acts as a user does: resting the pointer on the trigger, moving it away, focus.
|
|
7
|
+
*
|
|
8
|
+
* const tooltip = new TooltipHarness()
|
|
9
|
+
* await tooltip.hover() // waits out the open delay
|
|
10
|
+
* assert.strictEqual(tooltip.description, 'Add to library')
|
|
11
|
+
* await tooltip.unhover()
|
|
12
|
+
*/
|
|
13
|
+
export declare class TooltipHarness extends Harness {
|
|
14
|
+
static component: string;
|
|
15
|
+
/** The trigger: the `Trigger` part, or your own element with the `trigger` modifier. */
|
|
16
|
+
get trigger(): HTMLElement;
|
|
17
|
+
/** The tooltip, or `null` while it isn't rendered. */
|
|
18
|
+
get content(): HTMLElement | null;
|
|
19
|
+
/** How it is open, from the trigger's `data-state`: `delayed-open`, `instant-open` or `closed`. */
|
|
20
|
+
get state(): string | null;
|
|
21
|
+
/** Whether it is open. */
|
|
22
|
+
get isOpen(): boolean;
|
|
23
|
+
/** Whether the tooltip is showing in the browser's top layer. */
|
|
24
|
+
get isShown(): boolean;
|
|
25
|
+
/** The trigger's accessible description while it is open: what a screen reader announces. */
|
|
26
|
+
get description(): string;
|
|
27
|
+
/** The tooltip's text, whitespace collapsed. */
|
|
28
|
+
get text(): string;
|
|
29
|
+
/** The side it was placed on, after any flip (`data-side`). */
|
|
30
|
+
get side(): string | null;
|
|
31
|
+
/** Its alignment along that side (`data-align`). */
|
|
32
|
+
get align(): string | null;
|
|
33
|
+
/** The arrow's element (a `<span>` around an `<svg>`), or `null`. */
|
|
34
|
+
get arrow(): HTMLElement | null;
|
|
35
|
+
/** Rests the pointer on the trigger, and waits out the delay. */
|
|
36
|
+
hover(options?: HoverOptions): Promise<void>;
|
|
37
|
+
/** Moves the pointer off the trigger, away from the tooltip. */
|
|
38
|
+
unhover(options?: HoverOptions): Promise<void>;
|
|
39
|
+
/** Moves the pointer from the trigger onto the tooltip, as a user reading it does. */
|
|
40
|
+
hoverContent(): Promise<void>;
|
|
41
|
+
/** Focuses the trigger, as tabbing to it does: it opens at once. */
|
|
42
|
+
focus(): Promise<void>;
|
|
43
|
+
/** Moves focus away from the trigger: it closes. */
|
|
44
|
+
blur(): Promise<void>;
|
|
45
|
+
/** Presses Escape where focus is. */
|
|
46
|
+
pressEscape(): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../src/tooltip.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAGhE;;;;;;;;;GASG;AACH,qBAAa,cAAe,SAAQ,OAAO;IACzC,OAAgB,SAAS,SAAY;IAErC,wFAAwF;IACxF,IAAI,OAAO,IAAI,WAAW,CAEzB;IAED,sDAAsD;IACtD,IAAI,OAAO,IAAI,WAAW,GAAG,IAAI,CAEhC;IAED,mGAAmG;IACnG,IAAI,KAAK,IAAI,MAAM,GAAG,IAAI,CAEzB;IAED,0BAA0B;IAC1B,IAAI,MAAM,IAAI,OAAO,CAGpB;IAED,iEAAiE;IACjE,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,6FAA6F;IAC7F,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,gDAAgD;IAChD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,+DAA+D;IAC/D,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAExB;IAED,oDAAoD;IACpD,IAAI,KAAK,IAAI,MAAM,GAAG,IAAI,CAEzB;IAED,qEAAqE;IACrE,IAAI,KAAK,IAAI,WAAW,GAAG,IAAI,CAE9B;IAED,iEAAiE;IAC3D,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD,gEAAgE;IAC1D,OAAO,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpD,sFAAsF;IAChF,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAWnC,oEAAoE;IAC9D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,oDAAoD;IAC9C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,qCAAqC;IAC/B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAGnC"}
|
package/dist/tooltip.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { blur, focus } from '@ember/test-helpers';
|
|
2
|
+
import { Harness } from "./harness.js";
|
|
3
|
+
import { pressEscape } from "./layers.js";
|
|
4
|
+
import { hover, unhover } from "./pointer.js";
|
|
5
|
+
import { accessibleDescription, shownInTopLayer, text } from "./-private/overlay.js";
|
|
6
|
+
/**
|
|
7
|
+
* Drives a `<Tooltip>` from `@ember-joinery/ember` or `@ember-joinery/primitives/tooltip`. It
|
|
8
|
+
* reads the state from the trigger's `data-state` and what the trigger's `aria-describedby`
|
|
9
|
+
* names, and acts as a user does: resting the pointer on the trigger, moving it away, focus.
|
|
10
|
+
*
|
|
11
|
+
* const tooltip = new TooltipHarness()
|
|
12
|
+
* await tooltip.hover() // waits out the open delay
|
|
13
|
+
* assert.strictEqual(tooltip.description, 'Add to library')
|
|
14
|
+
* await tooltip.unhover()
|
|
15
|
+
*/
|
|
16
|
+
export class TooltipHarness extends Harness {
|
|
17
|
+
static component = 'tooltip';
|
|
18
|
+
/** The trigger: the `Trigger` part, or your own element with the `trigger` modifier. */
|
|
19
|
+
get trigger() {
|
|
20
|
+
return this.part('trigger');
|
|
21
|
+
}
|
|
22
|
+
/** The tooltip, or `null` while it isn't rendered. */
|
|
23
|
+
get content() {
|
|
24
|
+
return this.queryPart('content');
|
|
25
|
+
}
|
|
26
|
+
/** How it is open, from the trigger's `data-state`: `delayed-open`, `instant-open` or `closed`. */
|
|
27
|
+
get state() {
|
|
28
|
+
return this.trigger.getAttribute('data-state');
|
|
29
|
+
}
|
|
30
|
+
/** Whether it is open. */
|
|
31
|
+
get isOpen() {
|
|
32
|
+
const state = this.state;
|
|
33
|
+
return state === 'delayed-open' || state === 'instant-open';
|
|
34
|
+
}
|
|
35
|
+
/** Whether the tooltip is showing in the browser's top layer. */
|
|
36
|
+
get isShown() {
|
|
37
|
+
return shownInTopLayer(this.content);
|
|
38
|
+
}
|
|
39
|
+
/** The trigger's accessible description while it is open: what a screen reader announces. */
|
|
40
|
+
get description() {
|
|
41
|
+
return accessibleDescription(this.trigger);
|
|
42
|
+
}
|
|
43
|
+
/** The tooltip's text, whitespace collapsed. */
|
|
44
|
+
get text() {
|
|
45
|
+
return text(this.content);
|
|
46
|
+
}
|
|
47
|
+
/** The side it was placed on, after any flip (`data-side`). */
|
|
48
|
+
get side() {
|
|
49
|
+
return this.content?.getAttribute('data-side') ?? null;
|
|
50
|
+
}
|
|
51
|
+
/** Its alignment along that side (`data-align`). */
|
|
52
|
+
get align() {
|
|
53
|
+
return this.content?.getAttribute('data-align') ?? null;
|
|
54
|
+
}
|
|
55
|
+
/** The arrow's element (a `<span>` around an `<svg>`), or `null`. */
|
|
56
|
+
get arrow() {
|
|
57
|
+
return this.queryPart('arrow');
|
|
58
|
+
}
|
|
59
|
+
/** Rests the pointer on the trigger, and waits out the delay. */
|
|
60
|
+
async hover(options) {
|
|
61
|
+
await hover(this.trigger, options);
|
|
62
|
+
}
|
|
63
|
+
/** Moves the pointer off the trigger, away from the tooltip. */
|
|
64
|
+
async unhover(options) {
|
|
65
|
+
await unhover(this.trigger, { ...options, away: this.content });
|
|
66
|
+
}
|
|
67
|
+
/** Moves the pointer from the trigger onto the tooltip, as a user reading it does. */
|
|
68
|
+
async hoverContent() {
|
|
69
|
+
const content = this.content;
|
|
70
|
+
if (!content)
|
|
71
|
+
throw new Error(`Joinery harness: ${this} isn't open`);
|
|
72
|
+
await unhover(this.trigger, {
|
|
73
|
+
away: null,
|
|
74
|
+
side: this.side === 'bottom' ? 'bottom' : 'top',
|
|
75
|
+
distance: 1,
|
|
76
|
+
});
|
|
77
|
+
await hover(content);
|
|
78
|
+
}
|
|
79
|
+
/** Focuses the trigger, as tabbing to it does: it opens at once. */
|
|
80
|
+
async focus() {
|
|
81
|
+
await focus(this.trigger);
|
|
82
|
+
}
|
|
83
|
+
/** Moves focus away from the trigger: it closes. */
|
|
84
|
+
async blur() {
|
|
85
|
+
await blur(this.trigger);
|
|
86
|
+
}
|
|
87
|
+
/** Presses Escape where focus is. */
|
|
88
|
+
async pressEscape() {
|
|
89
|
+
await pressEscape();
|
|
90
|
+
}
|
|
91
|
+
}
|
package/dist/trace.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Drives a `<TraceLine>` from `@ember-joinery/ember`: one line of a trace. It reads the line's
|
|
4
|
+
* title, description and status, and clicks whatever wraps it (a collapsible's trigger, a link,
|
|
5
|
+
* a dialog's or a sheet's trigger), as a reader would:
|
|
6
|
+
*
|
|
7
|
+
* const build = new TraceLineHarness('build') // <TraceLine @name="build" @status="running">
|
|
8
|
+
* assert.true(build.isRunning)
|
|
9
|
+
* assert.strictEqual(build.title, 'Running pnpm build')
|
|
10
|
+
*/
|
|
11
|
+
export declare class TraceLineHarness extends Harness {
|
|
12
|
+
static component: string;
|
|
13
|
+
/** All the text it shows, whitespace collapsed: its title, then its description. */
|
|
14
|
+
get text(): string;
|
|
15
|
+
/** Its title part. Throws when it has none. */
|
|
16
|
+
get titleElement(): HTMLElement;
|
|
17
|
+
/** Its title's text, a hidden note (`sr-only`) included, as a screen reader hears it. */
|
|
18
|
+
get title(): string;
|
|
19
|
+
/** Its description's text, or `''` without one. */
|
|
20
|
+
get description(): string;
|
|
21
|
+
/** Whether it has a description. */
|
|
22
|
+
get hasDescription(): boolean;
|
|
23
|
+
/** Its icon slots, in order: the action's before the title, an indicator after it. */
|
|
24
|
+
get icons(): HTMLElement[];
|
|
25
|
+
/** Its `@status`: `running`, `error`, `pending`, or `null` for work that is done. */
|
|
26
|
+
get status(): string | null;
|
|
27
|
+
/** Whether the work it reports is under way. */
|
|
28
|
+
get isRunning(): boolean;
|
|
29
|
+
/** Whether the work it reports failed. */
|
|
30
|
+
get isError(): boolean;
|
|
31
|
+
/** Whether the work it reports hasn't started. */
|
|
32
|
+
get isPending(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* What wraps the line and acts for it: the nearest link or button around it (a
|
|
35
|
+
* `TraceCollapsible`'s trigger, an `<a>`, a dialog's or a sheet's trigger), or `null` for a
|
|
36
|
+
* line on its own, which reads as text.
|
|
37
|
+
*/
|
|
38
|
+
get control(): HTMLElement | null;
|
|
39
|
+
/** Whether it is a link: wrapped in an `<a href>`. */
|
|
40
|
+
get isLink(): boolean;
|
|
41
|
+
/** Where its link goes, or `null` when it isn't one. */
|
|
42
|
+
get href(): string | null;
|
|
43
|
+
/** Whether its link opens a new tab (`target="_blank"`). */
|
|
44
|
+
get opensInNewTab(): boolean;
|
|
45
|
+
/** Clicks what wraps it, as a reader would. Throws for a line on its own. */
|
|
46
|
+
click(): Promise<void>;
|
|
47
|
+
/** Moves focus to what wraps it. Throws for a line on its own, which isn't a tab stop. */
|
|
48
|
+
focus(): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Drives a `<TraceCollapsible>` from `@ember-joinery/ember`: a trace row that expands. Its state
|
|
52
|
+
* is read from the trigger's `aria-expanded`, so every test also checks what assistive
|
|
53
|
+
* technology hears:
|
|
54
|
+
*
|
|
55
|
+
* const run = new TraceCollapsibleHarness('node') // <TraceCollapsible @name="node">
|
|
56
|
+
* await run.open()
|
|
57
|
+
* assert.strictEqual(run.line.title, 'Ran node --version')
|
|
58
|
+
* assert.strictEqual(run.text, '$ node --version v24.18.0')
|
|
59
|
+
*/
|
|
60
|
+
export declare class TraceCollapsibleHarness extends Harness {
|
|
61
|
+
static component: string;
|
|
62
|
+
/** The button that opens and closes it. */
|
|
63
|
+
get trigger(): HTMLButtonElement;
|
|
64
|
+
/** The line in its trigger. */
|
|
65
|
+
get line(): TraceLineHarness;
|
|
66
|
+
/** The chevron after the line, which turns while it is open. */
|
|
67
|
+
get indicator(): HTMLElement;
|
|
68
|
+
/** The content's element, which is there (`hidden`, empty) while closed. */
|
|
69
|
+
get content(): HTMLElement;
|
|
70
|
+
/** Whether it is open, from the trigger's `aria-expanded`. */
|
|
71
|
+
get isOpen(): boolean;
|
|
72
|
+
/** Whether its content shows: open, or still animating out. */
|
|
73
|
+
get isShown(): boolean;
|
|
74
|
+
/** Whether the trigger can't open or close it. */
|
|
75
|
+
get isDisabled(): boolean;
|
|
76
|
+
/** The trigger's accessible name: its line's text (the chevron is hidden). */
|
|
77
|
+
get label(): string;
|
|
78
|
+
/** The content's text, whitespace collapsed: `''` while it is closed. */
|
|
79
|
+
get text(): string;
|
|
80
|
+
/** Whether the trigger names the content in `aria-controls`, as the ARIA pattern asks. */
|
|
81
|
+
get controlsContent(): boolean;
|
|
82
|
+
/** Clicks the trigger, as a reader does. */
|
|
83
|
+
toggle(): Promise<void>;
|
|
84
|
+
/** Opens it with the trigger, unless it is open. */
|
|
85
|
+
open(): Promise<void>;
|
|
86
|
+
/** Closes it with the trigger, unless it is closed. */
|
|
87
|
+
close(): Promise<void>;
|
|
88
|
+
/** Moves focus to the trigger. */
|
|
89
|
+
focus(): Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Drives a `<Trace>` from `@ember-joinery/ember`: a list of lines. It finds the lines and rows in
|
|
93
|
+
* it, nested ones included, in document order:
|
|
94
|
+
*
|
|
95
|
+
* const trace = new TraceHarness()
|
|
96
|
+
* assert.deepEqual(trace.titles, ['Searched for useChat', 'Ran pnpm test'])
|
|
97
|
+
* await trace.collapsible({ index: 0 }).open()
|
|
98
|
+
*/
|
|
99
|
+
export declare class TraceHarness extends Harness {
|
|
100
|
+
static component: string;
|
|
101
|
+
/** Every line in it, nested ones (in a row's content) included, in document order. */
|
|
102
|
+
get lines(): TraceLineHarness[];
|
|
103
|
+
/** Each line's title, in order. */
|
|
104
|
+
get titles(): string[];
|
|
105
|
+
/** Every row that expands in it, nested ones included, in document order. */
|
|
106
|
+
get collapsibles(): TraceCollapsibleHarness[];
|
|
107
|
+
/** A line in it, by `@name` or position. */
|
|
108
|
+
line(options?: string | {
|
|
109
|
+
name?: string;
|
|
110
|
+
index?: number;
|
|
111
|
+
}): TraceLineHarness;
|
|
112
|
+
/** A row in it, by `@name` or position. */
|
|
113
|
+
collapsible(options?: string | {
|
|
114
|
+
name?: string;
|
|
115
|
+
index?: number;
|
|
116
|
+
}): TraceCollapsibleHarness;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":"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"}
|
package/dist/trace.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { click, focus } from '@ember/test-helpers';
|
|
2
|
+
import { Harness } from "./harness.js";
|
|
3
|
+
import { isShowing } from "./-private/showing.js";
|
|
4
|
+
function text(element) {
|
|
5
|
+
return (element?.textContent ?? '').replace(/\s+/g, ' ').trim();
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Drives a `<TraceLine>` from `@ember-joinery/ember`: one line of a trace. It reads the line's
|
|
9
|
+
* title, description and status, and clicks whatever wraps it (a collapsible's trigger, a link,
|
|
10
|
+
* a dialog's or a sheet's trigger), as a reader would:
|
|
11
|
+
*
|
|
12
|
+
* const build = new TraceLineHarness('build') // <TraceLine @name="build" @status="running">
|
|
13
|
+
* assert.true(build.isRunning)
|
|
14
|
+
* assert.strictEqual(build.title, 'Running pnpm build')
|
|
15
|
+
*/
|
|
16
|
+
export class TraceLineHarness extends Harness {
|
|
17
|
+
static component = 'trace-line';
|
|
18
|
+
/** All the text it shows, whitespace collapsed: its title, then its description. */
|
|
19
|
+
get text() {
|
|
20
|
+
return text(this.element);
|
|
21
|
+
}
|
|
22
|
+
/** Its title part. Throws when it has none. */
|
|
23
|
+
get titleElement() {
|
|
24
|
+
return this.part('title');
|
|
25
|
+
}
|
|
26
|
+
/** Its title's text, a hidden note (`sr-only`) included, as a screen reader hears it. */
|
|
27
|
+
get title() {
|
|
28
|
+
return text(this.queryPart('title'));
|
|
29
|
+
}
|
|
30
|
+
/** Its description's text, or `''` without one. */
|
|
31
|
+
get description() {
|
|
32
|
+
return text(this.queryPart('description'));
|
|
33
|
+
}
|
|
34
|
+
/** Whether it has a description. */
|
|
35
|
+
get hasDescription() {
|
|
36
|
+
return this.queryPart('description') !== null;
|
|
37
|
+
}
|
|
38
|
+
/** Its icon slots, in order: the action's before the title, an indicator after it. */
|
|
39
|
+
get icons() {
|
|
40
|
+
return this.parts('icon');
|
|
41
|
+
}
|
|
42
|
+
/** Its `@status`: `running`, `error`, `pending`, or `null` for work that is done. */
|
|
43
|
+
get status() {
|
|
44
|
+
return this.element.getAttribute('data-status');
|
|
45
|
+
}
|
|
46
|
+
/** Whether the work it reports is under way. */
|
|
47
|
+
get isRunning() {
|
|
48
|
+
return this.status === 'running';
|
|
49
|
+
}
|
|
50
|
+
/** Whether the work it reports failed. */
|
|
51
|
+
get isError() {
|
|
52
|
+
return this.status === 'error';
|
|
53
|
+
}
|
|
54
|
+
/** Whether the work it reports hasn't started. */
|
|
55
|
+
get isPending() {
|
|
56
|
+
return this.status === 'pending';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* What wraps the line and acts for it: the nearest link or button around it (a
|
|
60
|
+
* `TraceCollapsible`'s trigger, an `<a>`, a dialog's or a sheet's trigger), or `null` for a
|
|
61
|
+
* line on its own, which reads as text.
|
|
62
|
+
*/
|
|
63
|
+
get control() {
|
|
64
|
+
return this.element.closest('a[href], button');
|
|
65
|
+
}
|
|
66
|
+
/** Whether it is a link: wrapped in an `<a href>`. */
|
|
67
|
+
get isLink() {
|
|
68
|
+
return this.control instanceof HTMLAnchorElement;
|
|
69
|
+
}
|
|
70
|
+
/** Where its link goes, or `null` when it isn't one. */
|
|
71
|
+
get href() {
|
|
72
|
+
return this.isLink ? this.control.getAttribute('href') : null;
|
|
73
|
+
}
|
|
74
|
+
/** Whether its link opens a new tab (`target="_blank"`). */
|
|
75
|
+
get opensInNewTab() {
|
|
76
|
+
return this.isLink && this.control.getAttribute('target') === '_blank';
|
|
77
|
+
}
|
|
78
|
+
/** Clicks what wraps it, as a reader would. Throws for a line on its own. */
|
|
79
|
+
async click() {
|
|
80
|
+
const control = this.control;
|
|
81
|
+
if (!control)
|
|
82
|
+
throw new Error(`Joinery harness: ${this} isn't wrapped in a link or a button`);
|
|
83
|
+
await click(control);
|
|
84
|
+
}
|
|
85
|
+
/** Moves focus to what wraps it. Throws for a line on its own, which isn't a tab stop. */
|
|
86
|
+
async focus() {
|
|
87
|
+
const control = this.control;
|
|
88
|
+
if (!control)
|
|
89
|
+
throw new Error(`Joinery harness: ${this} isn't wrapped in a link or a button`);
|
|
90
|
+
await focus(control);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Drives a `<TraceCollapsible>` from `@ember-joinery/ember`: a trace row that expands. Its state
|
|
95
|
+
* is read from the trigger's `aria-expanded`, so every test also checks what assistive
|
|
96
|
+
* technology hears:
|
|
97
|
+
*
|
|
98
|
+
* const run = new TraceCollapsibleHarness('node') // <TraceCollapsible @name="node">
|
|
99
|
+
* await run.open()
|
|
100
|
+
* assert.strictEqual(run.line.title, 'Ran node --version')
|
|
101
|
+
* assert.strictEqual(run.text, '$ node --version v24.18.0')
|
|
102
|
+
*/
|
|
103
|
+
export class TraceCollapsibleHarness extends Harness {
|
|
104
|
+
static component = 'trace-collapsible';
|
|
105
|
+
/** The button that opens and closes it. */
|
|
106
|
+
get trigger() {
|
|
107
|
+
return this.part('trigger');
|
|
108
|
+
}
|
|
109
|
+
/** The line in its trigger. */
|
|
110
|
+
get line() {
|
|
111
|
+
return new TraceLineHarness({ within: this.trigger });
|
|
112
|
+
}
|
|
113
|
+
/** The chevron after the line, which turns while it is open. */
|
|
114
|
+
get indicator() {
|
|
115
|
+
return this.part('indicator');
|
|
116
|
+
}
|
|
117
|
+
/** The content's element, which is there (`hidden`, empty) while closed. */
|
|
118
|
+
get content() {
|
|
119
|
+
return this.part('content');
|
|
120
|
+
}
|
|
121
|
+
/** Whether it is open, from the trigger's `aria-expanded`. */
|
|
122
|
+
get isOpen() {
|
|
123
|
+
return this.trigger.getAttribute('aria-expanded') === 'true';
|
|
124
|
+
}
|
|
125
|
+
/** Whether its content shows: open, or still animating out. */
|
|
126
|
+
get isShown() {
|
|
127
|
+
return isShowing(this.content);
|
|
128
|
+
}
|
|
129
|
+
/** Whether the trigger can't open or close it. */
|
|
130
|
+
get isDisabled() {
|
|
131
|
+
return this.trigger.disabled;
|
|
132
|
+
}
|
|
133
|
+
/** The trigger's accessible name: its line's text (the chevron is hidden). */
|
|
134
|
+
get label() {
|
|
135
|
+
return text(this.trigger);
|
|
136
|
+
}
|
|
137
|
+
/** The content's text, whitespace collapsed: `''` while it is closed. */
|
|
138
|
+
get text() {
|
|
139
|
+
const content = this.content;
|
|
140
|
+
return content.hidden ? '' : text(content);
|
|
141
|
+
}
|
|
142
|
+
/** Whether the trigger names the content in `aria-controls`, as the ARIA pattern asks. */
|
|
143
|
+
get controlsContent() {
|
|
144
|
+
const content = this.content;
|
|
145
|
+
return Boolean(content.id) && this.trigger.getAttribute('aria-controls') === content.id;
|
|
146
|
+
}
|
|
147
|
+
/** Clicks the trigger, as a reader does. */
|
|
148
|
+
async toggle() {
|
|
149
|
+
await click(this.trigger);
|
|
150
|
+
}
|
|
151
|
+
/** Opens it with the trigger, unless it is open. */
|
|
152
|
+
async open() {
|
|
153
|
+
if (!this.isOpen)
|
|
154
|
+
await this.toggle();
|
|
155
|
+
}
|
|
156
|
+
/** Closes it with the trigger, unless it is closed. */
|
|
157
|
+
async close() {
|
|
158
|
+
if (this.isOpen)
|
|
159
|
+
await this.toggle();
|
|
160
|
+
}
|
|
161
|
+
/** Moves focus to the trigger. */
|
|
162
|
+
async focus() {
|
|
163
|
+
await focus(this.trigger);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Drives a `<Trace>` from `@ember-joinery/ember`: a list of lines. It finds the lines and rows in
|
|
168
|
+
* it, nested ones included, in document order:
|
|
169
|
+
*
|
|
170
|
+
* const trace = new TraceHarness()
|
|
171
|
+
* assert.deepEqual(trace.titles, ['Searched for useChat', 'Ran pnpm test'])
|
|
172
|
+
* await trace.collapsible({ index: 0 }).open()
|
|
173
|
+
*/
|
|
174
|
+
export class TraceHarness extends Harness {
|
|
175
|
+
static component = 'trace';
|
|
176
|
+
/** Every line in it, nested ones (in a row's content) included, in document order. */
|
|
177
|
+
get lines() {
|
|
178
|
+
return this.findAll(TraceLineHarness);
|
|
179
|
+
}
|
|
180
|
+
/** Each line's title, in order. */
|
|
181
|
+
get titles() {
|
|
182
|
+
return this.lines.map(line => line.title);
|
|
183
|
+
}
|
|
184
|
+
/** Every row that expands in it, nested ones included, in document order. */
|
|
185
|
+
get collapsibles() {
|
|
186
|
+
return this.findAll(TraceCollapsibleHarness);
|
|
187
|
+
}
|
|
188
|
+
/** A line in it, by `@name` or position. */
|
|
189
|
+
line(options) {
|
|
190
|
+
return this.find(TraceLineHarness, options);
|
|
191
|
+
}
|
|
192
|
+
/** A row in it, by `@name` or position. */
|
|
193
|
+
collapsible(options) {
|
|
194
|
+
return this.find(TraceCollapsibleHarness, options);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { TestHooks } from './test-hooks.ts';
|
|
2
|
+
/** A built-in string, as `@ember-joinery/primitives/i18n` declares it (the msgid contract). */
|
|
3
|
+
export interface TranslatorMessage {
|
|
4
|
+
id: string;
|
|
5
|
+
message: string;
|
|
6
|
+
plural?: string;
|
|
7
|
+
context?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
}
|
|
10
|
+
/** What translates Joinery's built-in strings, as `@ember-joinery/primitives/i18n` declares it. */
|
|
11
|
+
export interface TestTranslator {
|
|
12
|
+
readonly locale: string;
|
|
13
|
+
t(message: TranslatorMessage, values?: Record<string, unknown>): string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Registers `translator` as the test's `translator:main` before each test, so Joinery's
|
|
17
|
+
* components show their built-in strings through it. Call it after `setupRenderingTest(hooks)`
|
|
18
|
+
* or `setupApplicationTest(hooks)`.
|
|
19
|
+
*
|
|
20
|
+
* module('in French', function (hooks) {
|
|
21
|
+
* setupRenderingTest(hooks)
|
|
22
|
+
* setupTranslator(hooks, myTranslator)
|
|
23
|
+
* })
|
|
24
|
+
*/
|
|
25
|
+
export declare function setupTranslator(hooks: TestHooks, translator: TestTranslator): void;
|
|
26
|
+
/**
|
|
27
|
+
* A pseudo-locale (`en-XA`): every string comes out accented and wrapped, `⟦Ćĺóśé⟧`, so a test
|
|
28
|
+
* can tell a built-in string that went through the translator from one that skipped it. Values
|
|
29
|
+
* (a name, a number, a date) are interpolated as given.
|
|
30
|
+
*
|
|
31
|
+
* setupTranslator(hooks, pseudoTranslator)
|
|
32
|
+
*/
|
|
33
|
+
export declare const pseudoTranslator: TestTranslator;
|
|
34
|
+
//# sourceMappingURL=translator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translator.d.ts","sourceRoot":"","sources":["../src/translator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,+FAA+F;AAC/F,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,mGAAmG;AACnG,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,CAAC,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAA;CACxE;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,GAAG,IAAI,CAWlF;AA6CD;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,cAO9B,CAAA"}
|