@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,92 @@
1
+ import { DialogHarness } from './dialog.ts';
2
+ import { type KeyModifiers } from './focus.ts';
3
+ import { Harness } from './harness.ts';
4
+ /**
5
+ * Drives a `<Command>` from `@ember-joinery/ember`, or the primitives' `Command`: the search
6
+ * box, the items it shows (in the order a search ranks them), the selected item, and the keys.
7
+ * It reads state through ARIA: the items are `role="option"` with `aria-selected` and
8
+ * `aria-disabled`, and the input names the selected one in `aria-activedescendant`.
9
+ *
10
+ * const command = new CommandHarness()
11
+ * await command.search('cal')
12
+ * assert.deepEqual(command.itemValues, ['Calendar', 'Calculator'])
13
+ * await command.press('ArrowDown')
14
+ * assert.strictEqual(command.selected, 'Calculator')
15
+ * await command.press('Enter') // chooses it
16
+ */
17
+ export declare class CommandHarness extends Harness {
18
+ static component: string;
19
+ /** The search box. */
20
+ get input(): HTMLInputElement;
21
+ /** The list the items show in. */
22
+ get list(): HTMLElement;
23
+ /** The items it shows, in the order they show. */
24
+ get items(): HTMLElement[];
25
+ /** Each shown item's value (its `@value`, or its text), in the order they show. */
26
+ get itemValues(): string[];
27
+ /** Each shown item's text, in the order they show. */
28
+ get texts(): string[];
29
+ /** The item with this value. Throws when it isn't shown. */
30
+ item(value: string): HTMLElement;
31
+ /** Whether an item with this value is shown. */
32
+ hasItem(value: string): boolean;
33
+ /** The selected item's value (`aria-selected`), or `null`. */
34
+ get selected(): string | null;
35
+ /** The item the input names in `aria-activedescendant`, or `null`. */
36
+ get activeItem(): HTMLElement | null;
37
+ /** Whether the item with this value is selected. */
38
+ isSelected(value: string): boolean;
39
+ /** Whether the item with this value is disabled (`aria-disabled`). */
40
+ isDisabled(value: string): boolean;
41
+ /** The groups shown (a search hides those it leaves nothing in), in the order they show. */
42
+ get groups(): HTMLElement[];
43
+ /** The headings of the groups shown, in the order they show. */
44
+ get headings(): string[];
45
+ /** The values of the items shown in the group with this heading. */
46
+ groupValues(heading: string): string[];
47
+ /** The separators shown: none during a search, unless they `@alwaysRender`. */
48
+ get separators(): HTMLElement[];
49
+ /** What shows when nothing matches, or `null` while something does. */
50
+ get empty(): HTMLElement | null;
51
+ /** Whether nothing matches the search. */
52
+ get isEmpty(): boolean;
53
+ /** What `role="status"` says for screen readers: `3 results`. */
54
+ get status(): string;
55
+ /** The text in the search box. */
56
+ get query(): string;
57
+ /** Whether focus is in the search box. */
58
+ get hasFocus(): boolean;
59
+ /** Types a search, replacing what was there, as a user typing it would. */
60
+ search(query: string): Promise<void>;
61
+ /** Empties the search box. */
62
+ clear(): Promise<void>;
63
+ /**
64
+ * Presses a key in the search box (focusing it first): `'ArrowDown'`, `'Enter'`, `'n'` with
65
+ * `{ ctrlKey: true }`.
66
+ */
67
+ press(key: string, modifiers?: KeyModifiers): Promise<void>;
68
+ /** Moves the pointer over an item, which selects it. */
69
+ hover(value: string): Promise<void>;
70
+ /** Chooses an item with a click. */
71
+ choose(value: string): Promise<void>;
72
+ }
73
+ /**
74
+ * Drives a `<CommandDialog>`: a `DialogHarness` (open or not, its title, Escape, a press
75
+ * outside) with the `<Command>` inside it as `command`.
76
+ *
77
+ * const palette = new CommandDialogHarness()
78
+ * await palette.pressHotkey('mod+k')
79
+ * assert.true(palette.isOpen)
80
+ * await palette.command.search('settings')
81
+ */
82
+ export declare class CommandDialogHarness extends DialogHarness {
83
+ static component: string | readonly string[];
84
+ /** The command menu inside it, while it is open. */
85
+ get command(): CommandHarness;
86
+ /**
87
+ * Presses a hotkey as the browser would, on whatever has focus: `"mod+k"`, where `mod` is ⌘
88
+ * on a Mac and Ctrl elsewhere, as `@hotkey` reads it.
89
+ */
90
+ pressHotkey(hotkey: string): Promise<void>;
91
+ }
92
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAatC;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAe,SAAQ,OAAO;IACzC,OAAgB,SAAS,SAAY;IAErC,sBAAsB;IACtB,IAAI,KAAK,IAAI,gBAAgB,CAE5B;IAED,kCAAkC;IAClC,IAAI,IAAI,IAAI,WAAW,CAEtB;IAED,kDAAkD;IAClD,IAAI,KAAK,IAAI,WAAW,EAAE,CAKzB;IAED,mFAAmF;IACnF,IAAI,UAAU,IAAI,MAAM,EAAE,CAEzB;IAED,sDAAsD;IACtD,IAAI,KAAK,IAAI,MAAM,EAAE,CAEpB;IAED,4DAA4D;IAC5D,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW;IAIhC,gDAAgD;IAChD,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI/B,8DAA8D;IAC9D,IAAI,QAAQ,IAAI,MAAM,GAAG,IAAI,CAG5B;IAED,sEAAsE;IACtE,IAAI,UAAU,IAAI,WAAW,GAAG,IAAI,CAGnC;IAED,oDAAoD;IACpD,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIlC,sEAAsE;IACtE,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIlC,4FAA4F;IAC5F,IAAI,MAAM,IAAI,WAAW,EAAE,CAM1B;IAED,gEAAgE;IAChE,IAAI,QAAQ,IAAI,MAAM,EAAE,CAEvB;IAED,oEAAoE;IACpE,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE;IAQtC,+EAA+E;IAC/E,IAAI,UAAU,IAAI,WAAW,EAAE,CAE9B;IAED,uEAAuE;IACvE,IAAI,KAAK,IAAI,WAAW,GAAG,IAAI,CAE9B;IAED,0CAA0C;IAC1C,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,iEAAiE;IACjE,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,kCAAkC;IAClC,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,0CAA0C;IAC1C,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,2EAA2E;IACrE,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1C,8BAA8B;IACxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;;OAGG;IACG,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjE,wDAAwD;IAClD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC,oCAAoC;IAC9B,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3C;AAED;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,SAAQ,aAAa;IACrD,OAAgB,SAAS,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAmB;IAExE,oDAAoD;IACpD,IAAI,OAAO,IAAI,cAAc,CAE5B;IAED;;;OAGG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAkBjD"}
@@ -0,0 +1,183 @@
1
+ import { click, fillIn, focus, settled, triggerEvent } from '@ember/test-helpers';
2
+ import { DialogHarness } from "./dialog.js";
3
+ import { pressKey } from "./focus.js";
4
+ import { Harness } from "./harness.js";
5
+ import { attributes } from "./selectors.js";
6
+ function text(element) {
7
+ return (element.textContent ?? '').replace(/\s+/g, ' ').trim();
8
+ }
9
+ /** Where an item shows: its `aria-posinset` while a search ranks the items, else its place. */
10
+ function position(element, index) {
11
+ const posinset = element.getAttribute('aria-posinset');
12
+ return posinset === null ? index : Number(posinset);
13
+ }
14
+ /**
15
+ * Drives a `<Command>` from `@ember-joinery/ember`, or the primitives' `Command`: the search
16
+ * box, the items it shows (in the order a search ranks them), the selected item, and the keys.
17
+ * It reads state through ARIA: the items are `role="option"` with `aria-selected` and
18
+ * `aria-disabled`, and the input names the selected one in `aria-activedescendant`.
19
+ *
20
+ * const command = new CommandHarness()
21
+ * await command.search('cal')
22
+ * assert.deepEqual(command.itemValues, ['Calendar', 'Calculator'])
23
+ * await command.press('ArrowDown')
24
+ * assert.strictEqual(command.selected, 'Calculator')
25
+ * await command.press('Enter') // chooses it
26
+ */
27
+ export class CommandHarness extends Harness {
28
+ static component = 'command';
29
+ /** The search box. */
30
+ get input() {
31
+ return this.part('input');
32
+ }
33
+ /** The list the items show in. */
34
+ get list() {
35
+ return this.part('list');
36
+ }
37
+ /** The items it shows, in the order they show. */
38
+ get items() {
39
+ return this.parts('item')
40
+ .map((element, index) => [element, position(element, index)])
41
+ .sort((a, b) => a[1] - b[1])
42
+ .map(([element]) => element);
43
+ }
44
+ /** Each shown item's value (its `@value`, or its text), in the order they show. */
45
+ get itemValues() {
46
+ return this.items.map(item => item.getAttribute(attributes.value) ?? '');
47
+ }
48
+ /** Each shown item's text, in the order they show. */
49
+ get texts() {
50
+ return this.items.map(text);
51
+ }
52
+ /** The item with this value. Throws when it isn't shown. */
53
+ item(value) {
54
+ return this.part('item', value);
55
+ }
56
+ /** Whether an item with this value is shown. */
57
+ hasItem(value) {
58
+ return this.queryPart('item', value) !== null;
59
+ }
60
+ /** The selected item's value (`aria-selected`), or `null`. */
61
+ get selected() {
62
+ const item = this.items.find(element => element.getAttribute('aria-selected') === 'true');
63
+ return item?.getAttribute(attributes.value) ?? null;
64
+ }
65
+ /** The item the input names in `aria-activedescendant`, or `null`. */
66
+ get activeItem() {
67
+ const id = this.input.getAttribute('aria-activedescendant');
68
+ return id ? (this.items.find(item => item.id === id) ?? null) : null;
69
+ }
70
+ /** Whether the item with this value is selected. */
71
+ isSelected(value) {
72
+ return this.item(value).getAttribute('aria-selected') === 'true';
73
+ }
74
+ /** Whether the item with this value is disabled (`aria-disabled`). */
75
+ isDisabled(value) {
76
+ return this.item(value).getAttribute('aria-disabled') === 'true';
77
+ }
78
+ /** The groups shown (a search hides those it leaves nothing in), in the order they show. */
79
+ get groups() {
80
+ return this.parts('group')
81
+ .filter(group => !group.hidden)
82
+ .map((element, index) => [element, Number(element.style.order) || 0, index])
83
+ .sort((a, b) => a[1] - b[1] || a[2] - b[2])
84
+ .map(([element]) => element);
85
+ }
86
+ /** The headings of the groups shown, in the order they show. */
87
+ get headings() {
88
+ return this.groups.map(group => group.getAttribute(attributes.value) ?? '');
89
+ }
90
+ /** The values of the items shown in the group with this heading. */
91
+ groupValues(heading) {
92
+ const group = this.parts('group').find(element => element.getAttribute(attributes.value) === heading);
93
+ if (!group)
94
+ return [];
95
+ return this.itemValues.filter(value => group.contains(this.item(value)));
96
+ }
97
+ /** The separators shown: none during a search, unless they `@alwaysRender`. */
98
+ get separators() {
99
+ return this.parts('separator');
100
+ }
101
+ /** What shows when nothing matches, or `null` while something does. */
102
+ get empty() {
103
+ return this.queryPart('empty');
104
+ }
105
+ /** Whether nothing matches the search. */
106
+ get isEmpty() {
107
+ return this.empty !== null;
108
+ }
109
+ /** What `role="status"` says for screen readers: `3 results`. */
110
+ get status() {
111
+ return text(this.part('status'));
112
+ }
113
+ /** The text in the search box. */
114
+ get query() {
115
+ return this.input.value;
116
+ }
117
+ /** Whether focus is in the search box. */
118
+ get hasFocus() {
119
+ return this.input.ownerDocument.activeElement === this.input;
120
+ }
121
+ /** Types a search, replacing what was there, as a user typing it would. */
122
+ async search(query) {
123
+ await fillIn(this.input, query);
124
+ }
125
+ /** Empties the search box. */
126
+ async clear() {
127
+ await fillIn(this.input, '');
128
+ }
129
+ /**
130
+ * Presses a key in the search box (focusing it first): `'ArrowDown'`, `'Enter'`, `'n'` with
131
+ * `{ ctrlKey: true }`.
132
+ */
133
+ async press(key, modifiers) {
134
+ if (!this.hasFocus)
135
+ await focus(this.input);
136
+ await pressKey(key, modifiers);
137
+ }
138
+ /** Moves the pointer over an item, which selects it. */
139
+ async hover(value) {
140
+ await triggerEvent(this.item(value), 'pointermove');
141
+ }
142
+ /** Chooses an item with a click. */
143
+ async choose(value) {
144
+ await click(this.item(value));
145
+ }
146
+ }
147
+ /**
148
+ * Drives a `<CommandDialog>`: a `DialogHarness` (open or not, its title, Escape, a press
149
+ * outside) with the `<Command>` inside it as `command`.
150
+ *
151
+ * const palette = new CommandDialogHarness()
152
+ * await palette.pressHotkey('mod+k')
153
+ * assert.true(palette.isOpen)
154
+ * await palette.command.search('settings')
155
+ */
156
+ export class CommandDialogHarness extends DialogHarness {
157
+ static component = 'command-dialog';
158
+ /** The command menu inside it, while it is open. */
159
+ get command() {
160
+ return this.child(CommandHarness);
161
+ }
162
+ /**
163
+ * Presses a hotkey as the browser would, on whatever has focus: `"mod+k"`, where `mod` is ⌘
164
+ * on a Mac and Ctrl elsewhere, as `@hotkey` reads it.
165
+ */
166
+ async pressHotkey(hotkey) {
167
+ const parts = hotkey.split('+').map(part => part.trim().toLowerCase());
168
+ const key = parts.pop() ?? '';
169
+ // As `isMac()` in @ember-joinery/primitives/keys decides it.
170
+ const nav = navigator;
171
+ const mac = /mac|ios/i.test(nav.userAgentData?.platform ?? '') ||
172
+ /Mac OS|Macintosh|iPhone|iPad/.test(nav.userAgent);
173
+ const has = (name) => parts.includes(name);
174
+ const modifiers = {
175
+ metaKey: has('meta') || (has('mod') && mac),
176
+ ctrlKey: has('ctrl') || (has('mod') && !mac),
177
+ altKey: has('alt'),
178
+ shiftKey: has('shift'),
179
+ };
180
+ await pressKey(key, modifiers);
181
+ await settled();
182
+ }
183
+ }
@@ -0,0 +1,37 @@
1
+ import { MenuHarness } from './-private/menu.ts';
2
+ /** Where in the viewport a right click or long press lands. */
3
+ export interface MenuPoint {
4
+ x: number;
5
+ y: number;
6
+ }
7
+ /**
8
+ * Drives a `<ContextMenu>` from `@ember-joinery/ember` or
9
+ * `@ember-joinery/primitives/context-menu`. It reads the state from the trigger's `data-state`
10
+ * and the items' ARIA, finds items by their text, and acts as a user does: a right click on the
11
+ * trigger (or a long press), keys, a click on an item.
12
+ *
13
+ * const menu = new ContextMenuHarness()
14
+ * await menu.open() // a right click in the middle of the trigger
15
+ * assert.deepEqual(menu.items, ['Back', 'Forward', 'Reload'])
16
+ * await menu.select('Reload')
17
+ */
18
+ export declare class ContextMenuHarness extends MenuHarness {
19
+ static component: string;
20
+ /** Whether it is open, from the trigger's `data-state`. */
21
+ get isOpen(): boolean;
22
+ /**
23
+ * Right-clicks the trigger, at `point` (in the viewport) or its centre: the menu opens there.
24
+ * A right click while it is open moves it to the new point.
25
+ */
26
+ open(point?: MenuPoint): Promise<void>;
27
+ /**
28
+ * Holds a touch (or a pen) on the trigger until the menu opens, as a long press on a phone
29
+ * does, then lifts it.
30
+ */
31
+ longPress(point?: MenuPoint, { pointerType }?: {
32
+ pointerType?: 'touch' | 'pen';
33
+ }): Promise<void>;
34
+ /** Closes it with Escape, unless it is closed. */
35
+ close(): Promise<void>;
36
+ }
37
+ //# sourceMappingURL=context-menu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-menu.d.ts","sourceRoot":"","sources":["../src/context-menu.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAkB,MAAM,oBAAoB,CAAA;AAEhE,+DAA+D;AAC/D,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED;;;;;;;;;;GAUG;AACH,qBAAa,kBAAmB,SAAQ,WAAW;IACjD,OAAgB,SAAS,SAAiB;IAE1C,2DAA2D;IAC3D,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED;;;OAGG;IACG,IAAI,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C;;;OAGG;IACG,SAAS,CACb,KAAK,CAAC,EAAE,SAAS,EACjB,EAAE,WAAqB,EAAE,GAAE;QAAE,WAAW,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;KAAO,GAChE,OAAO,CAAC,IAAI,CAAC;IAoBhB,kDAAkD;IAC5C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
@@ -0,0 +1,59 @@
1
+ import { settled } from '@ember/test-helpers';
2
+ import { MenuHarness, pressAsBrowser } from "./-private/menu.js";
3
+ /**
4
+ * Drives a `<ContextMenu>` from `@ember-joinery/ember` or
5
+ * `@ember-joinery/primitives/context-menu`. It reads the state from the trigger's `data-state`
6
+ * and the items' ARIA, finds items by their text, and acts as a user does: a right click on the
7
+ * trigger (or a long press), keys, a click on an item.
8
+ *
9
+ * const menu = new ContextMenuHarness()
10
+ * await menu.open() // a right click in the middle of the trigger
11
+ * assert.deepEqual(menu.items, ['Back', 'Forward', 'Reload'])
12
+ * await menu.select('Reload')
13
+ */
14
+ export class ContextMenuHarness extends MenuHarness {
15
+ static component = 'context-menu';
16
+ /** Whether it is open, from the trigger's `data-state`. */
17
+ get isOpen() {
18
+ return this.trigger.getAttribute('data-state') === 'open';
19
+ }
20
+ /**
21
+ * Right-clicks the trigger, at `point` (in the viewport) or its centre: the menu opens there.
22
+ * A right click while it is open moves it to the new point.
23
+ */
24
+ async open(point) {
25
+ await pressAsBrowser(this.trigger, { button: 2, point });
26
+ }
27
+ /**
28
+ * Holds a touch (or a pen) on the trigger until the menu opens, as a long press on a phone
29
+ * does, then lifts it.
30
+ */
31
+ async longPress(point, { pointerType = 'touch' } = {}) {
32
+ const { x, y } = point ?? centreOf(this.trigger);
33
+ const init = {
34
+ bubbles: true,
35
+ cancelable: true,
36
+ composed: true,
37
+ view: window,
38
+ clientX: x,
39
+ clientY: y,
40
+ pointerType,
41
+ pointerId: 1,
42
+ isPrimary: true,
43
+ };
44
+ this.trigger.dispatchEvent(new PointerEvent('pointerdown', { ...init, button: 0, buttons: 1 }));
45
+ // settled() waits out the long press.
46
+ await settled();
47
+ this.trigger.dispatchEvent(new PointerEvent('pointerup', { ...init, button: 0, buttons: 0 }));
48
+ await settled();
49
+ }
50
+ /** Closes it with Escape, unless it is closed. */
51
+ async close() {
52
+ if (this.isOpen)
53
+ await this.pressEscape();
54
+ }
55
+ }
56
+ function centreOf(element) {
57
+ const rect = element.getBoundingClientRect();
58
+ return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };
59
+ }
@@ -0,0 +1,48 @@
1
+ import { CalendarHarness, type CalendarDayInput } from './calendar.ts';
2
+ import { PopoverHarness } from './popover.ts';
3
+ /**
4
+ * Drives a date picker: a `<Popover>` whose content holds a `<Calendar>`, as upstream's Date
5
+ * Picker is built (there is no date picker component of its own). It is a `PopoverHarness`, so
6
+ * it opens, closes and reads the popover as that does, and it adds the calendar inside and the
7
+ * trigger's text, and picks a day as a user does: it opens the popover, goes to the day's month
8
+ * (with the month and year dropdowns when the calendar has them, else the previous and next
9
+ * buttons) and presses the day.
10
+ *
11
+ * const picker = new DatePickerHarness('due') // <Popover @name="due">
12
+ * assert.strictEqual(picker.text, 'Pick a date')
13
+ * await picker.pick('2026-03-04')
14
+ * assert.strictEqual(picker.text, 'March 4th, 2026')
15
+ * assert.deepEqual(picker.calendar.selectedDays, ['2026-03-04'])
16
+ *
17
+ * A day is a `Date` (its local day) or `yyyy-MM-dd`. This is not the Power Calendar add-on's
18
+ * `DatePickerHarness` (`@ember-joinery/power-calendar/test-support`), which drives that add-on's
19
+ * own `DatePicker` component.
20
+ */
21
+ export declare class DatePickerHarness extends PopoverHarness {
22
+ #private;
23
+ /** The calendar in the popover's content. It is there only while the popover is open. */
24
+ get calendar(): CalendarHarness;
25
+ /** What the trigger shows, whitespace collapsed: the date as written, or the placeholder. */
26
+ get text(): string;
27
+ /** Whether the open calendar shows `day` in its own month (not as an outside day). */
28
+ shows(day: CalendarDayInput): boolean;
29
+ /**
30
+ * Opens the popover, unless it is open, and moves its calendar to the month holding `day`:
31
+ * with the year and month dropdowns where they have the day's year and month, then the
32
+ * previous and next buttons, a month at a time. Throws when the calendar can't go there (the
33
+ * day is past `@startMonth` or `@endMonth`, or there are no buttons).
34
+ */
35
+ showMonth(day: CalendarDayInput): Promise<void>;
36
+ /** Opens the popover, goes to the day's month and presses the day. */
37
+ pick(day: CalendarDayInput): Promise<void>;
38
+ /**
39
+ * Picks the range from `from` to `to` (on or after it) in a calendar with `@mode="range"`,
40
+ * whatever it holds: it presses `from` until the range starts there and ends there or nowhere
41
+ * (a press on a day inside or outside a whole range moves only one end, as react-day-picker's
42
+ * does), then presses `to`, going to each one's month and opening the popover again if a
43
+ * press closed it. Throws when the calendar won't take that range (a day is disabled, or
44
+ * `@min` or `@max` rule it out).
45
+ */
46
+ pickRange(from: CalendarDayInput, to: CalendarDayInput): Promise<void>;
47
+ }
48
+ //# sourceMappingURL=date-picker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../src/date-picker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAgB7C;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,iBAAkB,SAAQ,cAAc;;IACnD,yFAAyF;IACzF,IAAI,QAAQ,IAAI,eAAe,CAE9B;IAED,6FAA6F;IAC7F,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,sFAAsF;IACtF,KAAK,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO;IAOrC;;;;;OAKG;IACG,SAAS,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IA8BrD,sEAAsE;IAChE,IAAI,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhD;;;;;;;OAOG;IACG,SAAS,CAAC,IAAI,EAAE,gBAAgB,EAAE,EAAE,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAuC7E"}
@@ -0,0 +1,136 @@
1
+ import { isString } from '@sindresorhus/is';
2
+ import { CalendarHarness } from "./calendar.js";
3
+ import { PopoverHarness } from "./popover.js";
4
+ import { text } from "./-private/overlay.js";
5
+ function pad(value, length = 2) {
6
+ return String(value).padStart(length, '0');
7
+ }
8
+ /** The day as `yyyy-MM-dd`, the key a calendar's days carry in `data-test-jn-value`. */
9
+ function iso(day) {
10
+ if (isString(day))
11
+ return day;
12
+ return `${pad(day.getFullYear(), 4)}-${pad(day.getMonth() + 1)}-${pad(day.getDate())}`;
13
+ }
14
+ /** The most months `showMonth()` pages through with the buttons: a hundred years. */
15
+ const MAX_STEPS = 1200;
16
+ /**
17
+ * Drives a date picker: a `<Popover>` whose content holds a `<Calendar>`, as upstream's Date
18
+ * Picker is built (there is no date picker component of its own). It is a `PopoverHarness`, so
19
+ * it opens, closes and reads the popover as that does, and it adds the calendar inside and the
20
+ * trigger's text, and picks a day as a user does: it opens the popover, goes to the day's month
21
+ * (with the month and year dropdowns when the calendar has them, else the previous and next
22
+ * buttons) and presses the day.
23
+ *
24
+ * const picker = new DatePickerHarness('due') // <Popover @name="due">
25
+ * assert.strictEqual(picker.text, 'Pick a date')
26
+ * await picker.pick('2026-03-04')
27
+ * assert.strictEqual(picker.text, 'March 4th, 2026')
28
+ * assert.deepEqual(picker.calendar.selectedDays, ['2026-03-04'])
29
+ *
30
+ * A day is a `Date` (its local day) or `yyyy-MM-dd`. This is not the Power Calendar add-on's
31
+ * `DatePickerHarness` (`@ember-joinery/power-calendar/test-support`), which drives that add-on's
32
+ * own `DatePicker` component.
33
+ */
34
+ export class DatePickerHarness extends PopoverHarness {
35
+ /** The calendar in the popover's content. It is there only while the popover is open. */
36
+ get calendar() {
37
+ return this.child(CalendarHarness);
38
+ }
39
+ /** What the trigger shows, whitespace collapsed: the date as written, or the placeholder. */
40
+ get text() {
41
+ return text(this.trigger);
42
+ }
43
+ /** Whether the open calendar shows `day` in its own month (not as an outside day). */
44
+ shows(day) {
45
+ const key = iso(day);
46
+ return this.calendar.cells.some(cell => cell.getAttribute('data-test-jn-value') === key && !cell.hasAttribute('data-outside'));
47
+ }
48
+ /**
49
+ * Opens the popover, unless it is open, and moves its calendar to the month holding `day`:
50
+ * with the year and month dropdowns where they have the day's year and month, then the
51
+ * previous and next buttons, a month at a time. Throws when the calendar can't go there (the
52
+ * day is past `@startMonth` or `@endMonth`, or there are no buttons).
53
+ */
54
+ async showMonth(day) {
55
+ await this.open();
56
+ const calendar = this.calendar;
57
+ const key = iso(day);
58
+ if (this.shows(key))
59
+ return;
60
+ const [year, month] = key.split('-').map(Number);
61
+ const years = calendar.yearDropdown();
62
+ if (years && [...years.options].some(option => option.value === String(year))) {
63
+ await calendar.chooseYear(year);
64
+ }
65
+ const months = calendar.monthDropdown();
66
+ const option = months?.options[month - 1];
67
+ const sameYear = !years || calendar.months[0]?.startsWith(`${pad(year, 4)}-`);
68
+ if (option && !option.disabled && sameYear && !this.shows(key)) {
69
+ await calendar.chooseMonth(month - 1);
70
+ }
71
+ for (let steps = 0; !this.shows(key); steps++) {
72
+ const first = calendar.months[0] ?? '';
73
+ const back = key < first;
74
+ const button = calendar.queryPart(back ? 'previous' : 'next');
75
+ const can = back ? button && calendar.canGoPrevious : button && calendar.canGoNext;
76
+ if (!can || steps >= MAX_STEPS) {
77
+ throw new Error(`Joinery harness: ${this}'s calendar can't go to the month of ${key}`);
78
+ }
79
+ await (back ? calendar.previous() : calendar.next());
80
+ }
81
+ }
82
+ /** Opens the popover, goes to the day's month and presses the day. */
83
+ async pick(day) {
84
+ await this.showMonth(day);
85
+ await this.calendar.select(day);
86
+ }
87
+ /**
88
+ * Picks the range from `from` to `to` (on or after it) in a calendar with `@mode="range"`,
89
+ * whatever it holds: it presses `from` until the range starts there and ends there or nowhere
90
+ * (a press on a day inside or outside a whole range moves only one end, as react-day-picker's
91
+ * does), then presses `to`, going to each one's month and opening the popover again if a
92
+ * press closed it. Throws when the calendar won't take that range (a day is disabled, or
93
+ * `@min` or `@max` rule it out).
94
+ */
95
+ async pickRange(from, to) {
96
+ const start = iso(from);
97
+ const end = iso(to);
98
+ if (end < start) {
99
+ throw new Error(`Joinery harness: ${this}.pickRange() takes from (${start}) before to (${end})`);
100
+ }
101
+ for (let presses = 0;; presses++) {
102
+ await this.showMonth(start);
103
+ const ends = this.#rangeAt(start);
104
+ if (ends === 'both' || (ends === 'from' && end !== start))
105
+ break;
106
+ if (presses >= 3) {
107
+ throw new Error(`Joinery harness: ${this}'s calendar won't start a range on ${start}`);
108
+ }
109
+ await this.calendar.select(start);
110
+ }
111
+ if (end === start)
112
+ return;
113
+ await this.pick(end);
114
+ // A press that closes the popover leaves nothing to read; while it is open, check the end.
115
+ if (this.isOpen && this.calendar.exists && this.#rangeAt(end) !== 'to') {
116
+ throw new Error(`Joinery harness: ${this}'s calendar didn't end the range on ${end}`);
117
+ }
118
+ }
119
+ /**
120
+ * Where a shown day is in the calendar's range: `both` ends (`{ from: day, to: day }`), the
121
+ * `from` of a range with no end yet, its `to`, or `other`.
122
+ */
123
+ #rangeAt(day) {
124
+ const calendar = this.calendar;
125
+ const button = calendar.button(day);
126
+ const isStart = button.getAttribute('data-range-start') === 'true';
127
+ const isEnd = button.getAttribute('data-range-end') === 'true';
128
+ if (isStart && isEnd)
129
+ return 'both';
130
+ if (isEnd)
131
+ return 'to';
132
+ if (isStart || button.getAttribute('data-range-middle') === 'true')
133
+ return 'other';
134
+ return calendar.isSelected(day) ? 'from' : 'other';
135
+ }
136
+ }
@@ -0,0 +1,64 @@
1
+ import { Harness } from './harness.ts';
2
+ /**
3
+ * Drives a `<Dialog>` from `@ember-joinery/ember` (or the headless one from
4
+ * `@ember-joinery/primitives/dialog`). It reads state through the trigger's `aria-expanded`
5
+ * and the content's role and ARIA, follows the content into the top layer, and acts as a user
6
+ * does: a click on the trigger, Escape, a press on the overlay.
7
+ *
8
+ * class EditProfile extends DialogHarness {
9
+ * static named = 'edit-profile'
10
+ * @child(ButtonHarness, 'save') declare save: ButtonHarness
11
+ * }
12
+ *
13
+ * const dialog = new EditProfile()
14
+ * await dialog.open()
15
+ * assert.strictEqual(dialog.label, 'Edit profile')
16
+ * await dialog.close()
17
+ * assert.dom(dialog.trigger).isFocused()
18
+ */
19
+ export declare class DialogHarness extends Harness {
20
+ static component: string | readonly string[];
21
+ /** The trigger. Throws when the dialog has none (one you open yourself, with `@open`). */
22
+ get trigger(): HTMLElement;
23
+ /** The content, or `null` while it is closed (it stays while it animates out). */
24
+ get content(): HTMLElement | null;
25
+ /** The overlay behind a modal dialog's content, or `null`. */
26
+ get overlay(): HTMLElement | null;
27
+ /** The title, or `null`. */
28
+ get title(): HTMLElement | null;
29
+ /** The description, or `null`. */
30
+ get description(): HTMLElement | null;
31
+ /** The close button in the corner (`@showCloseButton`), or `null`. */
32
+ get closeButton(): HTMLElement | null;
33
+ /**
34
+ * Whether it is open: the trigger's `aria-expanded`, or, without a trigger, the content's
35
+ * `data-state`. It is `false` as soon as it starts closing, while the content animates out.
36
+ */
37
+ get isOpen(): boolean;
38
+ /** Whether it is modal: its content has `aria-modal="true"`. */
39
+ get isModal(): boolean;
40
+ /** The content's role: `dialog`, or `alertdialog`. */
41
+ get role(): string | null;
42
+ /** Its accessible name: the content's `aria-label`, else the text its `aria-labelledby` names. */
43
+ get label(): string;
44
+ /** Its accessible description: the text its content's `aria-describedby` names. */
45
+ get descriptionText(): string;
46
+ /** Whether the content is in the browser's top layer. */
47
+ get isInTopLayer(): boolean;
48
+ /** Whether focus is inside the content. */
49
+ get hasFocus(): boolean;
50
+ /** Opens it with a click on its trigger, unless it is open. */
51
+ open(): Promise<void>;
52
+ /** Closes it as a user would: with its close button, or else Escape. */
53
+ close(): Promise<void>;
54
+ /** Presses Escape inside it. */
55
+ pressEscape(): Promise<void>;
56
+ /**
57
+ * Presses outside the content: on the overlay of a modal dialog, else outside every layer.
58
+ * On the overlay, the press goes as a browser sends it: `pointerdown` (which closes the
59
+ * dialog), then the mouse events, with focus leaving for nothing (the overlay can't take it),
60
+ * all before the dialog has finished closing and given focus back.
61
+ */
62
+ pressOutside(): Promise<void>;
63
+ }
64
+ //# sourceMappingURL=dialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../src/dialog.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAmBtC;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,aAAc,SAAQ,OAAO;IACxC,OAAgB,SAAS,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAW;IAEhE,0FAA0F;IAC1F,IAAI,OAAO,IAAI,WAAW,CAEzB;IAED,kFAAkF;IAClF,IAAI,OAAO,IAAI,WAAW,GAAG,IAAI,CAEhC;IAED,8DAA8D;IAC9D,IAAI,OAAO,IAAI,WAAW,GAAG,IAAI,CAEhC;IAED,4BAA4B;IAC5B,IAAI,KAAK,IAAI,WAAW,GAAG,IAAI,CAE9B;IAED,kCAAkC;IAClC,IAAI,WAAW,IAAI,WAAW,GAAG,IAAI,CAEpC;IAED,sEAAsE;IACtE,IAAI,WAAW,IAAI,WAAW,GAAG,IAAI,CAEpC;IAED;;;OAGG;IACH,IAAI,MAAM,IAAI,OAAO,CAIpB;IAED,gEAAgE;IAChE,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,sDAAsD;IACtD,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAExB;IAED,kGAAkG;IAClG,IAAI,KAAK,IAAI,MAAM,CAIlB;IAED,mFAAmF;IACnF,IAAI,eAAe,IAAI,MAAM,CAG5B;IAED,yDAAyD;IACzD,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,2CAA2C;IAC3C,IAAI,QAAQ,IAAI,OAAO,CAGtB;IAED,+DAA+D;IACzD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,wEAAwE;IAClE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAM5B,gCAAgC;IAC1B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAMlC;;;;;OAKG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAcpC"}