@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,53 @@
1
+ import { Harness } from './harness.ts';
2
+ /**
3
+ * Drives an `<Input>` from `@ember-joinery/ember`, or an `<input>` made one with its `asInput`
4
+ * modifier. State comes from the element and its ARIA; it types the way a user does.
5
+ *
6
+ * const email = new InputHarness('email') // <Input @name="email">
7
+ * await email.fillIn('ada@example.com')
8
+ * assert.strictEqual(email.value, 'ada@example.com')
9
+ * assert.strictEqual(email.label, 'Email')
10
+ */
11
+ export declare class InputHarness extends Harness {
12
+ static component: string;
13
+ /** The `<input>` itself. */
14
+ get control(): HTMLInputElement;
15
+ /** What it holds now. */
16
+ get value(): string;
17
+ /** Its `type`: `text` (the default), `email`, `password`, `file`… */
18
+ get type(): string;
19
+ /** Its `placeholder`, or `''`. */
20
+ get placeholder(): string;
21
+ /**
22
+ * Its accessible name, as assistive technology reads it: `aria-labelledby`'s text, else
23
+ * `aria-label`, else its `<label>`'s text, else `title`, else `placeholder`.
24
+ */
25
+ get label(): string;
26
+ /** The text of what its `aria-describedby` names (a field's description and errors), or `''`. */
27
+ get description(): string;
28
+ /** Whether it is `disabled`. */
29
+ get isDisabled(): boolean;
30
+ /** Whether it is `readonly`. */
31
+ get isReadOnly(): boolean;
32
+ /** Whether it is `required`. */
33
+ get isRequired(): boolean;
34
+ /** Whether it is marked invalid with `aria-invalid`. */
35
+ get isInvalid(): boolean;
36
+ /** Whether it has focus. */
37
+ get isFocused(): boolean;
38
+ /** For a file input, the names of the files chosen. */
39
+ get fileNames(): string[];
40
+ /** Replaces what it holds with `text`, as pasting does: one `input` event, then `change`. */
41
+ fillIn(text: string): Promise<void>;
42
+ /** Types `text` one key at a time after what it holds, as a user does. */
43
+ typeIn(text: string): Promise<void>;
44
+ /** Empties it. */
45
+ clear(): Promise<void>;
46
+ /** For a file input, chooses `files`, as the file picker does (a `change` event). */
47
+ chooseFiles(files: File[]): Promise<void>;
48
+ /** Moves focus to it, as tabbing to it would. Fails if it can't take focus. */
49
+ focus(): Promise<void>;
50
+ /** Moves focus away from it. */
51
+ blur(): Promise<void>;
52
+ }
53
+ //# sourceMappingURL=input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../src/input.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC;;;;;;;;GAQG;AACH,qBAAa,YAAa,SAAQ,OAAO;IACvC,OAAgB,SAAS,SAAU;IAEnC,4BAA4B;IAC5B,IAAI,OAAO,IAAI,gBAAgB,CAE9B;IAED,yBAAyB;IACzB,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,qEAAqE;IACrE,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,kCAAkC;IAClC,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;;OAGG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,iGAAiG;IACjG,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,gCAAgC;IAChC,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,gCAAgC;IAChC,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,gCAAgC;IAChC,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,wDAAwD;IACxD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,4BAA4B;IAC5B,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,uDAAuD;IACvD,IAAI,SAAS,IAAI,MAAM,EAAE,CAExB;IAED,6FAA6F;IACvF,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC,0EAA0E;IACpE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC,kBAAkB;IACZ,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,qFAAqF;IAC/E,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C,+EAA+E;IACzE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,gCAAgC;IAC1B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B"}
package/dist/input.js ADDED
@@ -0,0 +1,90 @@
1
+ import { blur, fillIn, focus, triggerEvent, typeIn } from '@ember/test-helpers';
2
+ import { Harness } from "./harness.js";
3
+ import { controlDescription, controlLabel, isMarkedInvalid } from "./-private/control.js";
4
+ /**
5
+ * Drives an `<Input>` from `@ember-joinery/ember`, or an `<input>` made one with its `asInput`
6
+ * modifier. State comes from the element and its ARIA; it types the way a user does.
7
+ *
8
+ * const email = new InputHarness('email') // <Input @name="email">
9
+ * await email.fillIn('ada@example.com')
10
+ * assert.strictEqual(email.value, 'ada@example.com')
11
+ * assert.strictEqual(email.label, 'Email')
12
+ */
13
+ export class InputHarness extends Harness {
14
+ static component = 'input';
15
+ /** The `<input>` itself. */
16
+ get control() {
17
+ return this.element;
18
+ }
19
+ /** What it holds now. */
20
+ get value() {
21
+ return this.control.value;
22
+ }
23
+ /** Its `type`: `text` (the default), `email`, `password`, `file`… */
24
+ get type() {
25
+ return this.control.type;
26
+ }
27
+ /** Its `placeholder`, or `''`. */
28
+ get placeholder() {
29
+ return this.control.placeholder;
30
+ }
31
+ /**
32
+ * Its accessible name, as assistive technology reads it: `aria-labelledby`'s text, else
33
+ * `aria-label`, else its `<label>`'s text, else `title`, else `placeholder`.
34
+ */
35
+ get label() {
36
+ return controlLabel(this.control);
37
+ }
38
+ /** The text of what its `aria-describedby` names (a field's description and errors), or `''`. */
39
+ get description() {
40
+ return controlDescription(this.control);
41
+ }
42
+ /** Whether it is `disabled`. */
43
+ get isDisabled() {
44
+ return this.control.disabled;
45
+ }
46
+ /** Whether it is `readonly`. */
47
+ get isReadOnly() {
48
+ return this.control.readOnly;
49
+ }
50
+ /** Whether it is `required`. */
51
+ get isRequired() {
52
+ return this.control.required;
53
+ }
54
+ /** Whether it is marked invalid with `aria-invalid`. */
55
+ get isInvalid() {
56
+ return isMarkedInvalid(this.control);
57
+ }
58
+ /** Whether it has focus. */
59
+ get isFocused() {
60
+ return this.control.ownerDocument.activeElement === this.control;
61
+ }
62
+ /** For a file input, the names of the files chosen. */
63
+ get fileNames() {
64
+ return [...(this.control.files ?? [])].map(file => file.name);
65
+ }
66
+ /** Replaces what it holds with `text`, as pasting does: one `input` event, then `change`. */
67
+ async fillIn(text) {
68
+ await fillIn(this.control, text);
69
+ }
70
+ /** Types `text` one key at a time after what it holds, as a user does. */
71
+ async typeIn(text) {
72
+ await typeIn(this.control, text);
73
+ }
74
+ /** Empties it. */
75
+ async clear() {
76
+ await fillIn(this.control, '');
77
+ }
78
+ /** For a file input, chooses `files`, as the file picker does (a `change` event). */
79
+ async chooseFiles(files) {
80
+ await triggerEvent(this.control, 'change', { files });
81
+ }
82
+ /** Moves focus to it, as tabbing to it would. Fails if it can't take focus. */
83
+ async focus() {
84
+ await focus(this.control);
85
+ }
86
+ /** Moves focus away from it. */
87
+ async blur() {
88
+ await blur(this.control);
89
+ }
90
+ }
package/dist/item.d.ts ADDED
@@ -0,0 +1,63 @@
1
+ import { Harness } from './harness.ts';
2
+ /**
3
+ * Drives an `<Item>` from `@ember-joinery/ember`, or an element made an item with `asItem`. It
4
+ * reads the title and description, reaches each part, and finds what is inside, such as its
5
+ * actions' buttons, with `find()`:
6
+ *
7
+ * const item = new ItemHarness('security') // <Item @name="security">
8
+ * assert.strictEqual(item.title, 'Security Alert')
9
+ * await item.find(ButtonHarness).click()
10
+ *
11
+ * An item that is a link (`@as="a"`) can be clicked and focused.
12
+ */
13
+ export declare class ItemHarness extends Harness {
14
+ static component: string;
15
+ /** All the text it shows, whitespace collapsed. */
16
+ get text(): string;
17
+ /** Its first title's text, or `''` without one. */
18
+ get title(): string;
19
+ /** Its first description's text, or `''` without one. */
20
+ get description(): string;
21
+ /** The text of every description, in order: a second content may hold one too. */
22
+ get descriptions(): string[];
23
+ /** Its `@variant`: `default`, `outline` or `muted`. */
24
+ get variant(): string | null;
25
+ /** Its `@size`: `default`, `sm` or `xs`. */
26
+ get size(): string | null;
27
+ /** The media's `@variant` (`default`, `icon` or `image`), or `null` without media. */
28
+ get mediaVariant(): string | null;
29
+ /** The media. Throws when it has none. */
30
+ get media(): HTMLElement;
31
+ /** The first content. Throws when it has none. */
32
+ get content(): HTMLElement;
33
+ /** The actions. Throws when it has none. */
34
+ get actions(): HTMLElement;
35
+ /** The header. Throws when it has none. */
36
+ get header(): HTMLElement;
37
+ /** The footer. Throws when it has none. */
38
+ get footer(): HTMLElement;
39
+ /** Whether it is a link: an `<a href>`. */
40
+ get isLink(): boolean;
41
+ /** Where it links to, or `null` when it isn't a link. */
42
+ get href(): string | null;
43
+ /** Whether it has focus. */
44
+ get isFocused(): boolean;
45
+ /** Clicks it, as a user would: follows a link item. */
46
+ click(): Promise<void>;
47
+ /** Moves focus to it, as tabbing to a link item would. Fails if it can't take focus. */
48
+ focus(): Promise<void>;
49
+ }
50
+ /**
51
+ * Drives an `<ItemGroup>` from `@ember-joinery/ember`: a list of items, with separators.
52
+ *
53
+ * const people = new ItemGroupHarness('people')
54
+ * assert.deepEqual(people.items.map(item => item.title), ['shadcn', 'maxleiter'])
55
+ */
56
+ export declare class ItemGroupHarness extends Harness {
57
+ static component: string;
58
+ /** A harness for each item in the group, in order. */
59
+ get items(): ItemHarness[];
60
+ /** Its separators, in order. */
61
+ get separators(): HTMLElement[];
62
+ }
63
+ //# sourceMappingURL=item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../src/item.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAMtC;;;;;;;;;;GAUG;AACH,qBAAa,WAAY,SAAQ,OAAO;IACtC,OAAgB,SAAS,SAAS;IAElC,mDAAmD;IACnD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,mDAAmD;IACnD,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,yDAAyD;IACzD,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,kFAAkF;IAClF,IAAI,YAAY,IAAI,MAAM,EAAE,CAE3B;IAED,uDAAuD;IACvD,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAED,4CAA4C;IAC5C,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAExB;IAED,sFAAsF;IACtF,IAAI,YAAY,IAAI,MAAM,GAAG,IAAI,CAEhC;IAED,0CAA0C;IAC1C,IAAI,KAAK,IAAI,WAAW,CAEvB;IAED,kDAAkD;IAClD,IAAI,OAAO,IAAI,WAAW,CAEzB;IAED,4CAA4C;IAC5C,IAAI,OAAO,IAAI,WAAW,CAEzB;IAED,2CAA2C;IAC3C,IAAI,MAAM,IAAI,WAAW,CAExB;IAED,2CAA2C;IAC3C,IAAI,MAAM,IAAI,WAAW,CAExB;IAED,2CAA2C;IAC3C,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,yDAAyD;IACzD,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAExB;IAED,4BAA4B;IAC5B,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,uDAAuD;IACjD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,wFAAwF;IAClF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B;AAED;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,OAAO;IAC3C,OAAgB,SAAS,SAAe;IAExC,sDAAsD;IACtD,IAAI,KAAK,IAAI,WAAW,EAAE,CAEzB;IAED,gCAAgC;IAChC,IAAI,UAAU,IAAI,WAAW,EAAE,CAE9B;CACF"}
package/dist/item.js ADDED
@@ -0,0 +1,104 @@
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 an `<Item>` from `@ember-joinery/ember`, or an element made an item with `asItem`. It
8
+ * reads the title and description, reaches each part, and finds what is inside, such as its
9
+ * actions' buttons, with `find()`:
10
+ *
11
+ * const item = new ItemHarness('security') // <Item @name="security">
12
+ * assert.strictEqual(item.title, 'Security Alert')
13
+ * await item.find(ButtonHarness).click()
14
+ *
15
+ * An item that is a link (`@as="a"`) can be clicked and focused.
16
+ */
17
+ export class ItemHarness extends Harness {
18
+ static component = 'item';
19
+ /** All the text it shows, whitespace collapsed. */
20
+ get text() {
21
+ return text(this.element);
22
+ }
23
+ /** Its first title's text, or `''` without one. */
24
+ get title() {
25
+ return text(this.queryPart('title'));
26
+ }
27
+ /** Its first description's text, or `''` without one. */
28
+ get description() {
29
+ return text(this.queryPart('description'));
30
+ }
31
+ /** The text of every description, in order: a second content may hold one too. */
32
+ get descriptions() {
33
+ return this.parts('description').map(text);
34
+ }
35
+ /** Its `@variant`: `default`, `outline` or `muted`. */
36
+ get variant() {
37
+ return this.element.getAttribute('data-variant');
38
+ }
39
+ /** Its `@size`: `default`, `sm` or `xs`. */
40
+ get size() {
41
+ return this.element.getAttribute('data-size');
42
+ }
43
+ /** The media's `@variant` (`default`, `icon` or `image`), or `null` without media. */
44
+ get mediaVariant() {
45
+ return this.queryPart('media')?.getAttribute('data-variant') ?? null;
46
+ }
47
+ /** The media. Throws when it has none. */
48
+ get media() {
49
+ return this.part('media');
50
+ }
51
+ /** The first content. Throws when it has none. */
52
+ get content() {
53
+ return this.part('content');
54
+ }
55
+ /** The actions. Throws when it has none. */
56
+ get actions() {
57
+ return this.part('actions');
58
+ }
59
+ /** The header. Throws when it has none. */
60
+ get header() {
61
+ return this.part('header');
62
+ }
63
+ /** The footer. Throws when it has none. */
64
+ get footer() {
65
+ return this.part('footer');
66
+ }
67
+ /** Whether it is a link: an `<a href>`. */
68
+ get isLink() {
69
+ return this.element instanceof HTMLAnchorElement && this.element.hasAttribute('href');
70
+ }
71
+ /** Where it links to, or `null` when it isn't a link. */
72
+ get href() {
73
+ return this.isLink ? this.element.getAttribute('href') : null;
74
+ }
75
+ /** Whether it has focus. */
76
+ get isFocused() {
77
+ return this.element.ownerDocument.activeElement === this.element;
78
+ }
79
+ /** Clicks it, as a user would: follows a link item. */
80
+ async click() {
81
+ await click(this.element);
82
+ }
83
+ /** Moves focus to it, as tabbing to a link item would. Fails if it can't take focus. */
84
+ async focus() {
85
+ await focus(this.element);
86
+ }
87
+ }
88
+ /**
89
+ * Drives an `<ItemGroup>` from `@ember-joinery/ember`: a list of items, with separators.
90
+ *
91
+ * const people = new ItemGroupHarness('people')
92
+ * assert.deepEqual(people.items.map(item => item.title), ['shadcn', 'maxleiter'])
93
+ */
94
+ export class ItemGroupHarness extends Harness {
95
+ static component = 'item-group';
96
+ /** A harness for each item in the group, in order. */
97
+ get items() {
98
+ return this.findAll(ItemHarness);
99
+ }
100
+ /** Its separators, in order. */
101
+ get separators() {
102
+ return this.parts('separator');
103
+ }
104
+ }
package/dist/kbd.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ import { Harness } from './harness.ts';
2
+ import { KeyHarness } from './keys.ts';
3
+ /**
4
+ * Drives a `<Kbd>` from `@ember-joinery/ember`: one key, a styled `<kbd>`. It reads like the
5
+ * primitives' `KeyHarness`.
6
+ *
7
+ * assert.strictEqual(new KbdHarness('save').label, 'S')
8
+ */
9
+ export declare class KbdHarness extends KeyHarness {
10
+ static component: string;
11
+ }
12
+ /**
13
+ * Drives a `<KbdGroup>` from `@ember-joinery/ember`: keys shown together, as a shortcut.
14
+ *
15
+ * const bold = new KbdGroupHarness('bold')
16
+ * assert.deepEqual(bold.keys, ['Ctrl', 'B'])
17
+ * assert.strictEqual(bold.label, 'Ctrl + B')
18
+ */
19
+ export declare class KbdGroupHarness extends Harness {
20
+ static component: string;
21
+ /** Each key's harness, in order. */
22
+ get kbds(): KbdHarness[];
23
+ /** The keys it shows, in order: `['Ctrl', 'B']`. */
24
+ get keys(): string[];
25
+ /** Everything it shows, keys and what's between them: `Ctrl + B`. */
26
+ get label(): string;
27
+ }
28
+ //# sourceMappingURL=kbd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kbd.d.ts","sourceRoot":"","sources":["../src/kbd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAMtC;;;;;GAKG;AACH,qBAAa,UAAW,SAAQ,UAAU;IACxC,OAAgB,SAAS,SAAQ;CAClC;AAED;;;;;;GAMG;AACH,qBAAa,eAAgB,SAAQ,OAAO;IAC1C,OAAgB,SAAS,SAAc;IAEvC,oCAAoC;IACpC,IAAI,IAAI,IAAI,UAAU,EAAE,CAEvB;IAED,oDAAoD;IACpD,IAAI,IAAI,IAAI,MAAM,EAAE,CAEnB;IAED,qEAAqE;IACrE,IAAI,KAAK,IAAI,MAAM,CAElB;CACF"}
package/dist/kbd.js ADDED
@@ -0,0 +1,36 @@
1
+ import { Harness } from "./harness.js";
2
+ import { KeyHarness } from "./keys.js";
3
+ function text(element) {
4
+ return (element.textContent ?? '').replace(/\s+/g, ' ').trim();
5
+ }
6
+ /**
7
+ * Drives a `<Kbd>` from `@ember-joinery/ember`: one key, a styled `<kbd>`. It reads like the
8
+ * primitives' `KeyHarness`.
9
+ *
10
+ * assert.strictEqual(new KbdHarness('save').label, 'S')
11
+ */
12
+ export class KbdHarness extends KeyHarness {
13
+ static component = 'kbd';
14
+ }
15
+ /**
16
+ * Drives a `<KbdGroup>` from `@ember-joinery/ember`: keys shown together, as a shortcut.
17
+ *
18
+ * const bold = new KbdGroupHarness('bold')
19
+ * assert.deepEqual(bold.keys, ['Ctrl', 'B'])
20
+ * assert.strictEqual(bold.label, 'Ctrl + B')
21
+ */
22
+ export class KbdGroupHarness extends Harness {
23
+ static component = 'kbd-group';
24
+ /** Each key's harness, in order. */
25
+ get kbds() {
26
+ return this.findAll(KbdHarness);
27
+ }
28
+ /** The keys it shows, in order: `['Ctrl', 'B']`. */
29
+ get keys() {
30
+ return this.kbds.map(kbd => kbd.label);
31
+ }
32
+ /** Everything it shows, keys and what's between them: `Ctrl + B`. */
33
+ get label() {
34
+ return text(this.element);
35
+ }
36
+ }
package/dist/keys.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import { Harness } from './harness.ts';
2
+ /** Drives a `<Key>` from `@ember-joinery/primitives/keys`: one `<kbd>`. */
3
+ export declare class KeyHarness extends Harness {
4
+ static component: string;
5
+ /** The key's label, as shown. */
6
+ get label(): string;
7
+ }
8
+ /** Drives a `<KeyCombo>` from `@ember-joinery/primitives/keys`: keys with separators between. */
9
+ export declare class KeyComboHarness extends Harness {
10
+ static component: string;
11
+ /** The keys shown, in order: `['Ctrl', 'K']` (or the `@mac` keys, on a Mac). */
12
+ get keys(): string[];
13
+ /** Each key's harness, in order. */
14
+ get keyHarnesses(): KeyHarness[];
15
+ /** The text between the keys, such as `+`. */
16
+ get separators(): string[];
17
+ /** The whole shortcut as read: `Ctrl + K`. */
18
+ get label(): string;
19
+ }
20
+ //# sourceMappingURL=keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAMtC,2EAA2E;AAC3E,qBAAa,UAAW,SAAQ,OAAO;IACrC,OAAgB,SAAS,SAAQ;IAEjC,iCAAiC;IACjC,IAAI,KAAK,IAAI,MAAM,CAElB;CACF;AAED,iGAAiG;AACjG,qBAAa,eAAgB,SAAQ,OAAO;IAC1C,OAAgB,SAAS,SAAc;IAEvC,gFAAgF;IAChF,IAAI,IAAI,IAAI,MAAM,EAAE,CAEnB;IAED,oCAAoC;IACpC,IAAI,YAAY,IAAI,UAAU,EAAE,CAE/B;IAED,8CAA8C;IAC9C,IAAI,UAAU,IAAI,MAAM,EAAE,CAEzB;IAED,8CAA8C;IAC9C,IAAI,KAAK,IAAI,MAAM,CAElB;CACF"}
package/dist/keys.js ADDED
@@ -0,0 +1,32 @@
1
+ import { Harness } from "./harness.js";
2
+ function text(element) {
3
+ return (element.textContent ?? '').replace(/\s+/g, ' ').trim();
4
+ }
5
+ /** Drives a `<Key>` from `@ember-joinery/primitives/keys`: one `<kbd>`. */
6
+ export class KeyHarness extends Harness {
7
+ static component = 'key';
8
+ /** The key's label, as shown. */
9
+ get label() {
10
+ return text(this.element);
11
+ }
12
+ }
13
+ /** Drives a `<KeyCombo>` from `@ember-joinery/primitives/keys`: keys with separators between. */
14
+ export class KeyComboHarness extends Harness {
15
+ static component = 'key-combo';
16
+ /** The keys shown, in order: `['Ctrl', 'K']` (or the `@mac` keys, on a Mac). */
17
+ get keys() {
18
+ return this.values('key');
19
+ }
20
+ /** Each key's harness, in order. */
21
+ get keyHarnesses() {
22
+ return this.findAll(KeyHarness);
23
+ }
24
+ /** The text between the keys, such as `+`. */
25
+ get separators() {
26
+ return this.parts('separator').map(text);
27
+ }
28
+ /** The whole shortcut as read: `Ctrl + K`. */
29
+ get label() {
30
+ return text(this.element);
31
+ }
32
+ }
@@ -0,0 +1,24 @@
1
+ import { Harness } from './harness.ts';
2
+ /**
3
+ * Drives a `<Label>`, from `@ember-joinery/ember` or `@ember-joinery/primitives/label`.
4
+ *
5
+ * const email = new LabelHarness('email')
6
+ * assert.strictEqual(email.text, 'Your email address')
7
+ * assert.strictEqual(email.control, find('#email'))
8
+ * await email.click() // focuses the input, as a press on a label does
9
+ */
10
+ export declare class LabelHarness extends Harness {
11
+ static component: string;
12
+ /** The text it shows, whitespace collapsed. */
13
+ get text(): string;
14
+ /**
15
+ * The control it labels, as the browser works it out: the element its `for` names, or the
16
+ * first control inside it. `null` when it labels nothing (or isn't a `<label>`).
17
+ */
18
+ get control(): HTMLElement | null;
19
+ /** Whether the control it labels is disabled, which dims the label. */
20
+ get isControlDisabled(): boolean;
21
+ /** Clicks it, as a user would: the browser passes the click to its control. */
22
+ click(): Promise<void>;
23
+ }
24
+ //# sourceMappingURL=label.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../src/label.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAMtC;;;;;;;GAOG;AACH,qBAAa,YAAa,SAAQ,OAAO;IACvC,OAAgB,SAAS,SAAU;IAEnC,+CAA+C;IAC/C,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;OAGG;IACH,IAAI,OAAO,IAAI,WAAW,GAAG,IAAI,CAGhC;IAED,uEAAuE;IACvE,IAAI,iBAAiB,IAAI,OAAO,CAI/B;IAED,+EAA+E;IACzE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
package/dist/label.js ADDED
@@ -0,0 +1,39 @@
1
+ import { click } 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 `<Label>`, from `@ember-joinery/ember` or `@ember-joinery/primitives/label`.
8
+ *
9
+ * const email = new LabelHarness('email')
10
+ * assert.strictEqual(email.text, 'Your email address')
11
+ * assert.strictEqual(email.control, find('#email'))
12
+ * await email.click() // focuses the input, as a press on a label does
13
+ */
14
+ export class LabelHarness extends Harness {
15
+ static component = 'label';
16
+ /** The text it shows, whitespace collapsed. */
17
+ get text() {
18
+ return text(this.element);
19
+ }
20
+ /**
21
+ * The control it labels, as the browser works it out: the element its `for` names, or the
22
+ * first control inside it. `null` when it labels nothing (or isn't a `<label>`).
23
+ */
24
+ get control() {
25
+ const element = this.element;
26
+ return element instanceof HTMLLabelElement ? element.control : null;
27
+ }
28
+ /** Whether the control it labels is disabled, which dims the label. */
29
+ get isControlDisabled() {
30
+ const control = this.control;
31
+ if (!control)
32
+ return false;
33
+ return ('disabled' in control && Boolean(control.disabled)) || control.matches(':disabled');
34
+ }
35
+ /** Clicks it, as a user would: the browser passes the click to its control. */
36
+ async click() {
37
+ await click(this.element);
38
+ }
39
+ }
@@ -0,0 +1,42 @@
1
+ import type { TestHooks } from './test-hooks.ts';
2
+ /**
3
+ * Presses Escape where focus is (or on `target`), as a user closing the top layer does. Only
4
+ * the top layer closes.
5
+ */
6
+ export declare function pressEscape(target?: Element): Promise<void>;
7
+ export interface PointerOptions {
8
+ /** `mouse` (the default), `pen` or `touch`. A touch dismisses on the click that follows. */
9
+ pointerType?: 'mouse' | 'pen' | 'touch';
10
+ }
11
+ /**
12
+ * A press on an element the way a pointer makes one: `pointerdown`, then `click()`'s
13
+ * `mousedown`, focus, `mouseup` and `click`, then `pointerup`. `click()` alone sends no
14
+ * pointer events, and the dismiss stack listens for `pointerdown`, as Radix's does.
15
+ */
16
+ export declare function press(target: Element, { pointerType }?: PointerOptions): Promise<void>;
17
+ /**
18
+ * A press outside every layer: on `target`, or else on the test's root element (outside any
19
+ * layer, which the top layer shows above it).
20
+ */
21
+ export declare function pressOutside(target?: Element, options?: PointerOptions): Promise<void>;
22
+ /** Whether an element is in the browser's top layer now: an open popover or a modal dialog. */
23
+ export declare function isInTopLayer(element: Element | null | undefined): boolean;
24
+ /** Where an anchored element was placed, from its `data-side` and `data-align`. */
25
+ export interface AnchorPlacement {
26
+ side: string | null;
27
+ align: string | null;
28
+ }
29
+ /** Where an anchored element was placed (after any flip), from `data-side` and `data-align`. */
30
+ export declare function placementOf(element: Element): AnchorPlacement;
31
+ /**
32
+ * Forces the Floating UI fallback for each test in a module, as CI's fallback run does for the
33
+ * whole suite, so one run covers both ways of positioning. It sets
34
+ * `globalThis.JOINERY_ANCHOR_FALLBACK` before each test and puts it back after.
35
+ *
36
+ * module('menu, Floating UI', function (hooks) {
37
+ * setupRenderingTest(hooks)
38
+ * setupAnchorFallback(hooks)
39
+ * })
40
+ */
41
+ export declare function setupAnchorFallback(hooks: TestHooks): void;
42
+ //# sourceMappingURL=layers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layers.d.ts","sourceRoot":"","sources":["../src/layers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD;;;GAGG;AACH,wBAAsB,WAAW,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAIjE;AAED,MAAM,WAAW,cAAc;IAC7B,4FAA4F;IAC5F,WAAW,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,OAAO,CAAA;CACxC;AAED;;;;GAIG;AACH,wBAAsB,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,WAAqB,EAAE,GAAE,cAAmB,iBAI1F;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAG5F;AAED,+FAA+F;AAC/F,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAOzE;AAED,mFAAmF;AACnF,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,gGAAgG;AAChG,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,CAE7D;AAID;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAa1D"}
package/dist/layers.js ADDED
@@ -0,0 +1,70 @@
1
+ import { click, getRootElement, triggerEvent, triggerKeyEvent } from '@ember/test-helpers';
2
+ /**
3
+ * Presses Escape where focus is (or on `target`), as a user closing the top layer does. Only
4
+ * the top layer closes.
5
+ */
6
+ export async function pressEscape(target) {
7
+ const where = target ?? document.activeElement ?? document.body;
8
+ await triggerKeyEvent(where, 'keydown', 'Escape');
9
+ await triggerKeyEvent(where, 'keyup', 'Escape');
10
+ }
11
+ /**
12
+ * A press on an element the way a pointer makes one: `pointerdown`, then `click()`'s
13
+ * `mousedown`, focus, `mouseup` and `click`, then `pointerup`. `click()` alone sends no
14
+ * pointer events, and the dismiss stack listens for `pointerdown`, as Radix's does.
15
+ */
16
+ export async function press(target, { pointerType = 'mouse' } = {}) {
17
+ await triggerEvent(target, 'pointerdown', { pointerType, isPrimary: true, button: 0 });
18
+ await click(target);
19
+ await triggerEvent(target, 'pointerup', { pointerType, isPrimary: true, button: 0 });
20
+ }
21
+ /**
22
+ * A press outside every layer: on `target`, or else on the test's root element (outside any
23
+ * layer, which the top layer shows above it).
24
+ */
25
+ export async function pressOutside(target, options) {
26
+ const root = getRootElement();
27
+ await press(target ?? (root instanceof Element ? root : root.body), options);
28
+ }
29
+ /** Whether an element is in the browser's top layer now: an open popover or a modal dialog. */
30
+ export function isInTopLayer(element) {
31
+ if (!element)
32
+ return false;
33
+ try {
34
+ return element.matches(':popover-open') || element.matches(':modal');
35
+ }
36
+ catch {
37
+ return false;
38
+ }
39
+ }
40
+ /** Where an anchored element was placed (after any flip), from `data-side` and `data-align`. */
41
+ export function placementOf(element) {
42
+ return { side: element.getAttribute('data-side'), align: element.getAttribute('data-align') };
43
+ }
44
+ const FLAG = 'JOINERY_ANCHOR_FALLBACK';
45
+ /**
46
+ * Forces the Floating UI fallback for each test in a module, as CI's fallback run does for the
47
+ * whole suite, so one run covers both ways of positioning. It sets
48
+ * `globalThis.JOINERY_ANCHOR_FALLBACK` before each test and puts it back after.
49
+ *
50
+ * module('menu, Floating UI', function (hooks) {
51
+ * setupRenderingTest(hooks)
52
+ * setupAnchorFallback(hooks)
53
+ * })
54
+ */
55
+ export function setupAnchorFallback(hooks) {
56
+ const global = globalThis;
57
+ let had = false;
58
+ let previous;
59
+ hooks.beforeEach(() => {
60
+ had = FLAG in global;
61
+ previous = global[FLAG];
62
+ global[FLAG] = true;
63
+ });
64
+ hooks.afterEach(() => {
65
+ if (had)
66
+ global[FLAG] = previous;
67
+ else
68
+ delete global[FLAG];
69
+ });
70
+ }