ngwr 11.1.0 → 11.2.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 (205) hide show
  1. package/circular-text/styles/_index.scss +11 -0
  2. package/command-palette/styles/_index.scss +12 -0
  3. package/fesm2022/ngwr-action-sheet-testing.mjs +313 -0
  4. package/fesm2022/ngwr-action-sheet-testing.mjs.map +1 -0
  5. package/fesm2022/ngwr-bar-chart-testing.mjs +89 -0
  6. package/fesm2022/ngwr-bar-chart-testing.mjs.map +1 -0
  7. package/fesm2022/ngwr-blur-text-testing.mjs +203 -0
  8. package/fesm2022/ngwr-blur-text-testing.mjs.map +1 -0
  9. package/fesm2022/ngwr-blur-text.mjs +15 -1
  10. package/fesm2022/ngwr-blur-text.mjs.map +1 -1
  11. package/fesm2022/ngwr-border-glow-testing.mjs +325 -0
  12. package/fesm2022/ngwr-border-glow-testing.mjs.map +1 -0
  13. package/fesm2022/ngwr-calendar-heatmap-testing.mjs +95 -0
  14. package/fesm2022/ngwr-calendar-heatmap-testing.mjs.map +1 -0
  15. package/fesm2022/ngwr-calendar-testing.mjs +368 -0
  16. package/fesm2022/ngwr-calendar-testing.mjs.map +1 -0
  17. package/fesm2022/ngwr-calendar.mjs +43 -3
  18. package/fesm2022/ngwr-calendar.mjs.map +1 -1
  19. package/fesm2022/ngwr-cascader.mjs +12 -0
  20. package/fesm2022/ngwr-cascader.mjs.map +1 -1
  21. package/fesm2022/ngwr-checkbox.mjs +8 -0
  22. package/fesm2022/ngwr-checkbox.mjs.map +1 -1
  23. package/fesm2022/ngwr-circular-text-testing.mjs +230 -0
  24. package/fesm2022/ngwr-circular-text-testing.mjs.map +1 -0
  25. package/fesm2022/ngwr-circular-text.mjs +2 -2
  26. package/fesm2022/ngwr-circular-text.mjs.map +1 -1
  27. package/fesm2022/ngwr-color-picker-testing.mjs +432 -0
  28. package/fesm2022/ngwr-color-picker-testing.mjs.map +1 -0
  29. package/fesm2022/ngwr-color-picker.mjs +29 -3
  30. package/fesm2022/ngwr-color-picker.mjs.map +1 -1
  31. package/fesm2022/ngwr-context-menu.mjs +25 -5
  32. package/fesm2022/ngwr-context-menu.mjs.map +1 -1
  33. package/fesm2022/ngwr-date-picker-testing.mjs +10 -79
  34. package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -1
  35. package/fesm2022/ngwr-decrypt-text-testing.mjs +261 -0
  36. package/fesm2022/ngwr-decrypt-text-testing.mjs.map +1 -0
  37. package/fesm2022/ngwr-decrypt-text.mjs +6 -1
  38. package/fesm2022/ngwr-decrypt-text.mjs.map +1 -1
  39. package/fesm2022/ngwr-donut-chart-testing.mjs +93 -0
  40. package/fesm2022/ngwr-donut-chart-testing.mjs.map +1 -0
  41. package/fesm2022/ngwr-drawer.mjs +36 -7
  42. package/fesm2022/ngwr-drawer.mjs.map +1 -1
  43. package/fesm2022/ngwr-dropdown.mjs +32 -2
  44. package/fesm2022/ngwr-dropdown.mjs.map +1 -1
  45. package/fesm2022/ngwr-event-calendar-testing.mjs +446 -0
  46. package/fesm2022/ngwr-event-calendar-testing.mjs.map +1 -0
  47. package/fesm2022/ngwr-event-calendar.mjs +43 -18
  48. package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
  49. package/fesm2022/ngwr-falling-text-testing.mjs +218 -0
  50. package/fesm2022/ngwr-falling-text-testing.mjs.map +1 -0
  51. package/fesm2022/ngwr-fuzzy-text-testing.mjs +134 -0
  52. package/fesm2022/ngwr-fuzzy-text-testing.mjs.map +1 -0
  53. package/fesm2022/ngwr-gauge-testing.mjs +86 -0
  54. package/fesm2022/ngwr-gauge-testing.mjs.map +1 -0
  55. package/fesm2022/ngwr-glitch-text-testing.mjs +181 -0
  56. package/fesm2022/ngwr-glitch-text-testing.mjs.map +1 -0
  57. package/fesm2022/ngwr-gradient-text-testing.mjs +223 -0
  58. package/fesm2022/ngwr-gradient-text-testing.mjs.map +1 -0
  59. package/fesm2022/ngwr-i18n-en.mjs +14 -0
  60. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  61. package/fesm2022/ngwr-i18n-ru.mjs +14 -0
  62. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  63. package/fesm2022/ngwr-image-cropper-testing.mjs +156 -0
  64. package/fesm2022/ngwr-image-cropper-testing.mjs.map +1 -0
  65. package/fesm2022/ngwr-image-cropper.mjs +10 -3
  66. package/fesm2022/ngwr-image-cropper.mjs.map +1 -1
  67. package/fesm2022/ngwr-input-number.mjs +73 -6
  68. package/fesm2022/ngwr-input-number.mjs.map +1 -1
  69. package/fesm2022/ngwr-knob-testing.mjs +220 -0
  70. package/fesm2022/ngwr-knob-testing.mjs.map +1 -0
  71. package/fesm2022/ngwr-lightbox-testing.mjs +223 -0
  72. package/fesm2022/ngwr-lightbox-testing.mjs.map +1 -0
  73. package/fesm2022/ngwr-lightbox.mjs +9 -2
  74. package/fesm2022/ngwr-lightbox.mjs.map +1 -1
  75. package/fesm2022/ngwr-line-chart-testing.mjs +119 -0
  76. package/fesm2022/ngwr-line-chart-testing.mjs.map +1 -0
  77. package/fesm2022/ngwr-marquee-testing.mjs +336 -0
  78. package/fesm2022/ngwr-marquee-testing.mjs.map +1 -0
  79. package/fesm2022/ngwr-meter-group-testing.mjs +80 -0
  80. package/fesm2022/ngwr-meter-group-testing.mjs.map +1 -0
  81. package/fesm2022/ngwr-overlay.mjs +28 -1
  82. package/fesm2022/ngwr-overlay.mjs.map +1 -1
  83. package/fesm2022/ngwr-popover.mjs +14 -0
  84. package/fesm2022/ngwr-popover.mjs.map +1 -1
  85. package/fesm2022/ngwr-rotating-text-testing.mjs +220 -0
  86. package/fesm2022/ngwr-rotating-text-testing.mjs.map +1 -0
  87. package/fesm2022/ngwr-rotating-text.mjs +2 -2
  88. package/fesm2022/ngwr-rotating-text.mjs.map +1 -1
  89. package/fesm2022/ngwr-select.mjs +70 -11
  90. package/fesm2022/ngwr-select.mjs.map +1 -1
  91. package/fesm2022/ngwr-shiny-text-testing.mjs +237 -0
  92. package/fesm2022/ngwr-shiny-text-testing.mjs.map +1 -0
  93. package/fesm2022/ngwr-slider.mjs +44 -6
  94. package/fesm2022/ngwr-slider.mjs.map +1 -1
  95. package/fesm2022/ngwr-sparkline-testing.mjs +76 -0
  96. package/fesm2022/ngwr-sparkline-testing.mjs.map +1 -0
  97. package/fesm2022/ngwr-speed-dial-testing.mjs +279 -0
  98. package/fesm2022/ngwr-speed-dial-testing.mjs.map +1 -0
  99. package/fesm2022/ngwr-splash-cursor-testing.mjs +89 -0
  100. package/fesm2022/ngwr-splash-cursor-testing.mjs.map +1 -0
  101. package/fesm2022/ngwr-split-text-testing.mjs +224 -0
  102. package/fesm2022/ngwr-split-text-testing.mjs.map +1 -0
  103. package/fesm2022/ngwr-split-text.mjs +15 -1
  104. package/fesm2022/ngwr-split-text.mjs.map +1 -1
  105. package/fesm2022/ngwr-splitter-testing.mjs +245 -0
  106. package/fesm2022/ngwr-splitter-testing.mjs.map +1 -0
  107. package/fesm2022/ngwr-spotlight-card-testing.mjs +368 -0
  108. package/fesm2022/ngwr-spotlight-card-testing.mjs.map +1 -0
  109. package/fesm2022/ngwr-star-border-testing.mjs +172 -0
  110. package/fesm2022/ngwr-star-border-testing.mjs.map +1 -0
  111. package/fesm2022/ngwr-table.mjs +13 -3
  112. package/fesm2022/ngwr-table.mjs.map +1 -1
  113. package/fesm2022/ngwr-tabs.mjs +15 -1
  114. package/fesm2022/ngwr-tabs.mjs.map +1 -1
  115. package/fesm2022/ngwr-tilt-card-testing.mjs +190 -0
  116. package/fesm2022/ngwr-tilt-card-testing.mjs.map +1 -0
  117. package/fesm2022/ngwr-tilt-card.mjs +19 -1
  118. package/fesm2022/ngwr-tilt-card.mjs.map +1 -1
  119. package/fesm2022/ngwr-toast.mjs +36 -7
  120. package/fesm2022/ngwr-toast.mjs.map +1 -1
  121. package/fesm2022/ngwr-tour-testing.mjs +173 -0
  122. package/fesm2022/ngwr-tour-testing.mjs.map +1 -0
  123. package/fesm2022/ngwr-tour.mjs +2 -2
  124. package/fesm2022/ngwr-tour.mjs.map +1 -1
  125. package/fesm2022/ngwr-tree.mjs +10 -3
  126. package/fesm2022/ngwr-tree.mjs.map +1 -1
  127. package/fesm2022/ngwr-typewriter-testing.mjs +228 -0
  128. package/fesm2022/ngwr-typewriter-testing.mjs.map +1 -0
  129. package/fesm2022/ngwr-version.mjs +1 -1
  130. package/fesm2022/ngwr-version.mjs.map +1 -1
  131. package/fesm2022/ngwr-waves-testing.mjs +128 -0
  132. package/fesm2022/ngwr-waves-testing.mjs.map +1 -0
  133. package/fesm2022/ngwr-window-testing.mjs +361 -0
  134. package/fesm2022/ngwr-window-testing.mjs.map +1 -0
  135. package/fesm2022/ngwr-window.mjs +84 -10
  136. package/fesm2022/ngwr-window.mjs.map +1 -1
  137. package/i18n/en.json +16 -2
  138. package/i18n/ru.json +16 -2
  139. package/llms-full.txt +147 -0
  140. package/llms.txt +27 -8
  141. package/mcp/providers.js +29 -0
  142. package/mcp/tools.js +1 -29
  143. package/package.json +145 -1
  144. package/skills/ngwr/SKILL.md +115 -0
  145. package/skills/ngwr/references/catalog.md +212 -0
  146. package/skills/ngwr/references/setup.md +73 -0
  147. package/types/ngwr-action-sheet-testing.d.ts +260 -0
  148. package/types/ngwr-bar-chart-testing.d.ts +77 -0
  149. package/types/ngwr-blur-text-testing.d.ts +180 -0
  150. package/types/ngwr-blur-text.d.ts +12 -0
  151. package/types/ngwr-border-glow-testing.d.ts +219 -0
  152. package/types/ngwr-calendar-heatmap-testing.d.ts +79 -0
  153. package/types/ngwr-calendar-testing.d.ts +277 -0
  154. package/types/ngwr-calendar.d.ts +10 -0
  155. package/types/ngwr-checkbox.d.ts +13 -0
  156. package/types/ngwr-circular-text-testing.d.ts +196 -0
  157. package/types/ngwr-color-picker-testing.d.ts +291 -0
  158. package/types/ngwr-color-picker.d.ts +13 -1
  159. package/types/ngwr-context-menu.d.ts +15 -1
  160. package/types/ngwr-date-picker-testing.d.ts +6 -66
  161. package/types/ngwr-decrypt-text-testing.d.ts +222 -0
  162. package/types/ngwr-donut-chart-testing.d.ts +79 -0
  163. package/types/ngwr-drawer.d.ts +12 -0
  164. package/types/ngwr-dropdown.d.ts +9 -0
  165. package/types/ngwr-event-calendar-testing.d.ts +301 -0
  166. package/types/ngwr-event-calendar.d.ts +9 -6
  167. package/types/ngwr-falling-text-testing.d.ts +186 -0
  168. package/types/ngwr-fuzzy-text-testing.d.ts +130 -0
  169. package/types/ngwr-gauge-testing.d.ts +71 -0
  170. package/types/ngwr-glitch-text-testing.d.ts +172 -0
  171. package/types/ngwr-gradient-text-testing.d.ts +173 -0
  172. package/types/ngwr-image-cropper-testing.d.ts +134 -0
  173. package/types/ngwr-image-cropper.d.ts +1 -0
  174. package/types/ngwr-input-number.d.ts +33 -1
  175. package/types/ngwr-knob-testing.d.ts +150 -0
  176. package/types/ngwr-lightbox-testing.d.ts +154 -0
  177. package/types/ngwr-lightbox.d.ts +6 -0
  178. package/types/ngwr-line-chart-testing.d.ts +93 -0
  179. package/types/ngwr-marquee-testing.d.ts +280 -0
  180. package/types/ngwr-meter-group-testing.d.ts +67 -0
  181. package/types/ngwr-overlay.d.ts +19 -1
  182. package/types/ngwr-rotating-text-testing.d.ts +191 -0
  183. package/types/ngwr-select.d.ts +32 -0
  184. package/types/ngwr-shiny-text-testing.d.ts +165 -0
  185. package/types/ngwr-slider.d.ts +15 -0
  186. package/types/ngwr-sparkline-testing.d.ts +69 -0
  187. package/types/ngwr-speed-dial-testing.d.ts +195 -0
  188. package/types/ngwr-splash-cursor-testing.d.ts +95 -0
  189. package/types/ngwr-split-text-testing.d.ts +209 -0
  190. package/types/ngwr-split-text.d.ts +12 -0
  191. package/types/ngwr-splitter-testing.d.ts +174 -0
  192. package/types/ngwr-spotlight-card-testing.d.ts +303 -0
  193. package/types/ngwr-star-border-testing.d.ts +135 -0
  194. package/types/ngwr-table.d.ts +10 -1
  195. package/types/ngwr-tilt-card-testing.d.ts +158 -0
  196. package/types/ngwr-tilt-card.d.ts +2 -0
  197. package/types/ngwr-toast.d.ts +14 -5
  198. package/types/ngwr-tour-testing.d.ts +143 -0
  199. package/types/ngwr-tree.d.ts +7 -0
  200. package/types/ngwr-typewriter-testing.d.ts +201 -0
  201. package/types/ngwr-version.d.ts +1 -1
  202. package/types/ngwr-waves-testing.d.ts +121 -0
  203. package/types/ngwr-window-testing.d.ts +263 -0
  204. package/types/ngwr-window.d.ts +27 -10
  205. package/window/styles/_index.scss +44 -16
