@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,9 +1,9 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
2
|
//
|
|
3
|
-
// The product sample page (`pages/product.page.json`):
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
3
|
+
// The product sample page (`pages/product.page.json`): header, breadcrumbs, the product-detail
|
|
4
|
+
// buy box for "Merino crew sweater", a related-products carousel, an FAQ and the footer, rendered
|
|
5
|
+
// together through `mountPage` exactly as `app/pages/[...slug].vue` renders a real page: the
|
|
6
|
+
// leading structure block (the header, which carries its own info strip) before `<main id="main">`,
|
|
7
7
|
// everything else inside it, the footer after it — see `app/utils/pageStructure.ts`.
|
|
8
8
|
//
|
|
9
9
|
// Carousel counts are read off the real demo storefront (`app/storefront/demo.ts`), not assumed:
|
|
@@ -45,13 +45,14 @@ async function mountProductPage() {
|
|
|
45
45
|
* drawer — the seeded header has nothing to put in one, so it draws neither the Menu button nor the
|
|
46
46
|
* drawer (see `withAuthoredHeaderLink`). */
|
|
47
47
|
async function mountProductPageWithHeaderLink() {
|
|
48
|
-
return mountPage(withAuthoredHeaderLink(fixture), {
|
|
48
|
+
return mountPage(withAuthoredHeaderLink(fixture), {
|
|
49
|
+
attachTo: document.body,
|
|
50
|
+
});
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
describe('product sample page', () => {
|
|
52
54
|
it('is composed of exactly the fixture blocks, in the documented order', () => {
|
|
53
55
|
expect(fixture.blocks.map((b) => b.apiId)).toEqual([
|
|
54
|
-
'announcement-bar',
|
|
55
56
|
'navigation',
|
|
56
57
|
'breadcrumbs',
|
|
57
58
|
'product-detail',
|
|
@@ -70,7 +71,6 @@ describe('product sample page', () => {
|
|
|
70
71
|
// `test/support/mountPage.spec.ts`'s own html.indexOf pattern).
|
|
71
72
|
const html = wrapper.html();
|
|
72
73
|
const markers = [
|
|
73
|
-
'Free shipping on orders over $80', // announcement-bar
|
|
74
74
|
'data-eldra-header-focus', // navigation
|
|
75
75
|
'aria-label="Breadcrumb"', // breadcrumbs
|
|
76
76
|
'aria-label="Product images"', // product-detail (gallery)
|
|
@@ -173,11 +173,11 @@ describe('product sample page', () => {
|
|
|
173
173
|
|
|
174
174
|
it('shares the same ground across product-detail, the carousel and the FAQ, with only the footer changing it', async () => {
|
|
175
175
|
const wrapper = await mountProductPage();
|
|
176
|
-
const [, ,
|
|
176
|
+
const [, , productDetail, carousel, faq, footer] = pageBlockRoots(wrapper);
|
|
177
177
|
expect(productDetail!.getAttribute('data-section-bg')).toBe('none');
|
|
178
178
|
expect(carousel!.getAttribute('data-section-bg')).toBe('none');
|
|
179
179
|
expect(faq!.getAttribute('data-section-bg')).toBe('none');
|
|
180
|
-
expect(footer!.getAttribute('data-section-bg')).toBe('
|
|
180
|
+
expect(footer!.getAttribute('data-section-bg')).toBe('primary');
|
|
181
181
|
// Adjacency (not just value) is what the package's CSS rule keys off:
|
|
182
182
|
expect(productDetail!.nextElementSibling).toBe(carousel);
|
|
183
183
|
expect(carousel!.nextElementSibling).toBe(faq);
|
|
@@ -217,7 +217,7 @@ describe('product sample page', () => {
|
|
|
217
217
|
describe('modals', () => {
|
|
218
218
|
it('menu drawer: opens as a dialog and Esc returns focus to the menu button', async () => {
|
|
219
219
|
const wrapper = await mountProductPageWithHeaderLink();
|
|
220
|
-
const menuButton = wrapper.get('button[aria-label="
|
|
220
|
+
const menuButton = wrapper.get('button[aria-label="Menu"]');
|
|
221
221
|
menuButton.element.focus();
|
|
222
222
|
await menuButton.trigger('click');
|
|
223
223
|
const dialog = wrapper.get('dialog[open]');
|
|
@@ -234,7 +234,10 @@ describe('product sample page', () => {
|
|
|
234
234
|
|
|
235
235
|
it('search: opens as a dialog and Esc returns focus to the search button', async () => {
|
|
236
236
|
const wrapper = await mountProductPage();
|
|
237
|
-
|
|
237
|
+
// The labelled Search tool, named by its visible label.
|
|
238
|
+
const searchButton = wrapper
|
|
239
|
+
.findAll('button')
|
|
240
|
+
.find((button) => button.text().trim() === 'Search')!;
|
|
238
241
|
searchButton.element.focus();
|
|
239
242
|
await searchButton.trigger('click');
|
|
240
243
|
expect(wrapper.findAll('dialog[open]').length).toBeGreaterThan(0);
|
|
@@ -248,9 +251,9 @@ describe('product sample page', () => {
|
|
|
248
251
|
wrapper.unmount();
|
|
249
252
|
});
|
|
250
253
|
|
|
251
|
-
it('lightbox: opens from
|
|
254
|
+
it('lightbox: opens from a mosaic tile and Esc returns focus to that tile', async () => {
|
|
252
255
|
const wrapper = await mountProductPage();
|
|
253
|
-
const zoomButton = wrapper.get('button[aria-haspopup="dialog"][aria-label^="
|
|
256
|
+
const zoomButton = wrapper.get('button[aria-haspopup="dialog"][aria-label^="Open image"]');
|
|
254
257
|
zoomButton.element.focus();
|
|
255
258
|
await zoomButton.trigger('click');
|
|
256
259
|
const dialog = wrapper.get('dialog[aria-label="Merino crew sweater, images"]');
|
|
@@ -312,7 +315,7 @@ describe('product sample page', () => {
|
|
|
312
315
|
});
|
|
313
316
|
|
|
314
317
|
it('exposes exactly one banner, one main and one contentinfo landmark', async () => {
|
|
315
|
-
// The
|
|
318
|
+
// The header renders before `<main id="main">` and the footer after it
|
|
316
319
|
// (`app/utils/pageStructure.ts`), which is the only way `<header>`/`<footer>` map to the
|
|
317
320
|
// `banner`/`contentinfo` roles at all.
|
|
318
321
|
const wrapper = await mountProductPage();
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// (`pages/{cart,wishlist,search,products}.page.json`, `app/templates.ts`'s `starterPages()`).
|
|
6
6
|
//
|
|
7
7
|
// One spec for all three rather than three near-identical files: they are the same page by design —
|
|
8
|
-
//
|
|
8
|
+
// the shared header (which carries its own info strip), breadcrumbs, the one block the page exists for, a
|
|
9
9
|
// recently-viewed carousel, the shared footer — and what each of them is *for* is the block in the
|
|
10
10
|
// middle. The per-page table below is the whole difference.
|
|
11
11
|
//
|
|
@@ -86,7 +86,6 @@ const PAGES: SeededPage[] = [
|
|
|
86
86
|
|
|
87
87
|
function expectedApiIds(page: SeededPage): string[] {
|
|
88
88
|
return [
|
|
89
|
-
'announcement-bar',
|
|
90
89
|
'navigation',
|
|
91
90
|
'breadcrumbs',
|
|
92
91
|
...(page.above === undefined ? [] : [page.above]),
|
|
@@ -111,10 +110,13 @@ describe.each(PAGES)('the seeded $slug page', (page) => {
|
|
|
111
110
|
|
|
112
111
|
const roots = pageBlockRoots(wrapper);
|
|
113
112
|
expect(roots).toHaveLength(expectedApiIds(page).length);
|
|
114
|
-
|
|
113
|
+
// Indexed off the expected order rather than literal positions, so a block added or removed
|
|
114
|
+
// ahead of them cannot silently point these at the wrong root.
|
|
115
|
+
const ids = expectedApiIds(page);
|
|
116
|
+
expect(roots[ids.indexOf('navigation')]!.tagName).toBe('HEADER');
|
|
115
117
|
expect(roots.at(-1)!.tagName).toBe('FOOTER');
|
|
116
118
|
// Breadcrumbs stays inside `<main>`: it renders a `<nav>`, a landmark wherever it sits.
|
|
117
|
-
expect(roots[
|
|
119
|
+
expect(roots[ids.indexOf('breadcrumbs')]!.querySelector('nav[aria-label]')).not.toBeNull();
|
|
118
120
|
});
|
|
119
121
|
|
|
120
122
|
it('has exactly one h1, and it is the block that owns the page’s title', async () => {
|
|
@@ -153,7 +155,7 @@ describe('the page seeds built from those fixtures', () => {
|
|
|
153
155
|
for (const [index, seed] of seeds.entries()) {
|
|
154
156
|
const page = PAGES[index]!;
|
|
155
157
|
expect(seed.title).toBe(page.title);
|
|
156
|
-
// The
|
|
158
|
+
// The header leads, exactly as the fixture has it: a region is a
|
|
157
159
|
// placement in the page's own order, not a frame around it.
|
|
158
160
|
expect(
|
|
159
161
|
seed.blocks.map((entry) => ('role' in entry ? `@${entry.role}` : entry.apiId))
|
|
@@ -171,7 +173,10 @@ describe('the page seeds built from those fixtures', () => {
|
|
|
171
173
|
(entry) => 'required' in entry && entry.required === true
|
|
172
174
|
);
|
|
173
175
|
expect(required).toHaveLength(1);
|
|
174
|
-
expect(required[0]).toMatchObject({
|
|
176
|
+
expect(required[0]).toMatchObject({
|
|
177
|
+
apiId: PAGES[index]!.fixed,
|
|
178
|
+
required: true,
|
|
179
|
+
});
|
|
175
180
|
}
|
|
176
181
|
});
|
|
177
182
|
|
|
@@ -111,10 +111,11 @@ describe('a prerendered route whose resolution failed', () => {
|
|
|
111
111
|
it('fails the build over it, rather than exiting 0 with the page missing', () => {
|
|
112
112
|
// `nitro.prerender.failOnError` (`nuxt.config.ts`) is the half that makes the *absence* loud:
|
|
113
113
|
// without it the generate still exits 0 and an artifact with a hole in its catalogue is
|
|
114
|
-
// deployable.
|
|
115
|
-
// build's console rather than in what `nuxi generate` hands back here.
|
|
114
|
+
// deployable. Nitro 2.14 (Nuxt 4.7) names each failed route in the output, with its status.
|
|
116
115
|
expect(generated.exitCode).not.toBe(0);
|
|
117
|
-
|
|
116
|
+
const printed = `${generated.stdout}\n${generated.stderr}`;
|
|
117
|
+
expect(printed).toMatch(/Failed to prerender \d+ routes?/);
|
|
118
|
+
expect(printed).toContain('/collections/the-winter-edit (500 Eldra route resolution failed)');
|
|
118
119
|
});
|
|
119
120
|
|
|
120
121
|
it('still writes every route the gateway could answer', () => {
|
|
@@ -314,7 +314,7 @@ interface GridState {
|
|
|
314
314
|
const GRID_SECTION = 'section[aria-label="The winter edit products"]';
|
|
315
315
|
|
|
316
316
|
function readGrid(page: Page): Promise<GridState> {
|
|
317
|
-
return page.evaluate((selector) => {
|
|
317
|
+
return page.evaluate(async (selector) => {
|
|
318
318
|
const section = document.querySelector(selector);
|
|
319
319
|
// `aria-labelledby`, not any `ul`: that is the grid's own card list. The active-filter chips
|
|
320
320
|
// are a `ul[aria-label]` in the same section, and they only exist once something is filtered.
|
|
@@ -324,9 +324,24 @@ function readGrid(page: Page): Promise<GridState> {
|
|
|
324
324
|
const status = [...(section?.querySelectorAll('p[role="status"]') ?? [])]
|
|
325
325
|
.map((node) => (node as HTMLElement).textContent?.trim() ?? '')
|
|
326
326
|
.filter((text) => text !== '');
|
|
327
|
-
const
|
|
328
|
-
(
|
|
329
|
-
|
|
327
|
+
const thumbs = (root: ParentNode | null): string[] =>
|
|
328
|
+
[...(root?.querySelectorAll('[role="slider"]') ?? [])].map(
|
|
329
|
+
(thumb) => thumb.getAttribute('aria-valuenow') ?? ''
|
|
330
|
+
);
|
|
331
|
+
// The sidebar shows its price thumbs all the time. The filter bar (the collection page's
|
|
332
|
+
// variant) keeps them in the Price chip's popover, which only renders while it is open, so the
|
|
333
|
+
// chip is opened to read them and closed again.
|
|
334
|
+
let price = thumbs(section?.querySelector('aside') ?? null);
|
|
335
|
+
const priceChip = [
|
|
336
|
+
...(section?.querySelectorAll('[role="group"] button[aria-controls]') ?? []),
|
|
337
|
+
].find((button) => (button.textContent ?? '').trim().startsWith('Price'));
|
|
338
|
+
if (price.length === 0 && priceChip instanceof HTMLElement) {
|
|
339
|
+
priceChip.click();
|
|
340
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
341
|
+
price = thumbs(document.getElementById(priceChip.getAttribute('aria-controls') ?? ''));
|
|
342
|
+
priceChip.click();
|
|
343
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
344
|
+
}
|
|
330
345
|
return { titles, count: status[0] ?? '', price };
|
|
331
346
|
}, GRID_SECTION);
|
|
332
347
|
}
|
|
@@ -674,8 +689,8 @@ describe('prerendered commerce data on the generated static site', () => {
|
|
|
674
689
|
// case would keep passing while quietly testing nothing.
|
|
675
690
|
expect(visited.url).toBe(`${statics.origin}${productPage}/`);
|
|
676
691
|
const instances = blockInstances(visited);
|
|
677
|
-
// The page's own
|
|
678
|
-
expect(Object.keys(instances.created).length).toBe(
|
|
692
|
+
// The page's own six, plus the shell's hosted cart drawer (see the control above).
|
|
693
|
+
expect(Object.keys(instances.created).length).toBe(7);
|
|
679
694
|
// The page is served at `/products/ash-glaze-mug/` and prerendered at
|
|
680
695
|
// `/products/ash-glaze-mug` (`startStaticServer`'s 308 is the deployed host's). Nuxt therefore
|
|
681
696
|
// re-navigates between the two while the page hydrates, and unless the route key and the page
|
|
@@ -731,11 +746,12 @@ describe('prerendered commerce data on the generated static site', () => {
|
|
|
731
746
|
}
|
|
732
747
|
});
|
|
733
748
|
|
|
734
|
-
it("opens a mega-menu that spans the header's container, whichever item opened it", async () => {
|
|
749
|
+
it("opens a mega-menu that spans the header, its columns in the bar's container, whichever item opened it", async () => {
|
|
735
750
|
// Geometry only a real browser can answer. The panel used to be pinned to the item that
|
|
736
751
|
// opened it at a width of its own, so where it started and stopped depended on which word in
|
|
737
|
-
// the bar the visitor happened to hover. It now
|
|
738
|
-
//
|
|
752
|
+
// the bar the visitor happened to hover. It is now a full-bleed sheet: its edges on the
|
|
753
|
+
// header's, its top on the bar's bottom edge, and its content inside the bar's own container —
|
|
754
|
+
// the first column on the brand's left edge, the "View all" on the actions' right edge.
|
|
739
755
|
const page = await browser.newPage({ viewport: { width: 1280, height: 900 } });
|
|
740
756
|
try {
|
|
741
757
|
await page.goto(`${statics.origin}${HOME_PAGE_PATH}`, { waitUntil: 'domcontentloaded' });
|
|
@@ -782,17 +798,17 @@ describe('prerendered commerce data on the generated static site', () => {
|
|
|
782
798
|
};
|
|
783
799
|
}, panelId ?? '');
|
|
784
800
|
|
|
785
|
-
expect(Math.round(edges.panel.left)).toBe(Math.round(edges.
|
|
786
|
-
expect(Math.round(edges.panel.right)).toBe(Math.round(edges.
|
|
801
|
+
expect(Math.round(edges.panel.left)).toBe(Math.round(edges.bar.left));
|
|
802
|
+
expect(Math.round(edges.panel.right)).toBe(Math.round(edges.bar.right));
|
|
803
|
+
expect(Math.abs(edges.firstColumn.left - edges.brand.left)).toBeLessThanOrEqual(1);
|
|
804
|
+
expect(Math.abs(edges.viewAll.right - edges.actions.right)).toBeLessThanOrEqual(1);
|
|
787
805
|
// Directly below the bar — within the bar's own 1px bottom border.
|
|
788
806
|
expect(Math.abs(edges.panel.top - edges.bar.bottom)).toBeLessThanOrEqual(2);
|
|
789
807
|
// And the premise: the trigger is nowhere near either edge, so "spans the container" is a
|
|
790
808
|
// real claim rather than a coincidence of where this item sits.
|
|
791
809
|
expect(edges.trigger.left).toBeGreaterThan(edges.panel.left + 1);
|
|
792
810
|
expect(edges.trigger.right).toBeLessThan(edges.panel.right - 1);
|
|
793
|
-
// And
|
|
794
|
-
// edges. 24px is the narrow-container figure; the wide container's own 32px clears it too,
|
|
795
|
-
// so one bound holds at every width this page is measured at.
|
|
811
|
+
// And nothing inside the panel sits flush against its edges: the page's own gutters at least.
|
|
796
812
|
expect(edges.firstColumn.left).toBeGreaterThanOrEqual(edges.panel.left + 24);
|
|
797
813
|
expect(edges.viewAll.right).toBeLessThanOrEqual(edges.panel.right - 24);
|
|
798
814
|
} finally {
|
|
@@ -952,8 +968,10 @@ describe('prerendered commerce data on the generated static site', () => {
|
|
|
952
968
|
// The height the spacer's *classes* alone reserve — all the first paint of a prerendered
|
|
953
969
|
// page has, before the bar has been measured at all — against the bar's own box for those
|
|
954
970
|
// same classes. A difference here is a page that jumps on hydration.
|
|
971
|
+
// The bar's box is the spacer's last child; an info strip, when the header has one,
|
|
972
|
+
// reserves its own box before it.
|
|
955
973
|
reserved:
|
|
956
|
-
spacer === null ? null : spacer.
|
|
974
|
+
spacer === null ? null : spacer.lastElementChild!.getBoundingClientRect().height,
|
|
957
975
|
nav: element.querySelector('[data-eldra-header-bar]')!.getBoundingClientRect().height,
|
|
958
976
|
wrapper: wrapper === null ? null : wrapper.getBoundingClientRect().height,
|
|
959
977
|
};
|
|
@@ -1011,6 +1029,9 @@ describe('prerendered commerce data on the generated static site', () => {
|
|
|
1011
1029
|
'storefront:catalog.category:[null]',
|
|
1012
1030
|
'storefront:catalog.collectionProducts:[null,{"page":1,"pageSize":8}]',
|
|
1013
1031
|
'storefront:catalog.product:["ash-glaze-mug"]',
|
|
1032
|
+
// `product-carousel`'s quick-add read, keyed `null` until a shopper presses Quick add: no
|
|
1033
|
+
// request and no data, in the payload because it exists, like the category read above.
|
|
1034
|
+
'storefront:catalog.product:[null]',
|
|
1014
1035
|
'storefront:catalog.related:["ash-glaze-mug",8]',
|
|
1015
1036
|
// The footer's sign-up spam guard (`useFormSpam`): a footer with no newsletter zone names no
|
|
1016
1037
|
// form, so the read is keyed `""`, resolves `null` without a request and is in the payload
|