@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
package/dist/tabs.js ADDED
@@ -0,0 +1,149 @@
1
+ import { click, focus, settled } from '@ember/test-helpers';
2
+ import { Harness } from "./harness.js";
3
+ import { attributes } from "./selectors.js";
4
+ import { pressKey } from "./focus.js";
5
+ function text(element) {
6
+ return (element.textContent ?? '').replace(/\s+/g, ' ').trim();
7
+ }
8
+ /** An element's accessible name: `aria-label`, else `aria-labelledby`'s text, else its text. */
9
+ function nameOf(element) {
10
+ const label = element.getAttribute('aria-label');
11
+ if (label)
12
+ return label.trim();
13
+ const labelledBy = element.getAttribute('aria-labelledby');
14
+ if (labelledBy) {
15
+ return labelledBy
16
+ .split(/\s+/)
17
+ .map(id => element.ownerDocument.getElementById(id))
18
+ .filter((found) => Boolean(found))
19
+ .map(text)
20
+ .join(' ');
21
+ }
22
+ return text(element);
23
+ }
24
+ /**
25
+ * Drives a `<Tabs>` from `@ember-joinery/ember`, or the primitives' `Tabs`. Its tabs and panels
26
+ * are found by their `@value` (`data-test-jn-value`), and read through ARIA: the selected tab by
27
+ * `aria-selected`, its panel by the tab's `aria-controls`.
28
+ *
29
+ * const settings = new TabsHarness('settings') // <Tabs @name="settings">
30
+ * await settings.select('password')
31
+ * assert.strictEqual(settings.selected, 'password')
32
+ * assert.strictEqual(settings.panelText, 'Change your password here.')
33
+ * await settings.press('ArrowLeft')
34
+ * assert.strictEqual(settings.focused, 'account')
35
+ */
36
+ export class TabsHarness extends Harness {
37
+ static component = 'tabs';
38
+ /** The tab list (`role="tablist"`). */
39
+ get list() {
40
+ return this.part('list');
41
+ }
42
+ /** Each tab's element, in order. */
43
+ get triggers() {
44
+ return this.parts('trigger');
45
+ }
46
+ /** Each tab's value, in order. */
47
+ get tabValues() {
48
+ return this.values('trigger');
49
+ }
50
+ /** The tab whose `@value` this is. Throws when there is none. */
51
+ trigger(value) {
52
+ return this.part('trigger', value);
53
+ }
54
+ /** The panel whose `@value` this is, shown or not. Throws when there is none. */
55
+ content(value) {
56
+ return this.part('content', value);
57
+ }
58
+ /** The value of the selected tab (`aria-selected="true"`), or `null` when none is. */
59
+ get selected() {
60
+ const tab = this.triggers.find(element => element.getAttribute('aria-selected') === 'true');
61
+ return tab?.getAttribute(attributes.value) ?? null;
62
+ }
63
+ /** Whether the tab with this value is selected (`aria-selected`). */
64
+ isSelected(value) {
65
+ return this.trigger(value).getAttribute('aria-selected') === 'true';
66
+ }
67
+ /**
68
+ * The panel shown now: the one the selected tab's `aria-controls` names, unless it is
69
+ * `hidden` (or isn't rendered), else `null`.
70
+ */
71
+ get panel() {
72
+ const selected = this.selected;
73
+ if (selected === null)
74
+ return null;
75
+ const id = this.trigger(selected).getAttribute('aria-controls');
76
+ const panel = id ? this.element.ownerDocument.getElementById(id) : null;
77
+ return panel && !panel.hidden ? panel : null;
78
+ }
79
+ /** The text of the panel shown now, whitespace collapsed, or `''` when none is. */
80
+ get panelText() {
81
+ const panel = this.panel;
82
+ return panel ? text(panel) : '';
83
+ }
84
+ /** Whether the panel for this value is rendered and not `hidden`. */
85
+ isShown(value) {
86
+ const panel = this.queryPart('content', value);
87
+ return Boolean(panel && !panel.hidden);
88
+ }
89
+ /** Whether the tab can't be selected: `disabled`, or `aria-disabled="true"` on a link. */
90
+ isDisabled(value) {
91
+ const tab = this.trigger(value);
92
+ if (tab instanceof HTMLButtonElement && tab.disabled)
93
+ return true;
94
+ return tab.getAttribute('aria-disabled') === 'true';
95
+ }
96
+ /** Whether the tab is a link tab (an `<a href>`, such as a `LinkTo`). */
97
+ isLink(value) {
98
+ const tab = this.trigger(value);
99
+ return tab instanceof HTMLAnchorElement && tab.hasAttribute('href');
100
+ }
101
+ /** A tab's accessible name: its `aria-label`, else `aria-labelledby`'s text, else its text. */
102
+ label(value) {
103
+ return nameOf(this.trigger(value));
104
+ }
105
+ /** The tab list's accessible name: its `aria-label` or `aria-labelledby`, else `''`. */
106
+ get listLabel() {
107
+ const list = this.list;
108
+ if (!list.hasAttribute('aria-label') && !list.hasAttribute('aria-labelledby'))
109
+ return '';
110
+ return nameOf(list);
111
+ }
112
+ /** `horizontal` or `vertical`: the tab list's `aria-orientation`. */
113
+ get orientation() {
114
+ return this.list.getAttribute('aria-orientation');
115
+ }
116
+ /** The styled tab list's `@variant` (`default` or `line`), or `null` on the primitive. */
117
+ get variant() {
118
+ return this.list.getAttribute('data-variant');
119
+ }
120
+ /** The value of the tab Tab lands on (`tabindex="0"`), or `null` while the list itself does. */
121
+ get tabStop() {
122
+ const tab = this.triggers.find(element => element.getAttribute('tabindex') === '0');
123
+ return tab?.getAttribute(attributes.value) ?? null;
124
+ }
125
+ /** The value of the tab that has focus, or `null` when focus is elsewhere. */
126
+ get focused() {
127
+ const active = this.element.ownerDocument.activeElement;
128
+ const tab = this.triggers.find(element => element === active || element.contains(active));
129
+ return tab?.getAttribute(attributes.value) ?? null;
130
+ }
131
+ /**
132
+ * Clicks a tab, as a user selects it. A disabled `<button>` ignores the click, as in a
133
+ * browser (`click()` from `@ember/test-helpers` would throw on one).
134
+ */
135
+ async select(value) {
136
+ const tab = this.trigger(value);
137
+ if (tab instanceof HTMLButtonElement && tab.disabled)
138
+ return settled();
139
+ await click(tab);
140
+ }
141
+ /** Focuses a tab, as a click or the arrow keys would (in `automatic` mode, that selects it). */
142
+ async focus(value) {
143
+ await focus(this.trigger(value));
144
+ }
145
+ /** Presses a key on the focused element: `'ArrowRight'`, `'Home'`, `'Enter'`, `' '`. */
146
+ async press(key, modifiers) {
147
+ await pressKey(key, modifiers);
148
+ }
149
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The test hooks a `setup…(hooks)` helper registers on: QUnit's `hooks`, or the same shape
3
+ * around Vitest's `beforeEach` and `afterEach`.
4
+ */
5
+ export interface TestHooks {
6
+ beforeEach(callback: () => void | Promise<void>): void;
7
+ afterEach(callback: () => void | Promise<void>): void;
8
+ }
9
+ //# sourceMappingURL=test-hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-hooks.d.ts","sourceRoot":"","sources":["../src/test-hooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACtD,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CACtD"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,47 @@
1
+ import { Harness } from './harness.ts';
2
+ /**
3
+ * Drives a `<Textarea>` from `@ember-joinery/ember`, or a `<textarea>` made one with its
4
+ * `asTextarea` modifier. State comes from the element and its ARIA; it types the way a user
5
+ * does.
6
+ *
7
+ * const message = new TextareaHarness('message') // <Textarea @name="message">
8
+ * await message.fillIn('Hello')
9
+ * assert.strictEqual(message.value, 'Hello')
10
+ */
11
+ export declare class TextareaHarness extends Harness {
12
+ static component: string;
13
+ /** The `<textarea>` itself. */
14
+ get control(): HTMLTextAreaElement;
15
+ /** What it holds now. */
16
+ get value(): string;
17
+ /** Its `placeholder`, or `''`. */
18
+ get placeholder(): string;
19
+ /**
20
+ * Its accessible name, as assistive technology reads it: `aria-labelledby`'s text, else
21
+ * `aria-label`, else its `<label>`'s text, else `title`, else `placeholder`.
22
+ */
23
+ get label(): string;
24
+ /** The text of what its `aria-describedby` names (a field's description and errors), or `''`. */
25
+ get description(): string;
26
+ /** Whether it is `disabled`. */
27
+ get isDisabled(): boolean;
28
+ /** Whether it is `readonly`. */
29
+ get isReadOnly(): boolean;
30
+ /** Whether it is `required`. */
31
+ get isRequired(): boolean;
32
+ /** Whether it is marked invalid with `aria-invalid`. */
33
+ get isInvalid(): boolean;
34
+ /** Whether it has focus. */
35
+ get isFocused(): boolean;
36
+ /** Replaces what it holds with `text`, as pasting does: one `input` event, then `change`. */
37
+ fillIn(text: string): Promise<void>;
38
+ /** Types `text` one key at a time after what it holds, as a user does. */
39
+ typeIn(text: string): Promise<void>;
40
+ /** Empties it. */
41
+ clear(): Promise<void>;
42
+ /** Moves focus to it, as tabbing to it would. Fails if it can't take focus. */
43
+ focus(): Promise<void>;
44
+ /** Moves focus away from it. */
45
+ blur(): Promise<void>;
46
+ }
47
+ //# sourceMappingURL=textarea.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../src/textarea.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC;;;;;;;;GAQG;AACH,qBAAa,eAAgB,SAAQ,OAAO;IAC1C,OAAgB,SAAS,SAAa;IAEtC,+BAA+B;IAC/B,IAAI,OAAO,IAAI,mBAAmB,CAEjC;IAED,yBAAyB;IACzB,IAAI,KAAK,IAAI,MAAM,CAElB;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,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,+EAA+E;IACzE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,gCAAgC;IAC1B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B"}
@@ -0,0 +1,78 @@
1
+ import { blur, fillIn, focus, typeIn } from '@ember/test-helpers';
2
+ import { Harness } from "./harness.js";
3
+ import { controlDescription, controlLabel, isMarkedInvalid } from "./-private/control.js";
4
+ /**
5
+ * Drives a `<Textarea>` from `@ember-joinery/ember`, or a `<textarea>` made one with its
6
+ * `asTextarea` modifier. State comes from the element and its ARIA; it types the way a user
7
+ * does.
8
+ *
9
+ * const message = new TextareaHarness('message') // <Textarea @name="message">
10
+ * await message.fillIn('Hello')
11
+ * assert.strictEqual(message.value, 'Hello')
12
+ */
13
+ export class TextareaHarness extends Harness {
14
+ static component = 'textarea';
15
+ /** The `<textarea>` 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 `placeholder`, or `''`. */
24
+ get placeholder() {
25
+ return this.control.placeholder;
26
+ }
27
+ /**
28
+ * Its accessible name, as assistive technology reads it: `aria-labelledby`'s text, else
29
+ * `aria-label`, else its `<label>`'s text, else `title`, else `placeholder`.
30
+ */
31
+ get label() {
32
+ return controlLabel(this.control);
33
+ }
34
+ /** The text of what its `aria-describedby` names (a field's description and errors), or `''`. */
35
+ get description() {
36
+ return controlDescription(this.control);
37
+ }
38
+ /** Whether it is `disabled`. */
39
+ get isDisabled() {
40
+ return this.control.disabled;
41
+ }
42
+ /** Whether it is `readonly`. */
43
+ get isReadOnly() {
44
+ return this.control.readOnly;
45
+ }
46
+ /** Whether it is `required`. */
47
+ get isRequired() {
48
+ return this.control.required;
49
+ }
50
+ /** Whether it is marked invalid with `aria-invalid`. */
51
+ get isInvalid() {
52
+ return isMarkedInvalid(this.control);
53
+ }
54
+ /** Whether it has focus. */
55
+ get isFocused() {
56
+ return this.control.ownerDocument.activeElement === this.control;
57
+ }
58
+ /** Replaces what it holds with `text`, as pasting does: one `input` event, then `change`. */
59
+ async fillIn(text) {
60
+ await fillIn(this.control, text);
61
+ }
62
+ /** Types `text` one key at a time after what it holds, as a user does. */
63
+ async typeIn(text) {
64
+ await typeIn(this.control, text);
65
+ }
66
+ /** Empties it. */
67
+ async clear() {
68
+ await fillIn(this.control, '');
69
+ }
70
+ /** Moves focus to it, as tabbing to it would. Fails if it can't take focus. */
71
+ async focus() {
72
+ await focus(this.control);
73
+ }
74
+ /** Moves focus away from it. */
75
+ async blur() {
76
+ await blur(this.control);
77
+ }
78
+ }
@@ -0,0 +1,172 @@
1
+ import { Harness, type ChildOptions } from './harness.ts';
2
+ import type { TestHooks } from './test-hooks.ts';
3
+ /** A direction a toast can be swiped off in. */
4
+ export type ToastSwipe = 'left' | 'right' | 'up' | 'down';
5
+ export interface ToastSwipeOptions {
6
+ /** How far the pointer moves, in pixels. Default 100 (sonner dismisses from 45). */
7
+ distance?: number;
8
+ /**
9
+ * How long the swipe takes, in milliseconds, before the pointer lifts. Default 0. A short,
10
+ * slow swipe (under 45px, and slower than 0.11px per millisecond) springs back.
11
+ */
12
+ duration?: number;
13
+ }
14
+ /**
15
+ * Drives one toast in a `<Toaster>` (from `@ember-joinery/ember` or
16
+ * `@ember-joinery/primitives/toast`): an `<li data-test-jn="toast">`, named by its id. State
17
+ * comes from sonner's data attributes and the toast's text.
18
+ *
19
+ * const toast = new ToasterHarness().toast() // the newest
20
+ * assert.strictEqual(toast.title, 'Event has been created')
21
+ * await toast.clickAction()
22
+ *
23
+ * new ToastHarness('saved') // toast('Saved', { id: 'saved' })
24
+ */
25
+ export declare class ToastHarness extends Harness {
26
+ #private;
27
+ static component: string;
28
+ /** Its id, as `toast()` returned it (or as you gave it), as a string. */
29
+ get id(): string;
30
+ /** Its title, whitespace collapsed. */
31
+ get title(): string;
32
+ /** Its description, or `null` without one. */
33
+ get description(): string | null;
34
+ /** Its type (`success`, `error`, `loading`…), or `null` for a plain toast. */
35
+ get type(): string | null;
36
+ /** Where it shows, as `top-center` or `bottom-right`. */
37
+ get position(): string;
38
+ /** Whether it is the newest in its stack, the one in front. */
39
+ get isFront(): boolean;
40
+ /** Whether it is among the toasts the stack shows (`@visibleToasts`, 3 by default). */
41
+ get isVisible(): boolean;
42
+ /** Whether its stack is expanded (hovered, focused from the keyboard, or `@expand`). */
43
+ get isExpanded(): boolean;
44
+ /** Whether it has finished coming in. */
45
+ get isMounted(): boolean;
46
+ /** Whether it is on its way out. */
47
+ get isRemoved(): boolean;
48
+ /** Whether it was swiped away. */
49
+ get isSwipedOut(): boolean;
50
+ /** Whether it is coloured by its type. */
51
+ get hasRichColors(): boolean;
52
+ /** Whether it is inverted. */
53
+ get isInverted(): boolean;
54
+ /** Whether the user can close it (`dismissible`). */
55
+ get isDismissible(): boolean;
56
+ /** Whether it shows sonner's look (`false` for `unstyled` and custom toasts). */
57
+ get isStyled(): boolean;
58
+ /** Whether it follows a promise (`toast.promise()`). */
59
+ get isPromise(): boolean;
60
+ /** Whether it is loading (`toast.loading()`, or a promise that hasn't settled). */
61
+ get isLoading(): boolean;
62
+ /** Its icon's box (`[data-icon]`), or `null` without one. */
63
+ get icon(): HTMLElement | null;
64
+ /** Its action button, or `null`. */
65
+ get action(): HTMLButtonElement | null;
66
+ /** Its cancel button, or `null`. */
67
+ get cancel(): HTMLButtonElement | null;
68
+ /** Its close button, or `null` without one (`closeButton`). */
69
+ get closeButton(): HTMLButtonElement | null;
70
+ /** Presses its action button. The toast closes, unless the handler prevents it. */
71
+ clickAction(): Promise<void>;
72
+ /** Presses its cancel button. The toast closes. */
73
+ clickCancel(): Promise<void>;
74
+ /** Presses its close button. The toast closes. */
75
+ close(): Promise<void>;
76
+ /** Moves focus to it, as tabbing to it would. */
77
+ focus(): Promise<void>;
78
+ /**
79
+ * Swipes it with a pointer, as a finger would: down on it, across, and up. Far enough (45px,
80
+ * or fast enough) towards a side it can leave by, it goes; otherwise it springs back.
81
+ */
82
+ swipe(direction: ToastSwipe, options?: ToastSwipeOptions): Promise<void>;
83
+ }
84
+ /** The data attributes a toaster's list (`<ol data-sonner-toaster>`) carries. */
85
+ export interface ToasterListState {
86
+ /** Its position, as `bottom-right`. */
87
+ position: string;
88
+ /** `light` or `dark`. */
89
+ theme: string | null;
90
+ /** `ltr` or `rtl`. */
91
+ dir: string | null;
92
+ }
93
+ /**
94
+ * Drives a `<Toaster>` (from `@ember-joinery/ember` or `@ember-joinery/primitives/toast`): the
95
+ * live region, its lists (one per position in use) and its toasts.
96
+ *
97
+ * const toaster = new ToasterHarness()
98
+ * await click(saveButton)
99
+ * assert.deepEqual(toaster.titles, ['Saved'])
100
+ * await toaster.hover() // expands the stack and pauses the timers
101
+ *
102
+ * Toasts belong to the app, so give each test its own with `setupToaster(hooks)`.
103
+ */
104
+ export declare class ToasterHarness extends Harness {
105
+ #private;
106
+ static component: string;
107
+ /** The region's name: `Notifications alt+T` unless given `@containerAriaLabel`. */
108
+ get label(): string;
109
+ /** Its lists (`<ol>`), one for each position with toasts, in document order. */
110
+ get lists(): HTMLOListElement[];
111
+ /** The positions it shows toasts in now. */
112
+ get positions(): string[];
113
+ /** What each list says about itself: its position, theme and direction. */
114
+ get listStates(): ToasterListState[];
115
+ /** Its theme (`light` or `dark`), from its lists; `null` while it shows no toasts. */
116
+ get theme(): string | null;
117
+ /** Every toast it shows (and any on its way out), newest first in each list. */
118
+ get toasts(): ToastHarness[];
119
+ /** The toasts' titles, newest first in each list. */
120
+ get titles(): string[];
121
+ /** How many toasts it shows, not counting any on their way out. */
122
+ get count(): number;
123
+ /**
124
+ * One toast: the newest without options, else by its id (`toast('…', { id })`) or its index
125
+ * among the toasts (newest first).
126
+ */
127
+ toast(options?: ChildOptions): ToastHarness;
128
+ /** Whether its stack is expanded. */
129
+ get isExpanded(): boolean;
130
+ /** Puts the pointer on a list (the first, or the one at `position`): it expands and pauses. */
131
+ hover(position?: string): Promise<void>;
132
+ /** Takes the pointer off a list: it collapses, and the timers run again. */
133
+ unhover(position?: string): Promise<void>;
134
+ /**
135
+ * Presses the hotkey, which expands the stack and moves focus to it. Give the keys as the
136
+ * Toaster's `@hotkey` names them: modifier properties and key codes. Default Alt+T,
137
+ * `['altKey', 'KeyT']`, sonner's.
138
+ */
139
+ pressHotkey(hotkey?: readonly string[]): Promise<void>;
140
+ /** Waits until it shows a toast with this title (or any toast), as one made after a delay. */
141
+ waitForToast(title?: string, options?: {
142
+ timeout?: number;
143
+ }): Promise<ToastHarness>;
144
+ /** Waits until every toast has gone, as their time runs out. */
145
+ waitForNoToasts(options?: {
146
+ timeout?: number;
147
+ }): Promise<void>;
148
+ }
149
+ /**
150
+ * Gives each test in a module its own toasts. `toast()` is called from anywhere, so it finds
151
+ * its app through the rendered `<Toaster>`; this points it at the test's owner from the start
152
+ * of each test, so a toast made before a Toaster renders (or in a test that renders none) goes
153
+ * to the test, and never to another one. It sets `globalThis.JOINERY_TOAST_OWNER`, which
154
+ * `@ember-joinery/primitives/toast` reads each time a toast is made, and takes it away after.
155
+ * Call it after `setupRenderingTest(hooks)` or `setupApplicationTest(hooks)`.
156
+ *
157
+ * module('saving', function (hooks) {
158
+ * setupRenderingTest(hooks)
159
+ * setupToaster(hooks)
160
+ *
161
+ * test('it says so', async function (assert) {
162
+ * await render(<template><SaveButton /><Toaster /></template>)
163
+ * await click('button')
164
+ * assert.deepEqual(new ToasterHarness().titles, ['Saved'])
165
+ * })
166
+ * })
167
+ *
168
+ * The toasts themselves are the owner's, so they, and their timers, go with it at the end of
169
+ * the test.
170
+ */
171
+ export declare function setupToaster(hooks: TestHooks): void;
172
+ //# sourceMappingURL=toaster.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toaster.d.ts","sourceRoot":"","sources":["../src/toaster.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AACzD,O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