@eldrajs/theme-cli 0.2.8 → 0.2.10

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 (165) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/package.json +1 -1
  3. package/template/.eldra/block-types.d.ts +28 -7
  4. package/template/.eldra/manifest.json +1034 -355
  5. package/template/.eldra/previews.json +35 -35
  6. package/template/README.md +32 -0
  7. package/template/app/assets/main.css +23 -0
  8. package/template/app/plugins/eldra-storefront.ts +3 -0
  9. package/template/app/storefront/demo.ts +75 -24
  10. package/template/app/storefront/gateway.ts +16 -2
  11. package/template/blocks/announcement-bar/preview.png +0 -0
  12. package/template/blocks/article/preview.json +4 -4
  13. package/template/blocks/article/preview.png +0 -0
  14. package/template/blocks/article-list/Block.vue +48 -19
  15. package/template/blocks/article-list/__tests__/Block.spec.ts +15 -0
  16. package/template/blocks/article-list/preview.json +43 -43
  17. package/template/blocks/article-list/preview.png +0 -0
  18. package/template/blocks/breadcrumbs/preview.png +0 -0
  19. package/template/blocks/cart/preview.png +0 -0
  20. package/template/blocks/collection-grid/Block.vue +260 -9
  21. package/template/blocks/collection-grid/__tests__/Block.spec.ts +202 -0
  22. package/template/blocks/collection-grid/block.json +3 -3
  23. package/template/blocks/collection-grid/preview.png +0 -0
  24. package/template/blocks/collection-header/Block.vue +82 -58
  25. package/template/blocks/collection-header/__tests__/Block.spec.ts +77 -1
  26. package/template/blocks/collection-header/preview.json +4 -4
  27. package/template/blocks/collection-header/preview.png +0 -0
  28. package/template/blocks/contact/preview.png +0 -0
  29. package/template/blocks/cta/preview.json +4 -4
  30. package/template/blocks/cta/preview.png +0 -0
  31. package/template/blocks/faq/preview.png +0 -0
  32. package/template/blocks/feature-grid/Block.vue +73 -4
  33. package/template/blocks/feature-grid/__tests__/Block.spec.ts +43 -1
  34. package/template/blocks/feature-grid/block.json +2 -2
  35. package/template/blocks/feature-grid/preview.json +49 -24
  36. package/template/blocks/feature-grid/preview.png +0 -0
  37. package/template/blocks/footer/Block.vue +186 -71
  38. package/template/blocks/footer/__tests__/Block.spec.ts +127 -32
  39. package/template/blocks/footer/block.json +42 -4
  40. package/template/blocks/footer/mock.json +31 -34
  41. package/template/blocks/footer/preview.png +0 -0
  42. package/template/blocks/form/preview.png +0 -0
  43. package/template/blocks/gallery/preview.json +24 -24
  44. package/template/blocks/gallery/preview.png +0 -0
  45. package/template/blocks/hero/Block.vue +117 -19
  46. package/template/blocks/hero/__tests__/Block.spec.ts +46 -0
  47. package/template/blocks/hero/block.json +36 -1
  48. package/template/blocks/hero/preview.json +33 -25
  49. package/template/blocks/hero/preview.png +0 -0
  50. package/template/blocks/image/preview.json +4 -4
  51. package/template/blocks/image/preview.png +0 -0
  52. package/template/blocks/logo-cloud/preview.png +0 -0
  53. package/template/blocks/navigation/Block.vue +623 -184
  54. package/template/blocks/navigation/__tests__/Block.spec.ts +416 -68
  55. package/template/blocks/navigation/__tests__/fixtures/menu.json +182 -0
  56. package/template/blocks/navigation/block.json +102 -6
  57. package/template/blocks/navigation/mock.json +279 -52
  58. package/template/blocks/navigation/preview.json +311 -0
  59. package/template/blocks/navigation/preview.png +0 -0
  60. package/template/blocks/newsletter/Block.vue +248 -144
  61. package/template/blocks/newsletter/__tests__/Block.spec.ts +42 -0
  62. package/template/blocks/newsletter/block.json +61 -2
  63. package/template/blocks/newsletter/preview.json +35 -0
  64. package/template/blocks/newsletter/preview.png +0 -0
  65. package/template/blocks/order-status/preview.png +0 -0
  66. package/template/blocks/pricing-table/preview.png +0 -0
  67. package/template/blocks/product-carousel/Block.vue +272 -26
  68. package/template/blocks/product-carousel/__tests__/Block.spec.ts +90 -0
  69. package/template/blocks/product-carousel/block.json +61 -0
  70. package/template/blocks/product-carousel/preview.json +12 -0
  71. package/template/blocks/product-carousel/preview.png +0 -0
  72. package/template/blocks/product-detail/Block.vue +148 -96
  73. package/template/blocks/product-detail/__tests__/Block.spec.ts +98 -74
  74. package/template/blocks/product-detail/block.json +11 -4
  75. package/template/blocks/product-detail/mock.json +53 -22
  76. package/template/blocks/product-detail/parts/Gallery.vue +52 -103
  77. package/template/blocks/product-detail/preview.png +0 -0
  78. package/template/blocks/quote/preview.png +0 -0
  79. package/template/blocks/rich-text/preview.png +0 -0
  80. package/template/blocks/search/Block.vue +1 -0
  81. package/template/blocks/search/TypeSection.vue +1 -0
  82. package/template/blocks/search/__tests__/Block.spec.ts +23 -0
  83. package/template/blocks/search/preview.png +0 -0
  84. package/template/blocks/split-content/Block.vue +98 -20
  85. package/template/blocks/split-content/__tests__/Block.spec.ts +57 -18
  86. package/template/blocks/split-content/block.json +72 -6
  87. package/template/blocks/split-content/preview.json +34 -13
  88. package/template/blocks/split-content/preview.png +0 -0
  89. package/template/blocks/stats/preview.png +0 -0
  90. package/template/blocks/tabs/preview.json +16 -16
  91. package/template/blocks/tabs/preview.png +0 -0
  92. package/template/blocks/team/preview.png +0 -0
  93. package/template/blocks/testimonials/preview.png +0 -0
  94. package/template/blocks/timeline/preview.png +0 -0
  95. package/template/blocks/trust-strip/Block.vue +67 -1
  96. package/template/blocks/trust-strip/__tests__/Block.spec.ts +30 -1
  97. package/template/blocks/trust-strip/block.json +4 -4
  98. package/template/blocks/trust-strip/preview.json +21 -0
  99. package/template/blocks/trust-strip/preview.png +0 -0
  100. package/template/blocks/video-embed/preview.png +0 -0
  101. package/template/blocks/wishlist/preview.png +0 -0
  102. package/template/i18n/en-US.json +16 -9
  103. package/template/i18n/is-IS.json +16 -9
  104. package/template/pages/article.page.json +19 -18
  105. package/template/pages/cart.page.json +3 -13
  106. package/template/pages/category.page.json +15 -7
  107. package/template/pages/collection.page.json +15 -14
  108. package/template/pages/home.page.json +217 -182
  109. package/template/pages/product.page.json +46 -36
  110. package/template/pages/products.page.json +3 -13
  111. package/template/pages/search.page.json +3 -13
  112. package/template/pages/wishlist.page.json +3 -13
  113. package/template/public/images/CREDITS.md +28 -0
  114. package/template/public/images/clay-hands.webp +0 -0
  115. package/template/public/images/coffee-table.webp +0 -0
  116. package/template/public/images/cup.webp +0 -0
  117. package/template/public/images/enamel-cups.webp +0 -0
  118. package/template/public/images/hero.webp +0 -0
  119. package/template/public/images/kitchen.webp +0 -0
  120. package/template/public/images/mug.webp +0 -0
  121. package/template/public/images/northwind-mark.svg +1 -0
  122. package/template/public/images/planters.webp +0 -0
  123. package/template/public/images/plates.webp +0 -0
  124. package/template/public/images/reading.webp +0 -0
  125. package/template/public/images/sweater.webp +0 -0
  126. package/template/public/images/terracotta.webp +0 -0
  127. package/template/public/images/throws.webp +0 -0
  128. package/template/public/images/vase.webp +0 -0
  129. package/template/public/images/wheel.webp +0 -0
  130. package/template/public/images/yarn-tools.webp +0 -0
  131. package/template/public/images/yarn.webp +0 -0
  132. package/template/stories/generated/collection-grid.stories.ts +6 -0
  133. package/template/stories/generated/feature-grid.stories.ts +6 -0
  134. package/template/stories/generated/footer.stories.ts +4 -4
  135. package/template/stories/generated/hero.stories.ts +6 -0
  136. package/template/stories/generated/navigation.stories.ts +14 -1
  137. package/template/stories/generated/newsletter.stories.ts +2 -1
  138. package/template/stories/generated/product-carousel.stories.ts +12 -0
  139. package/template/stories/generated/split-content.stories.ts +12 -0
  140. package/template/stories/generated/trust-strip.stories.ts +8 -1
  141. package/template/stories/pages/article.stories.ts +2 -1
  142. package/template/stories/pages/cart.stories.ts +2 -1
  143. package/template/stories/pages/category.stories.ts +2 -1
  144. package/template/stories/pages/collection.stories.ts +2 -1
  145. package/template/stories/pages/home.stories.ts +2 -1
  146. package/template/stories/pages/product.stories.ts +2 -1
  147. package/template/stories/pages/products.stories.ts +2 -1
  148. package/template/stories/pages/search.stories.ts +2 -1
  149. package/template/stories/pages/wishlist.stories.ts +2 -1
  150. package/template/stories/support/demoChrome.ts +32 -0
  151. package/template/stories/support/pageBlocks.ts +2 -4
  152. package/template/test/countPill.browser.spec.ts +21 -13
  153. package/template/test/localePrefix.spec.ts +11 -6
  154. package/template/test/pages/article.spec.ts +1 -1
  155. package/template/test/pages/category.spec.ts +34 -11
  156. package/template/test/pages/collection.spec.ts +182 -148
  157. package/template/test/pages/home.spec.ts +35 -40
  158. package/template/test/pages/hydration.spec.ts +4 -4
  159. package/template/test/pages/product.spec.ts +17 -14
  160. package/template/test/pages/seededPages.spec.ts +11 -6
  161. package/template/test/prerenderRefresh.browser.spec.ts +36 -15
  162. package/template/test/previewParity.browser.spec.ts +36 -2
  163. package/template/test/starter.spec.ts +31 -15
  164. package/template/test/storefront/gatewayPrerender.spec.ts +26 -0
  165. package/template/tokens.json +13 -13
