@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.
Files changed (285) hide show
  1. package/CHANGELOG.md +550 -0
  2. package/LICENSE.md +9 -0
  3. package/NOTICE +532 -0
  4. package/README.md +356 -2
  5. package/addon-main.cjs +4 -0
  6. package/dist/-private/checkable.d.ts +21 -0
  7. package/dist/-private/checkable.d.ts.map +1 -0
  8. package/dist/-private/checkable.js +80 -0
  9. package/dist/-private/control.d.ts +18 -0
  10. package/dist/-private/control.d.ts.map +1 -0
  11. package/dist/-private/control.js +55 -0
  12. package/dist/-private/menu.d.ts +145 -0
  13. package/dist/-private/menu.d.ts.map +1 -0
  14. package/dist/-private/menu.js +322 -0
  15. package/dist/-private/overlay.d.ts +9 -0
  16. package/dist/-private/overlay.d.ts.map +1 -0
  17. package/dist/-private/overlay.js +39 -0
  18. package/dist/-private/showing.d.ts +7 -0
  19. package/dist/-private/showing.d.ts.map +1 -0
  20. package/dist/-private/showing.js +10 -0
  21. package/dist/-private/size.d.ts +10 -0
  22. package/dist/-private/size.d.ts.map +1 -0
  23. package/dist/-private/size.js +24 -0
  24. package/dist/-private/tree.d.ts +34 -0
  25. package/dist/-private/tree.d.ts.map +1 -0
  26. package/dist/-private/tree.js +80 -0
  27. package/dist/accordion.d.ts +62 -0
  28. package/dist/accordion.d.ts.map +1 -0
  29. package/dist/accordion.js +112 -0
  30. package/dist/alert-dialog.d.ts +24 -0
  31. package/dist/alert-dialog.d.ts.map +1 -0
  32. package/dist/alert-dialog.js +37 -0
  33. package/dist/alert.d.ts +27 -0
  34. package/dist/alert.d.ts.map +1 -0
  35. package/dist/alert.js +43 -0
  36. package/dist/aspect-ratio.d.ts +21 -0
  37. package/dist/aspect-ratio.d.ts.map +1 -0
  38. package/dist/aspect-ratio.js +30 -0
  39. package/dist/attachment.d.ts +86 -0
  40. package/dist/attachment.d.ts.map +1 -0
  41. package/dist/attachment.js +156 -0
  42. package/dist/avatar.d.ts +65 -0
  43. package/dist/avatar.d.ts.map +1 -0
  44. package/dist/avatar.js +106 -0
  45. package/dist/badge.d.ts +29 -0
  46. package/dist/badge.d.ts.map +1 -0
  47. package/dist/badge.js +49 -0
  48. package/dist/breadcrumb.d.ts +36 -0
  49. package/dist/breadcrumb.d.ts.map +1 -0
  50. package/dist/breadcrumb.js +80 -0
  51. package/dist/bubble.d.ts +56 -0
  52. package/dist/bubble.d.ts.map +1 -0
  53. package/dist/bubble.js +94 -0
  54. package/dist/button-group.d.ts +34 -0
  55. package/dist/button-group.d.ts.map +1 -0
  56. package/dist/button-group.js +62 -0
  57. package/dist/button.d.ts +37 -0
  58. package/dist/button.d.ts.map +1 -0
  59. package/dist/button.js +77 -0
  60. package/dist/calendar.d.ts +115 -0
  61. package/dist/calendar.d.ts.map +1 -0
  62. package/dist/calendar.js +276 -0
  63. package/dist/card.d.ts +31 -0
  64. package/dist/card.d.ts.map +1 -0
  65. package/dist/card.js +49 -0
  66. package/dist/checkbox.d.ts +46 -0
  67. package/dist/checkbox.d.ts.map +1 -0
  68. package/dist/checkbox.js +84 -0
  69. package/dist/child.d.ts +29 -0
  70. package/dist/child.d.ts.map +1 -0
  71. package/dist/child.js +27 -0
  72. package/dist/collapsible.d.ts +44 -0
  73. package/dist/collapsible.d.ts.map +1 -0
  74. package/dist/collapsible.js +83 -0
  75. package/dist/color-scheme.d.ts +44 -0
  76. package/dist/color-scheme.d.ts.map +1 -0
  77. package/dist/color-scheme.js +123 -0
  78. package/dist/combobox.d.ts +114 -0
  79. package/dist/combobox.d.ts.map +1 -0
  80. package/dist/combobox.js +293 -0
  81. package/dist/command.d.ts +92 -0
  82. package/dist/command.d.ts.map +1 -0
  83. package/dist/command.js +183 -0
  84. package/dist/context-menu.d.ts +37 -0
  85. package/dist/context-menu.d.ts.map +1 -0
  86. package/dist/context-menu.js +59 -0
  87. package/dist/date-picker.d.ts +48 -0
  88. package/dist/date-picker.d.ts.map +1 -0
  89. package/dist/date-picker.js +136 -0
  90. package/dist/dialog.d.ts +64 -0
  91. package/dist/dialog.d.ts.map +1 -0
  92. package/dist/dialog.js +142 -0
  93. package/dist/drawer.d.ts +63 -0
  94. package/dist/drawer.d.ts.map +1 -0
  95. package/dist/drawer.js +136 -0
  96. package/dist/dropdown-menu.d.ts +35 -0
  97. package/dist/dropdown-menu.d.ts.map +1 -0
  98. package/dist/dropdown-menu.js +49 -0
  99. package/dist/empty.d.ts +29 -0
  100. package/dist/empty.d.ts.map +1 -0
  101. package/dist/empty.js +47 -0
  102. package/dist/field.d.ts +86 -0
  103. package/dist/field.d.ts.map +1 -0
  104. package/dist/field.js +150 -0
  105. package/dist/file-drop.d.ts +74 -0
  106. package/dist/file-drop.d.ts.map +1 -0
  107. package/dist/file-drop.js +137 -0
  108. package/dist/focus.d.ts +54 -0
  109. package/dist/focus.d.ts.map +1 -0
  110. package/dist/focus.js +174 -0
  111. package/dist/harness.d.ts +90 -0
  112. package/dist/harness.d.ts.map +1 -0
  113. package/dist/harness.js +189 -0
  114. package/dist/heading.d.ts +16 -0
  115. package/dist/heading.d.ts.map +1 -0
  116. package/dist/heading.js +19 -0
  117. package/dist/hero.d.ts +21 -0
  118. package/dist/hero.d.ts.map +1 -0
  119. package/dist/hero.js +28 -0
  120. package/dist/hover-card.d.ts +46 -0
  121. package/dist/hover-card.d.ts.map +1 -0
  122. package/dist/hover-card.js +85 -0
  123. package/dist/icon.d.ts +10 -0
  124. package/dist/icon.d.ts.map +1 -0
  125. package/dist/icon.js +13 -0
  126. package/dist/index.d.ts +86 -0
  127. package/dist/index.d.ts.map +1 -0
  128. package/dist/index.js +87 -0
  129. package/dist/input-group.d.ts +55 -0
  130. package/dist/input-group.d.ts.map +1 -0
  131. package/dist/input-group.js +103 -0
  132. package/dist/input-otp.d.ts +103 -0
  133. package/dist/input-otp.d.ts.map +1 -0
  134. package/dist/input-otp.js +293 -0
  135. package/dist/input.d.ts +53 -0
  136. package/dist/input.d.ts.map +1 -0
  137. package/dist/input.js +90 -0
  138. package/dist/item.d.ts +63 -0
  139. package/dist/item.d.ts.map +1 -0
  140. package/dist/item.js +104 -0
  141. package/dist/kbd.d.ts +28 -0
  142. package/dist/kbd.d.ts.map +1 -0
  143. package/dist/kbd.js +36 -0
  144. package/dist/keys.d.ts +20 -0
  145. package/dist/keys.d.ts.map +1 -0
  146. package/dist/keys.js +32 -0
  147. package/dist/label.d.ts +24 -0
  148. package/dist/label.d.ts.map +1 -0
  149. package/dist/label.js +39 -0
  150. package/dist/layers.d.ts +42 -0
  151. package/dist/layers.d.ts.map +1 -0
  152. package/dist/layers.js +70 -0
  153. package/dist/link.d.ts +44 -0
  154. package/dist/link.d.ts.map +1 -0
  155. package/dist/link.js +60 -0
  156. package/dist/marker.d.ts +42 -0
  157. package/dist/marker.d.ts.map +1 -0
  158. package/dist/marker.js +73 -0
  159. package/dist/menubar.d.ts +76 -0
  160. package/dist/menubar.d.ts.map +1 -0
  161. package/dist/menubar.js +139 -0
  162. package/dist/message-scroller.d.ts +101 -0
  163. package/dist/message-scroller.d.ts.map +1 -0
  164. package/dist/message-scroller.js +215 -0
  165. package/dist/message.d.ts +48 -0
  166. package/dist/message.d.ts.map +1 -0
  167. package/dist/message.js +72 -0
  168. package/dist/native-form.d.ts +44 -0
  169. package/dist/native-form.d.ts.map +1 -0
  170. package/dist/native-form.js +111 -0
  171. package/dist/native-select.d.ts +56 -0
  172. package/dist/native-select.d.ts.map +1 -0
  173. package/dist/native-select.js +100 -0
  174. package/dist/navigation-menu.d.ts +97 -0
  175. package/dist/navigation-menu.d.ts.map +1 -0
  176. package/dist/navigation-menu.js +207 -0
  177. package/dist/observers.d.ts +21 -0
  178. package/dist/observers.d.ts.map +1 -0
  179. package/dist/observers.js +34 -0
  180. package/dist/pagination.d.ts +39 -0
  181. package/dist/pagination.d.ts.map +1 -0
  182. package/dist/pagination.js +71 -0
  183. package/dist/pointer.d.ts +38 -0
  184. package/dist/pointer.d.ts.map +1 -0
  185. package/dist/pointer.js +82 -0
  186. package/dist/popover.d.ts +50 -0
  187. package/dist/popover.d.ts.map +1 -0
  188. package/dist/popover.js +90 -0
  189. package/dist/progress.d.ts +38 -0
  190. package/dist/progress.d.ts.map +1 -0
  191. package/dist/progress.js +81 -0
  192. package/dist/questionnaire.d.ts +117 -0
  193. package/dist/questionnaire.d.ts.map +1 -0
  194. package/dist/questionnaire.js +240 -0
  195. package/dist/radio-group.d.ts +53 -0
  196. package/dist/radio-group.d.ts.map +1 -0
  197. package/dist/radio-group.js +95 -0
  198. package/dist/rating.d.ts +67 -0
  199. package/dist/rating.d.ts.map +1 -0
  200. package/dist/rating.js +160 -0
  201. package/dist/resizable.d.ts +76 -0
  202. package/dist/resizable.d.ts.map +1 -0
  203. package/dist/resizable.js +138 -0
  204. package/dist/routing.d.ts +36 -0
  205. package/dist/routing.d.ts.map +1 -0
  206. package/dist/routing.js +50 -0
  207. package/dist/roving-focus.d.ts +38 -0
  208. package/dist/roving-focus.d.ts.map +1 -0
  209. package/dist/roving-focus.js +60 -0
  210. package/dist/scroll-area.d.ts +58 -0
  211. package/dist/scroll-area.d.ts.map +1 -0
  212. package/dist/scroll-area.js +153 -0
  213. package/dist/scroller.d.ts +41 -0
  214. package/dist/scroller.d.ts.map +1 -0
  215. package/dist/scroller.js +65 -0
  216. package/dist/select.d.ts +98 -0
  217. package/dist/select.d.ts.map +1 -0
  218. package/dist/select.js +203 -0
  219. package/dist/selectors.d.ts +44 -0
  220. package/dist/selectors.d.ts.map +1 -0
  221. package/dist/selectors.js +63 -0
  222. package/dist/send-pointer.d.ts +17 -0
  223. package/dist/send-pointer.d.ts.map +1 -0
  224. package/dist/send-pointer.js +35 -0
  225. package/dist/separator.d.ts +26 -0
  226. package/dist/separator.d.ts.map +1 -0
  227. package/dist/separator.js +40 -0
  228. package/dist/shadowed.d.ts +55 -0
  229. package/dist/shadowed.d.ts.map +1 -0
  230. package/dist/shadowed.js +97 -0
  231. package/dist/sheet.d.ts +14 -0
  232. package/dist/sheet.d.ts.map +1 -0
  233. package/dist/sheet.js +15 -0
  234. package/dist/sidebar.d.ts +159 -0
  235. package/dist/sidebar.d.ts.map +1 -0
  236. package/dist/sidebar.js +299 -0
  237. package/dist/skeleton.d.ts +18 -0
  238. package/dist/skeleton.d.ts.map +1 -0
  239. package/dist/skeleton.js +25 -0
  240. package/dist/slider.d.ts +66 -0
  241. package/dist/slider.d.ts.map +1 -0
  242. package/dist/slider.js +155 -0
  243. package/dist/spinner.d.ts +10 -0
  244. package/dist/spinner.d.ts.map +1 -0
  245. package/dist/spinner.js +13 -0
  246. package/dist/sticky-footer.d.ts +33 -0
  247. package/dist/sticky-footer.d.ts.map +1 -0
  248. package/dist/sticky-footer.js +65 -0
  249. package/dist/switch.d.ts +44 -0
  250. package/dist/switch.d.ts.map +1 -0
  251. package/dist/switch.js +77 -0
  252. package/dist/table.d.ts +41 -0
  253. package/dist/table.d.ts.map +1 -0
  254. package/dist/table.js +100 -0
  255. package/dist/tabs.d.ts +66 -0
  256. package/dist/tabs.d.ts.map +1 -0
  257. package/dist/tabs.js +149 -0
  258. package/dist/test-hooks.d.ts +9 -0
  259. package/dist/test-hooks.d.ts.map +1 -0
  260. package/dist/test-hooks.js +1 -0
  261. package/dist/textarea.d.ts +47 -0
  262. package/dist/textarea.d.ts.map +1 -0
  263. package/dist/textarea.js +78 -0
  264. package/dist/toaster.d.ts +172 -0
  265. package/dist/toaster.d.ts.map +1 -0
  266. package/dist/toaster.js +307 -0
  267. package/dist/toggle-group.d.ts +51 -0
  268. package/dist/toggle-group.d.ts.map +1 -0
  269. package/dist/toggle-group.js +97 -0
  270. package/dist/toggle.d.ts +21 -0
  271. package/dist/toggle.d.ts.map +1 -0
  272. package/dist/toggle.js +26 -0
  273. package/dist/tooltip.d.ts +48 -0
  274. package/dist/tooltip.d.ts.map +1 -0
  275. package/dist/tooltip.js +91 -0
  276. package/dist/trace.d.ts +118 -0
  277. package/dist/trace.d.ts.map +1 -0
  278. package/dist/trace.js +196 -0
  279. package/dist/translator.d.ts +34 -0
  280. package/dist/translator.d.ts.map +1 -0
  281. package/dist/translator.js +75 -0
  282. package/dist/zoetrope.d.ts +51 -0
  283. package/dist/zoetrope.d.ts.map +1 -0
  284. package/dist/zoetrope.js +94 -0
  285. package/package.json +68 -3