@@ -24,6 +24,17 @@
24
24
  user-select: none;
25
25
  transition: transform 0.6s var(--wr-ease-spring);
26
26
 
27
+ // The accessible copy of the string — the ring itself is `aria-hidden`.
28
+ &__sr-only {
29
+ position: absolute;
30
+ width: 1px;
31
+ height: 1px;
32
+ overflow: hidden;
33
+ clip: rect(0 0 0 0);
34
+ clip-path: inset(50%);
35
+ white-space: nowrap;
36
+ }
37
+
27
38
  &__spin {
28
39
  position: absolute;
29
40
  inset: 0;
@@ -127,6 +127,18 @@
127
127
  color: var(--wr-color-primary);
128
128
  }
129
129
 
130
+ // The keycap is the one thing on the active row that does NOT want the tint under
131
+ // it. `--wr-color-hover` is translucent, so on a plain row it composites to a light
132
+ // grey and the muted label reads at 4.63:1 — but over `--wr-color-primary-soft` it
133
+ // composites to #dce4f1, where the same label measures 4.17:1 and fails AA. Neither
134
+ // shipped gate can see it: the palette has to be OPEN with a row active, which is a
135
+ // state that walks past prerendered HTML and a page at rest alike. Putting the chip
136
+ // back on the surface restores the pairing the muted role is calibrated for, and
137
+ // keeps the chip reading as a keycap rather than as part of the highlight.
138
+ &__option--active &__option-shortcut {
139
+ background: var(--wr-color-surface);
140
+ }
141
+
130
142
  &__option-body {
131
143
  flex: 1 1 auto;
132
144
  min-width: 0;
@@ -0,0 +1,313 @@
1
+ import { ComponentHarness, HarnessPredicate, TestKey } from '@angular/cdk/testing';
2
+
3
+ /**
4
+ * @license
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
8
+ */
9
+ /**
10
+ * Test harness for one row inside a {@link WrActionSheetHarness}.
11
+ *
12
+ * A row is a real `<button>`, not an ARIA-decorated div, so `disabled` is the
13
+ * property rather than an attribute and the CDK refuses to click it — which is the
14
+ * behaviour a spec wants asserted, since the component ALSO checks `disabled`
15
+ * inside its own handler. Either guard alone would keep a disabled row inert; both
16
+ * being there means removing one is invisible until the other is removed too, and
17
+ * {@link click} is where that shows up.
18
+ *
19
+ * **Clicking a row closes the sheet.** The component emits `action` and clears
20
+ * `open` in the same call, so a harness held across a {@link click} is pointed at a
21
+ * detached element the moment it returns — read what you need first, and get a
22
+ * fresh harness afterwards if the sheet was reopened.
23
+ *
24
+ * @see https://ngwr.dev/guides/testing
25
+ */
26
+ class WrActionSheetActionHarness extends ComponentHarness {
27
+ /** The class every row carries, cancel rows included. */
28
+ static hostSelector = '.wr-action-sheet__action';
29
+ /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */
30
+ static with(options = {}) {
31
+ return new HarnessPredicate(WrActionSheetActionHarness, options)
32
+ .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label))
33
+ .addOption('role', options.role, async (harness, role) => (await harness.getRole()) === role)
34
+ .addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled);
35
+ }
36
+ /**
37
+ * The row's label, trimmed.
38
+ *
39
+ * Read from `.wr-action-sheet__label` rather than from the button, so a leading
40
+ * icon can never join it. The icon contributes no text today — it is an `<svg>` —
41
+ * but an icon set that ships a `<title>` for its own accessibility would, and the
42
+ * label element is the thing that actually holds the string.
43
+ */
44
+ async getLabel() {
45
+ return (await this.locatorFor('.wr-action-sheet__label')()).text();
46
+ }
47
+ /**
48
+ * The row's visual role, as the component painted it.
49
+ *
50
+ * `default` is returned for a row the caller left unroled, which is what the
51
+ * component does with the value: only `destructive` and `cancel` change anything,
52
+ * and everything else falls through to the plain row. The two modifiers are
53
+ * mutually exclusive by construction — `cancel` rows are filtered into their own
54
+ * group before the destructive class is ever considered — so reading them in
55
+ * either order gives the same answer.
56
+ */
57
+ async getRole() {
58
+ const host = await this.host();
59
+ if (await host.hasClass('wr-action-sheet__action--cancel'))
60
+ return 'cancel';
61
+ if (await host.hasClass('wr-action-sheet__action--destructive'))
62
+ return 'destructive';
63
+ return 'default';
64
+ }
65
+ /**
66
+ * Whether the row refuses interaction, from the button's own `disabled` property
67
+ * — the thing the CDK consults before dispatching a click, and the DOM before
68
+ * delivering one.
69
+ *
70
+ * There is no `aria-disabled` to fall back to here, and none is wanted: the row is
71
+ * a native button, where the property already carries the state to assistive tech.
72
+ */
73
+ async isDisabled() {
74
+ return (await this.host()).getProperty('disabled');
75
+ }
76
+ /** Whether the row draws a leading icon. */
77
+ async hasIcon() {
78
+ return (await this.locatorForOptional('.wr-action-sheet__icon')()) !== null;
79
+ }
80
+ /**
81
+ * The icon's registered name, or `null` on a row without one.
82
+ *
83
+ * From `wr-icon`'s reflected `data-icon`, which is the only place the name reaches
84
+ * the DOM — the rendered `<svg>` carries no trace of which entry of the set it
85
+ * came from.
86
+ */
87
+ async getIconName() {
88
+ const icon = await this.locatorForOptional('.wr-action-sheet__icon')();
89
+ return icon ? icon.getAttribute('data-icon') : null;
90
+ }
91
+ /**
92
+ * Pick this row — emitting `action` and closing the sheet.
93
+ *
94
+ * Throws on a disabled row instead of quietly doing nothing. The click would not
95
+ * land anyway (the DOM swallows it), so the alternative is a spec that reads as
96
+ * "picked the row" and asserts a sheet that never moved.
97
+ */
98
+ async click() {
99
+ if (await this.isDisabled()) {
100
+ throw new Error(`WrActionSheetActionHarness.click(): "${await this.getLabel()}" is disabled. The DOM swallows a click ` +
101
+ 'on a disabled button and the component checks `disabled` again before emitting, so nothing would ' +
102
+ 'happen — assert isDisabled() instead.');
103
+ }
104
+ await (await this.host()).click();
105
+ }
106
+ /** Move keyboard focus to the row. */
107
+ async focus() {
108
+ return (await this.host()).focus();
109
+ }
110
+ /** Whether the row currently holds focus. */
111
+ async isFocused() {
112
+ return (await this.host()).isFocused();
113
+ }
114
+ }
115
+
116
+ /**
117
+ * @license
118
+ *
119
+ * Use of this source code is governed by an MIT-style license that can be
120
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
121
+ */
122
+ /**
123
+ * One `.wr-action-sheet__group` — internal, and the only way to read the rows of ONE
124
+ * group: a `TestElement` cannot be queried into, so scoping to a child element means
125
+ * a harness anchored on it.
126
+ */
127
+ class GroupHarness extends ComponentHarness {
128
+ static hostSelector = '.wr-action-sheet__group';
129
+ async getLabels() {
130
+ const labels = await this.locatorForAll('.wr-action-sheet__label')();
131
+ return Promise.all(labels.map(label => label.text()));
132
+ }
133
+ }
134
+ /**
135
+ * Test harness for an open `<wr-action-sheet>` — the iOS-style bottom sheet of
136
+ * choices.
137
+ *
138
+ * The sheet renders through `<wr-drawer>`, so its rows are in the NGWR overlay
139
+ * container rather than in the fixture: load this from
140
+ * `TestbedHarnessEnvironment.documentRootLoader()`. A fixture-scoped loader finds
141
+ * nothing at all — the `<wr-action-sheet>` host element itself holds no content and
142
+ * the drawer it wraps is `display: none`.
143
+ *
144
+ * The anchor is `.wr-action-sheet`, the sheet's own root inside the drawer panel,
145
+ * which makes each instance self-scoping: two sheets open at once are two hosts, and
146
+ * every query here descends from one of them. That is worth stating because it is
147
+ * NOT how the drawer harness underneath has to work — a drawer publishes no link to
148
+ * the overlay it opened, so `WrDrawerHarness` anchors on the shared pane and scopes
149
+ * by id.
150
+ *
151
+ * **What belongs to the drawer, not here.** Dismissal by backdrop click or by the ✕
152
+ * button, the modal role, the focus trap and the panel's position are all the
153
+ * drawer's surface, and `WrDrawerHarness` from the same root loader answers them.
154
+ * {@link sendEscape} is the one exception, kept because dismissing without choosing
155
+ * is a documented behaviour of the sheet itself: it closes and emits NOTHING, which
156
+ * is the assertion most specs are actually after.
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * const rootLoader = TestbedHarnessEnvironment.documentRootLoader(fixture);
161
+ * const sheet = await rootLoader.getHarness(WrActionSheetHarness);
162
+ *
163
+ * expect(await sheet.getActionLabels()).toEqual(['Take Photo', 'Delete', 'Cancel']);
164
+ * await sheet.select({ label: 'Delete' });
165
+ * ```
166
+ *
167
+ * @see https://ngwr.dev/guides/testing
168
+ */
169
+ class WrActionSheetHarness extends ComponentHarness {
170
+ /** The sheet's root inside the drawer panel. A closed sheet renders none. */
171
+ static hostSelector = '.wr-action-sheet';
172
+ /** Build a predicate that narrows the query — sheets can be stacked. */
173
+ static with(options = {}) {
174
+ return new HarnessPredicate(WrActionSheetHarness, options)
175
+ .addOption('title', options.title, (harness, title) => HarnessPredicate.stringMatches(harness.getTitle(), title))
176
+ .addOption('message', options.message, (harness, message) => HarnessPredicate.stringMatches(harness.getMessage(), message))
177
+ .addOption('accessibleName', options.accessibleName, (harness, name) => HarnessPredicate.stringMatches(harness.getAccessibleName(), name));
178
+ }
179
+ /**
180
+ * Whether this sheet is still open.
181
+ *
182
+ * A harness can only be obtained while the sheet is open — closing disposes the
183
+ * overlay and everything in it — so this is the answer for a harness you are
184
+ * already HOLDING: it flips to `false` after a pick or a dismissal, where a fresh
185
+ * `getHarnessOrNull()` comes back `null`.
186
+ *
187
+ * Attachment is the test rather than a class, because disposal removes the element
188
+ * without changing anything on it.
189
+ */
190
+ async isOpen() {
191
+ return (await this.host()).matchesSelector('body .wr-action-sheet');
192
+ }
193
+ /** The visible heading, or `null` when the sheet was opened without a `title`. */
194
+ async getTitle() {
195
+ const title = await this.locatorForOptional('.wr-action-sheet__title')();
196
+ return title ? title.text() : null;
197
+ }
198
+ /** The muted sub-heading, or `null` when the sheet has no `message`. */
199
+ async getMessage() {
200
+ const message = await this.locatorForOptional('.wr-action-sheet__message')();
201
+ return message ? message.text() : null;
202
+ }
203
+ /**
204
+ * The name the dialog announces.
205
+ *
206
+ * The sheet always publishes one, and for an untitled sheet it is INVISIBLE: the
207
+ * component renders a screen-reader-only `[wrDrawerTitle]` carrying
208
+ * `actionSheet.label` (English default `Actions`), because a bottom sheet is an
209
+ * `aria-modal` dialog and an unnamed one is announced as nothing at all. Nothing
210
+ * on screen changes when that string is wrong or missing, which is exactly why it
211
+ * is worth an assertion.
212
+ *
213
+ * Read from `.wr-drawer__title` — the class the title directive applies — so the
214
+ * one query answers for both shapes: the visible heading carries it too.
215
+ */
216
+ async getAccessibleName() {
217
+ return (await this.locatorFor('.wr-drawer__title')()).text();
218
+ }
219
+ /** Whether the announced name comes from a visible heading rather than the fallback. */
220
+ async isTitleVisible() {
221
+ return (await this.locatorForOptional('.wr-action-sheet__title')()) !== null;
222
+ }
223
+ /**
224
+ * Whether the dialog is actually WIRED to that name — the drawer panel's
225
+ * `aria-labelledby` resolving to this sheet's own title element, and to nothing
226
+ * else on the page.
227
+ *
228
+ * {@link getAccessibleName} only proves a string exists in the markup; a screen
229
+ * reader reads it only if the reference points at it. The two are separate
230
+ * failures and the second is silent: the title renders, the sheet looks right, and
231
+ * the dialog is announced as unnamed. Worth its own assertion because the drawer
232
+ * resolves the reference AFTER attaching the panel rather than while rendering it,
233
+ * so a title that arrives late is named late or not at all.
234
+ *
235
+ * Counted across the document as well, because two panels answering to one id hand
236
+ * every reference to whichever comes first — which is how a second sheet ends up
237
+ * announcing the first one's title.
238
+ */
239
+ async isNamed() {
240
+ const id = await (await this.locatorFor('.wr-drawer__title')()).getAttribute('id');
241
+ if (!id)
242
+ return false;
243
+ const root = this.documentRootLocatorFactory();
244
+ const named = await root.locatorForAll(`[aria-labelledby="${id}"]`)();
245
+ const titles = await root.locatorForAll(`[id="${id}"]`)();
246
+ return named.length === 1 && titles.length === 1;
247
+ }
248
+ /** The rows this sheet offers, in DOM order — cancel rows last, in their own group. */
249
+ async getActions(filters = {}) {
250
+ return this.locatorForAll(WrActionSheetActionHarness.with(filters))();
251
+ }
252
+ /** The labels of every row, in DOM order. */
253
+ async getActionLabels() {
254
+ const actions = await this.getActions();
255
+ return Promise.all(actions.map(action => action.getLabel()));
256
+ }
257
+ /**
258
+ * The labels grouped the way the sheet lays them out: the main group first, then
259
+ * the cancel group when there is one.
260
+ *
261
+ * The grouping is the component's whole visual contract — a `cancel` row is pulled
262
+ * out of the list and pinned to the bottom with a gap above it — and it is
263
+ * invisible to {@link getActionLabels}, which flattens the two. A cancel row that
264
+ * stopped being separated would still come last in DOM order, so the flat list
265
+ * cannot catch it.
266
+ */
267
+ async getActionGroups() {
268
+ const groups = await this.locatorForAll(GroupHarness)();
269
+ return Promise.all(groups.map(group => group.getLabels()));
270
+ }
271
+ /**
272
+ * Whether the sheet drew a separate bottom group — true exactly when at least one
273
+ * row was given `role: 'cancel'`, since the component omits the group entirely
274
+ * rather than rendering an empty one.
275
+ */
276
+ async hasCancelGroup() {
277
+ return (await this.locatorForOptional('.wr-action-sheet__group--cancel')()) !== null;
278
+ }
279
+ /**
280
+ * Pick the first row matching the filters.
281
+ *
282
+ * Throws when nothing matches, naming what the sheet does offer — the alternative
283
+ * is a silent no-op followed by an assertion about a sheet that never moved. A
284
+ * disabled match throws too, from the row harness.
285
+ */
286
+ async select(filters) {
287
+ const [action] = await this.getActions(filters);
288
+ if (!action) {
289
+ const offered = await this.getActionLabels();
290
+ throw new Error(`WrActionSheetHarness.select(): no row matched ${JSON.stringify(filters)}. ` +
291
+ `The sheet offers: ${offered.join(', ')}.`);
292
+ }
293
+ await action.click();
294
+ }
295
+ /**
296
+ * Press Escape — dismissing the sheet WITHOUT emitting `action`.
297
+ *
298
+ * The key never needs to reach the sheet itself: the drawer underneath listens
299
+ * through the CDK's keyboard dispatcher, which keeps one document listener and
300
+ * hands the event to the top-most overlay. So with sheets stacked this dismisses
301
+ * the top one whichever harness it is called on.
302
+ */
303
+ async sendEscape() {
304
+ await (await this.host()).sendKeys(TestKey.ESCAPE);
305
+ }
306
+ }
307
+
308
+ /**
309
+ * Generated bundle index. Do not edit.
310
+ */
311
+
312
+ export { WrActionSheetActionHarness, WrActionSheetHarness };
313
+ //# sourceMappingURL=ngwr-action-sheet-testing.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngwr-action-sheet-testing.mjs","sources":["../../../projects/lib/action-sheet/testing/wr-action-sheet-action-harness.ts","../../../projects/lib/action-sheet/testing/wr-action-sheet-harness.ts","../../../projects/lib/action-sheet/testing/ngwr-action-sheet-testing.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport type { WrActionSheetAction } from 'ngwr/action-sheet';\n\nimport type { WrActionSheetActionHarnessFilters } from './interfaces';\n\n/**\n * Test harness for one row inside a {@link WrActionSheetHarness}.\n *\n * A row is a real `<button>`, not an ARIA-decorated div, so `disabled` is the\n * property rather than an attribute and the CDK refuses to click it — which is the\n * behaviour a spec wants asserted, since the component ALSO checks `disabled`\n * inside its own handler. Either guard alone would keep a disabled row inert; both\n * being there means removing one is invisible until the other is removed too, and\n * {@link click} is where that shows up.\n *\n * **Clicking a row closes the sheet.** The component emits `action` and clears\n * `open` in the same call, so a harness held across a {@link click} is pointed at a\n * detached element the moment it returns — read what you need first, and get a\n * fresh harness afterwards if the sheet was reopened.\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrActionSheetActionHarness extends ComponentHarness {\n /** The class every row carries, cancel rows included. */\n static hostSelector = '.wr-action-sheet__action';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrActionSheetActionHarnessFilters = {}): HarnessPredicate<WrActionSheetActionHarness> {\n return new HarnessPredicate(WrActionSheetActionHarness, options)\n .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label))\n .addOption('role', options.role, async (harness, role) => (await harness.getRole()) === role)\n .addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled);\n }\n\n /**\n * The row's label, trimmed.\n *\n * Read from `.wr-action-sheet__label` rather than from the button, so a leading\n * icon can never join it. The icon contributes no text today — it is an `<svg>` —\n * but an icon set that ships a `<title>` for its own accessibility would, and the\n * label element is the thing that actually holds the string.\n */\n async getLabel(): Promise<string> {\n return (await this.locatorFor('.wr-action-sheet__label')()).text();\n }\n\n /**\n * The row's visual role, as the component painted it.\n *\n * `default` is returned for a row the caller left unroled, which is what the\n * component does with the value: only `destructive` and `cancel` change anything,\n * and everything else falls through to the plain row. The two modifiers are\n * mutually exclusive by construction — `cancel` rows are filtered into their own\n * group before the destructive class is ever considered — so reading them in\n * either order gives the same answer.\n */\n async getRole(): Promise<NonNullable<WrActionSheetAction['role']>> {\n const host = await this.host();\n if (await host.hasClass('wr-action-sheet__action--cancel')) return 'cancel';\n if (await host.hasClass('wr-action-sheet__action--destructive')) return 'destructive';\n return 'default';\n }\n\n /**\n * Whether the row refuses interaction, from the button's own `disabled` property\n * — the thing the CDK consults before dispatching a click, and the DOM before\n * delivering one.\n *\n * There is no `aria-disabled` to fall back to here, and none is wanted: the row is\n * a native button, where the property already carries the state to assistive tech.\n */\n async isDisabled(): Promise<boolean> {\n return (await this.host()).getProperty<boolean>('disabled');\n }\n\n /** Whether the row draws a leading icon. */\n async hasIcon(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-action-sheet__icon')()) !== null;\n }\n\n /**\n * The icon's registered name, or `null` on a row without one.\n *\n * From `wr-icon`'s reflected `data-icon`, which is the only place the name reaches\n * the DOM — the rendered `<svg>` carries no trace of which entry of the set it\n * came from.\n */\n async getIconName(): Promise<string | null> {\n const icon = await this.locatorForOptional('.wr-action-sheet__icon')();\n return icon ? icon.getAttribute('data-icon') : null;\n }\n\n /**\n * Pick this row — emitting `action` and closing the sheet.\n *\n * Throws on a disabled row instead of quietly doing nothing. The click would not\n * land anyway (the DOM swallows it), so the alternative is a spec that reads as\n * \"picked the row\" and asserts a sheet that never moved.\n */\n async click(): Promise<void> {\n if (await this.isDisabled()) {\n throw new Error(\n `WrActionSheetActionHarness.click(): \"${await this.getLabel()}\" is disabled. The DOM swallows a click ` +\n 'on a disabled button and the component checks `disabled` again before emitting, so nothing would ' +\n 'happen — assert isDisabled() instead.'\n );\n }\n await (await this.host()).click();\n }\n\n /** Move keyboard focus to the row. */\n async focus(): Promise<void> {\n return (await this.host()).focus();\n }\n\n /** Whether the row currently holds focus. */\n async isFocused(): Promise<boolean> {\n return (await this.host()).isFocused();\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, HarnessPredicate, TestKey } from '@angular/cdk/testing';\n\nimport type { WrActionSheetActionHarnessFilters, WrActionSheetHarnessFilters } from './interfaces';\nimport { WrActionSheetActionHarness } from './wr-action-sheet-action-harness';\n\n/**\n * One `.wr-action-sheet__group` — internal, and the only way to read the rows of ONE\n * group: a `TestElement` cannot be queried into, so scoping to a child element means\n * a harness anchored on it.\n */\nclass GroupHarness extends ComponentHarness {\n static hostSelector = '.wr-action-sheet__group';\n\n async getLabels(): Promise<string[]> {\n const labels = await this.locatorForAll('.wr-action-sheet__label')();\n return Promise.all(labels.map(label => label.text()));\n }\n}\n\n/**\n * Test harness for an open `<wr-action-sheet>` — the iOS-style bottom sheet of\n * choices.\n *\n * The sheet renders through `<wr-drawer>`, so its rows are in the NGWR overlay\n * container rather than in the fixture: load this from\n * `TestbedHarnessEnvironment.documentRootLoader()`. A fixture-scoped loader finds\n * nothing at all — the `<wr-action-sheet>` host element itself holds no content and\n * the drawer it wraps is `display: none`.\n *\n * The anchor is `.wr-action-sheet`, the sheet's own root inside the drawer panel,\n * which makes each instance self-scoping: two sheets open at once are two hosts, and\n * every query here descends from one of them. That is worth stating because it is\n * NOT how the drawer harness underneath has to work — a drawer publishes no link to\n * the overlay it opened, so `WrDrawerHarness` anchors on the shared pane and scopes\n * by id.\n *\n * **What belongs to the drawer, not here.** Dismissal by backdrop click or by the ✕\n * button, the modal role, the focus trap and the panel's position are all the\n * drawer's surface, and `WrDrawerHarness` from the same root loader answers them.\n * {@link sendEscape} is the one exception, kept because dismissing without choosing\n * is a documented behaviour of the sheet itself: it closes and emits NOTHING, which\n * is the assertion most specs are actually after.\n *\n * @example\n * ```ts\n * const rootLoader = TestbedHarnessEnvironment.documentRootLoader(fixture);\n * const sheet = await rootLoader.getHarness(WrActionSheetHarness);\n *\n * expect(await sheet.getActionLabels()).toEqual(['Take Photo', 'Delete', 'Cancel']);\n * await sheet.select({ label: 'Delete' });\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrActionSheetHarness extends ComponentHarness {\n /** The sheet's root inside the drawer panel. A closed sheet renders none. */\n static hostSelector = '.wr-action-sheet';\n\n /** Build a predicate that narrows the query — sheets can be stacked. */\n static with(options: WrActionSheetHarnessFilters = {}): HarnessPredicate<WrActionSheetHarness> {\n return new HarnessPredicate(WrActionSheetHarness, options)\n .addOption('title', options.title, (harness, title) => HarnessPredicate.stringMatches(harness.getTitle(), title))\n .addOption('message', options.message, (harness, message) =>\n HarnessPredicate.stringMatches(harness.getMessage(), message)\n )\n .addOption('accessibleName', options.accessibleName, (harness, name) =>\n HarnessPredicate.stringMatches(harness.getAccessibleName(), name)\n );\n }\n\n /**\n * Whether this sheet is still open.\n *\n * A harness can only be obtained while the sheet is open — closing disposes the\n * overlay and everything in it — so this is the answer for a harness you are\n * already HOLDING: it flips to `false` after a pick or a dismissal, where a fresh\n * `getHarnessOrNull()` comes back `null`.\n *\n * Attachment is the test rather than a class, because disposal removes the element\n * without changing anything on it.\n */\n async isOpen(): Promise<boolean> {\n return (await this.host()).matchesSelector('body .wr-action-sheet');\n }\n\n /** The visible heading, or `null` when the sheet was opened without a `title`. */\n async getTitle(): Promise<string | null> {\n const title = await this.locatorForOptional('.wr-action-sheet__title')();\n return title ? title.text() : null;\n }\n\n /** The muted sub-heading, or `null` when the sheet has no `message`. */\n async getMessage(): Promise<string | null> {\n const message = await this.locatorForOptional('.wr-action-sheet__message')();\n return message ? message.text() : null;\n }\n\n /**\n * The name the dialog announces.\n *\n * The sheet always publishes one, and for an untitled sheet it is INVISIBLE: the\n * component renders a screen-reader-only `[wrDrawerTitle]` carrying\n * `actionSheet.label` (English default `Actions`), because a bottom sheet is an\n * `aria-modal` dialog and an unnamed one is announced as nothing at all. Nothing\n * on screen changes when that string is wrong or missing, which is exactly why it\n * is worth an assertion.\n *\n * Read from `.wr-drawer__title` — the class the title directive applies — so the\n * one query answers for both shapes: the visible heading carries it too.\n */\n async getAccessibleName(): Promise<string> {\n return (await this.locatorFor('.wr-drawer__title')()).text();\n }\n\n /** Whether the announced name comes from a visible heading rather than the fallback. */\n async isTitleVisible(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-action-sheet__title')()) !== null;\n }\n\n /**\n * Whether the dialog is actually WIRED to that name — the drawer panel's\n * `aria-labelledby` resolving to this sheet's own title element, and to nothing\n * else on the page.\n *\n * {@link getAccessibleName} only proves a string exists in the markup; a screen\n * reader reads it only if the reference points at it. The two are separate\n * failures and the second is silent: the title renders, the sheet looks right, and\n * the dialog is announced as unnamed. Worth its own assertion because the drawer\n * resolves the reference AFTER attaching the panel rather than while rendering it,\n * so a title that arrives late is named late or not at all.\n *\n * Counted across the document as well, because two panels answering to one id hand\n * every reference to whichever comes first — which is how a second sheet ends up\n * announcing the first one's title.\n */\n async isNamed(): Promise<boolean> {\n const id = await (await this.locatorFor('.wr-drawer__title')()).getAttribute('id');\n if (!id) return false;\n\n const root = this.documentRootLocatorFactory();\n const named = await root.locatorForAll(`[aria-labelledby=\"${id}\"]`)();\n const titles = await root.locatorForAll(`[id=\"${id}\"]`)();\n return named.length === 1 && titles.length === 1;\n }\n\n /** The rows this sheet offers, in DOM order — cancel rows last, in their own group. */\n async getActions(filters: WrActionSheetActionHarnessFilters = {}): Promise<WrActionSheetActionHarness[]> {\n return this.locatorForAll(WrActionSheetActionHarness.with(filters))();\n }\n\n /** The labels of every row, in DOM order. */\n async getActionLabels(): Promise<string[]> {\n const actions = await this.getActions();\n return Promise.all(actions.map(action => action.getLabel()));\n }\n\n /**\n * The labels grouped the way the sheet lays them out: the main group first, then\n * the cancel group when there is one.\n *\n * The grouping is the component's whole visual contract — a `cancel` row is pulled\n * out of the list and pinned to the bottom with a gap above it — and it is\n * invisible to {@link getActionLabels}, which flattens the two. A cancel row that\n * stopped being separated would still come last in DOM order, so the flat list\n * cannot catch it.\n */\n async getActionGroups(): Promise<string[][]> {\n const groups = await this.locatorForAll(GroupHarness)();\n return Promise.all(groups.map(group => group.getLabels()));\n }\n\n /**\n * Whether the sheet drew a separate bottom group — true exactly when at least one\n * row was given `role: 'cancel'`, since the component omits the group entirely\n * rather than rendering an empty one.\n */\n async hasCancelGroup(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-action-sheet__group--cancel')()) !== null;\n }\n\n /**\n * Pick the first row matching the filters.\n *\n * Throws when nothing matches, naming what the sheet does offer — the alternative\n * is a silent no-op followed by an assertion about a sheet that never moved. A\n * disabled match throws too, from the row harness.\n */\n async select(filters: WrActionSheetActionHarnessFilters): Promise<void> {\n const [action] = await this.getActions(filters);\n if (!action) {\n const offered = await this.getActionLabels();\n throw new Error(\n `WrActionSheetHarness.select(): no row matched ${JSON.stringify(filters)}. ` +\n `The sheet offers: ${offered.join(', ')}.`\n );\n }\n await action.click();\n }\n\n /**\n * Press Escape — dismissing the sheet WITHOUT emitting `action`.\n *\n * The key never needs to reach the sheet itself: the drawer underneath listens\n * through the CDK's keyboard dispatcher, which keeps one document listener and\n * hands the event to the top-most overlay. So with sheets stacked this dismisses\n * the top one whichever harness it is called on.\n */\n async sendEscape(): Promise<void> {\n await (await this.host()).sendKeys(TestKey.ESCAPE);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;;;;;AAKG;AAQH;;;;;;;;;;;;;;;;AAgBG;AACG,MAAO,0BAA2B,SAAQ,gBAAgB,CAAA;;AAE9D,IAAA,OAAO,YAAY,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,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE;AACvD,QAAA,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;IAC5D;AAEA;;;;AAIG;AACH,IAAA,MAAM,cAAc,GAAA;AAClB,QAAA,OAAO,CAAC,MAAM,IAAI,CAAC,kBAAkB,CAAC,iCAAiC,CAAC,EAAE,MAAM,IAAI;IACtF;AAEA;;;;;;AAMG;IACH,MAAM,MAAM,CAAC,OAA0C,EAAA;QACrD,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QAC/C,IAAI,CAAC,MAAM,EAAE;AACX,YAAA,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,eAAe,EAAE;YAC5C,MAAM,IAAI,KAAK,CACb,CAAA,8CAAA,EAAiD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA,EAAA,CAAI;gBAC1E,CAAA,kBAAA,EAAqB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAA,CAAG,CAC7C;QACH;AACA,QAAA,MAAM,MAAM,CAAC,KAAK,EAAE;IACtB;AAEA;;;;;;;AAOG;AACH,IAAA,MAAM,UAAU,GAAA;AACd,QAAA,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;IACpD;;;ACxNF;;AAEG;;;;"}
@@ -0,0 +1,89 @@
1
+ import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
2
+
3
+ /**
4
+ * @license
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
8
+ */
9
+ /**
10
+ * Test harness for `<wr-bar-chart>`.
11
+ *
12
+ * **The bars are read as PERCENTAGES, not as pixels.** Each column's height is
13
+ * written inline as a share of the chart's maximum, which is the one number that
14
+ * survives a test with no layout — and it is also the component's whole job, since
15
+ * the maximum is either given or derived from the data.
16
+ *
17
+ * **The visible label row is decoration.** Every column carries `role="img"` with
18
+ * the label AND the value in its name, and the printed labels underneath are
19
+ * `aria-hidden` — so {@link WrBarChartBar.name} is what a screen reader gets and
20
+ * {@link WrBarChartBar.label} is what is drawn. Asserting only the second would pass
21
+ * on a chart that announces nothing.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const chart = await loader.getHarness(WrBarChartHarness);
26
+ *
27
+ * expect(await chart.getLabels()).toEqual(['Mon', 'Tue', 'Wed']);
28
+ * expect((await chart.getBars())[1].heightPercent).toBe(100);
29
+ * ```
30
+ *
31
+ * @see https://ngwr.dev/guides/testing
32
+ */
33
+ class WrBarChartHarness extends ComponentHarness {
34
+ static hostSelector = 'wr-bar-chart';
35
+ /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */
36
+ static with(options = {}) {
37
+ return new HarnessPredicate(WrBarChartHarness, options).addOption('barLabel', options.barLabel, async (harness, label) => {
38
+ for (const printed of await harness.getLabels()) {
39
+ if (await HarnessPredicate.stringMatches(printed, label))
40
+ return true;
41
+ }
42
+ return false;
43
+ });
44
+ }
45
+ /** Every column, in data order. */
46
+ async getBars() {
47
+ const columns = await this.locatorForAll('.wr-bar-chart__column')();
48
+ const bars = await this.locatorForAll('.wr-bar-chart__bar')();
49
+ const labels = await this.getLabels();
50
+ return Promise.all(columns.map(async (column, index) => {
51
+ const value = await column.text();
52
+ return {
53
+ label: labels[index] ?? '',
54
+ value: value === '' ? null : value,
55
+ name: await column.getAttribute('aria-label'),
56
+ heightPercent: Number.parseFloat(await bars[index].getCssValue('height')),
57
+ };
58
+ }));
59
+ }
60
+ /** The labels printed under the columns, in order. */
61
+ async getLabels() {
62
+ const labels = await this.locatorForAll('.wr-bar-chart__label')();
63
+ return Promise.all(labels.map(label => label.text()));
64
+ }
65
+ /** What each column announces — the label and the value together. */
66
+ async getAccessibleNames() {
67
+ const columns = await this.locatorForAll('.wr-bar-chart__column')();
68
+ return Promise.all(columns.map(column => column.getAttribute('aria-label')));
69
+ }
70
+ /** How many columns the chart drew. */
71
+ async getBarCount() {
72
+ return (await this.locatorForAll('.wr-bar-chart__column')()).length;
73
+ }
74
+ /** Whether the values are printed above the bars (`showValues`). */
75
+ async hasValues() {
76
+ return (await this.locatorForOptional('.wr-bar-chart__value')()) !== null;
77
+ }
78
+ /** The plot's height in pixels, as the component writes it inline. */
79
+ async getPlotHeight() {
80
+ return Number.parseFloat(await (await this.locatorFor('.wr-bar-chart__plot')()).getCssValue('height'));
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Generated bundle index. Do not edit.
86
+ */
87
+
88
+ export { WrBarChartHarness };
89
+ //# sourceMappingURL=ngwr-bar-chart-testing.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngwr-bar-chart-testing.mjs","sources":["../../../projects/lib/bar-chart/testing/wr-bar-chart-harness.ts","../../../projects/lib/bar-chart/testing/ngwr-bar-chart-testing.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport type { WrBarChartBar, WrBarChartHarnessFilters } from './interfaces';\n\n/**\n * Test harness for `<wr-bar-chart>`.\n *\n * **The bars are read as PERCENTAGES, not as pixels.** Each column's height is\n * written inline as a share of the chart's maximum, which is the one number that\n * survives a test with no layout — and it is also the component's whole job, since\n * the maximum is either given or derived from the data.\n *\n * **The visible label row is decoration.** Every column carries `role=\"img\"` with\n * the label AND the value in its name, and the printed labels underneath are\n * `aria-hidden` — so {@link WrBarChartBar.name} is what a screen reader gets and\n * {@link WrBarChartBar.label} is what is drawn. Asserting only the second would pass\n * on a chart that announces nothing.\n *\n * @example\n * ```ts\n * const chart = await loader.getHarness(WrBarChartHarness);\n *\n * expect(await chart.getLabels()).toEqual(['Mon', 'Tue', 'Wed']);\n * expect((await chart.getBars())[1].heightPercent).toBe(100);\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrBarChartHarness extends ComponentHarness {\n static hostSelector = 'wr-bar-chart';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrBarChartHarnessFilters = {}): HarnessPredicate<WrBarChartHarness> {\n return new HarnessPredicate(WrBarChartHarness, options).addOption(\n 'barLabel',\n options.barLabel,\n async (harness, label) => {\n for (const printed of await harness.getLabels()) {\n if (await HarnessPredicate.stringMatches(printed, label)) return true;\n }\n return false;\n }\n );\n }\n\n /** Every column, in data order. */\n async getBars(): Promise<WrBarChartBar[]> {\n const columns = await this.locatorForAll('.wr-bar-chart__column')();\n const bars = await this.locatorForAll('.wr-bar-chart__bar')();\n const labels = await this.getLabels();\n\n return Promise.all(\n columns.map(async (column, index) => {\n const value = await column.text();\n return {\n label: labels[index] ?? '',\n value: value === '' ? null : value,\n name: await column.getAttribute('aria-label'),\n heightPercent: Number.parseFloat(await bars[index].getCssValue('height')),\n };\n })\n );\n }\n\n /** The labels printed under the columns, in order. */\n async getLabels(): Promise<string[]> {\n const labels = await this.locatorForAll('.wr-bar-chart__label')();\n return Promise.all(labels.map(label => label.text()));\n }\n\n /** What each column announces — the label and the value together. */\n async getAccessibleNames(): Promise<(string | null)[]> {\n const columns = await this.locatorForAll('.wr-bar-chart__column')();\n return Promise.all(columns.map(column => column.getAttribute('aria-label')));\n }\n\n /** How many columns the chart drew. */\n async getBarCount(): Promise<number> {\n return (await this.locatorForAll('.wr-bar-chart__column')()).length;\n }\n\n /** Whether the values are printed above the bars (`showValues`). */\n async hasValues(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-bar-chart__value')()) !== null;\n }\n\n /** The plot's height in pixels, as the component writes it inline. */\n async getPlotHeight(): Promise<number> {\n return Number.parseFloat(await (await this.locatorFor('.wr-bar-chart__plot')()).getCssValue('height'));\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;;;;;AAKG;AAMH;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACG,MAAO,iBAAkB,SAAQ,gBAAgB,CAAA;AACrD,IAAA,OAAO,YAAY,GAAG,cAAc;;AAGpC,IAAA,OAAO,IAAI,CAAC,OAAA,GAAoC,EAAE,EAAA;QAChD,OAAO,IAAI,gBAAgB,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,SAAS,CAC/D,UAAU,EACV,OAAO,CAAC,QAAQ,EAChB,OAAO,OAAO,EAAE,KAAK,KAAI;YACvB,KAAK,MAAM,OAAO,IAAI,MAAM,OAAO,CAAC,SAAS,EAAE,EAAE;gBAC/C,IAAI,MAAM,gBAAgB,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC;AAAE,oBAAA,OAAO,IAAI;YACvE;AACA,YAAA,OAAO,KAAK;AACd,QAAA,CAAC,CACF;IACH;;AAGA,IAAA,MAAM,OAAO,GAAA;QACX,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC,EAAE;QACnE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE;AAC7D,QAAA,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE;AAErC,QAAA,OAAO,OAAO,CAAC,GAAG,CAChB,OAAO,CAAC,GAAG,CAAC,OAAO,MAAM,EAAE,KAAK,KAAI;AAClC,YAAA,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE;YACjC,OAAO;AACL,gBAAA,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE;gBAC1B,KAAK,EAAE,KAAK,KAAK,EAAE,GAAG,IAAI,GAAG,KAAK;AAClC,gBAAA,IAAI,EAAE,MAAM,MAAM,CAAC,YAAY,CAAC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