@ember-joinery/test-support 0.0.0-stage → 1.1.0

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 (321) hide show
  1. package/CHANGELOG.md +574 -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/app-shell.d.ts +43 -0
  37. package/dist/app-shell.d.ts.map +1 -0
  38. package/dist/app-shell.js +78 -0
  39. package/dist/aspect-ratio.d.ts +21 -0
  40. package/dist/aspect-ratio.d.ts.map +1 -0
  41. package/dist/aspect-ratio.js +30 -0
  42. package/dist/attachment.d.ts +86 -0
  43. package/dist/attachment.d.ts.map +1 -0
  44. package/dist/attachment.js +156 -0
  45. package/dist/avatar.d.ts +65 -0
  46. package/dist/avatar.d.ts.map +1 -0
  47. package/dist/avatar.js +106 -0
  48. package/dist/badge.d.ts +29 -0
  49. package/dist/badge.d.ts.map +1 -0
  50. package/dist/badge.js +49 -0
  51. package/dist/breadcrumb.d.ts +36 -0
  52. package/dist/breadcrumb.d.ts.map +1 -0
  53. package/dist/breadcrumb.js +80 -0
  54. package/dist/bubble.d.ts +56 -0
  55. package/dist/bubble.d.ts.map +1 -0
  56. package/dist/bubble.js +94 -0
  57. package/dist/button-group.d.ts +34 -0
  58. package/dist/button-group.d.ts.map +1 -0
  59. package/dist/button-group.js +62 -0
  60. package/dist/button.d.ts +37 -0
  61. package/dist/button.d.ts.map +1 -0
  62. package/dist/button.js +77 -0
  63. package/dist/calendar.d.ts +115 -0
  64. package/dist/calendar.d.ts.map +1 -0
  65. package/dist/calendar.js +276 -0
  66. package/dist/card.d.ts +31 -0
  67. package/dist/card.d.ts.map +1 -0
  68. package/dist/card.js +49 -0
  69. package/dist/checkbox.d.ts +46 -0
  70. package/dist/checkbox.d.ts.map +1 -0
  71. package/dist/checkbox.js +84 -0
  72. package/dist/child.d.ts +29 -0
  73. package/dist/child.d.ts.map +1 -0
  74. package/dist/child.js +27 -0
  75. package/dist/collapsible.d.ts +44 -0
  76. package/dist/collapsible.d.ts.map +1 -0
  77. package/dist/collapsible.js +83 -0
  78. package/dist/color-scheme.d.ts +44 -0
  79. package/dist/color-scheme.d.ts.map +1 -0
  80. package/dist/color-scheme.js +123 -0
  81. package/dist/combobox.d.ts +114 -0
  82. package/dist/combobox.d.ts.map +1 -0
  83. package/dist/combobox.js +293 -0
  84. package/dist/command.d.ts +92 -0
  85. package/dist/command.d.ts.map +1 -0
  86. package/dist/command.js +183 -0
  87. package/dist/context-menu.d.ts +37 -0
  88. package/dist/context-menu.d.ts.map +1 -0
  89. package/dist/context-menu.js +59 -0
  90. package/dist/date-picker.d.ts +48 -0
  91. package/dist/date-picker.d.ts.map +1 -0
  92. package/dist/date-picker.js +136 -0
  93. package/dist/dialog.d.ts +64 -0
  94. package/dist/dialog.d.ts.map +1 -0
  95. package/dist/dialog.js +142 -0
  96. package/dist/drawer.d.ts +63 -0
  97. package/dist/drawer.d.ts.map +1 -0
  98. package/dist/drawer.js +136 -0
  99. package/dist/dropdown-menu.d.ts +35 -0
  100. package/dist/dropdown-menu.d.ts.map +1 -0
  101. package/dist/dropdown-menu.js +49 -0
  102. package/dist/empty.d.ts +29 -0
  103. package/dist/empty.d.ts.map +1 -0
  104. package/dist/empty.js +47 -0
  105. package/dist/field.d.ts +86 -0
  106. package/dist/field.d.ts.map +1 -0
  107. package/dist/field.js +150 -0
  108. package/dist/file-drop.d.ts +74 -0
  109. package/dist/file-drop.d.ts.map +1 -0
  110. package/dist/file-drop.js +137 -0
  111. package/dist/focus.d.ts +54 -0
  112. package/dist/focus.d.ts.map +1 -0
  113. package/dist/focus.js +174 -0
  114. package/dist/harness.d.ts +90 -0
  115. package/dist/harness.d.ts.map +1 -0
  116. package/dist/harness.js +189 -0
  117. package/dist/heading.d.ts +16 -0
  118. package/dist/heading.d.ts.map +1 -0
  119. package/dist/heading.js +19 -0
  120. package/dist/hero.d.ts +21 -0
  121. package/dist/hero.d.ts.map +1 -0
  122. package/dist/hero.js +28 -0
  123. package/dist/hover-card.d.ts +46 -0
  124. package/dist/hover-card.d.ts.map +1 -0
  125. package/dist/hover-card.js +85 -0
  126. package/dist/icon.d.ts +10 -0
  127. package/dist/icon.d.ts.map +1 -0
  128. package/dist/icon.js +13 -0
  129. package/dist/index.d.ts +98 -0
  130. package/dist/index.d.ts.map +1 -0
  131. package/dist/index.js +99 -0
  132. package/dist/input-group.d.ts +55 -0
  133. package/dist/input-group.d.ts.map +1 -0
  134. package/dist/input-group.js +103 -0
  135. package/dist/input-otp.d.ts +103 -0
  136. package/dist/input-otp.d.ts.map +1 -0
  137. package/dist/input-otp.js +293 -0
  138. package/dist/input.d.ts +53 -0
  139. package/dist/input.d.ts.map +1 -0
  140. package/dist/input.js +90 -0
  141. package/dist/inspector.d.ts +47 -0
  142. package/dist/inspector.d.ts.map +1 -0
  143. package/dist/inspector.js +97 -0
  144. package/dist/item.d.ts +63 -0
  145. package/dist/item.d.ts.map +1 -0
  146. package/dist/item.js +104 -0
  147. package/dist/kbd.d.ts +28 -0
  148. package/dist/kbd.d.ts.map +1 -0
  149. package/dist/kbd.js +36 -0
  150. package/dist/keys.d.ts +20 -0
  151. package/dist/keys.d.ts.map +1 -0
  152. package/dist/keys.js +32 -0
  153. package/dist/label.d.ts +24 -0
  154. package/dist/label.d.ts.map +1 -0
  155. package/dist/label.js +39 -0
  156. package/dist/layers.d.ts +42 -0
  157. package/dist/layers.d.ts.map +1 -0
  158. package/dist/layers.js +70 -0
  159. package/dist/link.d.ts +44 -0
  160. package/dist/link.d.ts.map +1 -0
  161. package/dist/link.js +60 -0
  162. package/dist/marker.d.ts +42 -0
  163. package/dist/marker.d.ts.map +1 -0
  164. package/dist/marker.js +73 -0
  165. package/dist/menubar.d.ts +76 -0
  166. package/dist/menubar.d.ts.map +1 -0
  167. package/dist/menubar.js +139 -0
  168. package/dist/message-scroller.d.ts +101 -0
  169. package/dist/message-scroller.d.ts.map +1 -0
  170. package/dist/message-scroller.js +215 -0
  171. package/dist/message.d.ts +48 -0
  172. package/dist/message.d.ts.map +1 -0
  173. package/dist/message.js +72 -0
  174. package/dist/native-form.d.ts +44 -0
  175. package/dist/native-form.d.ts.map +1 -0
  176. package/dist/native-form.js +111 -0
  177. package/dist/native-select.d.ts +56 -0
  178. package/dist/native-select.d.ts.map +1 -0
  179. package/dist/native-select.js +100 -0
  180. package/dist/navigation-bar.d.ts +30 -0
  181. package/dist/navigation-bar.d.ts.map +1 -0
  182. package/dist/navigation-bar.js +52 -0
  183. package/dist/navigation-menu.d.ts +97 -0
  184. package/dist/navigation-menu.d.ts.map +1 -0
  185. package/dist/navigation-menu.js +207 -0
  186. package/dist/navigation-stack.d.ts +36 -0
  187. package/dist/navigation-stack.d.ts.map +1 -0
  188. package/dist/navigation-stack.js +67 -0
  189. package/dist/observers.d.ts +21 -0
  190. package/dist/observers.d.ts.map +1 -0
  191. package/dist/observers.js +34 -0
  192. package/dist/page.d.ts +38 -0
  193. package/dist/page.d.ts.map +1 -0
  194. package/dist/page.js +68 -0
  195. package/dist/pagination.d.ts +39 -0
  196. package/dist/pagination.d.ts.map +1 -0
  197. package/dist/pagination.js +71 -0
  198. package/dist/pointer.d.ts +38 -0
  199. package/dist/pointer.d.ts.map +1 -0
  200. package/dist/pointer.js +82 -0
  201. package/dist/popover.d.ts +50 -0
  202. package/dist/popover.d.ts.map +1 -0
  203. package/dist/popover.js +90 -0
  204. package/dist/progress.d.ts +38 -0
  205. package/dist/progress.d.ts.map +1 -0
  206. package/dist/progress.js +81 -0
  207. package/dist/pull-to-refresh.d.ts +40 -0
  208. package/dist/pull-to-refresh.d.ts.map +1 -0
  209. package/dist/pull-to-refresh.js +65 -0
  210. package/dist/questionnaire.d.ts +117 -0
  211. package/dist/questionnaire.d.ts.map +1 -0
  212. package/dist/questionnaire.js +240 -0
  213. package/dist/radio-group.d.ts +53 -0
  214. package/dist/radio-group.d.ts.map +1 -0
  215. package/dist/radio-group.js +95 -0
  216. package/dist/rating.d.ts +67 -0
  217. package/dist/rating.d.ts.map +1 -0
  218. package/dist/rating.js +160 -0
  219. package/dist/resizable.d.ts +76 -0
  220. package/dist/resizable.d.ts.map +1 -0
  221. package/dist/resizable.js +138 -0
  222. package/dist/routing.d.ts +36 -0
  223. package/dist/routing.d.ts.map +1 -0
  224. package/dist/routing.js +50 -0
  225. package/dist/roving-focus.d.ts +38 -0
  226. package/dist/roving-focus.d.ts.map +1 -0
  227. package/dist/roving-focus.js +60 -0
  228. package/dist/scroll-area.d.ts +58 -0
  229. package/dist/scroll-area.d.ts.map +1 -0
  230. package/dist/scroll-area.js +153 -0
  231. package/dist/scroller.d.ts +41 -0
  232. package/dist/scroller.d.ts.map +1 -0
  233. package/dist/scroller.js +65 -0
  234. package/dist/select.d.ts +98 -0
  235. package/dist/select.d.ts.map +1 -0
  236. package/dist/select.js +203 -0
  237. package/dist/selectors.d.ts +44 -0
  238. package/dist/selectors.d.ts.map +1 -0
  239. package/dist/selectors.js +63 -0
  240. package/dist/send-pointer.d.ts +17 -0
  241. package/dist/send-pointer.d.ts.map +1 -0
  242. package/dist/send-pointer.js +35 -0
  243. package/dist/separator.d.ts +26 -0
  244. package/dist/separator.d.ts.map +1 -0
  245. package/dist/separator.js +40 -0
  246. package/dist/shadowed.d.ts +55 -0
  247. package/dist/shadowed.d.ts.map +1 -0
  248. package/dist/shadowed.js +97 -0
  249. package/dist/sheet.d.ts +14 -0
  250. package/dist/sheet.d.ts.map +1 -0
  251. package/dist/sheet.js +15 -0
  252. package/dist/sidebar.d.ts +159 -0
  253. package/dist/sidebar.d.ts.map +1 -0
  254. package/dist/sidebar.js +299 -0
  255. package/dist/skeleton.d.ts +18 -0
  256. package/dist/skeleton.d.ts.map +1 -0
  257. package/dist/skeleton.js +25 -0
  258. package/dist/slider.d.ts +66 -0
  259. package/dist/slider.d.ts.map +1 -0
  260. package/dist/slider.js +155 -0
  261. package/dist/spinner.d.ts +10 -0
  262. package/dist/spinner.d.ts.map +1 -0
  263. package/dist/spinner.js +13 -0
  264. package/dist/split-view.d.ts +77 -0
  265. package/dist/split-view.d.ts.map +1 -0
  266. package/dist/split-view.js +145 -0
  267. package/dist/status-bar.d.ts +25 -0
  268. package/dist/status-bar.d.ts.map +1 -0
  269. package/dist/status-bar.js +42 -0
  270. package/dist/sticky-footer.d.ts +33 -0
  271. package/dist/sticky-footer.d.ts.map +1 -0
  272. package/dist/sticky-footer.js +65 -0
  273. package/dist/switch.d.ts +44 -0
  274. package/dist/switch.d.ts.map +1 -0
  275. package/dist/switch.js +77 -0
  276. package/dist/tab-bar.d.ts +38 -0
  277. package/dist/tab-bar.d.ts.map +1 -0
  278. package/dist/tab-bar.js +78 -0
  279. package/dist/table.d.ts +41 -0
  280. package/dist/table.d.ts.map +1 -0
  281. package/dist/table.js +100 -0
  282. package/dist/tabs.d.ts +66 -0
  283. package/dist/tabs.d.ts.map +1 -0
  284. package/dist/tabs.js +149 -0
  285. package/dist/test-hooks.d.ts +9 -0
  286. package/dist/test-hooks.d.ts.map +1 -0
  287. package/dist/test-hooks.js +1 -0
  288. package/dist/textarea.d.ts +47 -0
  289. package/dist/textarea.d.ts.map +1 -0
  290. package/dist/textarea.js +78 -0
  291. package/dist/title-bar.d.ts +43 -0
  292. package/dist/title-bar.d.ts.map +1 -0
  293. package/dist/title-bar.js +74 -0
  294. package/dist/toaster.d.ts +172 -0
  295. package/dist/toaster.d.ts.map +1 -0
  296. package/dist/toaster.js +307 -0
  297. package/dist/toggle-group.d.ts +51 -0
  298. package/dist/toggle-group.d.ts.map +1 -0
  299. package/dist/toggle-group.js +97 -0
  300. package/dist/toggle.d.ts +21 -0
  301. package/dist/toggle.d.ts.map +1 -0
  302. package/dist/toggle.js +26 -0
  303. package/dist/toolbar.d.ts +40 -0
  304. package/dist/toolbar.d.ts.map +1 -0
  305. package/dist/toolbar.js +67 -0
  306. package/dist/tooltip.d.ts +48 -0
  307. package/dist/tooltip.d.ts.map +1 -0
  308. package/dist/tooltip.js +91 -0
  309. package/dist/trace.d.ts +118 -0
  310. package/dist/trace.d.ts.map +1 -0
  311. package/dist/trace.js +196 -0
  312. package/dist/translator.d.ts +34 -0
  313. package/dist/translator.d.ts.map +1 -0
  314. package/dist/translator.js +75 -0
  315. package/dist/window-frame.d.ts +40 -0
  316. package/dist/window-frame.d.ts.map +1 -0
  317. package/dist/window-frame.js +66 -0
  318. package/dist/zoetrope.d.ts +51 -0
  319. package/dist/zoetrope.d.ts.map +1 -0
  320. package/dist/zoetrope.js +94 -0
  321. package/package.json +68 -3