@@ -0,0 +1,90 @@
1
+ import { click } from '@ember/test-helpers';
2
+ import { Harness } from "./harness.js";
3
+ import { pressEscape, pressOutside } from "./layers.js";
4
+ import { accessibleDescription, accessibleName, shownInTopLayer, text } from "./-private/overlay.js";
5
+ /**
6
+ * Drives a `<Popover>` from `@ember-joinery/ember` or `@ember-joinery/primitives/popover`. It
7
+ * reads the state from the trigger's ARIA (`aria-expanded`) and the content's, and acts as a
8
+ * user does: a click on the trigger, Escape, a press outside.
9
+ *
10
+ * const popover = new PopoverHarness('dimensions') // <Popover @name="dimensions">
11
+ * await popover.open()
12
+ * assert.strictEqual(popover.label, 'Dimensions')
13
+ * await popover.pressEscape()
14
+ * assert.false(popover.isOpen)
15
+ */
16
+ export class PopoverHarness extends Harness {
17
+ static component = 'popover';
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 content, or `null` while it isn't rendered. */
23
+ get content() {
24
+ return this.queryPart('content');
25
+ }
26
+ /** Whether it is open, from the trigger's `aria-expanded`. */
27
+ get isOpen() {
28
+ return this.trigger.getAttribute('aria-expanded') === 'true';
29
+ }
30
+ /** Whether the content is showing in the browser's top layer. */
31
+ get isShown() {
32
+ return shownInTopLayer(this.content);
33
+ }
34
+ /** The content's accessible name: its Title, or else its trigger, or your `aria-label`. */
35
+ get label() {
36
+ const content = this.content;
37
+ return content ? accessibleName(content) : '';
38
+ }
39
+ /** The content's accessible description: its Description's text, or `''`. */
40
+ get description() {
41
+ const content = this.content;
42
+ return content ? accessibleDescription(content) : '';
43
+ }
44
+ /** The Title's text, or `''`. */
45
+ get title() {
46
+ return text(this.queryPart('title'));
47
+ }
48
+ /** The content's text, whitespace collapsed. */
49
+ get text() {
50
+ return text(this.content);
51
+ }
52
+ /** The side the content was placed on, after any flip (`data-side`). */
53
+ get side() {
54
+ return this.content?.getAttribute('data-side') ?? null;
55
+ }
56
+ /** The content's alignment along that side (`data-align`). */
57
+ get align() {
58
+ return this.content?.getAttribute('data-align') ?? null;
59
+ }
60
+ /** The arrow's element (Radix's arrow is a `<span>` around an `<svg>`), or `null`. */
61
+ get arrow() {
62
+ return this.queryPart('arrow');
63
+ }
64
+ /** Clicks the trigger. */
65
+ async toggle() {
66
+ await click(this.trigger);
67
+ }
68
+ /** Opens it with a click on the trigger, unless it is open. */
69
+ async open() {
70
+ if (!this.isOpen)
71
+ await this.toggle();
72
+ }
73
+ /** Closes it with a click on the trigger, unless it is closed. */
74
+ async close() {
75
+ if (this.isOpen)
76
+ await this.toggle();
77
+ }
78
+ /** Clicks its Close part (the first, if there are several). */
79
+ async clickClose() {
80
+ await click(this.part('close'));
81
+ }
82
+ /** Presses Escape where focus is. */
83
+ async pressEscape() {
84
+ await pressEscape();
85
+ }
86
+ /** A press outside the popover, as a user dismissing it makes. */
87
+ async pressOutside() {
88
+ await pressOutside();
89
+ }
90
+ }
@@ -0,0 +1,38 @@
1
+ import { Harness } from './harness.ts';
2
+ /**
3
+ * Drives a `<Progress>`, from `@ember-joinery/ember` or `@ember-joinery/primitives/progress`.
4
+ * Everything comes from its `progressbar` ARIA, as assistive technology reads it, and its
5
+ * `data-state`.
6
+ *
7
+ * const upload = new ProgressHarness('upload') // <Progress @name="upload">
8
+ * assert.strictEqual(upload.value, 66)
9
+ * assert.strictEqual(upload.valueText, '66%')
10
+ */
11
+ export declare class ProgressHarness extends Harness {
12
+ static component: string;
13
+ /** The bar that shows how far along it is (`data-test-jn-part="indicator"`). */
14
+ get indicator(): HTMLElement;
15
+ /** Its value (`aria-valuenow`), or `null` while it is indeterminate. */
16
+ get value(): number | null;
17
+ /** Its maximum (`aria-valuemax`): 100 unless given `@max`. */
18
+ get max(): number;
19
+ /** Its minimum (`aria-valuemin`), always 0. */
20
+ get min(): number;
21
+ /** What assistive technology announces for the value (`aria-valuetext`): `66%` by default. */
22
+ get valueText(): string | null;
23
+ /** How far along it is, from 0 to 100, or `null` while it is indeterminate. */
24
+ get percent(): number | null;
25
+ /** Radix's `data-state`: `indeterminate` (no value), `loading`, or `complete` (at its max). */
26
+ get state(): string | null;
27
+ /** Whether it has no value, so it shows no particular progress. */
28
+ get isIndeterminate(): boolean;
29
+ /** Whether its value is its max. */
30
+ get isComplete(): boolean;
31
+ /**
32
+ * Its accessible name: `aria-label`, else the text of the elements `aria-labelledby` names.
33
+ * A `<label for>` doesn't name a progress bar (it isn't a form control), so give it one of
34
+ * those.
35
+ */
36
+ get label(): string;
37
+ }
38
+ //# sourceMappingURL=progress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAYtC;;;;;;;;GAQG;AACH,qBAAa,eAAgB,SAAQ,OAAO;IAC1C,OAAgB,SAAS,SAAa;IAEtC,gFAAgF;IAChF,IAAI,SAAS,IAAI,WAAW,CAE3B;IAED,wEAAwE;IACxE,IAAI,KAAK,IAAI,MAAM,GAAG,IAAI,CAEzB;IAED,8DAA8D;IAC9D,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,+CAA+C;IAC/C,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,8FAA8F;IAC9F,IAAI,SAAS,IAAI,MAAM,GAAG,IAAI,CAE7B;IAED,+EAA+E;IAC/E,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAI3B;IAED,+FAA+F;IAC/F,IAAI,KAAK,IAAI,MAAM,GAAG,IAAI,CAEzB;IAED,mEAAmE;IACnE,IAAI,eAAe,IAAI,OAAO,CAE7B;IAED,oCAAoC;IACpC,IAAI,UAAU,IAAI,OAAO,CAExB;IAED;;;;OAIG;IACH,IAAI,KAAK,IAAI,MAAM,CAYlB;CACF"}
@@ -0,0 +1,81 @@
1
+ import { Harness } from "./harness.js";
2
+ function text(element) {
3
+ return (element.textContent ?? '').replace(/\s+/g, ' ').trim();
4
+ }
5
+ function numberOf(value) {
6
+ if (value === null || value.trim() === '')
7
+ return null;
8
+ const number = Number(value);
9
+ return Number.isNaN(number) ? null : number;
10
+ }
11
+ /**
12
+ * Drives a `<Progress>`, from `@ember-joinery/ember` or `@ember-joinery/primitives/progress`.
13
+ * Everything comes from its `progressbar` ARIA, as assistive technology reads it, and its
14
+ * `data-state`.
15
+ *
16
+ * const upload = new ProgressHarness('upload') // <Progress @name="upload">
17
+ * assert.strictEqual(upload.value, 66)
18
+ * assert.strictEqual(upload.valueText, '66%')
19
+ */
20
+ export class ProgressHarness extends Harness {
21
+ static component = 'progress';
22
+ /** The bar that shows how far along it is (`data-test-jn-part="indicator"`). */
23
+ get indicator() {
24
+ return this.part('indicator');
25
+ }
26
+ /** Its value (`aria-valuenow`), or `null` while it is indeterminate. */
27
+ get value() {
28
+ return numberOf(this.element.getAttribute('aria-valuenow'));
29
+ }
30
+ /** Its maximum (`aria-valuemax`): 100 unless given `@max`. */
31
+ get max() {
32
+ return numberOf(this.element.getAttribute('aria-valuemax')) ?? 100;
33
+ }
34
+ /** Its minimum (`aria-valuemin`), always 0. */
35
+ get min() {
36
+ return numberOf(this.element.getAttribute('aria-valuemin')) ?? 0;
37
+ }
38
+ /** What assistive technology announces for the value (`aria-valuetext`): `66%` by default. */
39
+ get valueText() {
40
+ return this.element.getAttribute('aria-valuetext');
41
+ }
42
+ /** How far along it is, from 0 to 100, or `null` while it is indeterminate. */
43
+ get percent() {
44
+ const value = this.value;
45
+ if (value === null)
46
+ return null;
47
+ return Math.round(((value - this.min) / (this.max - this.min)) * 100 * 100) / 100;
48
+ }
49
+ /** Radix's `data-state`: `indeterminate` (no value), `loading`, or `complete` (at its max). */
50
+ get state() {
51
+ return this.element.getAttribute('data-state');
52
+ }
53
+ /** Whether it has no value, so it shows no particular progress. */
54
+ get isIndeterminate() {
55
+ return this.value === null;
56
+ }
57
+ /** Whether its value is its max. */
58
+ get isComplete() {
59
+ return this.value !== null && this.value === this.max;
60
+ }
61
+ /**
62
+ * Its accessible name: `aria-label`, else the text of the elements `aria-labelledby` names.
63
+ * A `<label for>` doesn't name a progress bar (it isn't a form control), so give it one of
64
+ * those.
65
+ */
66
+ get label() {
67
+ const element = this.element;
68
+ const label = element.getAttribute('aria-label');
69
+ if (label)
70
+ return label.trim();
71
+ const labelledBy = element.getAttribute('aria-labelledby');
72
+ if (!labelledBy)
73
+ return '';
74
+ return labelledBy
75
+ .split(/\s+/)
76
+ .map(id => element.ownerDocument.getElementById(id))
77
+ .filter((found) => Boolean(found))
78
+ .map(text)
79
+ .join(' ');
80
+ }
81
+ }
@@ -0,0 +1,117 @@
1
+ import { Harness } from './harness.ts';
2
+ import { type KeyModifiers } from './focus.ts';
3
+ /** A navigation button, by the part it is. */
4
+ export type QuestionnaireButton = 'previous' | 'skip' | 'next' | 'submit';
5
+ /**
6
+ * Drives a `<Questionnaire>`, from `@ember-joinery/ember` or, headless, from
7
+ * `@ember-joinery/primitives/questionnaire`. It reads each item by its `@name` (the active one
8
+ * by default): its status, its answers and its error, through the fieldset's and the controls'
9
+ * ARIA and native state; it answers as a reader does, by clicking a choice or typing, and moves
10
+ * with the navigation buttons or the keyboard.
11
+ *
12
+ * const plan = new QuestionnaireHarness('plan') // <Questionnaire @name="plan">
13
+ * await plan.choose('tool-calls')
14
+ * await plan.next()
15
+ * assert.strictEqual(plan.activeItem, 'signals')
16
+ * assert.strictEqual(plan.progressText, 'Question 2 of 3')
17
+ */
18
+ export declare class QuestionnaireHarness extends Harness {
19
+ #private;
20
+ static component: string;
21
+ /**
22
+ * This questionnaire's parts named `part`, in document order: those inside its form and not
23
+ * in a questionnaire nested in it. Unlike `parts()`, it counts parts inside another
24
+ * component (a Card, a Dialog's header) that the questionnaire's parts sit in.
25
+ */
26
+ own<E extends HTMLElement = HTMLElement>(part: string): E[];
27
+ /** The `<form>`. */
28
+ get form(): HTMLFormElement;
29
+ /** What the form would submit now. */
30
+ get formData(): FormData;
31
+ /** Each item's `@name`, in document order. */
32
+ get itemNames(): string[];
33
+ /** An item's `<fieldset>`: the active one by default. Throws when there is none. */
34
+ item(name?: string | null): HTMLFieldSetElement;
35
+ /** The name of the item that shows, or `null`. */
36
+ get activeItem(): string | null;
37
+ /** Whether an item is the one that shows. */
38
+ isActive(name: string): boolean;
39
+ /** An item's status: `unanswered`, `answered` or `skipped`. */
40
+ status(name?: string | null): string | null;
41
+ /** Whether an item shows as invalid (`aria-invalid` on its fieldset). */
42
+ isInvalid(name?: string | null): boolean;
43
+ /** Whether an item must be answered. */
44
+ isRequired(name?: string | null): boolean;
45
+ /** Whether an item takes several answers. */
46
+ isMultiple(name?: string | null): boolean;
47
+ /** Whether an item is disabled (it doesn't apply). */
48
+ isDisabled(name: string): boolean;
49
+ /** Whether an item, or something in it, has focus. */
50
+ isFocused(name?: string | null): boolean;
51
+ /** Whether the item's fieldset itself has focus, as it does after moving to it. */
52
+ isItemFocused(name?: string | null): boolean;
53
+ /** An item's question. */
54
+ title(name?: string | null): string;
55
+ /** An item's description, or `''`. */
56
+ description(name?: string | null): string;
57
+ /** The names its fieldset's `aria-describedby` gives, as a screen reader hears them. */
58
+ describedBy(name?: string | null): string;
59
+ /** The error an item shows, or `''` while it shows none. */
60
+ error(name?: string | null): string;
61
+ /** An item's fixed answers' values, in order. */
62
+ choices(name?: string | null): string[];
63
+ /** A fixed answer's row (its `<label>`). */
64
+ choice(value: string, name?: string | null): HTMLLabelElement;
65
+ /** A fixed answer's radio or checkbox. */
66
+ choiceInput(value: string, name?: string | null): HTMLInputElement;
67
+ /** A fixed answer's text, without its shortcut key. */
68
+ choiceLabel(value: string, name?: string | null): string;
69
+ /** The values of the fixed answers checked in an item, in order. */
70
+ checked(name?: string | null): string[];
71
+ /** Whether a fixed answer is checked. */
72
+ isChecked(value: string, name?: string | null): boolean;
73
+ /** A fixed answer's shortcut key, or `null` when it shows none. */
74
+ shortcut(value: string, name?: string | null): string | null;
75
+ /** An item's freeform answer, or `null` without one. */
76
+ input(name?: string | null): HTMLInputElement | null;
77
+ /** The progress that shows (one may sit in each item, as in a card's header). */
78
+ get progress(): HTMLElement;
79
+ /** What the progress says to a screen reader: `Question 2 of 3`. */
80
+ get progressText(): string;
81
+ /** The active item's position, from 1. */
82
+ get current(): number;
83
+ /** How many items it steps through. */
84
+ get total(): number;
85
+ /** A navigation button. */
86
+ button(kind: QuestionnaireButton): HTMLButtonElement;
87
+ /** Whether a navigation button shows (each shows only where it applies). */
88
+ isShown(kind: QuestionnaireButton): boolean;
89
+ /** Whether Previous shows. */
90
+ get canGoBack(): boolean;
91
+ /** Whether Skip shows. */
92
+ get canSkip(): boolean;
93
+ /** Whether Next shows. */
94
+ get canGoNext(): boolean;
95
+ /** Whether Submit shows. */
96
+ get canSubmit(): boolean;
97
+ /** Clicks a fixed answer, as a reader does: checks a radio, toggles a checkbox. */
98
+ choose(value: string, name?: string | null): Promise<void>;
99
+ /** Types into an item's freeform answer, replacing what is there. */
100
+ fillIn(value: string, name?: string | null): Promise<void>;
101
+ /** Clicks Next. */
102
+ next(): Promise<void>;
103
+ /** Clicks Previous. */
104
+ previous(): Promise<void>;
105
+ /** Clicks Skip. */
106
+ skip(): Promise<void>;
107
+ /** Clicks Submit. */
108
+ submit(): Promise<void>;
109
+ /** Moves focus to a fixed answer's control. */
110
+ focusChoice(value: string, name?: string | null): Promise<void>;
111
+ /**
112
+ * Presses a key on the focused element, as the questionnaire's keyboard expects it:
113
+ * `ArrowDown`, `ArrowRight`, a shortcut letter, or `Enter` with `{ metaKey: true }`.
114
+ */
115
+ press(key: string, modifiers?: KeyModifiers): Promise<boolean>;
116
+ }
117
+ //# sourceMappingURL=questionnaire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"questionna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AGrE"}
@@ -0,0 +1,240 @@
1
+ import { click, fillIn, focus } from '@ember/test-helpers';
2
+ import { Harness } from "./harness.js";
3
+ import { pressKey } from "./focus.js";
4
+ function text(element) {
5
+ return (element?.textContent ?? '').replace(/\s+/g, ' ').trim();
6
+ }
7
+ /** Whether an element shows: neither it nor an ancestor is `hidden`. */
8
+ function shown(element) {
9
+ return !element.closest('[hidden]');
10
+ }
11
+ /**
12
+ * Drives a `<Questionnaire>`, from `@ember-joinery/ember` or, headless, from
13
+ * `@ember-joinery/primitives/questionnaire`. It reads each item by its `@name` (the active one
14
+ * by default): its status, its answers and its error, through the fieldset's and the controls'
15
+ * ARIA and native state; it answers as a reader does, by clicking a choice or typing, and moves
16
+ * with the navigation buttons or the keyboard.
17
+ *
18
+ * const plan = new QuestionnaireHarness('plan') // <Questionnaire @name="plan">
19
+ * await plan.choose('tool-calls')
20
+ * await plan.next()
21
+ * assert.strictEqual(plan.activeItem, 'signals')
22
+ * assert.strictEqual(plan.progressText, 'Question 2 of 3')
23
+ */
24
+ export class QuestionnaireHarness extends Harness {
25
+ static component = 'questionnaire';
26
+ /**
27
+ * This questionnaire's parts named `part`, in document order: those inside its form and not
28
+ * in a questionnaire nested in it. Unlike `parts()`, it counts parts inside another
29
+ * component (a Card, a Dialog's header) that the questionnaire's parts sit in.
30
+ */
31
+ own(part) {
32
+ const form = this.element;
33
+ return [...form.querySelectorAll(`[data-test-jn-part="${part}"]`)].filter(element => element.closest('[data-test-jn="questionnaire"]') === form);
34
+ }
35
+ /** The `<form>`. */
36
+ get form() {
37
+ return this.element;
38
+ }
39
+ /** What the form would submit now. */
40
+ get formData() {
41
+ return new FormData(this.form);
42
+ }
43
+ /** Each item's `@name`, in document order. */
44
+ get itemNames() {
45
+ return this.own('item').map(item => item.getAttribute('data-test-jn-value'));
46
+ }
47
+ /** An item's `<fieldset>`: the active one by default. Throws when there is none. */
48
+ item(name = this.activeItem) {
49
+ if (name === null)
50
+ throw new Error(`Joinery harness: ${this} shows no item`);
51
+ const item = this.own('item').find(element => element.getAttribute('data-test-jn-value') === name);
52
+ if (!item)
53
+ throw new Error(`Joinery harness: no item "${name}" in ${this}`);
54
+ return item;
55
+ }
56
+ /** The name of the item that shows, or `null`. */
57
+ get activeItem() {
58
+ const active = this.own('item').find(item => !item.hidden);
59
+ return active?.getAttribute('data-test-jn-value') ?? null;
60
+ }
61
+ /** Whether an item is the one that shows. */
62
+ isActive(name) {
63
+ return !this.item(name).hidden;
64
+ }
65
+ /** An item's status: `unanswered`, `answered` or `skipped`. */
66
+ status(name = this.activeItem) {
67
+ return this.item(name).getAttribute('data-status');
68
+ }
69
+ /** Whether an item shows as invalid (`aria-invalid` on its fieldset). */
70
+ isInvalid(name = this.activeItem) {
71
+ return this.item(name).getAttribute('aria-invalid') === 'true';
72
+ }
73
+ /** Whether an item must be answered. */
74
+ isRequired(name = this.activeItem) {
75
+ return this.item(name).hasAttribute('data-required');
76
+ }
77
+ /** Whether an item takes several answers. */
78
+ isMultiple(name = this.activeItem) {
79
+ return this.item(name).hasAttribute('data-multiple');
80
+ }
81
+ /** Whether an item is disabled (it doesn't apply). */
82
+ isDisabled(name) {
83
+ return this.item(name).disabled;
84
+ }
85
+ /** Whether an item, or something in it, has focus. */
86
+ isFocused(name = this.activeItem) {
87
+ const active = document.activeElement;
88
+ return Boolean(active && this.item(name).contains(active));
89
+ }
90
+ /** Whether the item's fieldset itself has focus, as it does after moving to it. */
91
+ isItemFocused(name = this.activeItem) {
92
+ return document.activeElement === this.item(name);
93
+ }
94
+ #within(name, part) {
95
+ const item = this.item(name);
96
+ return this.own(part).filter(element => item.contains(element));
97
+ }
98
+ /** An item's question. */
99
+ title(name = this.activeItem) {
100
+ return text(this.#within(name, 'title')[0]);
101
+ }
102
+ /** An item's description, or `''`. */
103
+ description(name = this.activeItem) {
104
+ return text(this.#within(name, 'description')[0]);
105
+ }
106
+ /** The names its fieldset's `aria-describedby` gives, as a screen reader hears them. */
107
+ describedBy(name = this.activeItem) {
108
+ const ids = this.item(name).getAttribute('aria-describedby')?.split(/\s+/) ?? [];
109
+ return ids
110
+ .map(id => text(document.getElementById(id)))
111
+ .filter(Boolean)
112
+ .join(' ');
113
+ }
114
+ /** The error an item shows, or `''` while it shows none. */
115
+ error(name = this.activeItem) {
116
+ const error = this.#within(name, 'error').find(element => !element.hidden);
117
+ return text(error);
118
+ }
119
+ /** An item's fixed answers' values, in order. */
120
+ choices(name = this.activeItem) {
121
+ return this.#within(name, 'choice').map(choice => choice.getAttribute('data-test-jn-value'));
122
+ }
123
+ /** A fixed answer's row (its `<label>`). */
124
+ choice(value, name = this.activeItem) {
125
+ const choice = this.#within(name, 'choice').find(element => element.getAttribute('data-test-jn-value') === value);
126
+ if (!choice)
127
+ throw new Error(`Joinery harness: no choice "${value}" in item "${name}"`);
128
+ return choice;
129
+ }
130
+ /** A fixed answer's radio or checkbox. */
131
+ choiceInput(value, name = this.activeItem) {
132
+ return this.choice(value, name).querySelector('[data-test-jn-part="choice-input"]');
133
+ }
134
+ /** A fixed answer's text, without its shortcut key. */
135
+ choiceLabel(value, name = this.activeItem) {
136
+ return text(this.choice(value, name).querySelector('[data-test-jn-part="choice-label"]'));
137
+ }
138
+ /** The values of the fixed answers checked in an item, in order. */
139
+ checked(name = this.activeItem) {
140
+ return this.choices(name).filter(value => this.choiceInput(value, name).checked);
141
+ }
142
+ /** Whether a fixed answer is checked. */
143
+ isChecked(value, name = this.activeItem) {
144
+ return this.choiceInput(value, name).checked;
145
+ }
146
+ /** A fixed answer's shortcut key, or `null` when it shows none. */
147
+ shortcut(value, name = this.activeItem) {
148
+ const key = this.choice(value, name).querySelector('[data-test-jn-part="shortcut"]');
149
+ return key && !key.hidden ? text(key) : null;
150
+ }
151
+ /** An item's freeform answer, or `null` without one. */
152
+ input(name = this.activeItem) {
153
+ return this.#within(name, 'input')[0] ?? null;
154
+ }
155
+ /** The progress that shows (one may sit in each item, as in a card's header). */
156
+ get progress() {
157
+ const progress = this.own('progress').find(shown);
158
+ if (!progress)
159
+ throw new Error(`Joinery harness: ${this} shows no progress`);
160
+ return progress;
161
+ }
162
+ /** What the progress says to a screen reader: `Question 2 of 3`. */
163
+ get progressText() {
164
+ return this.progress.getAttribute('aria-valuetext') ?? '';
165
+ }
166
+ /** The active item's position, from 1. */
167
+ get current() {
168
+ return Number(this.form.getAttribute('data-current'));
169
+ }
170
+ /** How many items it steps through. */
171
+ get total() {
172
+ return Number(this.form.getAttribute('data-total'));
173
+ }
174
+ /** A navigation button. */
175
+ button(kind) {
176
+ const button = this.own(kind)[0];
177
+ if (!button)
178
+ throw new Error(`Joinery harness: no "${kind}" button in ${this}`);
179
+ return button;
180
+ }
181
+ /** Whether a navigation button shows (each shows only where it applies). */
182
+ isShown(kind) {
183
+ const button = this.own(kind)[0];
184
+ return Boolean(button && shown(button));
185
+ }
186
+ /** Whether Previous shows. */
187
+ get canGoBack() {
188
+ return this.isShown('previous');
189
+ }
190
+ /** Whether Skip shows. */
191
+ get canSkip() {
192
+ return this.isShown('skip');
193
+ }
194
+ /** Whether Next shows. */
195
+ get canGoNext() {
196
+ return this.isShown('next');
197
+ }
198
+ /** Whether Submit shows. */
199
+ get canSubmit() {
200
+ return this.isShown('submit');
201
+ }
202
+ /** Clicks a fixed answer, as a reader does: checks a radio, toggles a checkbox. */
203
+ async choose(value, name = this.activeItem) {
204
+ await click(this.choiceInput(value, name));
205
+ }
206
+ /** Types into an item's freeform answer, replacing what is there. */
207
+ async fillIn(value, name = this.activeItem) {
208
+ const input = this.input(name);
209
+ if (!input)
210
+ throw new Error(`Joinery harness: item "${name}" has no freeform answer`);
211
+ await fillIn(input, value);
212
+ }
213
+ /** Clicks Next. */
214
+ async next() {
215
+ await click(this.button('next'));
216
+ }
217
+ /** Clicks Previous. */
218
+ async previous() {
219
+ await click(this.button('previous'));
220
+ }
221
+ /** Clicks Skip. */
222
+ async skip() {
223
+ await click(this.button('skip'));
224
+ }
225
+ /** Clicks Submit. */
226
+ async submit() {
227
+ await click(this.button('submit'));
228
+ }
229
+ /** Moves focus to a fixed answer's control. */
230
+ async focusChoice(value, name = this.activeItem) {
231
+ await focus(this.choiceInput(value, name));
232
+ }
233
+ /**
234
+ * Presses a key on the focused element, as the questionnaire's keyboard expects it:
235
+ * `ArrowDown`, `ArrowRight`, a shortcut letter, or `Enter` with `{ metaKey: true }`.
236
+ */
237
+ async press(key, modifiers) {
238
+ return pressKey(key, modifiers);
239
+ }
240
+ }
@@ -0,0 +1,53 @@
1
+ import { Harness } from './harness.ts';
2
+ import { type KeyModifiers } from './focus.ts';
3
+ /**
4
+ * Drives a `<RadioGroup>` from `@ember-joinery/ember`, or the headless one from
5
+ * `@ember-joinery/primitives/radio-group`. Items are found by their `@value`
6
+ * (`data-test-jn-value`), and state comes from ARIA: each item's `aria-checked`, the group's
7
+ * `aria-required` and `aria-orientation`.
8
+ *
9
+ * const spacing = new RadioGroupHarness('spacing') // <RadioGroup @name="spacing">
10
+ * await spacing.choose('compact')
11
+ * assert.strictEqual(spacing.value, 'compact')
12
+ * await spacing.press('ArrowUp') // focus, and the choice, move to the previous item
13
+ */
14
+ export declare class RadioGroupHarness extends Harness {
15
+ static component: string;
16
+ /** Each item's element, in order. */
17
+ get items(): HTMLElement[];
18
+ /** Each item's value, in order. */
19
+ get options(): string[];
20
+ /** The item with this value. Throws when there is none. */
21
+ item(value: string): HTMLElement;
22
+ /** The chosen item's value, or `null` when none is. */
23
+ get value(): string | null;
24
+ /** Whether the item with this value is chosen. */
25
+ isChecked(value: string): boolean;
26
+ /** Whether the item with this value can't be chosen. */
27
+ isItemDisabled(value: string): boolean;
28
+ /** Whether the item with this value is marked invalid (`aria-invalid`). */
29
+ isItemInvalid(value: string): boolean;
30
+ /** The accessible name of the item with this value: its `<label>`'s text, or its ARIA. */
31
+ labelOf(value: string): string;
32
+ /** The group's accessible name: `aria-label` or `aria-labelledby`. */
33
+ get label(): string;
34
+ /** Whether every item is disabled (the group's `@disabled`). */
35
+ get isDisabled(): boolean;
36
+ /** Whether a form needs a choice (`aria-required="true"`). */
37
+ get isRequired(): boolean;
38
+ /** `horizontal`, `vertical`, or `null` when every arrow key moves (`aria-orientation`). */
39
+ get orientation(): string | null;
40
+ /** The value of the item that has focus, or `null` when focus is elsewhere. */
41
+ get focused(): string | null;
42
+ /** The value of the item Tab enters on (`tabindex="0"`), or `null` before any has had focus. */
43
+ get tabStop(): string | null;
44
+ /** The hidden native radio the item with this value renders in a form, or `null`. */
45
+ inputOf(value: string): HTMLInputElement | null;
46
+ /** Clicks the item with this value, as a user would, which chooses it. */
47
+ choose(value: string): Promise<void>;
48
+ /** Moves focus to the item with this value, as a click would, without choosing it. */
49
+ focus(value: string): Promise<void>;
50
+ /** Presses a key on the focused item: an arrow moves focus and the choice. */
51
+ press(key: string, modifiers?: KeyModifiers): Promise<boolean>;
52
+ }
53
+ //# sourceMappingURL=radio-group.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"radio-group.d.ts","sourceRoot":"","sources":["../src/radio-group.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,YAAY,CAAA;AAGxD;;;;;;;;;;GAUG;AACH,qBAAa,iBAAkB,SAAQ,OAAO;IAC5C,OAAgB,SAAS,SAAgB;IAEzC,qCAAqC;IACrC,IAAI,KAAK,IAAI,WAAW,EAAE,CAEzB;IAED,mCAAmC;IACnC,IAAI,OAAO,IAAI,MAAM,EAAE,CAEtB;IAED,2DAA2D;IAC3D,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW;IAIhC,uDAAuD;IACvD,IAAI,KAAK,IAAI,MAAM,GAAG,IAAI,CAGzB;IAED,kDAAkD;IAClD,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIjC,wDAAwD;IACxD,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAItC,2EAA2E;IAC3E,aAAa,CAAC,KAAK,EAAE,M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