@@ -1,6 +1,7 @@
1
1
  // @vitest-environment jsdom
2
2
  import { afterEach, describe, expect, it } from 'vitest';
3
3
  import { flushPromises, type VueWrapper } from '@vue/test-utils';
4
+ import { nextTick } from 'vue';
4
5
  import { axe } from '../support/axe';
5
6
  import {
6
7
  expectPageLandmarks,
@@ -16,6 +17,8 @@ const page = fixture as unknown as PageFixture;
16
17
 
17
18
  const COLLECTION_TITLE = 'The winter edit';
18
19
  const ACTIVE_FILTERS_LABEL = 'Active filters';
20
+ /** The filter bar's own group label (`grid.filterAndSort`, `i18n/en-US.json`). */
21
+ const FILTER_BAR_LABEL = 'Filter and sort';
19
22
 
20
23
  /** jsdom reports `scrollHeight`/`clientHeight` as `0`/`0` for every element, so `collection-header`'s
21
24
  * clamp never "overflows" on its own — the same limitation that block's own spec works around.
@@ -59,44 +62,72 @@ afterEach(() => {
59
62
 
60
63
  /**
61
64
  * `mountPage` does not attach its harness to `document.body` (most page specs never need real
62
- * focus tracking). The filter drawer's own dialog contract does — `document.activeElement` only
63
- * reflects reality for a node that is actually in the live document — so this appends the mounted
64
- * root the same way `collection-grid`'s own block spec passes `attachTo: document.body`.
65
+ * focus tracking). The filter bar's group popovers do — each teleports its panel to the body, and
66
+ * `document.activeElement` only reflects reality for a node that is actually in the live document —
67
+ * so this attaches the harness the same way `collection-grid`'s own block spec passes
68
+ * `attachTo: document.body`.
65
69
  */
66
70
  async function mountAttached(): Promise<VueWrapper> {
67
- const wrapper = await mountPage(page);
68
- document.body.appendChild(wrapper.element);
71
+ const wrapper = await mountPage(page, { attachTo: document.body });
69
72
  wrappers.push(wrapper);
70
73
  return wrapper;
71
74
  }
72
75
 
73
- /** The filter-group disclosure triggers — a `<button>` inside an `h3`, the same shape
74
- * `collection-grid`'s own spec keys off (nothing else on the page nests a button in an `h3`). */
75
- function groupTriggers(root: Element): HTMLButtonElement[] {
76
- return Array.from(root.querySelectorAll<HTMLButtonElement>('h3 > button[aria-expanded]'));
76
+ /** The `filter-bar` variant's one row of controls: a chip per group, a pressed chip per on/off
77
+ * value, then the sort — the same `role="group"` `collection-grid`'s own filter-bar spec keys off. */
78
+ function filterBar(gridEl: Element): Element {
79
+ const bar = gridEl.querySelector(`[role="group"][aria-label="${FILTER_BAR_LABEL}"]`);
80
+ if (!bar) throw new Error('No filter bar found in the grid.');
81
+ return bar;
77
82
  }
78
- /** A group's panel, found by its own visually hidden `<legend>` text, scoped to `root` — pass the
79
- * sidebar (excluding the drawer) or the open `<dialog>` to pick the right one of the two copies. */
80
- function panelFor(root: Element, legend: string): Element {
81
- const trigger = groupTriggers(root).find(
82
- (candidate) =>
83
- root.querySelector(`#${candidate.getAttribute('aria-controls')}`)?.querySelector('legend')
84
- ?.textContent === legend
85
- );
86
- if (!trigger) throw new Error(`No filter group panel named "${legend}" found.`);
87
- return root.querySelector(`#${trigger.getAttribute('aria-controls')}`)!;
83
+ /** A group's popover trigger in the bar, by its visible label (a count badge may follow it). */
84
+ function barTrigger(gridEl: Element, label: string): HTMLButtonElement {
85
+ const trigger = Array.from(
86
+ filterBar(gridEl).querySelectorAll<HTMLButtonElement>('button[aria-haspopup="dialog"]')
87
+ ).find((button) => button.textContent?.trim().startsWith(label));
88
+ if (!trigger) throw new Error(`No filter bar chip named "${label}" found.`);
89
+ return trigger;
90
+ }
91
+ /** The open popover a trigger controls — teleported, so looked up in the document, and only
92
+ * present while open. */
93
+ function popoverOf(trigger: Element): HTMLElement | null {
94
+ return document.getElementById(trigger.getAttribute('aria-controls') ?? '');
95
+ }
96
+ /** The bar's on/off chip for a value (`aria-pressed`), by its visible label. */
97
+ function pressedChip(gridEl: Element, label: string): HTMLButtonElement {
98
+ const chip = Array.from(
99
+ filterBar(gridEl).querySelectorAll<HTMLButtonElement>('button[aria-pressed]')
100
+ ).find((button) => button.textContent?.trim() === label);
101
+ if (!chip) throw new Error(`No on/off chip named "${label}" found.`);
102
+ return chip;
88
103
  }
89
104
 
90
- /**
91
- * jsdom (30.x, this repo's pin) runs a checkbox's native click activation — `checked` flips — but
92
- * does not follow it with an `input`/`change` event the way a real browser does, so a plain
93
- * `.click()` never reaches the block's own `@change` handler (Vue Test Utils' own `setValue()`
94
- * works around exactly this by setting `checked` and dispatching `change` by hand, rather than
95
- * clicking). This does the same for a raw DOM reference.
96
- */
97
- function checkBox(input: HTMLInputElement): void {
98
- input.checked = true;
99
- input.dispatchEvent(new Event('change', { bubbles: true }));
105
+ /** The popover's open sequence and the panel's live path both settle over a few ticks and a
106
+ * macrotask (the same flush the block spec's filter-bar tests use). */
107
+ async function flush(): Promise<void> {
108
+ for (let index = 0; index < 4; index += 1) {
109
+ await nextTick();
110
+ await new Promise((resolve) => setTimeout(resolve, 0));
111
+ }
112
+ }
113
+
114
+ /** What a browser does when `Enter` activates a focused `<button>`: keydown, then a `detail: 0`
115
+ * click (jsdom turns neither into the other). */
116
+ async function pressEnter(button: HTMLElement): Promise<void> {
117
+ button.focus();
118
+ button.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }));
119
+ button.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, detail: 0 }));
120
+ await flush();
121
+ }
122
+
123
+ /** Opens a group's popover from its bar chip and ticks its `index`-th checkbox. */
124
+ async function tickInPopover(gridEl: Element, group: string, index: number): Promise<void> {
125
+ const trigger = barTrigger(gridEl, group);
126
+ await pressEnter(trigger);
127
+ const panel = popoverOf(trigger);
128
+ if (!panel) throw new Error(`The "${group}" popover did not open.`);
129
+ panel.querySelectorAll<HTMLInputElement>('input[type="checkbox"]')[index]!.click();
130
+ await flush();
100
131
  }