@@ -0,0 +1,75 @@
1
+ import { isNumber } from '@sindresorhus/is';
2
+ import { getContext } from '@ember/test-helpers';
3
+ /**
4
+ * Registers `translator` as the test's `translator:main` before each test, so Joinery's
5
+ * components show their built-in strings through it. Call it after `setupRenderingTest(hooks)`
6
+ * or `setupApplicationTest(hooks)`.
7
+ *
8
+ * module('in French', function (hooks) {
9
+ * setupRenderingTest(hooks)
10
+ * setupTranslator(hooks, myTranslator)
11
+ * })
12
+ */
13
+ export function setupTranslator(hooks, translator) {
14
+ hooks.beforeEach(() => {
15
+ const context = getContext();
16
+ if (!context?.owner) {
17
+ throw new Error('Joinery: setupTranslator(hooks) found no test owner; call it after setupRenderingTest(hooks) or setupApplicationTest(hooks)');
18
+ }
19
+ context.owner.register('translator:main', translator, { instantiate: false });
20
+ });
21
+ }
22
+ const ACCENTS = {
23
+ a: 'á',
24
+ c: 'ç',
25
+ e: 'é',
26
+ i: 'í',
27
+ n: 'ñ',
28
+ o: 'ó',
29
+ s: 'ś',
30
+ u: 'ú',
31
+ y: 'ý',
32
+ z: 'ź',
33
+ A: 'Á',
34
+ C: 'Ç',
35
+ E: 'É',
36
+ I: 'Í',
37
+ N: 'Ñ',
38
+ O: 'Ó',
39
+ S: 'Ś',
40
+ U: 'Ú',
41
+ Y: 'Ý',
42
+ Z: 'Ź',
43
+ };
44
+ // The English, accented outside its `{placeholders}`, so a value passed in shows as given.
45
+ function accent(text) {
46
+ return text.replace(/\{\w+\}|[A-Za-z]/g, match => ACCENTS[match] ?? match);
47
+ }
48
+ // shortcut: a local copy of the msgid contract's English formatting, until msgid is published.
49
+ function format(message, values) {
50
+ const count = values?.['count'];
51
+ const text = message.plural !== undefined &&
52
+ isNumber(count) &&
53
+ new Intl.PluralRules('en').select(count) !== 'one'
54
+ ? message.plural
55
+ : message.message;
56
+ if (!values)
57
+ return text;
58
+ return text.replace(/\{(\w+)\}/g, (placeholder, name) => Object.hasOwn(values, name) ? String(values[name]) : placeholder);
59
+ }
60
+ /**
61
+ * A pseudo-locale (`en-XA`): every string comes out accented and wrapped, `⟦Ćĺóśé⟧`, so a test
62
+ * can tell a built-in string that went through the translator from one that skipped it. Values
63
+ * (a name, a number, a date) are interpolated as given.
64
+ *
65
+ * setupTranslator(hooks, pseudoTranslator)
66
+ */
67
+ export const pseudoTranslator = {
68
+ locale: 'en-XA',
69
+ t(message, values) {
70
+ const accented = { ...message, message: accent(message.message) };
71
+ if (message.plural !== undefined)
72
+ accented.plural = accent(message.plural);
73
+ return `⟦${format(accented, values)}⟧`;
74
+ },
75
+ };
@@ -0,0 +1,40 @@
1
+ import { Harness } from './harness.ts';
2
+ type Region = 'title-bar' | 'sidebar' | 'body' | 'status-bar';
3
+ /**
4
+ * Reads a `<WindowFrame>` from `@ember-joinery/ember`: what kind of window it is, and its
5
+ * regions.
6
+ *
7
+ * const frame = new WindowFrameHarness('mail') // <WindowFrame @name="mail">
8
+ * assert.strictEqual(frame.label, 'Mail')
9
+ * assert.strictEqual(frame.find(TitleBarHarness).title, 'Mail')
10
+ *
11
+ * The frame wraps the app, so the parts inside it still belong to the components around them;
12
+ * its own regions are found by their `data-jn-window-frame-*` attributes. A page object can
13
+ * extend this class and declare the app's components with `@child`.
14
+ */
15
+ export declare class WindowFrameHarness extends Harness {
16
+ #private;
17
+ static component: string;
18
+ /** Its accessible name: the title (`aria-labelledby`), or its `aria-label`. */
19
+ get label(): string;
20
+ /** Its `@variant`: `window`, `settings`, `panel` or `hud`. */
21
+ get variant(): string | null;
22
+ /** Whether it fills the viewport, as the root of an app. */
23
+ get isFill(): boolean;
24
+ /** Whether it has the inactive look. */
25
+ get isInactive(): boolean;
26
+ /** Whether the sidebar runs the full height, beside the title bar. */
27
+ get hasFullHeightSidebar(): boolean;
28
+ /** The title bar region. Throws when it has none. */
29
+ get titleBar(): HTMLElement;
30
+ /** The sidebar region. Throws when it has none. */
31
+ get sidebar(): HTMLElement;
32
+ /** The body. Throws when it has none. */
33
+ get body(): HTMLElement;
34
+ /** The status bar region. Throws when it has none. */
35
+ get statusBar(): HTMLElement;
36
+ /** Whether it has the region: `title-bar`, `sidebar`, `body` or `status-bar`. */
37
+ has(region: Region): boolean;
38
+ }
39
+ export {};
40
+ //# sourceMappingURL=window-frame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"window-frame.d.ts","sourceRoot":"","sources":["../src/window-frame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC,KAAK,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,YAAY,CAAA;AAE7D;;;;;;;;;;;GAWG;AACH,qBAAa,kBAAmB,SAAQ,OAAO;;IAC7C,OAAgB,SAAS,SAAiB;IAY1C,+EAA+E;IAC/E,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,8DAA8D;IAC9D,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAED,4DAA4D;IAC5D,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,wCAAwC;IACxC,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,sEAAsE;IACtE,IAAI,oBAAoB,IAAI,OAAO,CAElC;IAED,qDAAqD;IACrD,IAAI,QAAQ,IAAI,WAAW,CAE1B;IAED,mDAAmD;IACnD,IAAI,OAAO,IAAI,WAAW,CAEzB;IAED,yCAAyC;IACzC,IAAI,IAAI,IAAI,WAAW,CAEtB;IAED,sDAAsD;IACtD,IAAI,SAAS,IAAI,WAAW,CAE3B;IAED,iFAAiF;IACjF,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;CAG7B"}
@@ -0,0 +1,66 @@
1
+ import { Harness } from "./harness.js";
2
+ import { accessibleName } from "./-private/checkable.js";
3
+ /**
4
+ * Reads a `<WindowFrame>` from `@ember-joinery/ember`: what kind of window it is, and its
5
+ * regions.
6
+ *
7
+ * const frame = new WindowFrameHarness('mail') // <WindowFrame @name="mail">
8
+ * assert.strictEqual(frame.label, 'Mail')
9
+ * assert.strictEqual(frame.find(TitleBarHarness).title, 'Mail')
10
+ *
11
+ * The frame wraps the app, so the parts inside it still belong to the components around them;
12
+ * its own regions are found by their `data-jn-window-frame-*` attributes. A page object can
13
+ * extend this class and declare the app's components with `@child`.
14
+ */
15
+ export class WindowFrameHarness extends Harness {
16
+ static component = 'window-frame';
17
+ #query(region) {
18
+ return this.element.querySelector(`:scope > [data-jn-window-frame-${region}]`);
19
+ }
20
+ #region(region) {
21
+ const element = this.#query(region);
22
+ if (!element)
23
+ throw new Error(`Joinery harness: no ${region} in ${this}`);
24
+ return element;
25
+ }
26
+ /** Its accessible name: the title (`aria-labelledby`), or its `aria-label`. */
27
+ get label() {
28
+ return accessibleName(this.element);
29
+ }
30
+ /** Its `@variant`: `window`, `settings`, `panel` or `hud`. */
31
+ get variant() {
32
+ return this.element.getAttribute('data-variant');
33
+ }
34
+ /** Whether it fills the viewport, as the root of an app. */
35
+ get isFill() {
36
+ return this.element.hasAttribute('data-fill');
37
+ }
38
+ /** Whether it has the inactive look. */
39
+ get isInactive() {
40
+ return this.element.hasAttribute('data-inactive');
41
+ }
42
+ /** Whether the sidebar runs the full height, beside the title bar. */
43
+ get hasFullHeightSidebar() {
44
+ return this.element.hasAttribute('data-full-height-sidebar');
45
+ }
46
+ /** The title bar region. Throws when it has none. */
47
+ get titleBar() {
48
+ return this.#region('title-bar');
49
+ }
50
+ /** The sidebar region. Throws when it has none. */
51
+ get sidebar() {
52
+ return this.#region('sidebar');
53
+ }
54
+ /** The body. Throws when it has none. */
55
+ get body() {
56
+ return this.#region('body');
57
+ }
58
+ /** The status bar region. Throws when it has none. */
59
+ get statusBar() {
60
+ return this.#region('status-bar');
61
+ }
62
+ /** Whether it has the region: `title-bar`, `sidebar`, `body` or `status-bar`. */
63
+ has(region) {
64
+ return this.#query(region) !== null;
65
+ }
66
+ }
@@ -0,0 +1,51 @@
1
+ import { Harness } from './harness.ts';
2
+ /**
3
+ * Drives a `<Zoetrope>` from `@ember-joinery/primitives/zoetrope`: its items, which of them are
4
+ * in view, and the buttons that scroll it. It is ember-primitives' `ZoetropeHelper`, as a
5
+ * harness.
6
+ *
7
+ * const releases = new ZoetropeHarness('releases') // <Zoetrope @name="releases">
8
+ * assert.strictEqual(releases.visibleItemCount, 2)
9
+ * await releases.scrollRight()
10
+ * assert.false(releases.canScrollRight)
11
+ *
12
+ * `scrollLeft()` and `scrollRight()` click the `scroll-left` and `scroll-right` parts: the
13
+ * default buttons, or yours in `<:controls>` when they carry `data-test-jn-part="scroll-left"`
14
+ * and `"scroll-right"`.
15
+ */
16
+ export declare class ZoetropeHarness extends Harness {
17
+ static component: string;
18
+ /** The header block's element, or `null` without one. */
19
+ get header(): HTMLElement | null;
20
+ /** The default buttons' element, or `null` when they aren't shown. */
21
+ get controls(): HTMLElement | null;
22
+ /** The track the items are in, which scrolls. */
23
+ get scroller(): HTMLElement;
24
+ /** The button that scrolls left, or `null` when there is none (nothing to scroll). */
25
+ get leftButton(): HTMLButtonElement | null;
26
+ /** The button that scrolls right, or `null` when there is none. */
27
+ get rightButton(): HTMLButtonElement | null;
28
+ /** Every item, in order. */
29
+ get items(): HTMLElement[];
30
+ /**
31
+ * The items at least partly inside the track's box, in order: what a user sees of the row.
32
+ */
33
+ get visibleItems(): HTMLElement[];
34
+ /** How many items are at least partly in view. */
35
+ get visibleItemCount(): number;
36
+ /** How far the track is scrolled from where its items start, in pixels, in either direction. */
37
+ get scrolled(): number;
38
+ /** Whether there is a left button and it can be used. */
39
+ get canScrollLeft(): boolean;
40
+ /** Whether there is a right button and it can be used. */
41
+ get canScrollRight(): boolean;
42
+ /** Clicks the left button, and waits for the scroll to end. */
43
+ scrollLeft(): Promise<void>;
44
+ /** Clicks the right button, and waits for the scroll to end. */
45
+ scrollRight(): Promise<void>;
46
+ /** Moves focus to an item, by its index, as a click or a script would. */
47
+ focusItem(index: number): Promise<void>;
48
+ /** The index of the item that has focus, or `-1`. */
49
+ get focusedIndex(): number;
50
+ }
51
+ //# sourceMappingURL=zoetrope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zoetrope.d.ts","sourceRoot":"","sources":["../src/zoetrope.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC;;;;;;;;;;;;;GAaG;AACH,qBAAa,eAAgB,SAAQ,OAAO;IAC1C,OAAgB,SAAS,SAAa;IAEtC,yDAAyD;IACzD,IAAI,MAAM,IAAI,WAAW,GAAG,IAAI,CAE/B;IAED,sEAAsE;IACtE,IAAI,QAAQ,IAAI,WAAW,GAAG,IAAI,CAEjC;IAED,iDAAiD;IACjD,IAAI,QAAQ,IAAI,WAAW,CAE1B;IAED,sFAAsF;IACtF,IAAI,UAAU,IAAI,iBAAiB,GAAG,IAAI,CAEzC;IAED,mEAAmE;IACnE,IAAI,WAAW,IAAI,iBAAiB,GAAG,IAAI,CAE1C;IAED,4BAA4B;IAC5B,IAAI,KAAK,IAAI,WAAW,EAAE,CAEzB;IAED;;OAEG;IACH,IAAI,YAAY,IAAI,WAAW,EAAE,CAMhC;IAED,kDAAkD;IAClD,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAED,gGAAgG;IAChG,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,yDAAyD;IACzD,IAAI,aAAa,IAAI,OAAO,CAG3B;IAED,0DAA0D;IAC1D,IAAI,cAAc,IAAI,OAAO,CAG5B;IAED,+DAA+D;IACzD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC,gEAAgE;IAC1D,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAKlC,0EAA0E;IACpE,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM7C,qDAAqD;IACrD,IAAI,YAAY,IAAI,MAAM,CAGzB;CACF"}
@@ -0,0 +1,94 @@
1
+ import { click, focus } from '@ember/test-helpers';
2
+ import { Harness } from "./harness.js";
3
+ import { waitForObservers } from "./observers.js";
4
+ /**
5
+ * Drives a `<Zoetrope>` from `@ember-joinery/primitives/zoetrope`: its items, which of them are
6
+ * in view, and the buttons that scroll it. It is ember-primitives' `ZoetropeHelper`, as a
7
+ * harness.
8
+ *
9
+ * const releases = new ZoetropeHarness('releases') // <Zoetrope @name="releases">
10
+ * assert.strictEqual(releases.visibleItemCount, 2)
11
+ * await releases.scrollRight()
12
+ * assert.false(releases.canScrollRight)
13
+ *
14
+ * `scrollLeft()` and `scrollRight()` click the `scroll-left` and `scroll-right` parts: the
15
+ * default buttons, or yours in `<:controls>` when they carry `data-test-jn-part="scroll-left"`
16
+ * and `"scroll-right"`.
17
+ */
18
+ export class ZoetropeHarness extends Harness {
19
+ static component = 'zoetrope';
20
+ /** The header block's element, or `null` without one. */
21
+ get header() {
22
+ return this.queryPart('header');
23
+ }
24
+ /** The default buttons' element, or `null` when they aren't shown. */
25
+ get controls() {
26
+ return this.queryPart('controls');
27
+ }
28
+ /** The track the items are in, which scrolls. */
29
+ get scroller() {
30
+ return this.part('scroller');
31
+ }
32
+ /** The button that scrolls left, or `null` when there is none (nothing to scroll). */
33
+ get leftButton() {
34
+ return this.queryPart('scroll-left');
35
+ }
36
+ /** The button that scrolls right, or `null` when there is none. */
37
+ get rightButton() {
38
+ return this.queryPart('scroll-right');
39
+ }
40
+ /** Every item, in order. */
41
+ get items() {
42
+ return [...this.scroller.children];
43
+ }
44
+ /**
45
+ * The items at least partly inside the track's box, in order: what a user sees of the row.
46
+ */
47
+ get visibleItems() {
48
+ const track = this.scroller.getBoundingClientRect();
49
+ return this.items.filter(item => {
50
+ const box = item.getBoundingClientRect();
51
+ return box.right > track.left && box.left < track.right;
52
+ });
53
+ }
54
+ /** How many items are at least partly in view. */
55
+ get visibleItemCount() {
56
+ return this.visibleItems.length;
57
+ }
58
+ /** How far the track is scrolled from where its items start, in pixels, in either direction. */
59
+ get scrolled() {
60
+ return Math.abs(this.scroller.scrollLeft);
61
+ }
62
+ /** Whether there is a left button and it can be used. */
63
+ get canScrollLeft() {
64
+ const button = this.leftButton;
65
+ return Boolean(button && !button.disabled);
66
+ }
67
+ /** Whether there is a right button and it can be used. */
68
+ get canScrollRight() {
69
+ const button = this.rightButton;
70
+ return Boolean(button && !button.disabled);
71
+ }
72
+ /** Clicks the left button, and waits for the scroll to end. */
73
+ async scrollLeft() {
74
+ await click(this.part('scroll-left'));
75
+ await waitForObservers();
76
+ }
77
+ /** Clicks the right button, and waits for the scroll to end. */
78
+ async scrollRight() {
79
+ await click(this.part('scroll-right'));
80
+ await waitForObservers();
81
+ }
82
+ /** Moves focus to an item, by its index, as a click or a script would. */
83
+ async focusItem(index) {
84
+ const item = this.items[index];
85
+ if (!item)
86
+ throw new Error(`Joinery harness: ${this} has no item ${index}`);
87
+ await focus(item);
88
+ }
89
+ /** The index of the item that has focus, or `-1`. */
90
+ get focusedIndex() {
91
+ const active = this.element.ownerDocument.activeElement;
92
+ return this.items.findIndex(item => item === active);
93
+ }
94
+ }
package/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
2
  "name": "@ember-joinery/test-support",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.1.0",
