@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.
- package/CHANGELOG.md +3 -1
- package/package.json +1 -1
- package/template/.eldra/block-types.d.ts +28 -7
- package/template/.eldra/manifest.json +1034 -355
- 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 +82 -58
- package/template/blocks/collection-header/__tests__/Block.spec.ts +77 -1
- 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 +623 -184
- package/template/blocks/navigation/__tests__/Block.spec.ts +416 -68
- package/template/blocks/navigation/__tests__/fixtures/menu.json +182 -0
- package/template/blocks/navigation/block.json +102 -6
- package/template/blocks/navigation/mock.json +279 -52
- 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/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/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/prerenderRefresh.browser.spec.ts +36 -15
- package/template/test/previewParity.browser.spec.ts +36 -2
- package/template/test/starter.spec.ts +31 -15
- package/template/test/storefront/gatewayPrerender.spec.ts +26 -0
- package/template/tokens.json +13 -13
|
@@ -6,7 +6,8 @@ import { Badge } from '@eldrajs/ui';
|
|
|
6
6
|
import { enUS as uiEnUS } from '@eldrajs/ui';
|
|
7
7
|
import { axe } from '../../../test/support/axe';
|
|
8
8
|
import Block from '../Block.vue';
|
|
9
|
-
import
|
|
9
|
+
import seed from '../mock.json';
|
|
10
|
+
import menuFixture from './fixtures/menu.json';
|
|
10
11
|
import { mountOptions } from '../../../test/support/mountBlock';
|
|
11
12
|
import { computed, nextTick, ref, type Ref } from 'vue';
|
|
12
13
|
import { STOREFRONT_KEY } from '../../../app/storefront/types';
|
|
@@ -21,6 +22,15 @@ import { createDemoStorefront } from '../../../app/storefront/demo';
|
|
|
21
22
|
// slug and a title before rendering. `resolveTargets` does both here, so a spec can assert the
|
|
22
23
|
// hrefs a real page produces; `mock` itself stays the unresolved seed, which is what a header
|
|
23
24
|
// looks like the moment it is inserted and nothing has resolved yet.
|
|
25
|
+
// The menu and keyboard specs below were written against a five-item bar — Knitwear and Ceramics
|
|
26
|
+
// as mega-menus, then Kitchen, Journal and Visit the studio as plain links — and they count
|
|
27
|
+
// triggers and walk panels by position. That menu is kept as a fixture (`fixtures/menu.json`, the
|
|
28
|
+
// seed's links before the Northwind redesign) so those specs keep measuring `NavMenu`'s behaviour
|
|
29
|
+
// rather than whichever demo menu the seed happens to ship; everything else is the real seed, info
|
|
30
|
+
// strip included. The redesigned seed's own menu (sections with cards, a badge, a dropdown) has its
|
|
31
|
+
// own specs under "the Northwind menu".
|
|
32
|
+
const mock = { ...seed, links: menuFixture.links, searchStyle: 'icon' as const };
|
|
33
|
+
|
|
24
34
|
const COLLECTION_TEMPLATE = {
|
|
25
35
|
id: 'rt-collection',
|
|
26
36
|
data: {
|
|
@@ -107,6 +117,16 @@ function stubFocusVisible(matches: boolean): () => void {
|
|
|
107
117
|
};
|
|
108
118
|
}
|
|
109
119
|
|
|
120
|
+
/** The labelled Search tool: named by its visible label, so it carries no `aria-label` to find it by. */
|
|
121
|
+
function findSearchTool(wrapper: { findAll: (selector: string) => DOMWrapper<Element>[] }) {
|
|
122
|
+
return wrapper.findAll('button').find((button) => button.text().trim() === 'Search');
|
|
123
|
+
}
|
|
124
|
+
function searchTool(wrapper: { findAll: (selector: string) => DOMWrapper<Element>[] }) {
|
|
125
|
+
const button = findSearchTool(wrapper);
|
|
126
|
+
if (button === undefined) throw new Error('no Search tool in the bar');
|
|
127
|
+
return button;
|
|
128
|
+
}
|
|
129
|
+
|
|
110
130
|
function mountBlock(data: Record<string, unknown>, opts?: { attachTo?: Element }) {
|
|
111
131
|
const base = mountOptions({ entry: { id: 'e1', data } }, { links: resolved.links });
|
|
112
132
|
return mount(Block, {
|
|
@@ -344,7 +364,7 @@ describe('header block (navigation apiId)', () => {
|
|
|
344
364
|
expect(cards).toHaveLength(2);
|
|
345
365
|
const image = cards[0]!.get('img');
|
|
346
366
|
expect(image.attributes('src')).toBe('https://media.test/mug-md.jpg');
|
|
347
|
-
expect((image.element as HTMLImageElement).style.aspectRatio).toBe('4 /
|
|
367
|
+
expect((image.element as HTMLImageElement).style.aspectRatio).toBe('4 / 5');
|
|
348
368
|
expect(cards[0]!.get('[data-part="cardTitle"]').text()).toBe('Ash glaze mug');
|
|
349
369
|
expect(cards[0]!.get('[data-part="cardPrice"]').text()).toMatch(/28/);
|
|
350
370
|
expect(cards[1]!.get('img').attributes('src')).toBe('https://media.test/winter-md.jpg');
|
|
@@ -543,11 +563,20 @@ describe('header block (navigation apiId)', () => {
|
|
|
543
563
|
expect(spacer.classes()).toContain('@container');
|
|
544
564
|
expect(spacer.classes()).toContain('border-b');
|
|
545
565
|
expect(spacer.classes()).toContain('border-transparent');
|
|
546
|
-
|
|
566
|
+
// The info strip's box first (the seed has one), then the bar's. The strip mirrors its own
|
|
567
|
+
// two boxes too: the hairline on the outer, the height on the inner, so the border adds to
|
|
568
|
+
// the height (36px + 1px) rather than eating into it (`border-box`).
|
|
569
|
+
const [strip, reserved] = spacer.findAll(':scope > div');
|
|
570
|
+
const info = wrapper.get('[data-eldra-header-info]');
|
|
571
|
+
expect(info.classes()).toContain('border-b');
|
|
572
|
+
expect(strip!.classes()).toContain('border-b');
|
|
573
|
+
expect(strip!.classes()).not.toContain('min-h-9');
|
|
574
|
+
expect(info.get(':scope > div').classes()).toContain('min-h-9');
|
|
575
|
+
expect(strip!.get(':scope > div').classes()).toContain('min-h-9');
|
|
547
576
|
const bar = wrapper.get('[data-eldra-header-bar]');
|
|
548
|
-
for (const height of ['h-
|
|
577
|
+
for (const height of ['min-h-[4.5rem]', '@max-[47.5625rem]:min-h-[3.75rem]']) {
|
|
549
578
|
expect(bar.classes()).toContain(height);
|
|
550
|
-
expect(reserved
|
|
579
|
+
expect(reserved!.classes()).toContain(height);
|
|
551
580
|
}
|
|
552
581
|
|
|
553
582
|
wrapper.unmount();
|
|
@@ -645,7 +674,7 @@ describe('header block (navigation apiId)', () => {
|
|
|
645
674
|
window.dispatchEvent(new Event('scroll'));
|
|
646
675
|
await nextTick();
|
|
647
676
|
};
|
|
648
|
-
const searchButton = wrapper
|
|
677
|
+
const searchButton = searchTool(wrapper);
|
|
649
678
|
|
|
650
679
|
await searchButton.trigger('focusin');
|
|
651
680
|
await scrollTo(300);
|
|
@@ -1215,38 +1244,37 @@ describe('header block (navigation apiId)', () => {
|
|
|
1215
1244
|
});
|
|
1216
1245
|
|
|
1217
1246
|
/**
|
|
1218
|
-
*
|
|
1219
|
-
*
|
|
1220
|
-
*
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1223
|
-
*
|
|
1224
|
-
* `min-h-6`/`text-badge` must not survive the merge — that overshoot (1.5rem tall, the wrong
|
|
1225
|
-
* type scale) was the original defect.
|
|
1247
|
+
* The Northwind design's corner badge on a labelled tool: 1.125rem tall, `0.6875rem` bold
|
|
1248
|
+
* figures, at the tool's top-right (`top-0.5 right-1.5`, `right-0.5` on a phone), no ring (a ring
|
|
1249
|
+
* separates a pill from what sits *beside* it; this one sits deliberately *on* the icon's
|
|
1250
|
+
* corner). `Badge`'s own `min-h-6`/`text-badge` must not survive the merge — that overshoot
|
|
1251
|
+
* (1.5rem tall, the wrong type scale) was the original defect. The real-browser measurement is
|
|
1252
|
+
* `test/countPill.browser.spec.ts`.
|
|
1226
1253
|
*/
|
|
1227
1254
|
it('sizes and positions the pill as a corner badge, with none of Badge’s own oversized defaults left behind', async () => {
|
|
1228
1255
|
const wrapper = mountWithCartCount(mock, 2);
|
|
1229
1256
|
await nextTick();
|
|
1230
1257
|
const badge = countPill(findCartButton(wrapper))!;
|
|
1231
1258
|
for (const token of [
|
|
1232
|
-
'min-h-
|
|
1233
|
-
'min-w-
|
|
1234
|
-
'h-
|
|
1259
|
+
'min-h-[1.125rem]',
|
|
1260
|
+
'min-w-[1.125rem]',
|
|
1261
|
+
'h-[1.125rem]',
|
|
1235
1262
|
'px-1',
|
|
1236
|
-
'text-[0.
|
|
1263
|
+
'text-[0.6875rem]',
|
|
1237
1264
|
'font-bold',
|
|
1238
1265
|
'tabular-nums',
|
|
1239
1266
|
'leading-none',
|
|
1240
|
-
'
|
|
1241
|
-
'
|
|
1267
|
+
'top-0.5',
|
|
1268
|
+
'right-1.5',
|
|
1269
|
+
'@max-[47.5625rem]:right-0.5',
|
|
1242
1270
|
]) {
|
|
1243
1271
|
expect([...badge.classList]).toContain(token);
|
|
1244
1272
|
}
|
|
1245
1273
|
for (const stale of [
|
|
1246
1274
|
'min-h-6',
|
|
1247
1275
|
'text-badge',
|
|
1248
|
-
'top-0.5',
|
|
1249
|
-
'right-0.5',
|
|
1276
|
+
'-top-0.5',
|
|
1277
|
+
'-right-0.5',
|
|
1250
1278
|
'ring-2',
|
|
1251
1279
|
'ring-background',
|
|
1252
1280
|
'min-h-5',
|
|
@@ -1318,7 +1346,7 @@ describe('header block (navigation apiId)', () => {
|
|
|
1318
1346
|
function findHeart(wrapper: ReturnType<typeof mountBlock>) {
|
|
1319
1347
|
return wrapper
|
|
1320
1348
|
.findAll('a, button')
|
|
1321
|
-
.find((control) => control.attributes('aria-label')?.startsWith('
|
|
1349
|
+
.find((control) => control.attributes('aria-label')?.startsWith('Saved'));
|
|
1322
1350
|
}
|
|
1323
1351
|
|
|
1324
1352
|
function saveInBrowser(...handles: string[]): void {
|
|
@@ -1330,7 +1358,7 @@ describe('header block (navigation apiId)', () => {
|
|
|
1330
1358
|
const heart = findHeart(wrapper)!;
|
|
1331
1359
|
// No number in the name, so the prerendered header reads the same for every visitor — and
|
|
1332
1360
|
// the destination is there from the first paint, not grown later.
|
|
1333
|
-
expect(heart.attributes('aria-label')).toBe('
|
|
1361
|
+
expect(heart.attributes('aria-label')).toBe('Saved');
|
|
1334
1362
|
expect(heart.attributes('href')).toBe('/wishlist');
|
|
1335
1363
|
expect(countPill(heart)).toBeNull();
|
|
1336
1364
|
// The bag's own pill is absent too (an empty cart), so this is the whole actions row: two
|
|
@@ -1361,7 +1389,7 @@ describe('header block (navigation apiId)', () => {
|
|
|
1361
1389
|
await nextTick();
|
|
1362
1390
|
|
|
1363
1391
|
const heart = findHeart(wrapper)!;
|
|
1364
|
-
expect(heart.attributes('aria-label')).toBe('
|
|
1392
|
+
expect(heart.attributes('aria-label')).toBe('Saved, 1 item');
|
|
1365
1393
|
expect(heart.element.tagName).toBe('A');
|
|
1366
1394
|
expect(heart.attributes('href')).toBe('/wishlist');
|
|
1367
1395
|
// It is a link to a page, so it claims no popup — the same rule the bag's link form follows.
|
|
@@ -1374,7 +1402,7 @@ describe('header block (navigation apiId)', () => {
|
|
|
1374
1402
|
await nextTick();
|
|
1375
1403
|
|
|
1376
1404
|
const heart = findHeart(wrapper)!;
|
|
1377
|
-
expect(heart.attributes('aria-label')).toBe('
|
|
1405
|
+
expect(heart.attributes('aria-label')).toBe('Saved, 2 items');
|
|
1378
1406
|
const badge = countPill(heart)!;
|
|
1379
1407
|
expect(badge.getAttribute('aria-hidden')).toBe('true');
|
|
1380
1408
|
expect(badge.textContent?.trim()).toBe('2');
|
|
@@ -1387,7 +1415,7 @@ describe('header block (navigation apiId)', () => {
|
|
|
1387
1415
|
await nextTick();
|
|
1388
1416
|
|
|
1389
1417
|
const heart = findHeart(wrapper)!;
|
|
1390
|
-
expect(heart.attributes('aria-label')).toBe('
|
|
1418
|
+
expect(heart.attributes('aria-label')).toBe('Saved, 120 items');
|
|
1391
1419
|
expect(countPill(heart)?.textContent?.trim()).toBe('99+');
|
|
1392
1420
|
});
|
|
1393
1421
|
|
|
@@ -1413,7 +1441,13 @@ describe('header block (navigation apiId)', () => {
|
|
|
1413
1441
|
expect(heartPill.className).toBe(cartPill.className);
|
|
1414
1442
|
// And the corner-badge classes are actually on it, not just shared with an equally-wrong
|
|
1415
1443
|
// sibling.
|
|
1416
|
-
for (const token of [
|
|
1444
|
+
for (const token of [
|
|
1445
|
+
'min-h-[1.125rem]',
|
|
1446
|
+
'min-w-[1.125rem]',
|
|
1447
|
+
'h-[1.125rem]',
|
|
1448
|
+
'top-0.5',
|
|
1449
|
+
'right-1.5',
|
|
1450
|
+
]) {
|
|
1417
1451
|
expect([...heartPill.classList]).toContain(token);
|
|
1418
1452
|
}
|
|
1419
1453
|
});
|
|
@@ -1431,7 +1465,7 @@ describe('header block (navigation apiId)', () => {
|
|
|
1431
1465
|
* control's own, which is the state every prerendered page is served in. */
|
|
1432
1466
|
it('is axe-clean with nothing saved, where the heart carries no pill', async () => {
|
|
1433
1467
|
const wrapper = mountBlock(resolved.data);
|
|
1434
|
-
expect(findHeart(wrapper)!.attributes('aria-label')).toBe('
|
|
1468
|
+
expect(findHeart(wrapper)!.attributes('aria-label')).toBe('Saved');
|
|
1435
1469
|
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
1436
1470
|
});
|
|
1437
1471
|
});
|
|
@@ -1447,6 +1481,16 @@ describe('header block (navigation apiId)', () => {
|
|
|
1447
1481
|
expect(other.attributes('aria-current')).toBeUndefined();
|
|
1448
1482
|
});
|
|
1449
1483
|
|
|
1484
|
+
it("marks the current bar link with the pill alone, turning off the package's underline", () => {
|
|
1485
|
+
window.history.pushState({}, '', '/collections/kitchen');
|
|
1486
|
+
const wrapper = mountBlock(resolved.data);
|
|
1487
|
+
const current = wrapper
|
|
1488
|
+
.findAll('a')
|
|
1489
|
+
.find((a) => a.attributes('href') === '/collections/kitchen')!;
|
|
1490
|
+
expect(current.classes()).toContain('aria-[current=page]:bg-surface-strong');
|
|
1491
|
+
expect(current.classes()).toContain('aria-[current=page]:no-underline');
|
|
1492
|
+
});
|
|
1493
|
+
|
|
1450
1494
|
it('marks a current page inside a mega-menu on its link and on the trigger that holds it', async () => {
|
|
1451
1495
|
window.history.pushState({}, '', '/collections/womens-sweaters');
|
|
1452
1496
|
const wrapper = mountBlock(resolved.data, { attachTo: document.body });
|
|
@@ -1561,15 +1605,15 @@ describe('header block (navigation apiId)', () => {
|
|
|
1561
1605
|
});
|
|
1562
1606
|
|
|
1563
1607
|
describe('mega-menu panel geometry', () => {
|
|
1564
|
-
// jsdom computes no layout
|
|
1565
|
-
//
|
|
1566
|
-
//
|
|
1567
|
-
//
|
|
1568
|
-
// columns are the container's 12-column grid.
|
|
1608
|
+
// jsdom computes no layout; what is checkable here is the arrangement. The Northwind panel is a
|
|
1609
|
+
// full-bleed sheet: pinned to the whole `<header>` (fixed when sticky, `relative` when not) rather
|
|
1610
|
+
// than to the item that opened it or to the bar's grid, with its columns held inside the same
|
|
1611
|
+
// wide container the bar uses.
|
|
1569
1612
|
it('pins the panel to the header container, not to the trigger that opened it', async () => {
|
|
1570
1613
|
const wrapper = mountBlock(resolved.data, { attachTo: document.body });
|
|
1571
|
-
// The
|
|
1572
|
-
expect(wrapper.get('
|
|
1614
|
+
// The header is the panel's positioning box; the bar's grid and the menu's own root take none.
|
|
1615
|
+
expect(wrapper.get('header').classes()).toContain('fixed');
|
|
1616
|
+
expect(wrapper.get('[data-eldra-header-bar]').classes()).not.toContain('relative');
|
|
1573
1617
|
const root = [...menuRoot(wrapper).classList];
|
|
1574
1618
|
expect(root).toContain('static');
|
|
1575
1619
|
expect(root).toContain('contents');
|
|
@@ -1589,30 +1633,34 @@ describe('header block (navigation apiId)', () => {
|
|
|
1589
1633
|
const panelTokens = panel.classes().map((token) => token.replace(/^eldra:/, ''));
|
|
1590
1634
|
expect(panelTokens).not.toContain('w-screen');
|
|
1591
1635
|
expect(panelTokens.some((token) => token.startsWith('max-w-'))).toBe(false);
|
|
1592
|
-
// The bar's own bottom border is the sheet's top edge
|
|
1636
|
+
// The bar's own bottom border is the sheet's top edge; the sheet draws only a bottom rule and
|
|
1637
|
+
// the float shadow, square-cornered, 2rem above and below, the page's own gutters at the sides.
|
|
1593
1638
|
const sheet = panel.get('[data-part="content"]').classes();
|
|
1594
1639
|
for (const token of [
|
|
1595
|
-
'eldra:border',
|
|
1596
|
-
'border-t-0',
|
|
1597
|
-
'eldra:border-border',
|
|
1598
1640
|
'rounded-none',
|
|
1599
|
-
'
|
|
1641
|
+
'border-0',
|
|
1642
|
+
'border-b',
|
|
1643
|
+
'border-border',
|
|
1600
1644
|
'shadow-(--eldra-shadow-float)',
|
|
1601
|
-
'
|
|
1602
|
-
'
|
|
1645
|
+
'py-8',
|
|
1646
|
+
'px-(--eldra-gutter-mobile)',
|
|
1647
|
+
'@tablet:px-(--eldra-gutter-tablet)',
|
|
1648
|
+
'@content:px-(--eldra-gutter-desktop)',
|
|
1603
1649
|
]) {
|
|
1604
1650
|
expect(sheet).toContain(token);
|
|
1605
1651
|
}
|
|
1606
1652
|
|
|
1607
|
-
// The
|
|
1608
|
-
// the panel's own edges — 24px, 32px once the container passes `wide`. The browser case
|
|
1609
|
-
// measures what this produces; here it is only the arrangement.
|
|
1653
|
+
// The columns: inside the wide container, 12 tracks with 2rem gutters.
|
|
1610
1654
|
const columns = panel.get('[data-part="columns"]').classes();
|
|
1611
|
-
for (const token of [
|
|
1655
|
+
for (const token of [
|
|
1656
|
+
'eldra:grid',
|
|
1657
|
+
'grid-cols-12',
|
|
1658
|
+
'gap-8',
|
|
1659
|
+
'mx-auto',
|
|
1660
|
+
'max-w-[calc(var(--eldra-container-wide)-2*var(--eldra-gutter-desktop))]',
|
|
1661
|
+
]) {
|
|
1612
1662
|
expect(columns).toContain(token);
|
|
1613
1663
|
}
|
|
1614
|
-
expect(sheet).not.toContain('eldra:py-8');
|
|
1615
|
-
expect(sheet).not.toContain('py-8');
|
|
1616
1664
|
wrapper.unmount();
|
|
1617
1665
|
});
|
|
1618
1666
|
|
|
@@ -1738,7 +1786,7 @@ describe('header block (navigation apiId)', () => {
|
|
|
1738
1786
|
|
|
1739
1787
|
it('the search control has aria-haspopup="dialog" and opens SearchModal', async () => {
|
|
1740
1788
|
const wrapper = mountBlock(resolved.data, { attachTo: document.body });
|
|
1741
|
-
const searchButton = wrapper
|
|
1789
|
+
const searchButton = searchTool(wrapper);
|
|
1742
1790
|
expect(searchButton.attributes('aria-haspopup')).toBe('dialog');
|
|
1743
1791
|
await searchButton.trigger('click');
|
|
1744
1792
|
const dialogs = wrapper.findAll('dialog');
|
|
@@ -1823,7 +1871,7 @@ describe('header block (navigation apiId)', () => {
|
|
|
1823
1871
|
}
|
|
1824
1872
|
|
|
1825
1873
|
async function openOverlay(wrapper: ReturnType<typeof mountWithSearch>) {
|
|
1826
|
-
await wrapper
|
|
1874
|
+
await searchTool(wrapper).trigger('click');
|
|
1827
1875
|
return wrapper.get('dialog[open] input[type="search"]');
|
|
1828
1876
|
}
|
|
1829
1877
|
|
|
@@ -1956,32 +2004,43 @@ describe('header block (navigation apiId)', () => {
|
|
|
1956
2004
|
});
|
|
1957
2005
|
|
|
1958
2006
|
describe('actions row spacing', () => {
|
|
1959
|
-
//
|
|
1960
|
-
// the
|
|
1961
|
-
// so
|
|
1962
|
-
|
|
1963
|
-
it('puts one 0.25rem gap everywhere in the bar’s grid — never a larger one between columns', () => {
|
|
2007
|
+
// Below 68.8125rem the brand is centred by symmetry alone: Menu and Search on one side, Saved
|
|
2008
|
+
// and Cart on the other, all one fixed width, with the grid's gap equal to the actions row's own
|
|
2009
|
+
// — so the two sides measure the same. A larger gap on either breaks the centring.
|
|
2010
|
+
it('puts the same 0.125rem gap in the bar’s grid and in the actions row, so the brand stays centred', () => {
|
|
1964
2011
|
const wrapper = mountBlock(resolved.data);
|
|
1965
2012
|
const bar = wrapper.get('[data-eldra-header-bar]');
|
|
1966
|
-
expect(bar.classes()).toContain('gap-
|
|
1967
|
-
expect(bar.classes()
|
|
1968
|
-
|
|
2013
|
+
expect(bar.classes()).toContain('gap-x-0.5');
|
|
2014
|
+
expect(bar.classes()).toContain(
|
|
2015
|
+
'grid-cols-[auto_auto_minmax(0,1fr)_minmax(0,auto)_minmax(0,1fr)_auto]'
|
|
2016
|
+
);
|
|
1969
2017
|
const actions = wrapper.get('[data-eldra-header-actions]');
|
|
1970
|
-
expect(actions.classes()).toContain('gap-
|
|
2018
|
+
expect(actions.classes()).toContain('gap-0.5');
|
|
2019
|
+
// Every tool on either side is the same fixed width.
|
|
2020
|
+
const menu = wrapper.get('button[aria-label="Menu"]');
|
|
2021
|
+
const saved = wrapper.get('[aria-label^="Saved"]');
|
|
2022
|
+
const tools = [menu, searchTool(wrapper), saved, findCartButtonIn(wrapper)!];
|
|
2023
|
+
for (const tool of tools) {
|
|
2024
|
+
expect(tool.classes()).toEqual(
|
|
2025
|
+
expect.arrayContaining(['w-14', '@max-[47.5625rem]:w-11', '@max-[22.5rem]:w-10'])
|
|
2026
|
+
);
|
|
2027
|
+
}
|
|
1971
2028
|
});
|
|
1972
2029
|
|
|
1973
2030
|
it('gives the call to action its own 0.75rem from the cart, not only the row’s 0.25rem gap', () => {
|
|
1974
2031
|
const wrapper = mountBlock(resolved.data);
|
|
1975
2032
|
const actions = wrapper.get('[data-eldra-header-actions]');
|
|
1976
2033
|
const cta = actions.findAll('a, button').find((el) => el.text() === mock.ctaLabel)!;
|
|
1977
|
-
// 0.
|
|
1978
|
-
//
|
|
1979
|
-
expect(cta.classes()).toContain('
|
|
2034
|
+
// 0.625rem of margin on top of the row's own 0.125rem gap: the call to action "sits 0.75rem
|
|
2035
|
+
// after the cart".
|
|
2036
|
+
expect(cta.classes()).toContain('ml-2.5');
|
|
1980
2037
|
// And the row's only hidden/visible pair lands on the button's own root — the flex item the
|
|
1981
2038
|
// row's `gap-1` actually counts — not on a wrapper around it. A wrapper carrying `hidden`
|
|
1982
2039
|
// while the button inside it carries the visible class would still occupy a gap slot: the
|
|
1983
2040
|
// parent check is what rules that out, not just the classes existing somewhere in the tree.
|
|
1984
|
-
expect(cta.classes()).toEqual(
|
|
2041
|
+
expect(cta.classes()).toEqual(
|
|
2042
|
+
expect.arrayContaining(['hidden', '@min-[68.8125rem]:inline-flex'])
|
|
2043
|
+
);
|
|
1985
2044
|
expect(cta.element.parentElement).toBe(actions.element);
|
|
1986
2045
|
});
|
|
1987
2046
|
});
|
|
@@ -2009,7 +2068,7 @@ describe('header block (navigation apiId)', () => {
|
|
|
2009
2068
|
// The bar's link list is not drawn at all with nothing in it, so no empty `<ul>` is left
|
|
2010
2069
|
// sitting in the grid.
|
|
2011
2070
|
expect(wrapper.find('ul.list-none.items-center').exists()).toBe(false);
|
|
2012
|
-
expect(wrapper
|
|
2071
|
+
expect(findSearchTool(wrapper)).toBeDefined();
|
|
2013
2072
|
expect(wrapper.find('[aria-label="Cart, empty"]').exists()).toBe(true);
|
|
2014
2073
|
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
2015
2074
|
});
|
|
@@ -2018,7 +2077,7 @@ describe('header block (navigation apiId)', () => {
|
|
|
2018
2077
|
// The drawer holds the links and the call to action. With neither there is nothing to open,
|
|
2019
2078
|
// and a Menu button that opens an empty sheet is a control that does nothing.
|
|
2020
2079
|
const wrapper = mountBlock(SEEDED);
|
|
2021
|
-
expect(wrapper.find('button[aria-label="
|
|
2080
|
+
expect(wrapper.find('button[aria-label="Menu"]').exists()).toBe(false);
|
|
2022
2081
|
// `dialog[aria-label="Menu"]` is the drawer itself; the search overlay's own `<dialog>`
|
|
2023
2082
|
// renders either way, so the drawer has to be named rather than counted.
|
|
2024
2083
|
expect(wrapper.find('dialog[aria-label="Menu"]').exists()).toBe(false);
|
|
@@ -2031,7 +2090,7 @@ describe('header block (navigation apiId)', () => {
|
|
|
2031
2090
|
{ ...SEEDED, ctaLabel: 'Shop', cta: { kind: 'url', url: '/collections/all' } },
|
|
2032
2091
|
]) {
|
|
2033
2092
|
const wrapper = mountBlock(data);
|
|
2034
|
-
expect(wrapper.find('button[aria-label="
|
|
2093
|
+
expect(wrapper.find('button[aria-label="Menu"]').exists()).toBe(true);
|
|
2035
2094
|
}
|
|
2036
2095
|
});
|
|
2037
2096
|
|
|
@@ -2049,7 +2108,7 @@ describe('header block (navigation apiId)', () => {
|
|
|
2049
2108
|
wrapper.findAll('a, button').some((control) => control.attributes('href') === '/account')
|
|
2050
2109
|
).toBe(false);
|
|
2051
2110
|
expect(wrapper.text()).not.toContain('Account');
|
|
2052
|
-
expect(wrapper.find('button[aria-label="
|
|
2111
|
+
expect(wrapper.find('button[aria-label="Menu"]').exists()).toBe(false);
|
|
2053
2112
|
expect(wrapper.find('dialog[aria-label="Menu"]').exists()).toBe(false);
|
|
2054
2113
|
}
|
|
2055
2114
|
});
|
|
@@ -2212,3 +2271,292 @@ describe('header block (navigation apiId)', () => {
|
|
|
2212
2271
|
});
|
|
2213
2272
|
});
|
|
2214
2273
|
});
|
|
2274
|
+
|
|
2275
|
+
/**
|
|
2276
|
+
* The redesigned seed: an info strip, labelled tools, a scalable brand, and a menu of sections with
|
|
2277
|
+
* cards, a badge and a dropdown — the Northwind design's header boards.
|
|
2278
|
+
*/
|
|
2279
|
+
describe('the Northwind menu (the seed’s own)', () => {
|
|
2280
|
+
const PRODUCT_TEMPLATE = {
|
|
2281
|
+
id: 'rt-product',
|
|
2282
|
+
data: { schemaApiId: 'catalog:product', routePattern: '/products/:slug', slugField: 'slug' },
|
|
2283
|
+
};
|
|
2284
|
+
const PRODUCT_TARGETS: Record<string, { image: string; price: number }> = {
|
|
2285
|
+
'speckled-latte-mug': { image: '/images/mug.webp', price: 28 },
|
|
2286
|
+
'merino-crew-sweater': { image: '/images/sweater.webp', price: 96 },
|
|
2287
|
+
'hand-thrown-serving-bowl': { image: '/images/bowl.webp', price: 64 },
|
|
2288
|
+
};
|
|
2289
|
+
const northwind = resolveTargets(seed);
|
|
2290
|
+
const links = {
|
|
2291
|
+
templates: [COLLECTION_TEMPLATE, PRODUCT_TEMPLATE] as (typeof COLLECTION_TEMPLATE)[],
|
|
2292
|
+
targets: new Map(
|
|
2293
|
+
[...northwind.links.targets].map(([key, info]) => {
|
|
2294
|
+
const slug = (info as { slug: string }).slug;
|
|
2295
|
+
const extra = key.startsWith('product:') ? PRODUCT_TARGETS[slug] : undefined;
|
|
2296
|
+
return [key, { ...(info as object), ...extra }];
|
|
2297
|
+
})
|
|
2298
|
+
),
|
|
2299
|
+
};
|
|
2300
|
+
function mountSeed(data: Record<string, unknown> = {}) {
|
|
2301
|
+
return mount(Block, {
|
|
2302
|
+
...mountOptions({ entry: { id: 'e1', data: { ...northwind.data, ...data } } }, { links }),
|
|
2303
|
+
attachTo: document.body,
|
|
2304
|
+
});
|
|
2305
|
+
}
|
|
2306
|
+
type Wrapper = ReturnType<typeof mountSeed>;
|
|
2307
|
+
const trigger = (wrapper: Wrapper, label: string) =>
|
|
2308
|
+
wrapper.findAll('button').find((button) => button.text().includes(label))!;
|
|
2309
|
+
const panel = (wrapper: Wrapper, label: string) =>
|
|
2310
|
+
wrapper.get(`#${trigger(wrapper, label).attributes('aria-controls')}`);
|
|
2311
|
+
|
|
2312
|
+
afterEach(() => {
|
|
2313
|
+
document.body.innerHTML = '';
|
|
2314
|
+
});
|
|
2315
|
+
|
|
2316
|
+
it('renders the seed axe-clean in every variant', async () => {
|
|
2317
|
+
for (const variant of ['default', 'centered', 'minimal']) {
|
|
2318
|
+
const wrapper = mountSeed({ variant });
|
|
2319
|
+
expect(await axe(wrapper.element), variant).toHaveNoViolations();
|
|
2320
|
+
wrapper.unmount();
|
|
2321
|
+
}
|
|
2322
|
+
});
|
|
2323
|
+
|
|
2324
|
+
describe('info strip', () => {
|
|
2325
|
+
it('is a named region: the start items with icons, the end items as links', async () => {
|
|
2326
|
+
const wrapper = mountSeed();
|
|
2327
|
+
const strip = wrapper.get('[data-eldra-header-info]');
|
|
2328
|
+
expect(strip.attributes('role')).toBe('region');
|
|
2329
|
+
expect(strip.attributes('aria-label')).toBe('Store information');
|
|
2330
|
+
const [start, end] = strip.findAll('ul');
|
|
2331
|
+
expect(start!.findAll('li').map((li) => li.text())).toEqual([
|
|
2332
|
+
'Free delivery over $80',
|
|
2333
|
+
'30-day returns',
|
|
2334
|
+
'Shop open today 10–18',
|
|
2335
|
+
]);
|
|
2336
|
+
const phone = end!.findAll('a').find((a) => a.text() === '(555) 014-2290')!;
|
|
2337
|
+
expect(phone.attributes('href')).toBe('tel:+15550142290');
|
|
2338
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
2339
|
+
});
|
|
2340
|
+
|
|
2341
|
+
it('keeps only the first item on a phone, and moves the end of the strip into the drawer', () => {
|
|
2342
|
+
const wrapper = mountSeed();
|
|
2343
|
+
const [start, end] = wrapper.get('[data-eldra-header-info]').findAll('ul');
|
|
2344
|
+
const items = start!.findAll('li');
|
|
2345
|
+
expect(items[0]!.classes()).not.toContain('@max-[47.5625rem]:hidden');
|
|
2346
|
+
for (const item of items.slice(1))
|
|
2347
|
+
expect(item.classes()).toContain('@max-[47.5625rem]:hidden');
|
|
2348
|
+
expect(end!.classes()).toContain('@max-[68.8125rem]:hidden');
|
|
2349
|
+
// The drawer's footer repeats the end links the strip hides there.
|
|
2350
|
+
const drawerLinks = wrapper.get('[data-eldra-header-drawer-links]');
|
|
2351
|
+
expect(drawerLinks.text()).toContain('Order status');
|
|
2352
|
+
expect(drawerLinks.text()).toContain('(555) 014-2290');
|
|
2353
|
+
expect(drawerLinks.text()).toContain('Saved items');
|
|
2354
|
+
});
|
|
2355
|
+
|
|
2356
|
+
it('is not drawn with no items, and drops a javascript: link to plain text', () => {
|
|
2357
|
+
const empty = mountSeed({ infoItems: [] });
|
|
2358
|
+
expect(empty.find('[data-eldra-header-info]').exists()).toBe(false);
|
|
2359
|
+
empty.unmount();
|
|
2360
|
+
const wrapper = mountSeed({
|
|
2361
|
+
infoItems: [{ text: 'Call us', href: 'javascript:alert(1)' }],
|
|
2362
|
+
});
|
|
2363
|
+
const strip = wrapper.get('[data-eldra-header-info]');
|
|
2364
|
+
expect(strip.find('a').exists()).toBe(false);
|
|
2365
|
+
expect(strip.text()).toBe('Call us');
|
|
2366
|
+
});
|
|
2367
|
+
});
|
|
2368
|
+
|
|
2369
|
+
describe('labelled tools', () => {
|
|
2370
|
+
it('names every tool with its visible label first (WCAG 2.5.3)', async () => {
|
|
2371
|
+
const wrapper = mountSeed();
|
|
2372
|
+
const menu = wrapper.get('button[aria-label="Menu"]');
|
|
2373
|
+
expect(menu.text()).toBe('Menu');
|
|
2374
|
+
const search = wrapper
|
|
2375
|
+
.findAll('button')
|
|
2376
|
+
.filter((button) => button.text().trim() === 'Search');
|
|
2377
|
+
expect(search).toHaveLength(1);
|
|
2378
|
+
expect(search[0]!.attributes('aria-label')).toBeUndefined();
|
|
2379
|
+
// The design's pill field, from 80rem; the Search tool below it.
|
|
2380
|
+
const pill = wrapper.findAll('button').find((b) => b.text().trim() === 'Search the shop')!;
|
|
2381
|
+
expect(pill.classes()).toEqual(expect.arrayContaining(['hidden', '@wide:inline-flex']));
|
|
2382
|
+
expect(search[0]!.classes()).toContain('@wide:hidden');
|
|
2383
|
+
for (const tool of [
|
|
2384
|
+
wrapper.get('[aria-label^="Saved"]'),
|
|
2385
|
+
wrapper.get('[aria-label^="Cart"]'),
|
|
2386
|
+
]) {
|
|
2387
|
+
const label = tool.get('[data-part="label"]').text().trim();
|
|
2388
|
+
expect(tool.attributes('aria-label')!.startsWith(label)).toBe(true);
|
|
2389
|
+
}
|
|
2390
|
+
});
|
|
2391
|
+
|
|
2392
|
+
it('shows Account only when it is linked, as a tool and in the drawer', async () => {
|
|
2393
|
+
const bare = mountSeed();
|
|
2394
|
+
expect(bare.text()).not.toContain('Account');
|
|
2395
|
+
bare.unmount();
|
|
2396
|
+
const wrapper = mountSeed({ account: { kind: 'url', url: '/account' } });
|
|
2397
|
+
const tools = wrapper
|
|
2398
|
+
.get('[data-eldra-header-actions]')
|
|
2399
|
+
.findAll('a')
|
|
2400
|
+
.filter((a) => a.text().trim() === 'Account');
|
|
2401
|
+
expect(tools).toHaveLength(1);
|
|
2402
|
+
expect(tools[0]!.attributes('href')).toBe('/account');
|
|
2403
|
+
expect(tools[0]!.classes()).toContain('@max-[68.8125rem]:hidden');
|
|
2404
|
+
expect(wrapper.get('[data-eldra-header-drawer-links]').text()).toContain('Account');
|
|
2405
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
2406
|
+
});
|
|
2407
|
+
});
|
|
2408
|
+
|
|
2409
|
+
describe('brand', () => {
|
|
2410
|
+
const logo = (width: number, height: number) => ({
|
|
2411
|
+
assetId: 'logo',
|
|
2412
|
+
url: '/logo.svg',
|
|
2413
|
+
altText: 'Northwind Goods',
|
|
2414
|
+
width,
|
|
2415
|
+
height,
|
|
2416
|
+
});
|
|
2417
|
+
const mark = { assetId: 'mark', url: '/mark.svg', altText: '', width: 64, height: 64 };
|
|
2418
|
+
const brand = (wrapper: Wrapper) => wrapper.get('[data-eldra-header-brand]');
|
|
2419
|
+
|
|
2420
|
+
it('names the link once, so whichever picture a width shows, it reads the same', async () => {
|
|
2421
|
+
const wrapper = mountSeed({ brandMark: mark, brandLogo: logo(300, 100) });
|
|
2422
|
+
expect(brand(wrapper).attributes('aria-label')).toBe('Northwind Goods, home');
|
|
2423
|
+
for (const img of brand(wrapper).findAll('img')) expect(img.attributes('alt')).toBe('');
|
|
2424
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
2425
|
+
});
|
|
2426
|
+
|
|
2427
|
+
it('draws a mark beside the wordmark, and the mark alone below 400px', () => {
|
|
2428
|
+
const wrapper = mountSeed({ brandMark: mark });
|
|
2429
|
+
const [img] = brand(wrapper).findAll('img');
|
|
2430
|
+
expect(img!.classes()).not.toContain('hidden');
|
|
2431
|
+
expect(brand(wrapper).get('span span').classes()).toContain('@max-[25.0625rem]:hidden');
|
|
2432
|
+
});
|
|
2433
|
+
|
|
2434
|
+
it('swaps a logo for its mark below 400px', () => {
|
|
2435
|
+
const wrapper = mountSeed({ brandMark: mark, brandLogo: logo(300, 100) });
|
|
2436
|
+
const [markImg, logoImg] = brand(wrapper).findAll('img');
|
|
2437
|
+
expect(markImg!.classes()).toEqual(
|
|
2438
|
+
expect.arrayContaining(['hidden', '@max-[25.0625rem]:block'])
|
|
2439
|
+
);
|
|
2440
|
+
expect(logoImg!.classes()).toContain('@max-[25.0625rem]:hidden');
|
|
2441
|
+
expect(brand(wrapper).text()).toBe('');
|
|
2442
|
+
});
|
|
2443
|
+
|
|
2444
|
+
it('prints the store name below 400px for a logo wider than 4:1 with no mark', () => {
|
|
2445
|
+
const wrapper = mountSeed({ brandLogo: logo(1000, 100) });
|
|
2446
|
+
const [logoImg] = brand(wrapper).findAll('img');
|
|
2447
|
+
expect(logoImg!.classes()).toContain('@max-[25.0625rem]:hidden');
|
|
2448
|
+
const name = brand(wrapper).get('span span');
|
|
2449
|
+
expect(name.text()).toBe('Northwind Goods');
|
|
2450
|
+
expect(name.classes()).toEqual(expect.arrayContaining(['hidden', '@max-[25.0625rem]:block']));
|
|
2451
|
+
});
|
|
2452
|
+
|
|
2453
|
+
it('keeps a logo of 4:1 or narrower at every width, sized by height', () => {
|
|
2454
|
+
const wrapper = mountSeed({ brandLogo: logo(400, 100) });
|
|
2455
|
+
const [logoImg] = brand(wrapper).findAll('img');
|
|
2456
|
+
expect(logoImg!.classes()).toEqual(
|
|
2457
|
+
expect.arrayContaining(['h-9', 'w-auto', 'max-w-60', '@max-[47.5625rem]:max-h-8'])
|
|
2458
|
+
);
|
|
2459
|
+
expect(logoImg!.classes()).not.toContain('@max-[25.0625rem]:hidden');
|
|
2460
|
+
expect(brand(wrapper).text()).toBe('');
|
|
2461
|
+
});
|
|
2462
|
+
|
|
2463
|
+
it('wraps a text-only wordmark onto two centred lines below 360px', () => {
|
|
2464
|
+
const wrapper = mountSeed();
|
|
2465
|
+
const name = brand(wrapper).get('span span');
|
|
2466
|
+
expect(name.classes()).toEqual(
|
|
2467
|
+
expect.arrayContaining([
|
|
2468
|
+
'@max-[22.5rem]:whitespace-normal',
|
|
2469
|
+
'@max-[22.5rem]:text-center',
|
|
2470
|
+
'@max-[22.5rem]:max-w-[5.75rem]',
|
|
2471
|
+
])
|
|
2472
|
+
);
|
|
2473
|
+
});
|
|
2474
|
+
});
|
|
2475
|
+
|
|
2476
|
+
describe('panels', () => {
|
|
2477
|
+
it('draws column headings, linked or plain, a badge and a see-all link', async () => {
|
|
2478
|
+
const wrapper = mountSeed();
|
|
2479
|
+
await trigger(wrapper, 'Ceramics').trigger('click');
|
|
2480
|
+
const ceramics = panel(wrapper, 'Ceramics');
|
|
2481
|
+
const headings = ceramics.findAll('[data-part="groupHeading"]');
|
|
2482
|
+
expect(headings.map((heading) => heading.text())).toEqual([
|
|
2483
|
+
'By type',
|
|
2484
|
+
'By glaze',
|
|
2485
|
+
'Makers',
|
|
2486
|
+
'Best sellers',
|
|
2487
|
+
]);
|
|
2488
|
+
expect(headings[0]!.find('a').exists()).toBe(true);
|
|
2489
|
+
expect(headings[1]!.find('a').exists()).toBe(false);
|
|
2490
|
+
const vases = ceramics.findAll('a').find((a) => a.text().startsWith('Vases'))!;
|
|
2491
|
+
expect(vases.get('[data-part="label"]').text()).toBe('New');
|
|
2492
|
+
const seeAll = ceramics.get('[data-see-all]');
|
|
2493
|
+
expect(seeAll.text()).toBe('All ceramics');
|
|
2494
|
+
expect(seeAll.attributes('href')).toBe('/categories/home/ceramics');
|
|
2495
|
+
// A column's own see-all link stands in for the panel's "View all" row.
|
|
2496
|
+
expect(ceramics.find('[data-eldra-mega-view-all]').exists()).toBe(false);
|
|
2497
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
2498
|
+
});
|
|
2499
|
+
|
|
2500
|
+
it('draws product cards with their picture, title and price', async () => {
|
|
2501
|
+
const wrapper = mountSeed();
|
|
2502
|
+
await trigger(wrapper, 'Shop').trigger('click');
|
|
2503
|
+
const cards = panel(wrapper, 'Shop').findAll('[data-part="card"]');
|
|
2504
|
+
expect(cards).toHaveLength(2);
|
|
2505
|
+
expect(cards[0]!.get('img').attributes('src')).toBe('/images/mug.webp');
|
|
2506
|
+
expect(cards[0]!.get('[data-part="cardTitle"]').text()).toBe('Speckled latte mug');
|
|
2507
|
+
expect(cards[0]!.find('[data-part="cardPrice"]').exists()).toBe(true);
|
|
2508
|
+
expect(cards[0]!.element.closest('a')!.getAttribute('href')).toBe(
|
|
2509
|
+
'/products/speckled-latte-mug'
|
|
2510
|
+
);
|
|
2511
|
+
});
|
|
2512
|
+
|
|
2513
|
+
it('hangs a one-column panel with no heading under its trigger, descriptions under the links', async () => {
|
|
2514
|
+
const wrapper = mountSeed();
|
|
2515
|
+
await trigger(wrapper, 'Journal').trigger('click');
|
|
2516
|
+
const journal = panel(wrapper, 'Journal');
|
|
2517
|
+
expect(journal.get('[data-part="content"]').classes()).toContain(
|
|
2518
|
+
'eldra:eldra-nav-menu-dropdown'
|
|
2519
|
+
);
|
|
2520
|
+
expect(journal.findAll('[data-part="description"]').map((d) => d.text())).toEqual([
|
|
2521
|
+
'Washing linen, seasoning boards, storing wool',
|
|
2522
|
+
'Mornings with the people who make our goods',
|
|
2523
|
+
'Small rituals and slow mornings',
|
|
2524
|
+
]);
|
|
2525
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
2526
|
+
});
|
|
2527
|
+
|
|
2528
|
+
it('opens the dropdown from the keyboard and walks its links', async () => {
|
|
2529
|
+
const wrapper = mountSeed();
|
|
2530
|
+
const journal = trigger(wrapper, 'Journal');
|
|
2531
|
+
(journal.element as HTMLElement).focus();
|
|
2532
|
+
await journal.trigger('keydown', { key: 'ArrowDown' });
|
|
2533
|
+
await nextTick();
|
|
2534
|
+
expect(journal.attributes('aria-expanded')).toBe('true');
|
|
2535
|
+
const rows = panel(wrapper, 'Journal').findAll('a');
|
|
2536
|
+
expect(document.activeElement).toBe(rows[0]!.element);
|
|
2537
|
+
await rows[0]!.trigger('keydown', { key: 'ArrowDown' });
|
|
2538
|
+
expect(document.activeElement).toBe(rows[1]!.element);
|
|
2539
|
+
await rows[1]!.trigger('keydown', { key: 'Escape' });
|
|
2540
|
+
await nextTick();
|
|
2541
|
+
expect(journal.attributes('aria-expanded')).toBe('false');
|
|
2542
|
+
expect(document.activeElement).toBe(journal.element);
|
|
2543
|
+
});
|
|
2544
|
+
|
|
2545
|
+
it('lays the drawer out as an accordion by default, and as open sections on request', async () => {
|
|
2546
|
+
const accordion = mountSeed();
|
|
2547
|
+
expect(accordion.find('[data-part="drawerSectionHeading"]').exists()).toBe(false);
|
|
2548
|
+
accordion.unmount();
|
|
2549
|
+
const sections = mountSeed({ drawerLayout: 'sections' });
|
|
2550
|
+
const headings = sections.findAll('[data-part="drawerSectionHeading"]');
|
|
2551
|
+
expect(headings.map((heading) => heading.text())).toEqual(['Shop', 'Ceramics', 'Journal']);
|
|
2552
|
+
expect(await axe(sections.element)).toHaveNoViolations();
|
|
2553
|
+
});
|
|
2554
|
+
});
|
|
2555
|
+
|
|
2556
|
+
it('pads the fixed bar by the scrollbar width an open overlay takes away', () => {
|
|
2557
|
+
expect(mountSeed().get('header').classes()).toContain('pr-(--eldra-scrollbar-width,0px)');
|
|
2558
|
+
expect(mountSeed({ sticky: false }).get('header').classes()).not.toContain(
|
|
2559
|
+
'pr-(--eldra-scrollbar-width,0px)'
|
|
2560
|
+
);
|
|
2561
|
+
});
|
|
2562
|
+
});
|