@eldrajs/theme-cli 0.2.7 → 0.2.9
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.
- package/CHANGELOG.md +2 -0
- package/package.json +3 -3
- package/template/.eldra/block-types.d.ts +28 -7
- package/template/.eldra/manifest.json +1152 -445
- package/template/.eldra/previews.json +35 -35
- package/template/README.md +32 -0
- package/template/app/assets/main.css +23 -0
- package/template/app/plugins/eldra-storefront.ts +3 -0
- package/template/app/storefront/demo.ts +75 -24
- package/template/app/storefront/gateway.ts +16 -2
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/preview.json +4 -4
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/Block.vue +48 -19
- package/template/blocks/article-list/__tests__/Block.spec.ts +15 -0
- package/template/blocks/article-list/preview.json +43 -43
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/preview.png +0 -0
- package/template/blocks/cart/preview.png +0 -0
- package/template/blocks/collection-grid/Block.vue +260 -9
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +202 -0
- package/template/blocks/collection-grid/block.json +3 -3
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/Block.vue +65 -52
- package/template/blocks/collection-header/preview.json +4 -4
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/preview.json +4 -4
- package/template/blocks/cta/preview.png +0 -0
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/Block.vue +73 -4
- package/template/blocks/feature-grid/__tests__/Block.spec.ts +43 -1
- package/template/blocks/feature-grid/block.json +2 -2
- package/template/blocks/feature-grid/preview.json +49 -24
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +186 -71
- package/template/blocks/footer/__tests__/Block.spec.ts +127 -32
- package/template/blocks/footer/block.json +42 -4
- package/template/blocks/footer/mock.json +31 -34
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/form/preview.png +0 -0
- package/template/blocks/gallery/preview.json +24 -24
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/Block.vue +117 -19
- package/template/blocks/hero/__tests__/Block.spec.ts +46 -0
- package/template/blocks/hero/block.json +36 -1
- package/template/blocks/hero/preview.json +33 -25
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/preview.json +4 -4
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +665 -184
- package/template/blocks/navigation/__tests__/Block.spec.ts +496 -75
- package/template/blocks/navigation/__tests__/fixtures/menu.json +182 -0
- package/template/blocks/navigation/block.json +110 -6
- package/template/blocks/navigation/mock.json +372 -140
- package/template/blocks/navigation/preview.json +311 -0
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/newsletter/Block.vue +248 -144
- package/template/blocks/newsletter/__tests__/Block.spec.ts +42 -0
- package/template/blocks/newsletter/block.json +61 -2
- package/template/blocks/newsletter/preview.json +35 -0
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/preview.png +0 -0
- package/template/blocks/pricing-table/preview.png +0 -0
- package/template/blocks/product-carousel/Block.vue +272 -26
- package/template/blocks/product-carousel/__tests__/Block.spec.ts +90 -0
- package/template/blocks/product-carousel/block.json +61 -0
- package/template/blocks/product-carousel/preview.json +12 -0
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/Block.vue +148 -96
- package/template/blocks/product-detail/__tests__/Block.spec.ts +98 -74
- package/template/blocks/product-detail/block.json +11 -4
- package/template/blocks/product-detail/mock.json +53 -22
- package/template/blocks/product-detail/parts/Gallery.vue +52 -103
- package/template/blocks/product-detail/preview.png +0 -0
- package/template/blocks/quote/preview.png +0 -0
- package/template/blocks/rich-text/preview.png +0 -0
- package/template/blocks/search/Block.vue +1 -0
- package/template/blocks/search/TypeSection.vue +1 -0
- package/template/blocks/search/__tests__/Block.spec.ts +23 -0
- package/template/blocks/search/preview.png +0 -0
- package/template/blocks/split-content/Block.vue +98 -20
- package/template/blocks/split-content/__tests__/Block.spec.ts +57 -18
- package/template/blocks/split-content/block.json +72 -6
- package/template/blocks/split-content/preview.json +34 -13
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/preview.json +16 -16
- package/template/blocks/tabs/preview.png +0 -0
- package/template/blocks/team/preview.png +0 -0
- package/template/blocks/testimonials/preview.png +0 -0
- package/template/blocks/timeline/preview.png +0 -0
- package/template/blocks/trust-strip/Block.vue +67 -1
- package/template/blocks/trust-strip/__tests__/Block.spec.ts +30 -1
- package/template/blocks/trust-strip/block.json +4 -4
- package/template/blocks/trust-strip/preview.json +21 -0
- package/template/blocks/trust-strip/preview.png +0 -0
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/preview.png +0 -0
- package/template/i18n/en-US.json +16 -9
- package/template/i18n/is-IS.json +16 -9
- package/template/package.json +1 -1
- package/template/pages/article.page.json +19 -18
- package/template/pages/cart.page.json +3 -13
- package/template/pages/category.page.json +15 -7
- package/template/pages/collection.page.json +15 -14
- package/template/pages/home.page.json +217 -182
- package/template/pages/product.page.json +46 -36
- package/template/pages/products.page.json +3 -13
- package/template/pages/search.page.json +3 -13
- package/template/pages/wishlist.page.json +3 -13
- package/template/public/images/CREDITS.md +28 -0
- package/template/public/images/bowl.webp +0 -0
- package/template/public/images/clay-hands.webp +0 -0
- package/template/public/images/coffee-table.webp +0 -0
- package/template/public/images/cup.webp +0 -0
- package/template/public/images/enamel-cups.webp +0 -0
- package/template/public/images/hero.webp +0 -0
- package/template/public/images/kitchen.webp +0 -0
- package/template/public/images/mug.webp +0 -0
- package/template/public/images/northwind-mark.svg +1 -0
- package/template/public/images/planters.webp +0 -0
- package/template/public/images/plates.webp +0 -0
- package/template/public/images/reading.webp +0 -0
- package/template/public/images/sweater.webp +0 -0
- package/template/public/images/terracotta.webp +0 -0
- package/template/public/images/throws.webp +0 -0
- package/template/public/images/vase.webp +0 -0
- package/template/public/images/wheel.webp +0 -0
- package/template/public/images/yarn-tools.webp +0 -0
- package/template/public/images/yarn.webp +0 -0
- package/template/stories/generated/collection-grid.stories.ts +6 -0
- package/template/stories/generated/feature-grid.stories.ts +6 -0
- package/template/stories/generated/footer.stories.ts +4 -4
- package/template/stories/generated/hero.stories.ts +6 -0
- package/template/stories/generated/navigation.stories.ts +14 -1
- package/template/stories/generated/newsletter.stories.ts +2 -1
- package/template/stories/generated/product-carousel.stories.ts +12 -0
- package/template/stories/generated/split-content.stories.ts +12 -0
- package/template/stories/generated/trust-strip.stories.ts +8 -1
- package/template/stories/pages/article.stories.ts +2 -1
- package/template/stories/pages/cart.stories.ts +2 -1
- package/template/stories/pages/category.stories.ts +2 -1
- package/template/stories/pages/collection.stories.ts +2 -1
- package/template/stories/pages/home.stories.ts +2 -1
- package/template/stories/pages/product.stories.ts +2 -1
- package/template/stories/pages/products.stories.ts +2 -1
- package/template/stories/pages/search.stories.ts +2 -1
- package/template/stories/pages/wishlist.stories.ts +2 -1
- package/template/stories/support/demoChrome.ts +32 -0
- package/template/stories/support/pageBlocks.ts +2 -4
- package/template/test/countPill.browser.spec.ts +21 -13
- package/template/test/localePrefix.spec.ts +11 -6
- package/template/test/pages/article.spec.ts +1 -1
- package/template/test/pages/category.spec.ts +34 -11
- package/template/test/pages/collection.spec.ts +182 -148
- package/template/test/pages/home.spec.ts +35 -40
- package/template/test/pages/hydration.spec.ts +4 -4
- package/template/test/pages/product.spec.ts +17 -14
- package/template/test/pages/seededPages.spec.ts +11 -6
- package/template/test/prerenderFailure.spec.ts +4 -3
- package/template/test/prerenderRefresh.browser.spec.ts +36 -15
- package/template/test/previewParity.browser.spec.ts +1152 -0
- package/template/test/starter.spec.ts +37 -16
- package/template/test/storefront/gatewayPrerender.spec.ts +26 -0
- package/template/test/support/previewParity.ts +302 -0
- package/template/test/support/previewParityContent.ts +726 -0
- 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
|
|
63
|
-
* reflects reality for a node that is actually in the live document —
|
|
64
|
-
*
|
|
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-
|
|
74
|
-
* `collection-grid`'s own spec keys off
|
|
75
|
-
function
|
|
76
|
-
|
|
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
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
*
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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', '
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
)
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
)!;
|
|
215
|
-
expect(
|
|
216
|
-
|
|
217
|
-
|
|
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(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
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
|
|
249
|
-
const wrapper = await
|
|
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
|
|
259
|
-
// `modelValue`
|
|
260
|
-
//
|
|
261
|
-
//
|
|
262
|
-
//
|
|
263
|
-
|
|
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
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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
|
|
281
|
-
//
|
|
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
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
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 →
|
|
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
|
|
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
|
-
|
|
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
|
|
315
|
-
|
|
316
|
-
)
|
|
317
|
-
|
|
318
|
-
|
|
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
|
|
329
|
-
|
|
330
|
-
|
|
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
|
|
341
|
-
//
|
|
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(
|
|
356
|
-
expect(indexOf(
|
|
357
|
-
expect(indexOf(
|
|
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
|
-
'
|
|
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"
|
|
39
|
-
//
|
|
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
|
-
'
|
|
51
|
-
'none', //
|
|
52
|
-
'none', //
|
|
53
|
-
'
|
|
54
|
-
'
|
|
55
|
-
'
|
|
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
|
-
|
|
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(
|
|
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(
|
|
89
|
+
expect(journal.querySelector('h2')?.textContent).toBe('From the journal');
|
|
98
90
|
|
|
99
|
-
|
|
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 [
|
|
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 `
|
|
124
|
-
expect(main.text()).toContain('
|
|
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
|
|
153
|
-
//
|
|
154
|
-
const splitRows = roots[5].querySelectorAll('li');
|
|
155
|
-
expect(splitRows).toHaveLength(
|
|
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(
|
|
153
|
+
expect(roots[5].textContent).toContain('Harbour Pottery');
|
|
158
154
|
|
|
159
|
-
//
|
|
160
|
-
|
|
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="
|
|
472
|
-
expect(html).not.toContain('
|
|
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('
|
|
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('
|
|
487
|
+
expect(run.container.innerHTML).toContain('Saved, 1 item');
|
|
488
488
|
expect(run.container.innerHTML).toContain('href="/wishlist"');
|
|
489
489
|
});
|
|
490
490
|
|