4
+ "description": "A test harness for every Joinery primitive and component, driven through data-test-jn selectors and ARIA.",
5
+ "keywords": [
6
+ "ember-addon",
7
+ "ember",
8
+ "testing",
9
+ "harness",
10
+ "joinery"
11
+ ],
12
+ "license": "MIT",
13
+ "author": "Joe Gaudet <joe@joegaudet.com>",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/joegaudet/ember-joinery.git",
17
+ "directory": "packages/test-support"
18
+ },
19
+ "homepage": "https://joegaudet.com/ember-joinery/",
20
+ "bugs": "https://github.com/joegaudet/ember-joinery/issues",
21
+ "type": "module",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.js"
26
+ },
27
+ "./addon-main.js": "./addon-main.cjs"
28
+ },
29
+ "files": [
30
+ "addon-main.cjs",
31
+ "dist",
32
+ "README.md",
33
+ "CHANGELOG.md",
34
+ "LICENSE.md",
35
+ "NOTICE"
36
+ ],
37
+ "sideEffects": false,
38
+ "dependencies": {
39
+ "@embroider/addon-shim": "^1.10.3",
40
+ "@sindresorhus/is": "^8.1.0"
41
+ },
42
+ "peerDependencies": {
43
+ "@ember/test-helpers": ">= 5.0.0"
44
+ },
45
+ "devDependencies": {
46
+ "@ember/library-tsconfig": "^3.0.0",
47
+ "@ember/test-helpers": "^5.7.0",
48
+ "ember-source": "~7.3.0",
49
+ "typescript": "~6.0.3"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "engines": {
55
+ "node": ">=22.12.0"
56
+ },
57
+ "ember-addon": {
58
+ "version": 2,
59
+ "type": "addon",
60
+ "main": "addon-main.cjs"
61
+ },
62
+ "joinery": {
63
+ "barrels": [
64
+ "src"
65
+ ]
66
+ },
67
+ "scripts": {
68
+ "build": "node ../../scripts/gen-barrels.mjs . && rm -rf dist && tsc -p tsconfig.json",
69
+ "typecheck": "node ../../scripts/gen-barrels.mjs . && tsc -p tsconfig.json --noEmit && tsc -p type-tests/tsconfig.json"
70
+ }
6
71
  }