101
132
 
102
133
  describe('collection sample page', () => {
@@ -122,7 +153,7 @@ describe('collection sample page', () => {
122
153
  // breadcrumbs are not Sections, so they carry no ground at all and never take part in the
123
154
  // adjacent-section padding collapse.
124
155
  const grounds = children.map((el) => el.getAttribute('data-section-bg'));
125
- expect(grounds).toEqual([null, null, 'none', 'none', 'surface', 'surface-strong']);
156
+ expect(grounds).toEqual([null, null, 'none', 'none', 'surface', 'primary']);
126
157
 
127
158
  // The grid starts directly under the collection header with its own short 1.5rem top padding
128
159
  // (`pt-6`, hand-rolled rather than read from `Section`'s `spacing` prop — see the block's own
@@ -168,7 +199,7 @@ describe('collection sample page', () => {
168
199
 
169
200
  // The grid's own count is the block's polite status line — a `<p>` with `tabindex="-1"`, which
170
201
  // is what tells it apart from a searchable list facet's own `role="status"` "No matches" line
171
- // in the sidebar (also persistent, with no `aria-live` of its own — a native `role="status"`
202
+ // in a filter panel (also persistent, with no `aria-live` of its own — a native `role="status"`
172
203
  // needs none).
173
204
  const gridCount = gridEl!.querySelector('p[role="status"][tabindex="-1"]');
174
205
  expect(gridCount).not.toBeNull();
@@ -176,109 +207,97 @@ describe('collection sample page', () => {
176
207
  expect(gridCount!.textContent).toContain('48 products');
177
208
  });
178
209
 
179
- it('opens the filter drawer as a dialog from the Filter button, returns focus on Esc, and applies nothing until "Show 48 products" is pressed', async () => {
210
+ /**
211
+ * The `filter-bar` variant replaces the sidebar *and* the drawer: there is no Filter button and no
212
+ * `<dialog>` drawer at any width — the bar's row wraps on a phone (`flex-wrap`), and the block
213
+ * renders its drawer only when `!isBar` — so the drawer's old dialog contract has no subject on
214
+ * this page. What it guarded still does: a filter control that opens a dialog-like surface names
215
+ * it (`aria-haspopup`/`aria-expanded`/`aria-controls`), applies on the shopper's action, and Esc
216
+ * returns focus to the control that opened it. Unlike the drawer, a bar popover applies **live**
217
+ * (the sidebar's own path), so there is no pending "Show N products" step to defer to.
218
+ */
219
+ it('offers its filters in a bar with no drawer; a group chip opens a dialog popover, applies live, and Esc returns focus to the chip', async () => {
180
220
  const wrapper = await mountAttached();
181
221
  const gridEl = pageBlockRoots(wrapper)[3]!;
182
222
 
183
- const filterButton = gridEl.querySelector<HTMLButtonElement>('button[aria-haspopup="dialog"]')!;
184
- filterButton.focus();
185
- filterButton.click();
186
- // `useDialog` calls the native `showModal()` from a `watch(open, …)` callback, then applies
187
- // initial focus a tick *after that* (`void nextTick(focusInitial)`) so slot content has time to
188
- // render first — two ticks, not one, before focus actually lands on the close button.
189
- await wrapper.vm.$nextTick();
190
- await wrapper.vm.$nextTick();
191
-
192
- const dialog = gridEl.querySelector('dialog')!;
193
- expect(dialog.getAttribute('open')).toBe('');
194
- expect(filterButton.getAttribute('aria-expanded')).toBe('true');
195
- expect(filterButton.getAttribute('aria-controls')).toBe(dialog.id);
196
- expect(document.activeElement).toBe(dialog.querySelector('[data-part="close"]'));
197
-
198
- // The drawer's own primary button always reads the demo collection's full count.
199
- const applyButton = Array.from(dialog.querySelectorAll('button')).find((button) =>
200
- button.textContent?.trim().startsWith('Show ')
201
- )!;
202
- expect(applyButton.textContent?.trim()).toBe('Show 48 products');
203
-
204
- // Ticking a box in the drawer's own copy of the groups changes nothing live yet.
205
- const drawerColour = panelFor(dialog, 'Colour');
206
- const drawerOatCheckbox =
207
- drawerColour.querySelectorAll<HTMLInputElement>('input[type="checkbox"]')[0]!;
208
- checkBox(drawerOatCheckbox);
209
- await wrapper.vm.$nextTick();
210
- // Nothing live has moved — the drawer's own chip row shows its still-pending tick (its own
211
- // preview of what applying would do), but the sidebar's own applied panel has none.
212
- const sidebarForChips = Array.from(gridEl.querySelectorAll('aside')).find(
213
- (el) => el.closest('dialog') === null
214
- )!;
215
- expect(sidebarForChips.querySelector(`ul[aria-label="${ACTIVE_FILTERS_LABEL}"]`)).toBeNull();
216
-
217
- applyButton.click();
218
- await wrapper.vm.$nextTick();
219
-
220
- // The visible chip text is just the value's own label; the facet name rides in its remove
221
- // button's own aria-label instead. Both panels now agree (the drawer's own pending copy
222
- // matches the just-applied selection), so the sidebar's own row is found by element rather
223
- // than by the (now ambiguous) aria-label alone.
224
- const chipsEl = sidebarForChips.querySelector(`ul[aria-label="${ACTIVE_FILTERS_LABEL}"]`)!;
225
- expect(chipsEl.textContent).toContain('Oat');
226
- expect(chipsEl.querySelector('[data-part="removeButton"]')!.getAttribute('aria-label')).toBe(
223
+ // No sidebar, no Filter button, no drawer — the bar is the only filter path, at every width.
224
+ expect(gridEl.querySelector('aside')).toBeNull();
225
+ expect(gridEl.querySelector('dialog')).toBeNull();
226
+ expect(
227
+ Array.from(gridEl.querySelectorAll('button')).some(
228
+ (button) => button.textContent?.trim() === 'Filter'
229
+ )
230
+ ).toBe(false);
231
+ // A chip per group (on/off Availability is a pressed chip of its own, not a popover).
232
+ expect(
233
+ Array.from(filterBar(gridEl).querySelectorAll('button[aria-haspopup="dialog"]')).map(
234
+ (button) => button.textContent?.trim()
235
+ )
236
+ ).toEqual(['Category', 'Size', 'Colour', 'Price']);
237
+
238
+ const colour = barTrigger(gridEl, 'Colour');
239
+ expect(colour.getAttribute('aria-expanded')).toBe('false');
240
+ await pressEnter(colour);
241
+ expect(colour.getAttribute('aria-expanded')).toBe('true');
242
+ const panel = popoverOf(colour)!;
243
+ expect(panel).not.toBeNull();
244
+ expect(panel.getAttribute('role')).toBe('dialog');
245
+ expect(panel.getAttribute('aria-label')).toBe('Colour');
246
+ expect(await axe(panel)).toHaveNoViolations();
247
+
248
+ // Oat — the demo catalogue's first colour value — applies at once: its tag appears under the
249
+ // bar and the chip counts it, with nothing left to confirm.
250
+ const oat = panel.querySelectorAll<HTMLInputElement>('input[type="checkbox"]')[0]!;
251
+ oat.focus();
252
+ oat.click();
253
+ await flush();
254
+ const tags = gridEl.querySelector(`ul[aria-label="${ACTIVE_FILTERS_LABEL}"]`)!;
255
+ expect(tags).not.toBeNull();
256
+ expect(tags.textContent).toContain('Oat');
257
+ expect(tags.querySelector('[data-part="removeButton"]')!.getAttribute('aria-label')).toBe(
227
258
  'Remove filter Colour: Oat'
228
259
  );
229
- expect(dialog.getAttribute('open')).toBeNull();
230
-
231
- // Reopen, then Esc closes it and returns focus to the Filter button. Waits out the same two
232
- // ticks as the first open (see above) so the drawer's own initial-focus placement has already
233
- // landed on the close button before Esc is pressed — otherwise that still-pending focus call
234
- // fires *after* Esc's own focus-return and steals it back.
235
- filterButton.click();
236
- await wrapper.vm.$nextTick();
237
- await wrapper.vm.$nextTick();
238
- expect(dialog.getAttribute('open')).toBe('');
239
-
240
- document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }));
241
- await new Promise((resolve) => setTimeout(resolve));
242
- await wrapper.vm.$nextTick();
243
-
244
- expect(dialog.getAttribute('open')).toBeNull();
245
- expect(document.activeElement).toBe(filterButton);
260
+ expect(barTrigger(gridEl, 'Colour').textContent).toContain('1');
261
+
262
+ oat.dispatchEvent(
263
+ new KeyboardEvent('keydown', {
264
+ key: 'Escape',
265
+ bubbles: true,
266
+ cancelable: true,
267
+ })
268
+ );
269
+ await flush();
270
+ expect(popoverOf(colour)).toBeNull();
271
+ expect(colour.getAttribute('aria-expanded')).toBe('false');
272
+ expect(document.activeElement).toBe(colour);
246
273
  });
247
274
 
248
- it('live-applies exactly the three chips Size: M, Colour: Oat and Availability: In stock, in that order, from the sidebar', async () => {
249
- const wrapper = await mountPage(page);
250
- const main = wrapper.get('main#main');
275
+ it('live-applies exactly the three tags Size: M, Colour: Oat and Availability: In stock, in that order, from the filter bar', async () => {
276
+ const wrapper = await mountAttached();
251
277
  const gridEl = pageBlockRoots(wrapper)[3]!;
252
- // The sidebar's own copies of the groups — excluding the drawer's duplicate set, which sits
253
- // inside a `<dialog>` the same page also renders.
254
- const sidebar = Array.from(gridEl.querySelectorAll('aside')).find(
255
- (el) => el.closest('dialog') === null
256
- )!;
257
278
 
258
- // Each tick is awaited before the next: the panel is a *controlled* component now (its own
259
- // `modelValue` prop is the parent's `selection`, round-tripped through a render), so a second
260
- // change read back through a prop that has not re-rendered yet would overwrite the first
261
- // rather than add to it — unlike the old uncontrolled `FilterGroups.vue`, which read the
262
- // parent's own ref directly.
263
- const sizePanel = panelFor(sidebar, 'Size');
264
- // XS, S, M, L, XL — M is the third pill.
265
- checkBox(sizePanel.querySelectorAll<HTMLInputElement>('input[type="checkbox"]')[2]!);
266
- await wrapper.vm.$nextTick();
267
- const colourPanel = panelFor(sidebar, 'Colour');
279
+ // Each change is flushed before the next: the popover's panel is a *controlled* component (its
280
+ // `modelValue` is the grid's selection, round-tripped through a render), so a second change
281
+ // read back through a prop that has not re-rendered yet would overwrite the first rather than
282
+ // add to it.
283
+ // XS, S, M, L, XL — M is the third box in the Size popover.
284
+ await tickInPopover(gridEl, 'Size', 2);
268
285
  // Oat is the demo catalogue's first colour value.
269
- checkBox(colourPanel.querySelectorAll<HTMLInputElement>('input[type="checkbox"]')[0]!);
270
- await wrapper.vm.$nextTick();
271
- // Availability is a `toggle` facet now (a real `<button role="switch">`, not a checkbox).
272
- const availabilityPanel = panelFor(sidebar, 'Availability');
273
- const availabilitySwitch =
274
- availabilityPanel.querySelector<HTMLButtonElement>('[role="switch"]')!;
275
- availabilitySwitch.click();
276
- await wrapper.vm.$nextTick();
277
-
278
- const chips = main.get(`ul[aria-label="${ACTIVE_FILTERS_LABEL}"]`).findAll('li');
286
+ await tickInPopover(gridEl, 'Colour', 0);
287
+ // Availability is an on/off facet: a pressed chip in the bar itself, not a popover.
288
+ const inStock = pressedChip(gridEl, 'In stock only');
289
+ expect(inStock.getAttribute('aria-pressed')).toBe('false');
290
+ inStock.click();
291
+ await flush();
292
+ expect(inStock.getAttribute('aria-pressed')).toBe('true');
293
+
294
+ const chips = wrapper
295
+ .get('main#main')
296
+ .get(`ul[aria-label="${ACTIVE_FILTERS_LABEL}"]`)
297
+ .findAll('li');
279
298
  expect(chips).toHaveLength(3);
280
- // The visible chip text is just the value's own label; the facet rides in each remove
281
- // button's own aria-label.
299
+ // The visible tag text is just the value's own label; the facet rides in each remove button's
300
+ // own aria-label.
282
301
  expect(chips[0]!.text()).toContain('M');
283
302
  expect(chips[0]!.get('[data-part="removeButton"]').attributes('aria-label')).toBe(
284
303
  'Remove filter Size: M'
@@ -291,33 +310,38 @@ describe('collection sample page', () => {
291
310
  expect(chips[2]!.get('[data-part="removeButton"]').attributes('aria-label')).toBe(
292
311
  'Remove filter Availability: In stock only'
293
312
  );
313
+ // The group chips count what each applied.
314
+ expect(barTrigger(gridEl, 'Size').textContent).toContain('1');
315
+ expect(barTrigger(gridEl, 'Colour').textContent).toContain('1');
316
+ expect(
317
+ Array.from(gridEl.querySelectorAll('button')).some(
318
+ (button) => button.textContent?.trim() === 'Clear all'
319
+ )
320
+ ).toBe(true);
321
+
322
+ expect(await axe(wrapper.element)).toHaveNoViolations();
294
323
  });
295
324
 
296
325
  /**
297
- * The panel's own head — **Clear all** and the applied chips — comes before its group triggers
298
- * now (the panel owns applied state), so a chip for an already-ticked filter sits before
299
- * every facet control in the sidebar, including the one that produced it.
326
+ * In `filter-bar` the controls come first — the group chips, the on/off chips, the sort — and the
327
+ * applied tags and Clear all sit *under* the bar beside the count, before the cards. So a tag for
328
+ * an already-applied filter follows every bar control, including the one that produced it (the
329
+ * sidebar put its applied chips at the head of the panel instead).
300
330
  */
301
- it('follows the tab order header → breadcrumbs → Read more → sidebar chips → filters → cards → Load more → call to action → footer', async () => {
331
+ it('follows the tab order header → breadcrumbs → Read more → filter bar → applied tags → Clear all → cards → Load more → call to action → footer', async () => {
302
332
  stubOverflow(200, 100);
303
- const wrapper = await mountPage(page);
304
- const main = wrapper.get('main#main');
333
+ const wrapper = await mountAttached();
305
334
  const [navEl, breadcrumbsEl, headerEl, gridEl, ctaEl, footerEl] = pageBlockRoots(wrapper);
306
335
 
307
- const sidebar = Array.from(gridEl!.querySelectorAll('aside')).find(
308
- (el) => el.closest('dialog') === null
309
- )!;
310
- // Availability → In stock rather than Size → M: the demo source honours `filters` now
336
+ // Availability → In stock rather than Size → M: the demo source honours `filters`
311
337
  // (`app/storefront/demo.ts`), and 44 of this collection's 48 items are in stock, so the grid
312
338
  // still has more than one page and a real Load more button in the tab order — Size → M leaves
313
339
  // 12, i.e. everything already shown, and no Load more at all.
314
- const availabilitySwitch = panelFor(sidebar, 'Availability').querySelector<HTMLButtonElement>(
315
- '[role="switch"]'
316
- )!;
317
- availabilitySwitch.click();
318
- // Ticking a sidebar filter starts a new (demo-async) `collectionProducts` request — the grid
319
- // shows skeletons (an `aria-hidden` list) until it resolves, so this waits for the real card
320
- // list to come back rather than a single `nextTick`.
340
+ const inStock = pressedChip(gridEl!, 'In stock only');
341
+ inStock.click();
342
+ // A filter change starts a new (demo-async) `collectionProducts` request — the grid shows
343
+ // skeletons (an `aria-hidden` list) until it resolves, so this waits for the real card list.
344
+ await flush();
321
345
  await flushPromises();
322
346
 
323
347
  const readMore = Array.from(headerEl!.querySelectorAll('button')).find(
@@ -325,9 +349,15 @@ describe('collection sample page', () => {
325
349
  )!;
326
350
  expect(readMore).toBeDefined();
327
351
 
328
- const chipRemove = main
329
- .get(`ul[aria-label="${ACTIVE_FILTERS_LABEL}"]`)
330
- .element.querySelector('[data-part="removeButton"]')!;
352
+ const firstGroupChip = barTrigger(gridEl!, 'Category');
353
+ const lastGroupChip = barTrigger(gridEl!, 'Price');
354
+ const sort = filterBar(gridEl!).querySelector('[role="combobox"]')!;
355
+ const tagRemove = gridEl!
356
+ .querySelector(`ul[aria-label="${ACTIVE_FILTERS_LABEL}"]`)!
357
+ .querySelector('[data-part="removeButton"]')!;
358
+ const clearAll = Array.from(gridEl!.querySelectorAll('button')).find(
359
+ (button) => button.textContent?.trim() === 'Clear all'
360
+ )!;
331
361
  const firstCardLink = gridEl!.querySelector(
332
362
  'ul[aria-labelledby]:not([aria-hidden]) li a[href]'
333
363
  )!;
@@ -337,8 +367,8 @@ describe('collection sample page', () => {
337
367
  )!;
338
368
  const footerFirstLink = footerEl!.querySelector('a[href]')!;
339
369
 
340
- // Whole page, not just `<main>`: the header block is a sibling of it now, and its own controls
341
- // are the first stop in the page's tab order.
370
+ // Whole page, not just `<main>`: the header block is a sibling of it, and its own controls are
371
+ // the first stop in the page's tab order.
342
372
  const focusable = Array.from(
343
373
  wrapper.element.querySelectorAll<HTMLElement>('a[href], button, input, [tabindex]')
344
374
  ).filter((el) => el.getAttribute('tabindex') !== '-1' && el.closest('dialog') === null);
@@ -352,9 +382,13 @@ describe('collection sample page', () => {
352
382
  expect(indexOf(navFirst)).toBeGreaterThanOrEqual(0);
353
383
  expect(indexOf(navFirst)).toBeLessThan(indexOf(breadcrumbShopLink));
354
384
  expect(indexOf(breadcrumbShopLink)).toBeLessThan(indexOf(readMore));
355
- expect(indexOf(readMore)).toBeLessThan(indexOf(chipRemove));
356
- expect(indexOf(chipRemove)).toBeLessThan(indexOf(availabilitySwitch));
357
- expect(indexOf(chipRemove)).toBeLessThan(indexOf(firstCardLink));
385
+ expect(indexOf(readMore)).toBeLessThan(indexOf(firstGroupChip));
386
+ expect(indexOf(firstGroupChip)).toBeLessThan(indexOf(lastGroupChip));
387
+ expect(indexOf(lastGroupChip)).toBeLessThan(indexOf(inStock));
388
+ expect(indexOf(inStock)).toBeLessThan(indexOf(sort));
389
+ expect(indexOf(sort)).toBeLessThan(indexOf(tagRemove));
390
+ expect(indexOf(tagRemove)).toBeLessThan(indexOf(clearAll));
391
+ expect(indexOf(clearAll)).toBeLessThan(indexOf(firstCardLink));
358
392
  expect(indexOf(firstCardLink)).toBeLessThan(indexOf(loadMoreButton));
359
393
  expect(indexOf(loadMoreButton)).toBeLessThan(indexOf(ctaButton));
360
394
  expect(indexOf(ctaButton)).toBeLessThan(indexOf(footerFirstLink));
@@ -20,13 +20,13 @@ import fixture from '../../pages/home.page.json';
20
20
  const homeFixture = fixture as PageFixture;
21
21
 
22
22
  const EXPECTED_APIID_ORDER = [
23
- 'announcement-bar',
24
23
  'navigation',
25
24
  'hero',
26
25
  'trust-strip',
26
+ 'feature-grid',
27
27
  'product-carousel',
28
28
  'split-content',
29
- 'testimonials',
29
+ 'article-list',
30
30
  'newsletter',
31
31
  'footer',
32
32
  ];
@@ -35,8 +35,10 @@ const EXPECTED_APIID_ORDER = [
35
35
  // `data-section-bg` regardless of colour (`@eldrajs/ui`'s `Section.vue`), and the CSS rule that
36
36
  // drops a repeated ground's top padding keys off two *adjacent* siblings sharing that same value
37
37
  // (`packages/ui/src/__tests__/sectionAdjacentBackground.spec.ts`) — so this exact sequence is both
38
- // "which ground each block sits on" and "where the padding collapses" (index 4→5 and 5→6, the only
39
- // repeated neighbours, are Product carousel→Split content and Split content→Testimonials).
38
+ // "which ground each block sits on" and "where the padding collapses": the hero, the numbered
39
+ // promises, the category arches and the new arrivals share the page's own ground, so each one after
40
+ // the hero drops its top padding; the makers band on `surface` keeps its own, and the journal and the
41
+ // help + newsletter band after it collapse into each other again.
40
42
  //
41
43
  // `navigation` (the header) is `null`, not `'none'`: it is fixed chrome, not a `Section` (spec
42
44
  // "Header": it must never take part in the adjacent-background collapse rule, so the Hero right
@@ -44,15 +46,15 @@ const EXPECTED_APIID_ORDER = [
44
46
  // comment on `barRootClasses`). Because it carries no `data-section-bg` at all, it can never match
45
47
  // the Hero's `'none'` even though both sit on the same visual ground.
46
48
  const EXPECTED_SECTION_BACKGROUNDS = [
47
- 'primary', // announcement-bar
48
49
  null, // navigation (header) — not a Section; never collapses the Hero's top padding
49
- 'none', // hero — keeps its own full top padding after the header
50
- 'surface', // trust-strip
51
- 'none', // product-carousel
52
- 'none', // split-content — same ground as product-carousel: top padding collapses
53
- 'none', // testimonials — same ground as split-content: top padding collapses
54
- 'surface', // newsletter
55
- 'surface-strong', // footer
50
+ 'none', // hero (card) — keeps its own full top padding after the header
51
+ 'none', // trust-strip (numbered)
52
+ 'none', // feature-grid (arched categories)
53
+ 'none', // product-carousel (new arrivals)
54
+ 'surface', // split-content (the makers)
55
+ 'none', // article-list (the journal)
56
+ 'none', // newsletter (help + sign-up band; the band paints its own panels)
57
+ 'primary', // footer
56
58
  ];
57
59
 
58
60
  describe('home page (pages/home.page.json)', () => {
@@ -68,20 +70,8 @@ describe('home page (pages/home.page.json)', () => {
68
70
  // Each root identified by a stable marker that block already emits itself: the section's own
69
71
  // `aria-labelledby`/`aria-label` target text (read off the rendered heading, not re-typed), or
70
72
  // the landmark tag for header/footer.
71
- const [
72
- announcement,
73
- header,
74
- hero,
75
- trustStrip,
76
- carousel,
77
- split,
78
- testimonials,
79
- newsletter,
80
- footer,
81
- ] = roots;
82
-
83
- expect(announcement.tagName).toBe('SECTION');
84
- expect(announcement.textContent).toContain('Free shipping on orders over $80');
73
+ const [header, hero, trustStrip, categories, carousel, split, journal, newsletter, footer] =
74
+ roots;
85
75
 
86
76
  expect(header.tagName).toBe('HEADER');
87
77
  expect(header.querySelector('[data-eldra-header-focus]')).not.toBeNull();
@@ -90,13 +80,19 @@ describe('home page (pages/home.page.json)', () => {
90
80
 
91
81
  expect(trustStrip.textContent).toContain('Why shop with Northwind');
92
82
 
93
- expect(carousel.querySelector('h2')?.textContent).toBe('New this season');
83
+ expect(categories.querySelector('h2')?.textContent).toBe('Shop by category');
84
+
85
+ expect(carousel.querySelector('h2')?.textContent).toBe('New arrivals');
94
86
 
95
87
  expect(split.getAttribute('aria-label')).toBe('Our story');
96
88
 
97
- expect(testimonials.querySelector('h2')?.textContent).toBe('Used every day, reviewed honestly');
89
+ expect(journal.querySelector('h2')?.textContent).toBe('From the journal');
98
90
 
99
- expect(newsletter.querySelector('h2')?.textContent).toBe('Letters from the workshop');
91
+ // The band's two panels: help on the left, the sign-up on the right.
92
+ expect([...newsletter.querySelectorAll('h2')].map((el) => el.textContent)).toEqual([
93
+ 'Questions before you buy?',
94
+ 'Letters from the workshop',
95
+ ]);
100
96
 
101
97
  expect(footer.tagName).toBe('FOOTER');
102
98
 
@@ -108,7 +104,7 @@ describe('home page (pages/home.page.json)', () => {
108
104
 
109
105
  it("keeps the hero's full top padding after the header (header takes no part in the adjacent-background collapse rule)", async () => {
110
106
  const wrapper = await mountPage(homeFixture);
111
- const [, header, hero] = pageBlockRoots(wrapper);
107
+ const [header, hero] = pageBlockRoots(wrapper);
112
108
 
113
109
  expect(header!.hasAttribute('data-section-bg')).toBe(false);
114
110
  expect(header!.hasAttribute('data-section')).toBe(false);
@@ -120,8 +116,8 @@ describe('home page (pages/home.page.json)', () => {
120
116
  const main = wrapper.get('main#main');
121
117
  const roots = pageBlockRoots(wrapper);
122
118
 
123
- // trust-strip `columns` (not `inline`): the per-item body line only renders in `columns`.
124
- expect(main.text()).toContain('Delivered in 2–4 business days, carbon-neutral.');
119
+ // trust-strip `numbered`: each promise's body line renders under its number.
120
+ expect(main.text()).toContain('Every piece comes from one of nine workshops.');
125
121
 
126
122
  // product-carousel `collection`, sourced through the seed form of a reference:
127
123
  // `sourceCollection: { _type: "collection", slug: "the-winter-edit" }`, the only form a theme
@@ -149,16 +145,15 @@ describe('home page (pages/home.page.json)', () => {
149
145
  expect(carouselData.sourceCollection).toEqual({ _type: 'collection', slug: 'the-winter-edit' });
150
146
  expect(Object.hasOwn(carouselData, 'sourceHandle')).toBe(false);
151
147
 
152
- // split-content `startWith: "image-left"`: row 1's image sits on the left (no reorder class),
153
- // row 2 alternates to the right (`@tablet:order-2`) — the visual side only `startWith` decides.
154
- const splitRows = roots[5].querySelectorAll('li');
155
- expect(splitRows).toHaveLength(2);
148
+ // split-content: one makers row, its image on the left (`startWith: "image-left"`, no reorder
149
+ // class), and the block-level `list` of three makers under the row's text.
150
+ const splitRows = roots[5].querySelectorAll(':scope ol > li');
151
+ expect(splitRows).toHaveLength(1);
156
152
  expect(splitRows[0]!.children[0]?.className).not.toContain('order-2');
157
- expect(splitRows[1]!.children[0]?.className).toContain('order-2');
153
+ expect(roots[5].textContent).toContain('Harbour Pottery');
158
154
 
159
- // testimonials `grid`, first three items only.
160
- const names = [...roots[6].querySelectorAll('cite')].map((el) => el.textContent);
161
- expect(names).toEqual(['Hannah Reeve', 'Marcus Bell', 'Priya Nair']);
155
+ // article-list: the three journal stories the fixture names.
156
+ expect(roots[6].querySelectorAll('h3')).toHaveLength(3);
162
157
 
163
158
  // footer `showNewsletter: false`: its own newsletter copy never renders.
164
159
  expect(roots[8].textContent).not.toContain('New pieces, maker stories');
@@ -468,8 +468,8 @@ describe('hydrating a prerendered commerce block', () => {
468
468
 
469
469
  const html = await renderBlockHtml(Navigation, entry);
470
470
  // The heart is in the file — it is nobody's state — and its name has no number in it.
471
- expect(html).toContain('aria-label="Wishlist"');
472
- expect(html).not.toContain('Wishlist, 1 item');
471
+ expect(html).toContain('aria-label="Saved"');
472
+ expect(html).not.toContain('Saved, 1 item');
473
473
 
474
474
  const run = hydrateBlock(Navigation, entry, html);
475
475
  runs.push(run);
@@ -478,13 +478,13 @@ describe('hydrating a prerendered commerce block', () => {
478
478
  expect(withoutPackageEnhancement(run.firstPaint)).toBe(
479
479
  withoutPackageEnhancement(run.expected)
480
480
  );
481
- expect(run.firstPaint).not.toContain('Wishlist, 1 item');
481
+ expect(run.firstPaint).not.toContain('Saved, 1 item');
482
482
 
483
483
  // `onMounted` ran inside the mount; the render it queued is the next tick, and the store's
484
484
  // read reaches the count through one more.
485
485
  await nextTick();
486
486
  await nextTick();
487
- expect(run.container.innerHTML).toContain('Wishlist, 1 item');
487
+ expect(run.container.innerHTML).toContain('Saved, 1 item');
488
488
  expect(run.container.innerHTML).toContain('href="/wishlist"');
489
489
  });
490
490