@ember-joinery/test-support 0.0.0-stage → 1.0.1
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 +550 -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/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 +86 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +87 -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/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-menu.d.ts +97 -0
- package/dist/navigation-menu.d.ts.map +1 -0
- package/dist/navigation-menu.js +207 -0
- package/dist/observers.d.ts +21 -0
- package/dist/observers.d.ts.map +1 -0
- package/dist/observers.js +34 -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/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/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/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/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/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/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/bubble.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { click, focus } from '@ember/test-helpers';
|
|
2
|
+
import { Harness } from "./harness.js";
|
|
3
|
+
function text(element) {
|
|
4
|
+
return (element?.textContent ?? '').replace(/\s+/g, ' ').trim();
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Drives a `<Bubble>` from `@ember-joinery/ember`. It reads the bubble's text, look and side,
|
|
8
|
+
* its reactions, and clicks a bubble whose content is a button or a link:
|
|
9
|
+
*
|
|
10
|
+
* const reply = new BubbleHarness('reply') // <Bubble @name="reply">
|
|
11
|
+
* assert.strictEqual(reply.text, 'I forgot my password')
|
|
12
|
+
* assert.strictEqual(reply.reactionsLabel, 'Reaction: thumbs up')
|
|
13
|
+
* await reply.click()
|
|
14
|
+
*
|
|
15
|
+
* Find what is inside its reactions, such as a button, with `find()`.
|
|
16
|
+
*/
|
|
17
|
+
export class BubbleHarness extends Harness {
|
|
18
|
+
static component = 'bubble';
|
|
19
|
+
/** Its content's text, whitespace collapsed; the reactions are left out. */
|
|
20
|
+
get text() {
|
|
21
|
+
return this.parts('content').map(text).join(' ');
|
|
22
|
+
}
|
|
23
|
+
/** Its `@variant`: `default`, `secondary`, `muted`, `tinted`, `outline`, `ghost` or `destructive`. */
|
|
24
|
+
get variant() {
|
|
25
|
+
return this.element.getAttribute('data-variant');
|
|
26
|
+
}
|
|
27
|
+
/** Its `@align`: `start` or `end`. */
|
|
28
|
+
get align() {
|
|
29
|
+
return this.element.getAttribute('data-align');
|
|
30
|
+
}
|
|
31
|
+
/** Its content, the framed surface. Throws when it has none. */
|
|
32
|
+
get content() {
|
|
33
|
+
return this.part('content');
|
|
34
|
+
}
|
|
35
|
+
/** Its reactions. Throws when it has none. */
|
|
36
|
+
get reactions() {
|
|
37
|
+
return this.part('reactions');
|
|
38
|
+
}
|
|
39
|
+
/** Whether it has reactions. */
|
|
40
|
+
get hasReactions() {
|
|
41
|
+
return this.queryPart('reactions') !== null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The reactions' accessible name, as assistive technology reads it: their `aria-label`
|
|
45
|
+
* (`role="img"` reads the row once, by it), else their text. `''` without reactions.
|
|
46
|
+
*/
|
|
47
|
+
get reactionsLabel() {
|
|
48
|
+
const reactions = this.queryPart('reactions');
|
|
49
|
+
if (!reactions)
|
|
50
|
+
return '';
|
|
51
|
+
return reactions.getAttribute('aria-label')?.trim() || text(reactions);
|
|
52
|
+
}
|
|
53
|
+
/** The edge the reactions overlap (`top` or `bottom`), or `null` without reactions. */
|
|
54
|
+
get reactionsSide() {
|
|
55
|
+
return this.queryPart('reactions')?.getAttribute('data-side') ?? null;
|
|
56
|
+
}
|
|
57
|
+
/** The end of that edge they sit at (`start` or `end`), or `null` without reactions. */
|
|
58
|
+
get reactionsAlign() {
|
|
59
|
+
return this.queryPart('reactions')?.getAttribute('data-align') ?? null;
|
|
60
|
+
}
|
|
61
|
+
/** Whether its content is a button or a link, which a user can press. */
|
|
62
|
+
get isInteractive() {
|
|
63
|
+
const content = this.queryPart('content');
|
|
64
|
+
if (!content)
|
|
65
|
+
return false;
|
|
66
|
+
return (content instanceof HTMLButtonElement ||
|
|
67
|
+
(content instanceof HTMLAnchorElement && content.hasAttribute('href')));
|
|
68
|
+
}
|
|
69
|
+
/** Whether its content has focus. */
|
|
70
|
+
get isFocused() {
|
|
71
|
+
return this.element.ownerDocument.activeElement === this.queryPart('content');
|
|
72
|
+
}
|
|
73
|
+
/** Clicks its content, as a user would: presses a button bubble, follows a link bubble. */
|
|
74
|
+
async click() {
|
|
75
|
+
await click(this.content);
|
|
76
|
+
}
|
|
77
|
+
/** Moves focus to its content, as tabbing to a button or link bubble would. */
|
|
78
|
+
async focus() {
|
|
79
|
+
await focus(this.content);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Drives a `<BubbleGroup>` from `@ember-joinery/ember`: consecutive bubbles from one sender.
|
|
84
|
+
*
|
|
85
|
+
* const group = new BubbleGroupHarness()
|
|
86
|
+
* assert.deepEqual(group.bubbles.map(bubble => bubble.text), ['You tell me!', '…'])
|
|
87
|
+
*/
|
|
88
|
+
export class BubbleGroupHarness extends Harness {
|
|
89
|
+
static component = 'bubble-group';
|
|
90
|
+
/** A harness for each bubble in the group, in order. */
|
|
91
|
+
get bubbles() {
|
|
92
|
+
return this.findAll(BubbleHarness);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ButtonHarness } from './button.ts';
|
|
2
|
+
import { Harness } from './harness.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Drives a `<ButtonGroup>` from `@ember-joinery/ember`: its name, its orientation, and the
|
|
5
|
+
* buttons, nested groups, separators and text inside it.
|
|
6
|
+
*
|
|
7
|
+
* const toolbar = new ButtonGroupHarness('actions') // <ButtonGroup @name="actions">
|
|
8
|
+
* assert.strictEqual(toolbar.label, 'Media controls')
|
|
9
|
+
* await toolbar.find(ButtonHarness, 'archive').click()
|
|
10
|
+
*/
|
|
11
|
+
export declare class ButtonGroupHarness extends Harness {
|
|
12
|
+
static component: string;
|
|
13
|
+
/** Its role, `group`. */
|
|
14
|
+
get role(): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Its accessible name: `aria-label`, else the text of the elements `aria-labelledby` names,
|
|
17
|
+
* else `''` (a group has no name of its own).
|
|
18
|
+
*/
|
|
19
|
+
get label(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Its `@orientation`: `horizontal` (the default, which renders no `data-orientation`, as
|
|
22
|
+
* upstream's) or `vertical`.
|
|
23
|
+
*/
|
|
24
|
+
get orientation(): string;
|
|
25
|
+
/** A harness for each button in it, nested groups' included, in order. */
|
|
26
|
+
get buttons(): ButtonHarness[];
|
|
27
|
+
/** A harness for each group nested in it, in order. */
|
|
28
|
+
get groups(): ButtonGroupHarness[];
|
|
29
|
+
/** Its own separators (not a nested group's), in order. */
|
|
30
|
+
get separators(): HTMLElement[];
|
|
31
|
+
/** The text of each of its own text parts, in order. */
|
|
32
|
+
get texts(): string[];
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=button-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button-group.d.ts","sourceRoot":"","sources":["../src/button-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAMtC;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,OAAO;IAC7C,OAAgB,SAAS,SAAiB;IAE1C,yBAAyB;IACzB,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAExB;IAED;;;OAGG;IACH,IAAI,KAAK,IAAI,MAAM,CAYlB;IAED;;;OAGG;IACH,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,0EAA0E;IAC1E,IAAI,OAAO,IAAI,aAAa,EAAE,CAE7B;IAED,uDAAuD;IACvD,IAAI,MAAM,IAAI,kBAAkB,EAAE,CAEjC;IAED,2DAA2D;IAC3D,IAAI,UAAU,IAAI,WAAW,EAAE,CAE9B;IAED,wDAAwD;IACxD,IAAI,KAAK,IAAI,MAAM,EAAE,CAEpB;CACF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ButtonHarness } from "./button.js";
|
|
2
|
+
import { Harness } from "./harness.js";
|
|
3
|
+
function text(element) {
|
|
4
|
+
return (element.textContent ?? '').replace(/\s+/g, ' ').trim();
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Drives a `<ButtonGroup>` from `@ember-joinery/ember`: its name, its orientation, and the
|
|
8
|
+
* buttons, nested groups, separators and text inside it.
|
|
9
|
+
*
|
|
10
|
+
* const toolbar = new ButtonGroupHarness('actions') // <ButtonGroup @name="actions">
|
|
11
|
+
* assert.strictEqual(toolbar.label, 'Media controls')
|
|
12
|
+
* await toolbar.find(ButtonHarness, 'archive').click()
|
|
13
|
+
*/
|
|
14
|
+
export class ButtonGroupHarness extends Harness {
|
|
15
|
+
static component = 'button-group';
|
|
16
|
+
/** Its role, `group`. */
|
|
17
|
+
get role() {
|
|
18
|
+
return this.element.getAttribute('role');
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Its accessible name: `aria-label`, else the text of the elements `aria-labelledby` names,
|
|
22
|
+
* else `''` (a group has no name of its own).
|
|
23
|
+
*/
|
|
24
|
+
get label() {
|
|
25
|
+
const element = this.element;
|
|
26
|
+
const label = element.getAttribute('aria-label');
|
|
27
|
+
if (label)
|
|
28
|
+
return label.trim();
|
|
29
|
+
const labelledBy = element.getAttribute('aria-labelledby');
|
|
30
|
+
if (!labelledBy)
|
|
31
|
+
return '';
|
|
32
|
+
return labelledBy
|
|
33
|
+
.split(/\s+/)
|
|
34
|
+
.map(id => element.ownerDocument.getElementById(id))
|
|
35
|
+
.filter((found) => Boolean(found))
|
|
36
|
+
.map(text)
|
|
37
|
+
.join(' ');
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Its `@orientation`: `horizontal` (the default, which renders no `data-orientation`, as
|
|
41
|
+
* upstream's) or `vertical`.
|
|
42
|
+
*/
|
|
43
|
+
get orientation() {
|
|
44
|
+
return this.element.getAttribute('data-orientation') ?? 'horizontal';
|
|
45
|
+
}
|
|
46
|
+
/** A harness for each button in it, nested groups' included, in order. */
|
|
47
|
+
get buttons() {
|
|
48
|
+
return this.findAll(ButtonHarness);
|
|
49
|
+
}
|
|
50
|
+
/** A harness for each group nested in it, in order. */
|
|
51
|
+
get groups() {
|
|
52
|
+
return this.findAll(ButtonGroupHarness);
|
|
53
|
+
}
|
|
54
|
+
/** Its own separators (not a nested group's), in order. */
|
|
55
|
+
get separators() {
|
|
56
|
+
return this.parts('separator');
|
|
57
|
+
}
|
|
58
|
+
/** The text of each of its own text parts, in order. */
|
|
59
|
+
get texts() {
|
|
60
|
+
return this.parts('text').map(text);
|
|
61
|
+
}
|
|
62
|
+
}
|
package/dist/button.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Drives a `<Button>` from `@ember-joinery/ember`, or an element made a button with its
|
|
4
|
+
* `asButton` modifier (`<LinkTo {{asButton}}>`). State comes from the element and its ARIA.
|
|
5
|
+
*
|
|
6
|
+
* const save = new ButtonHarness('save') // <Button @name="save">
|
|
7
|
+
* await save.click()
|
|
8
|
+
* assert.false(save.isDisabled)
|
|
9
|
+
*/
|
|
10
|
+
export declare class ButtonHarness extends Harness {
|
|
11
|
+
static component: string;
|
|
12
|
+
/** The text it shows, whitespace collapsed. */
|
|
13
|
+
get text(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Its accessible name, as assistive technology reads it: `aria-label`, else the text of
|
|
16
|
+
* the elements `aria-labelledby` names, else its text. An icon button needs one of the first
|
|
17
|
+
* two.
|
|
18
|
+
*/
|
|
19
|
+
get label(): string;
|
|
20
|
+
/** Its `@variant`: `default`, `outline`, `secondary`, `ghost`, `destructive` or `link`. */
|
|
21
|
+
get variant(): string | null;
|
|
22
|
+
/** Its `@size`: `default`, `xs`, `sm`, `lg`, `icon`, `icon-xs`, `icon-sm` or `icon-lg`. */
|
|
23
|
+
get size(): string | null;
|
|
24
|
+
/** Whether it can't be used: `disabled`, or `aria-disabled="true"` on an element of your own. */
|
|
25
|
+
get isDisabled(): boolean;
|
|
26
|
+
/** For a toggle button, whether it is pressed (`aria-pressed`); otherwise `undefined`. */
|
|
27
|
+
get isPressed(): boolean | undefined;
|
|
28
|
+
/** Whether it has focus. */
|
|
29
|
+
get isFocused(): boolean;
|
|
30
|
+
/** Clicks it, as a user would. A disabled button ignores the click, as in a browser. */
|
|
31
|
+
click(): Promise<void>;
|
|
32
|
+
/** Moves focus to it, as tabbing to it would. Fails if it can't take focus. */
|
|
33
|
+
focus(): Promise<void>;
|
|
34
|
+
/** Moves focus away from it. */
|
|
35
|
+
blur(): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../src/button.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAMtC;;;;;;;GAOG;AACH,qBAAa,aAAc,SAAQ,OAAO;IACxC,OAAgB,SAAS,SAAW;IAEpC,+CAA+C;IAC/C,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;OAIG;IACH,IAAI,KAAK,IAAI,MAAM,CAclB;IAED,2FAA2F;IAC3F,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAED,2FAA2F;IAC3F,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAExB;IAED,iGAAiG;IACjG,IAAI,UAAU,IAAI,OAAO,CAIxB;IAED,0FAA0F;IAC1F,IAAI,SAAS,IAAI,OAAO,GAAG,SAAS,CAGnC;IAED,4BAA4B;IAC5B,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,wFAAwF;IAClF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,+EAA+E;IACzE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,gCAAgC;IAC1B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B"}
|
package/dist/button.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { blur, click, focus } from '@ember/test-helpers';
|
|
2
|
+
import { Harness } from "./harness.js";
|
|
3
|
+
function text(element) {
|
|
4
|
+
return (element.textContent ?? '').replace(/\s+/g, ' ').trim();
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Drives a `<Button>` from `@ember-joinery/ember`, or an element made a button with its
|
|
8
|
+
* `asButton` modifier (`<LinkTo {{asButton}}>`). State comes from the element and its ARIA.
|
|
9
|
+
*
|
|
10
|
+
* const save = new ButtonHarness('save') // <Button @name="save">
|
|
11
|
+
* await save.click()
|
|
12
|
+
* assert.false(save.isDisabled)
|
|
13
|
+
*/
|
|
14
|
+
export class ButtonHarness extends Harness {
|
|
15
|
+
static component = 'button';
|
|
16
|
+
/** The text it shows, whitespace collapsed. */
|
|
17
|
+
get text() {
|
|
18
|
+
return text(this.element);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Its accessible name, as assistive technology reads it: `aria-label`, else the text of
|
|
22
|
+
* the elements `aria-labelledby` names, else its text. An icon button needs one of the first
|
|
23
|
+
* two.
|
|
24
|
+
*/
|
|
25
|
+
get label() {
|
|
26
|
+
const element = this.element;
|
|
27
|
+
const label = element.getAttribute('aria-label');
|
|
28
|
+
if (label)
|
|
29
|
+
return label.trim();
|
|
30
|
+
const labelledBy = element.getAttribute('aria-labelledby');
|
|
31
|
+
if (labelledBy) {
|
|
32
|
+
return labelledBy
|
|
33
|
+
.split(/\s+/)
|
|
34
|
+
.map(id => element.ownerDocument.getElementById(id))
|
|
35
|
+
.filter((found) => Boolean(found))
|
|
36
|
+
.map(text)
|
|
37
|
+
.join(' ');
|
|
38
|
+
}
|
|
39
|
+
return this.text;
|
|
40
|
+
}
|
|
41
|
+
/** Its `@variant`: `default`, `outline`, `secondary`, `ghost`, `destructive` or `link`. */
|
|
42
|
+
get variant() {
|
|
43
|
+
return this.element.getAttribute('data-variant');
|
|
44
|
+
}
|
|
45
|
+
/** Its `@size`: `default`, `xs`, `sm`, `lg`, `icon`, `icon-xs`, `icon-sm` or `icon-lg`. */
|
|
46
|
+
get size() {
|
|
47
|
+
return this.element.getAttribute('data-size');
|
|
48
|
+
}
|
|
49
|
+
/** Whether it can't be used: `disabled`, or `aria-disabled="true"` on an element of your own. */
|
|
50
|
+
get isDisabled() {
|
|
51
|
+
const element = this.element;
|
|
52
|
+
if ('disabled' in element && element.disabled)
|
|
53
|
+
return true;
|
|
54
|
+
return element.getAttribute('aria-disabled') === 'true';
|
|
55
|
+
}
|
|
56
|
+
/** For a toggle button, whether it is pressed (`aria-pressed`); otherwise `undefined`. */
|
|
57
|
+
get isPressed() {
|
|
58
|
+
const pressed = this.element.getAttribute('aria-pressed');
|
|
59
|
+
return pressed === null ? undefined : pressed === 'true';
|
|
60
|
+
}
|
|
61
|
+
/** Whether it has focus. */
|
|
62
|
+
get isFocused() {
|
|
63
|
+
return this.element.ownerDocument.activeElement === this.element;
|
|
64
|
+
}
|
|
65
|
+
/** Clicks it, as a user would. A disabled button ignores the click, as in a browser. */
|
|
66
|
+
async click() {
|
|
67
|
+
await click(this.element);
|
|
68
|
+
}
|
|
69
|
+
/** Moves focus to it, as tabbing to it would. Fails if it can't take focus. */
|
|
70
|
+
async focus() {
|
|
71
|
+
await focus(this.element);
|
|
72
|
+
}
|
|
73
|
+
/** Moves focus away from it. */
|
|
74
|
+
async blur() {
|
|
75
|
+
await blur(this.element);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Harness } from './harness.ts';
|
|
2
|
+
import { type KeyModifiers } from './focus.ts';
|
|
3
|
+
/** A day, as the harness takes one: a `Date` (its local day) or `yyyy-MM-dd`. */
|
|
4
|
+
export type CalendarDayInput = Date | string;
|
|
5
|
+
/**
|
|
6
|
+
* Drives a `<Calendar>` from `@ember-joinery/ember` or `@ember-joinery/primitives/calendar`. It
|
|
7
|
+
* reads the state from each day's cell and button (`aria-selected`, `disabled`, `data-today`,
|
|
8
|
+
* `data-outside`) and the grid's ARIA, and acts as a user does: presses on the days, the
|
|
9
|
+
* previous and next buttons and the dropdowns, and the arrow keys on the focused day.
|
|
10
|
+
*
|
|
11
|
+
* const calendar = new CalendarHarness('booking') // <Calendar @name="booking">
|
|
12
|
+
* await calendar.select('2026-01-12')
|
|
13
|
+
* assert.deepEqual(calendar.selectedDays, ['2026-01-12'])
|
|
14
|
+
* await calendar.press('ArrowRight')
|
|
15
|
+
* assert.strictEqual(calendar.focusedDay, '2026-01-13')
|
|
16
|
+
*
|
|
17
|
+
* A day is a `Date` or `yyyy-MM-dd`. Where a day shows twice (an outside day of one month is a
|
|
18
|
+
* day of the next one shown), the harness takes the one in its own month.
|
|
19
|
+
*/
|
|
20
|
+
export declare class CalendarHarness extends Harness {
|
|
21
|
+
static component: string;
|
|
22
|
+
/** Its `@mode` (`single`, `multiple`, `range`), or `null` when its days aren't buttons. */
|
|
23
|
+
get mode(): string | null;
|
|
24
|
+
/** Each month shown: its grid. */
|
|
25
|
+
get grids(): HTMLTableElement[];
|
|
26
|
+
/** Each month's caption, in order: `January 2026`. */
|
|
27
|
+
get captions(): string[];
|
|
28
|
+
/** The first month's caption. */
|
|
29
|
+
get caption(): string;
|
|
30
|
+
/** Each month's grid's name (`aria-label`), in order. */
|
|
31
|
+
get monthLabels(): string[];
|
|
32
|
+
/** The first day of each month shown, as `yyyy-MM-dd`, in order. */
|
|
33
|
+
get months(): string[];
|
|
34
|
+
/** The column headings, as shown (`Su`, `Mo`…). */
|
|
35
|
+
get weekdays(): string[];
|
|
36
|
+
/** The columns' full names (`Sunday`…), from their `aria-label`. */
|
|
37
|
+
get weekdayLabels(): string[];
|
|
38
|
+
/** The week numbers shown, in order, as shown (`01`). */
|
|
39
|
+
get weekNumbers(): string[];
|
|
40
|
+
/** Every day cell (`role="gridcell"`) of every month, in order. */
|
|
41
|
+
get cells(): HTMLElement[];
|
|
42
|
+
/**
|
|
43
|
+
* A day's cell: the one in its own month, or else the first showing it. Throws when no month
|
|
44
|
+
* shows it.
|
|
45
|
+
*/
|
|
46
|
+
cell(day: CalendarDayInput): HTMLElement;
|
|
47
|
+
/** A day's button. Throws when the day has none (it's hidden, or the calendar has no mode). */
|
|
48
|
+
button(day: CalendarDayInput): HTMLButtonElement;
|
|
49
|
+
/** What a day shows, whitespace collapsed. */
|
|
50
|
+
dayText(day: CalendarDayInput): string;
|
|
51
|
+
/** A day's name, as assistive technology reads it: its button's, or its cell's. */
|
|
52
|
+
dayLabel(day: CalendarDayInput): string;
|
|
53
|
+
/** Whether a day is selected (`aria-selected`). */
|
|
54
|
+
isSelected(day: CalendarDayInput): boolean;
|
|
55
|
+
/** Whether a day can't be selected (its button is `disabled`). */
|
|
56
|
+
isDisabled(day: CalendarDayInput): boolean;
|
|
57
|
+
/** Whether a day is today (`data-today`). */
|
|
58
|
+
isToday(day: CalendarDayInput): boolean;
|
|
59
|
+
/** Whether a day belongs to a month around the one it's shown in (`data-outside`). */
|
|
60
|
+
isOutside(day: CalendarDayInput): boolean;
|
|
61
|
+
/** Whether a day's cell is there but hidden (`data-hidden`). */
|
|
62
|
+
isHidden(day: CalendarDayInput): boolean;
|
|
63
|
+
/** Where a day is in a selected range: `start`, `middle`, `end`, or `null`. */
|
|
64
|
+
rangePosition(day: CalendarDayInput): 'start' | 'middle' | 'end' | null;
|
|
65
|
+
/** The selected days shown, as `yyyy-MM-dd`, once each, in order. */
|
|
66
|
+
get selectedDays(): string[];
|
|
67
|
+
/** The selected days shown, as dates. */
|
|
68
|
+
get selected(): Date[];
|
|
69
|
+
/** The disabled days shown, as `yyyy-MM-dd`, once each. */
|
|
70
|
+
get disabledDays(): string[];
|
|
71
|
+
/** The day whose button has focus, as `yyyy-MM-dd`, or `null`. */
|
|
72
|
+
get focusedDay(): string | null;
|
|
73
|
+
/** The day in the tab order (the one button with `tabindex="0"`), as `yyyy-MM-dd`, or `null`. */
|
|
74
|
+
get tabStop(): string | null;
|
|
75
|
+
/** The previous-month button. */
|
|
76
|
+
get previousButton(): HTMLButtonElement;
|
|
77
|
+
/** The next-month button. */
|
|
78
|
+
get nextButton(): HTMLButtonElement;
|
|
79
|
+
/** Whether the previous button goes anywhere (it isn't `aria-disabled`). */
|
|
80
|
+
get canGoPrevious(): boolean;
|
|
81
|
+
/** Whether the next button goes anywhere. */
|
|
82
|
+
get canGoNext(): boolean;
|
|
83
|
+
/** Presses the previous-month button. */
|
|
84
|
+
previous(): Promise<void>;
|
|
85
|
+
/** Presses the next-month button. */
|
|
86
|
+
next(): Promise<void>;
|
|
87
|
+
/** A month's month dropdown (the first month's by default), or `null` when it has none. */
|
|
88
|
+
monthDropdown(index?: number): HTMLSelectElement | null;
|
|
89
|
+
/** A month's year dropdown, or `null` when it has none. */
|
|
90
|
+
yearDropdown(index?: number): HTMLSelectElement | null;
|
|
91
|
+
/** The options of a month's month dropdown, as shown (`Jan`…). */
|
|
92
|
+
monthOptions(index?: number): string[];
|
|
93
|
+
/** The options of a month's year dropdown, as shown. */
|
|
94
|
+
yearOptions(index?: number): string[];
|
|
95
|
+
/**
|
|
96
|
+
* Picks a month in a month's month dropdown: its index in the year (0 for the first) or the
|
|
97
|
+
* option's text (`Mar`), as choosing it does.
|
|
98
|
+
*/
|
|
99
|
+
chooseMonth(month: number | string, index?: number): Promise<void>;
|
|
100
|
+
/** Picks a year in a month's year dropdown, by its number or its text. */
|
|
101
|
+
chooseYear(year: number | string, index?: number): Promise<void>;
|
|
102
|
+
/** Presses a day's button, as a click selects it (or lets it go). */
|
|
103
|
+
select(day: CalendarDayInput): Promise<void>;
|
|
104
|
+
/** Presses each day in turn: the ends of a range, or several days. */
|
|
105
|
+
selectAll(...days: CalendarDayInput[]): Promise<void>;
|
|
106
|
+
/** Moves focus to a day's button. */
|
|
107
|
+
focus(day: CalendarDayInput): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Presses a key on the focused day (focusing the tab stop first when no day has focus):
|
|
110
|
+
* the arrow keys, `PageUp`, `PageDown`, `Home` and `End`, with `shiftKey` for months and
|
|
111
|
+
* years.
|
|
112
|
+
*/
|
|
113
|
+
press(key: string, modifiers?: KeyModifiers): Promise<void>;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=calendar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../src/calendar.ts"],"names":[],"mappings":"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"}
|