@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,156 @@
1
+ import { click, focus } from '@ember/test-helpers';
2
+ import { ButtonHarness } from "./button.js";
3
+ import { Harness } from "./harness.js";
4
+ function text(element) {
5
+ return (element?.textContent ?? '').replace(/\s+/g, ' ').trim();
6
+ }
7
+ /** The accessible name of a control with no text of its own: its `aria-label`, else its text. */
8
+ function label(element) {
9
+ if (!element)
10
+ return '';
11
+ return element.getAttribute('aria-label')?.trim() || text(element);
12
+ }
13
+ /**
14
+ * Drives an `<Attachment>` from `@ember-joinery/ember`. It reads the attachment's name, its
15
+ * metadata and its upload state, finds its actions by their labels, and presses its trigger:
16
+ *
17
+ * const upload = new AttachmentHarness('report') // <Attachment @name="report">
18
+ * assert.strictEqual(upload.title, 'sales-dashboard.pdf')
19
+ * assert.strictEqual(upload.state, 'uploading')
20
+ * await upload.action('Cancel upload').click()
21
+ * await upload.open() // its trigger
22
+ */
23
+ export class AttachmentHarness extends Harness {
24
+ static component = 'attachment';
25
+ /** Its `@state`: `idle`, `uploading`, `processing`, `error` or `done`. */
26
+ get state() {
27
+ return this.element.getAttribute('data-state');
28
+ }
29
+ /** Its `@size`: `default`, `sm` or `xs`. */
30
+ get size() {
31
+ return this.element.getAttribute('data-size');
32
+ }
33
+ /** Its `@orientation`: `horizontal` or `vertical`. */
34
+ get orientation() {
35
+ return this.element.getAttribute('data-orientation');
36
+ }
37
+ /** Whether it is uploading or processing, the states that shimmer its title. */
38
+ get isBusy() {
39
+ return this.state === 'uploading' || this.state === 'processing';
40
+ }
41
+ /** Whether its upload failed. */
42
+ get isError() {
43
+ return this.state === 'error';
44
+ }
45
+ /** Its title's text, whitespace collapsed, or `''` without one. */
46
+ get title() {
47
+ return text(this.queryPart('title'));
48
+ }
49
+ /** Its description's text, whitespace collapsed, or `''` without one. */
50
+ get description() {
51
+ return text(this.queryPart('description'));
52
+ }
53
+ /** Its media. Throws when it has none. */
54
+ get media() {
55
+ return this.part('media');
56
+ }
57
+ /** Its media's `@variant` (`icon` or `image`), or `null` without media. */
58
+ get mediaVariant() {
59
+ return this.queryPart('media')?.getAttribute('data-variant') ?? null;
60
+ }
61
+ /** The image in its media, or `null` without one. */
62
+ get image() {
63
+ return this.queryPart('media')?.querySelector('img') ?? null;
64
+ }
65
+ /** Its image's `alt`, or `null` without an image. */
66
+ get imageAlt() {
67
+ return this.image?.getAttribute('alt') ?? null;
68
+ }
69
+ /** Its content. Throws when it has none. */
70
+ get content() {
71
+ return this.part('content');
72
+ }
73
+ /** Its title. Throws when it has none. */
74
+ get titleElement() {
75
+ return this.part('title');
76
+ }
77
+ /** Its description. Throws when it has none. */
78
+ get descriptionElement() {
79
+ return this.part('description');
80
+ }
81
+ /** The element holding its actions. Throws when it has none. */
82
+ get actionsElement() {
83
+ return this.part('actions');
84
+ }
85
+ /** A `ButtonHarness` for each of its actions, in order. */
86
+ get actions() {
87
+ return this.parts('action').map((_, index) => new ButtonHarness({ within: this.actionsElement, index }));
88
+ }
89
+ /** The accessible name of each of its actions, in order. */
90
+ get actionLabels() {
91
+ return this.parts('action').map(label);
92
+ }
93
+ /** The action whose accessible name (its `aria-label`, else its text) is `name`. Throws when there is none. */
94
+ action(name) {
95
+ const index = this.actionLabels.indexOf(name);
96
+ if (index === -1) {
97
+ throw new Error(`Joinery: no action "${name}" in ${this} (its actions: ${this.actionLabels.join(', ') || 'none'})`);
98
+ }
99
+ return this.actions[index];
100
+ }
101
+ /** Its trigger, the button or link over the whole card. Throws when it has none. */
102
+ get trigger() {
103
+ return this.part('trigger');
104
+ }
105
+ /** Whether it has a trigger. */
106
+ get hasTrigger() {
107
+ return this.queryPart('trigger') !== null;
108
+ }
109
+ /** Its trigger's accessible name, or `''` without one. */
110
+ get triggerLabel() {
111
+ return label(this.queryPart('trigger'));
112
+ }
113
+ /** Where its trigger links to, or `null` when it is a button (or there is none). */
114
+ get href() {
115
+ return this.queryPart('trigger')?.getAttribute('href') ?? null;
116
+ }
117
+ /** Presses its trigger, as a user clicking the card would. */
118
+ async open() {
119
+ await click(this.trigger);
120
+ }
121
+ /** Moves focus to its trigger, as tabbing to it would. */
122
+ async focusTrigger() {
123
+ await focus(this.trigger);
124
+ }
125
+ }
126
+ /**
127
+ * Drives an `<AttachmentGroup>` from `@ember-joinery/ember`: a row of attachments that scrolls
128
+ * across.
129
+ *
130
+ * const group = new AttachmentGroupHarness()
131
+ * assert.deepEqual(group.titles, ['workspace.png', 'desk-reference.jpg'])
132
+ * assert.true(group.isScrollable)
133
+ */
134
+ export class AttachmentGroupHarness extends Harness {
135
+ static component = 'attachment-group';
136
+ /** An `AttachmentHarness` for each attachment in the row, in order. */
137
+ get attachments() {
138
+ return this.findAll(AttachmentHarness);
139
+ }
140
+ /** The title of each attachment, in order. */
141
+ get titles() {
142
+ return this.attachments.map(attachment => attachment.title);
143
+ }
144
+ /** Whether the row is wider than it shows, so it scrolls across. */
145
+ get isScrollable() {
146
+ const element = this.element;
147
+ return element.scrollWidth > element.clientWidth + 1;
148
+ }
149
+ /**
150
+ * How far it is scrolled across, from its start, in pixels: right to left, a positive
151
+ * distance too.
152
+ */
153
+ get scrollOffset() {
154
+ return Math.abs(this.element.scrollLeft);
155
+ }
156
+ }
@@ -0,0 +1,65 @@
1
+ import { Harness } from './harness.ts';
2
+ /** Where an avatar's image is, as the primitives' `ImageLoadingStatus` names it. */
3
+ export type AvatarStatus = 'idle' | 'loading' | 'loaded' | 'error';
4
+ /**
5
+ * Drives an `<Avatar>` from `@ember-joinery/ember`, or the headless one from
6
+ * `@ember-joinery/primitives/avatar`. It reads where the image is, and what shows: the image
7
+ * once it has loaded, the fallback until then and if it fails.
8
+ *
9
+ * const avatar = new AvatarHarness('shadcn') // <Avatar @name="shadcn">
10
+ * assert.true(avatar.isLoaded)
11
+ * assert.strictEqual(avatar.label, '@shadcn') // the image's alt
12
+ *
13
+ * Tests wait for the image (`settled()` resolves once it has loaded or failed), so after
14
+ * `render()` the status is `loaded` or `error`.
15
+ */
16
+ export declare class AvatarHarness extends Harness {
17
+ static component: string;
18
+ /**
19
+ * Where the image is: `loaded` when it shows, `loading` or `error` from the avatar's
20
+ * `data-loading` and `data-error`, and `idle` with no image to load.
21
+ */
22
+ get status(): AvatarStatus;
23
+ /** Whether the image has loaded, and shows. */
24
+ get isLoaded(): boolean;
25
+ /** Whether the image is loading. */
26
+ get isLoading(): boolean;
27
+ /** Whether the image failed to load. */
28
+ get isError(): boolean;
29
+ /** The `<img>`, once it has loaded, or `null`. */
30
+ get image(): HTMLImageElement | null;
31
+ /** The fallback while it shows, or `null`. */
32
+ get fallback(): HTMLElement | null;
33
+ /** The fallback's text (`CN`), or `''` while it doesn't show. */
34
+ get fallbackText(): string;
35
+ /** The image's URL, once it has loaded, or `null`. */
36
+ get src(): string | null;
37
+ /**
38
+ * What it stands for, as a screen reader reads it: the image's `alt` once it shows, else the
39
+ * fallback's text.
40
+ */
41
+ get label(): string;
42
+ /** Its `@size`: `default`, `sm` or `lg`. `null` for the headless avatar, which has none. */
43
+ get size(): string | null;
44
+ /** The badge, or `null` without one. */
45
+ get badge(): HTMLElement | null;
46
+ /** Whether it has a badge. */
47
+ get hasBadge(): boolean;
48
+ }
49
+ /**
50
+ * Drives an `<AvatarGroup>` from `@ember-joinery/ember`: its avatars, in order, and its count.
51
+ *
52
+ * const team = new AvatarGroupHarness('team')
53
+ * assert.strictEqual(team.avatars.length, 3)
54
+ * assert.strictEqual(team.count, '+3')
55
+ */
56
+ export declare class AvatarGroupHarness extends Harness {
57
+ static component: string;
58
+ /** A harness for each avatar in the group, in order. */
59
+ get avatars(): AvatarHarness[];
60
+ /** The count's text (`+3`), `''` for one that shows an icon, or `null` without a count. */
61
+ get count(): string | null;
62
+ /** The count element, or `null` without one. */
63
+ get countElement(): HTMLElement | null;
64
+ }
65
+ //# sourceMappingURL=avatar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar.d.ts","sourceRoot":"","sources":["../src/avatar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAMtC,oFAAoF;AACpF,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;AAElE;;;;;;;;;;;GAWG;AACH,qBAAa,aAAc,SAAQ,OAAO;IACxC,OAAgB,SAAS,SAAW;IAEpC;;;OAGG;IACH,IAAI,MAAM,IAAI,YAAY,CAMzB;IAED,+CAA+C;IAC/C,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,oCAAoC;IACpC,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,wCAAwC;IACxC,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,kDAAkD;IAClD,IAAI,KAAK,IAAI,gBAAgB,GAAG,IAAI,CAEnC;IAED,8CAA8C;IAC9C,IAAI,QAAQ,IAAI,WAAW,GAAG,IAAI,CAEjC;IAED,iEAAiE;IACjE,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,sDAAsD;IACtD,IAAI,GAAG,IAAI,MAAM,GAAG,IAAI,CAEvB;IAED;;;OAGG;IACH,IAAI,KAAK,IAAI,MAAM,CAIlB;IAED,4FAA4F;IAC5F,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAExB;IAED,wCAAwC;IACxC,IAAI,KAAK,IAAI,WAAW,GAAG,IAAI,CAE9B;IAED,8BAA8B;IAC9B,IAAI,QAAQ,IAAI,OAAO,CAEtB;CACF;AAED;;;;;;GAMG;AACH,qBAAa,kBAAmB,SAAQ,OAAO;IAC7C,OAAgB,SAAS,SAAiB;IAE1C,wDAAwD;IACxD,IAAI,OAAO,IAAI,aAAa,EAAE,CAE7B;IAED,2FAA2F;IAC3F,IAAI,KAAK,IAAI,MAAM,GAAG,IAAI,CAGzB;IAED,gDAAgD;IAChD,IAAI,YAAY,IAAI,WAAW,GAAG,IAAI,CAErC;CACF"}
package/dist/avatar.js ADDED
@@ -0,0 +1,106 @@
1
+ import { Harness } from "./harness.js";
2
+ function text(element) {
3
+ return (element?.textContent ?? '').replace(/\s+/g, ' ').trim();
4
+ }
5
+ /**
6
+ * Drives an `<Avatar>` from `@ember-joinery/ember`, or the headless one from
7
+ * `@ember-joinery/primitives/avatar`. It reads where the image is, and what shows: the image
8
+ * once it has loaded, the fallback until then and if it fails.
9
+ *
10
+ * const avatar = new AvatarHarness('shadcn') // <Avatar @name="shadcn">
11
+ * assert.true(avatar.isLoaded)
12
+ * assert.strictEqual(avatar.label, '@shadcn') // the image's alt
13
+ *
14
+ * Tests wait for the image (`settled()` resolves once it has loaded or failed), so after
15
+ * `render()` the status is `loaded` or `error`.
16
+ */
17
+ export class AvatarHarness extends Harness {
18
+ static component = 'avatar';
19
+ /**
20
+ * Where the image is: `loaded` when it shows, `loading` or `error` from the avatar's
21
+ * `data-loading` and `data-error`, and `idle` with no image to load.
22
+ */
23
+ get status() {
24
+ if (this.image)
25
+ return 'loaded';
26
+ const element = this.element;
27
+ if (element.hasAttribute('data-error'))
28
+ return 'error';
29
+ if (element.hasAttribute('data-loading'))
30
+ return 'loading';
31
+ return 'idle';
32
+ }
33
+ /** Whether the image has loaded, and shows. */
34
+ get isLoaded() {
35
+ return this.status === 'loaded';
36
+ }
37
+ /** Whether the image is loading. */
38
+ get isLoading() {
39
+ return this.status === 'loading';
40
+ }
41
+ /** Whether the image failed to load. */
42
+ get isError() {
43
+ return this.status === 'error';
44
+ }
45
+ /** The `<img>`, once it has loaded, or `null`. */
46
+ get image() {
47
+ return this.queryPart('image');
48
+ }
49
+ /** The fallback while it shows, or `null`. */
50
+ get fallback() {
51
+ return this.queryPart('fallback');
52
+ }
53
+ /** The fallback's text (`CN`), or `''` while it doesn't show. */
54
+ get fallbackText() {
55
+ return text(this.fallback);
56
+ }
57
+ /** The image's URL, once it has loaded, or `null`. */
58
+ get src() {
59
+ return this.image?.getAttribute('src') ?? null;
60
+ }
61
+ /**
62
+ * What it stands for, as a screen reader reads it: the image's `alt` once it shows, else the
63
+ * fallback's text.
64
+ */
65
+ get label() {
66
+ const image = this.image;
67
+ if (image)
68
+ return image.getAttribute('alt') ?? '';
69
+ return this.fallbackText;
70
+ }
71
+ /** Its `@size`: `default`, `sm` or `lg`. `null` for the headless avatar, which has none. */
72
+ get size() {
73
+ return this.element.getAttribute('data-size');
74
+ }
75
+ /** The badge, or `null` without one. */
76
+ get badge() {
77
+ return this.queryPart('badge');
78
+ }
79
+ /** Whether it has a badge. */
80
+ get hasBadge() {
81
+ return this.badge !== null;
82
+ }
83
+ }
84
+ /**
85
+ * Drives an `<AvatarGroup>` from `@ember-joinery/ember`: its avatars, in order, and its count.
86
+ *
87
+ * const team = new AvatarGroupHarness('team')
88
+ * assert.strictEqual(team.avatars.length, 3)
89
+ * assert.strictEqual(team.count, '+3')
90
+ */
91
+ export class AvatarGroupHarness extends Harness {
92
+ static component = 'avatar-group';
93
+ /** A harness for each avatar in the group, in order. */
94
+ get avatars() {
95
+ return this.findAll(AvatarHarness);
96
+ }
97
+ /** The count's text (`+3`), `''` for one that shows an icon, or `null` without a count. */
98
+ get count() {
99
+ const count = this.queryPart('count');
100
+ return count ? text(count) : null;
101
+ }
102
+ /** The count element, or `null` without one. */
103
+ get countElement() {
104
+ return this.queryPart('count');
105
+ }
106
+ }
@@ -0,0 +1,29 @@
1
+ import { Harness } from './harness.ts';
2
+ /**
3
+ * Drives a `<Badge>` from `@ember-joinery/ember`, or an element made a badge with its `asBadge`
4
+ * modifier (`<LinkTo {{asBadge}}>`).
5
+ *
6
+ * const status = new BadgeHarness('status') // <Badge @name="status">
7
+ * assert.strictEqual(status.text, 'Verified')
8
+ * assert.strictEqual(status.variant, 'secondary')
9
+ */
10
+ export declare class BadgeHarness extends Harness {
11
+ static component: string;
12
+ /** The text it shows, whitespace collapsed. */
13
+ get text(): string;
14
+ /** Its `@variant`: `default`, `secondary`, `destructive`, `outline`, `ghost` or `link`. */
15
+ get variant(): string | null;
16
+ /** Whether it is a link: an `<a href>` (`@as="a"`, or the modifier on a link). */
17
+ get isLink(): boolean;
18
+ /** Where it links to, for a link badge; otherwise `null`. */
19
+ get href(): string | null;
20
+ /** Whether it has focus. */
21
+ get isFocused(): boolean;
22
+ /** Clicks it, as a user would: a link badge follows its link. */
23
+ click(): Promise<void>;
24
+ /** Moves focus to it, as tabbing to a link badge would. Fails if it can't take focus. */
25
+ focus(): Promise<void>;
26
+ /** Moves focus away from it. */
27
+ blur(): Promise<void>;
28
+ }
29
+ //# sourceMappingURL=badge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../src/badge.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,2FAA2F;IAC3F,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAED,kFAAkF;IAClF,IAAI,MAAM,IAAI,OAAO,CAGpB;IAED,6DAA6D;IAC7D,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAExB;IAED,4BAA4B;IAC5B,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,iEAAiE;IAC3D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,yFAAyF;IACnF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,gCAAgC;IAC1B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B"}
package/dist/badge.js ADDED
@@ -0,0 +1,49 @@
1
+ import { blur, click, focus } from '@ember/test-helpers';
2
+ import { Harness } from "./harness.js";
3
+ function text(element) {
4
+ return (element.textContent ?? '').replace(/\s+/g, ' ').trim();
5
+ }
6
+ /**
7
+ * Drives a `<Badge>` from `@ember-joinery/ember`, or an element made a badge with its `asBadge`
8
+ * modifier (`<LinkTo {{asBadge}}>`).
9
+ *
10
+ * const status = new BadgeHarness('status') // <Badge @name="status">
11
+ * assert.strictEqual(status.text, 'Verified')
12
+ * assert.strictEqual(status.variant, 'secondary')
13
+ */
14
+ export class BadgeHarness extends Harness {
15
+ static component = 'badge';
16
+ /** The text it shows, whitespace collapsed. */
17
+ get text() {
18
+ return text(this.element);
19
+ }
20
+ /** Its `@variant`: `default`, `secondary`, `destructive`, `outline`, `ghost` or `link`. */
21
+ get variant() {
22
+ return this.element.getAttribute('data-variant');
23
+ }
24
+ /** Whether it is a link: an `<a href>` (`@as="a"`, or the modifier on a link). */
25
+ get isLink() {
26
+ const element = this.element;
27
+ return element.localName === 'a' && element.hasAttribute('href');
28
+ }
29
+ /** Where it links to, for a link badge; otherwise `null`. */
30
+ get href() {
31
+ return this.isLink ? this.element.getAttribute('href') : null;
32
+ }
33
+ /** Whether it has focus. */
34
+ get isFocused() {
35
+ return this.element.ownerDocument.activeElement === this.element;
36
+ }
37
+ /** Clicks it, as a user would: a link badge follows its link. */
38
+ async click() {
39
+ await click(this.element);
40
+ }
41
+ /** Moves focus to it, as tabbing to a link badge would. Fails if it can't take focus. */
42
+ async focus() {
43
+ await focus(this.element);
44
+ }
45
+ /** Moves focus away from it. */
46
+ async blur() {
47
+ await blur(this.element);
48
+ }
49
+ }
@@ -0,0 +1,36 @@
1
+ import { Harness } from './harness.ts';
2
+ /**
3
+ * Drives a `<Breadcrumb>`, from `@ember-joinery/ember` or `@ember-joinery/primitives/breadcrumb`:
4
+ * a `nav` around a list of crumbs, with separators that assistive technology skips. It reads the
5
+ * crumbs as a screen reader does, through the list's items and `aria-current`.
6
+ *
7
+ * const path = new BreadcrumbHarness()
8
+ * assert.deepEqual(path.items, ['Home', 'Components', 'Breadcrumb'])
9
+ * assert.strictEqual(path.current, 'Breadcrumb')
10
+ * await path.clickLink('Components')
11
+ */
12
+ export declare class BreadcrumbHarness extends Harness {
13
+ #private;
14
+ static component: string;
15
+ /** Its accessible name, the `nav`'s `aria-label`. */
16
+ get label(): string;
17
+ /** Its list (`ol`). */
18
+ get list(): HTMLOListElement | HTMLUListElement;
19
+ /** Each crumb's `li`, in order: the list's items, but the separators. */
20
+ get itemElements(): HTMLLIElement[];
21
+ /** The text of each crumb, in order, whitespace collapsed. A collapsed crumb reads as ''. */
22
+ get items(): string[];
23
+ /** The separators between the crumbs: the list's items assistive technology skips. */
24
+ get separators(): HTMLElement[];
25
+ /** The text of each crumb that is a link (`a[href]`), in order. */
26
+ get links(): string[];
27
+ /** The current page (`aria-current="page"`), or `null` when no crumb is marked. */
28
+ get current(): string | null;
29
+ /** Whether some crumbs are collapsed into an ellipsis (the styled Breadcrumb's `Ellipsis`). */
30
+ get isCollapsed(): boolean;
31
+ /** The link whose text is `name`. Throws when there is none. */
32
+ link(name: string): HTMLAnchorElement;
33
+ /** Clicks the link whose text is `name`, as a user would. */
34
+ clickLink(name: string): Promise<void>;
35
+ }
36
+ //# sourceMappingURL=breadcrumb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breadcrumb.d.ts","sourceRoot":"","sources":["../src/breadcrumb.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AActC;;;;;;;;;GASG;AACH,qBAAa,iBAAkB,SAAQ,OAAO;;IAC5C,OAAgB,SAAS,SAAe;IAExC,qDAAqD;IACrD,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,uBAAuB;IACvB,IAAI,IAAI,IAAI,gBAAgB,GAAG,gBAAgB,CAI9C;IAED,yEAAyE;IACzE,IAAI,YAAY,IAAI,aAAa,EAAE,CAIlC;IAED,6FAA6F;IAC7F,IAAI,KAAK,IAAI,MAAM,EAAE,CAWpB;IAED,sFAAsF;IACtF,IAAI,UAAU,IAAI,WAAW,EAAE,CAI9B;IAED,mEAAmE;IACnE,IAAI,KAAK,IAAI,MAAM,EAAE,CAEpB;IAED,mFAAmF;IACnF,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAG3B;IAED,+FAA+F;IAC/F,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,gEAAgE;IAChE,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB;IAMrC,6DAA6D;IACvD,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAO7C"}
@@ -0,0 +1,80 @@
1
+ import { click } from '@ember/test-helpers';
2
+ import { Harness } from "./harness.js";
3
+ import { NotFoundError } from "./-private/tree.js";
4
+ function text(element) {
5
+ return (element.textContent ?? '').replace(/\s+/g, ' ').trim();
6
+ }
7
+ function isHidden(element) {
8
+ const role = element.getAttribute('role');
9
+ return (element.getAttribute('aria-hidden') === 'true' || role === 'presentation' || role === 'none');
10
+ }
11
+ /**
12
+ * Drives a `<Breadcrumb>`, from `@ember-joinery/ember` or `@ember-joinery/primitives/breadcrumb`:
13
+ * a `nav` around a list of crumbs, with separators that assistive technology skips. It reads the
14
+ * crumbs as a screen reader does, through the list's items and `aria-current`.
15
+ *
16
+ * const path = new BreadcrumbHarness()
17
+ * assert.deepEqual(path.items, ['Home', 'Components', 'Breadcrumb'])
18
+ * assert.strictEqual(path.current, 'Breadcrumb')
19
+ * await path.clickLink('Components')
20
+ */
21
+ export class BreadcrumbHarness extends Harness {
22
+ static component = 'breadcrumb';
23
+ /** Its accessible name, the `nav`'s `aria-label`. */
24
+ get label() {
25
+ return this.element.getAttribute('aria-label') ?? '';
26
+ }
27
+ /** Its list (`ol`). */
28
+ get list() {
29
+ const list = this.element.querySelector('ol, ul');
30
+ if (!list)
31
+ throw new NotFoundError(`no list found in ${this}`);
32
+ return list;
33
+ }
34
+ /** Each crumb's `li`, in order: the list's items, but the separators. */
35
+ get itemElements() {
36
+ return [...this.list.children].filter((element) => element.localName === 'li' && !isHidden(element));
37
+ }
38
+ /** The text of each crumb, in order, whitespace collapsed. A collapsed crumb reads as ''. */
39
+ get items() {
40
+ return this.itemElements.map(element => {
41
+ const visible = [...element.childNodes].filter(node => !(node instanceof Element && isHidden(node)));
42
+ return visible
43
+ .map(node => node.textContent ?? '')
44
+ .join('')
45
+ .replace(/\s+/g, ' ')
46
+ .trim();
47
+ });
48
+ }
49
+ /** The separators between the crumbs: the list's items assistive technology skips. */
50
+ get separators() {
51
+ return [...this.list.children].filter((element) => element.localName === 'li' && isHidden(element));
52
+ }
53
+ /** The text of each crumb that is a link (`a[href]`), in order. */
54
+ get links() {
55
+ return this.#links().map(text);
56
+ }
57
+ /** The current page (`aria-current="page"`), or `null` when no crumb is marked. */
58
+ get current() {
59
+ const current = this.list.querySelector('[aria-current="page"]');
60
+ return current ? text(current) : null;
61
+ }
62
+ /** Whether some crumbs are collapsed into an ellipsis (the styled Breadcrumb's `Ellipsis`). */
63
+ get isCollapsed() {
64
+ return this.queryPart('ellipsis') !== null;
65
+ }
66
+ /** The link whose text is `name`. Throws when there is none. */
67
+ link(name) {
68
+ const found = this.#links().find(link => text(link) === name);
69
+ if (!found)
70
+ throw new NotFoundError(`no link "${name}" in ${this}`);
71
+ return found;
72
+ }
73
+ /** Clicks the link whose text is `name`, as a user would. */
74
+ async clickLink(name) {
75
+ await click(this.link(name));
76
+ }
77
+ #links() {
78
+ return [...this.list.querySelectorAll('a[href]')];
79
+ }
80
+ }
@@ -0,0 +1,56 @@
1
+ import { Harness } from './harness.ts';
2
+ /**
3
+ * Drives a `<Bubble>` from `@ember-joinery/ember`. It reads the bubble's text, look and side,
4
+ * its reactions, and clicks a bubble whose content is a button or a link:
5
+ *
6
+ * const reply = new BubbleHarness('reply') // <Bubble @name="reply">
7
+ * assert.strictEqual(reply.text, 'I forgot my password')
8
+ * assert.strictEqual(reply.reactionsLabel, 'Reaction: thumbs up')
9
+ * await reply.click()
10
+ *
11
+ * Find what is inside its reactions, such as a button, with `find()`.
12
+ */
13
+ export declare class BubbleHarness extends Harness {
14
+ static component: string;
15
+ /** Its content's text, whitespace collapsed; the reactions are left out. */
16
+ get text(): string;
17
+ /** Its `@variant`: `default`, `secondary`, `muted`, `tinted`, `outline`, `ghost` or `destructive`. */
18
+ get variant(): string | null;
19
+ /** Its `@align`: `start` or `end`. */
20
+ get align(): string | null;
21
+ /** Its content, the framed surface. Throws when it has none. */
22
+ get content(): HTMLElement;
23
+ /** Its reactions. Throws when it has none. */
24
+ get reactions(): HTMLElement;
25
+ /** Whether it has reactions. */
26
+ get hasReactions(): boolean;
27
+ /**
28
+ * The reactions' accessible name, as assistive technology reads it: their `aria-label`
29
+ * (`role="img"` reads the row once, by it), else their text. `''` without reactions.
30
+ */
31
+ get reactionsLabel(): string;
32
+ /** The edge the reactions overlap (`top` or `bottom`), or `null` without reactions. */
33
+ get reactionsSide(): string | null;
34
+ /** The end of that edge they sit at (`start` or `end`), or `null` without reactions. */
35
+ get reactionsAlign(): string | null;
36
+ /** Whether its content is a button or a link, which a user can press. */
37
+ get isInteractive(): boolean;
38
+ /** Whether its content has focus. */
39
+ get isFocused(): boolean;
40
+ /** Clicks its content, as a user would: presses a button bubble, follows a link bubble. */
41
+ click(): Promise<void>;
42
+ /** Moves focus to its content, as tabbing to a button or link bubble would. */
43
+ focus(): Promise<void>;
44
+ }
45
+ /**
46
+ * Drives a `<BubbleGroup>` from `@ember-joinery/ember`: consecutive bubbles from one sender.
47
+ *
48
+ * const group = new BubbleGroupHarness()
49
+ * assert.deepEqual(group.bubbles.map(bubble => bubble.text), ['You tell me!', '…'])
50
+ */
51
+ export declare class BubbleGroupHarness extends Harness {
52
+ static component: string;
53
+ /** A harness for each bubble in the group, in order. */
54
+ get bubbles(): BubbleHarness[];
55
+ }
56
+ //# sourceMappingURL=bubble.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bubble.d.ts","sourceRoot":"","sources":["../src/bubble.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAMtC;;;;;;;;;;GAUG;AACH,qBAAa,aAAc,SAAQ,OAAO;IACxC,OAAgB,SAAS,SAAW;IAEpC,4EAA4E;IAC5E,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,sGAAsG;IACtG,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAED,sCAAsC;IACtC,IAAI,KAAK,IAAI,MAAM,GAAG,IAAI,CAEzB;IAED,gEAAgE;IAChE,IAAI,OAAO,IAAI,WAAW,CAEzB;IAED,8CAA8C;IAC9C,IAAI,SAAS,IAAI,WAAW,CAE3B;IAED,gCAAgC;IAChC,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED;;;OAGG;IACH,IAAI,cAAc,IAAI,MAAM,CAI3B;IAED,uFAAuF;IACvF,IAAI,aAAa,IAAI,MAAM,GAAG,IAAI,CAEjC;IAED,wFAAwF;IACxF,IAAI,cAAc,IAAI,MAAM,GAAG,IAAI,CAElC;IAED,yEAAyE;IACzE,IAAI,aAAa,IAAI,OAAO,CAO3B;IAED,qCAAqC;IACrC,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,2FAA2F;IACrF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,+EAA+E;IACzE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B;AAED;;;;;GAKG;AACH,qBAAa,kBAAmB,SAAQ,OAAO;IAC7C,OAAgB,SAAS,SAAiB;IAE1C,wDAAwD;IACxD,IAAI,OAAO,IAAI,aAAa,EAAE,CAE7B;CACF"}