@eldrajs/theme-cli 0.2.10 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/package.json +3 -3
  3. package/template/.eldra/block-types.d.ts +4 -6
  4. package/template/.eldra/manifest.json +228 -246
  5. package/template/.eldra/previews.json +35 -35
  6. package/template/.storybook/eldra.ts +7 -2
  7. package/template/app/assets/main.css +5 -0
  8. package/template/app/composables/useBlockData.ts +9 -2
  9. package/template/app/composables/usePriceTokens.ts +150 -0
  10. package/template/app/composables/useQuickAdd.ts +95 -0
  11. package/template/app/composables/useRegionalFormat.ts +94 -0
  12. package/template/app/icons.ts +4 -0
  13. package/template/app/plugins/eldra-storefront.ts +2 -0
  14. package/template/app/plugins/eldra-ui-messages.ts +22 -8
  15. package/template/app/storefront/demo.ts +188 -16
  16. package/template/app/storefront/gateway.ts +19 -0
  17. package/template/app/storefront/productCardLook.ts +76 -0
  18. package/template/app/storefront/productReference.ts +17 -0
  19. package/template/app/storefront/toProductCard.ts +12 -8
  20. package/template/app/storefront/types.ts +17 -0
  21. package/template/blocks/announcement-bar/__tests__/Block.spec.ts +19 -7
  22. package/template/blocks/announcement-bar/block.json +2 -1
  23. package/template/blocks/announcement-bar/mock.json +1 -1
  24. package/template/blocks/announcement-bar/preview.png +0 -0
  25. package/template/blocks/article/Block.vue +8 -18
  26. package/template/blocks/article/block.json +3 -1
  27. package/template/blocks/article/preview.png +0 -0
  28. package/template/blocks/article-list/block.json +10 -1
  29. package/template/blocks/article-list/preview.png +0 -0
  30. package/template/blocks/breadcrumbs/Block.vue +15 -3
  31. package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +13 -0
  32. package/template/blocks/breadcrumbs/block.json +1 -0
  33. package/template/blocks/breadcrumbs/preview.png +0 -0
  34. package/template/blocks/cart/Block.vue +15 -5
  35. package/template/blocks/cart/__tests__/Block.spec.ts +53 -10
  36. package/template/blocks/cart/__tests__/ShippingBar.spec.ts +10 -8
  37. package/template/blocks/cart/block.json +8 -5
  38. package/template/blocks/cart/mock.json +2 -2
  39. package/template/blocks/cart/parts/ShippingBar.vue +24 -30
  40. package/template/blocks/cart/parts/notSold.ts +4 -3
  41. package/template/blocks/collection-grid/Block.vue +168 -85
  42. package/template/blocks/collection-grid/__tests__/Block.spec.ts +101 -23
  43. package/template/blocks/collection-grid/preview.png +0 -0
  44. package/template/blocks/collection-header/Block.vue +34 -11
  45. package/template/blocks/collection-header/__tests__/Block.spec.ts +3 -3
  46. package/template/blocks/collection-header/block.json +2 -0
  47. package/template/blocks/collection-header/preview.png +0 -0
  48. package/template/blocks/contact/block.json +4 -0
  49. package/template/blocks/contact/preview.png +0 -0
  50. package/template/blocks/cta/block.json +2 -0
  51. package/template/blocks/faq/Block.vue +5 -10
  52. package/template/blocks/faq/block.json +2 -1
  53. package/template/blocks/faq/mock.json +12 -1
  54. package/template/blocks/faq/preview.png +0 -0
  55. package/template/blocks/feature-grid/__tests__/Block.spec.ts +30 -7
  56. package/template/blocks/feature-grid/block.json +3 -2
  57. package/template/blocks/feature-grid/mock.json +1 -1
  58. package/template/blocks/feature-grid/preview.png +0 -0
  59. package/template/blocks/footer/Block.vue +64 -21
  60. package/template/blocks/footer/__tests__/Block.spec.ts +97 -1
  61. package/template/blocks/footer/block.json +5 -2
  62. package/template/blocks/footer/mock.json +1 -1
  63. package/template/blocks/footer/preview.png +0 -0
  64. package/template/blocks/form/block.json +1 -0
  65. package/template/blocks/gallery/preview.png +0 -0
  66. package/template/blocks/hero/Block.vue +38 -9
  67. package/template/blocks/hero/__tests__/Block.spec.ts +71 -19
  68. package/template/blocks/hero/block.json +16 -22
  69. package/template/blocks/hero/preview.json +1 -3
  70. package/template/blocks/hero/preview.png +0 -0
  71. package/template/blocks/image/block.json +2 -1
  72. package/template/blocks/image/preview.png +0 -0
  73. package/template/blocks/logo-cloud/block.json +1 -0
  74. package/template/blocks/logo-cloud/preview.png +0 -0
  75. package/template/blocks/navigation/Block.vue +404 -159
  76. package/template/blocks/navigation/__tests__/Block.spec.ts +806 -172
  77. package/template/blocks/navigation/__tests__/currentItem.spec.ts +90 -0
  78. package/template/blocks/navigation/block.json +2 -11
  79. package/template/blocks/navigation/mock.json +3 -3
  80. package/template/blocks/navigation/parts/LocalePicker.vue +103 -0
  81. package/template/blocks/navigation/parts/currentItem.ts +82 -0
  82. package/template/blocks/navigation/preview.json +7 -1
  83. package/template/blocks/navigation/preview.png +0 -0
  84. package/template/blocks/newsletter/Block.vue +6 -2
  85. package/template/blocks/newsletter/block.json +2 -0
  86. package/template/blocks/newsletter/preview.png +0 -0
  87. package/template/blocks/order-status/Block.vue +8 -17
  88. package/template/blocks/order-status/block.json +3 -0
  89. package/template/blocks/order-status/preview.png +0 -0
  90. package/template/blocks/pricing-table/__tests__/Block.spec.ts +12 -4
  91. package/template/blocks/pricing-table/block.json +2 -0
  92. package/template/blocks/pricing-table/mock.json +6 -6
  93. package/template/blocks/pricing-table/preview.png +0 -0
  94. package/template/blocks/product-carousel/Block.vue +36 -126
  95. package/template/blocks/product-carousel/__tests__/Block.spec.ts +88 -0
  96. package/template/blocks/product-carousel/block.json +1 -0
  97. package/template/blocks/product-carousel/preview.png +0 -0
  98. package/template/blocks/product-detail/Block.vue +84 -31
  99. package/template/blocks/product-detail/__tests__/Block.spec.ts +86 -0
  100. package/template/blocks/product-detail/__tests__/specs.spec.ts +79 -0
  101. package/template/blocks/product-detail/block.json +3 -1
  102. package/template/blocks/product-detail/mock.json +54 -4
  103. package/template/blocks/product-detail/parts/Gallery.vue +8 -2
  104. package/template/blocks/product-detail/preview.png +0 -0
  105. package/template/blocks/product-detail/specs.ts +75 -0
  106. package/template/blocks/quote/block.json +1 -0
  107. package/template/blocks/rich-text/preview.png +0 -0
  108. package/template/blocks/search/Block.vue +6 -1
  109. package/template/blocks/search/TypeSection.vue +8 -1
  110. package/template/blocks/search/__tests__/Block.spec.ts +24 -1
  111. package/template/blocks/search/block.json +1 -0
  112. package/template/blocks/search/preview.png +0 -0
  113. package/template/blocks/split-content/Block.vue +12 -5
  114. package/template/blocks/split-content/__tests__/Block.spec.ts +13 -0
  115. package/template/blocks/split-content/block.json +4 -2
  116. package/template/blocks/split-content/preview.png +0 -0
  117. package/template/blocks/stats/preview.png +0 -0
  118. package/template/blocks/tabs/Block.vue +3 -4
  119. package/template/blocks/tabs/block.json +1 -1
  120. package/template/blocks/tabs/preview.png +0 -0
  121. package/template/blocks/team/block.json +3 -1
  122. package/template/blocks/team/preview.png +0 -0
  123. package/template/blocks/testimonials/block.json +2 -0
  124. package/template/blocks/testimonials/preview.png +0 -0
  125. package/template/blocks/timeline/block.json +2 -1
  126. package/template/blocks/timeline/preview.png +0 -0
  127. package/template/blocks/trust-strip/Block.vue +2 -2
  128. package/template/blocks/trust-strip/__tests__/Block.spec.ts +38 -9
  129. package/template/blocks/trust-strip/block.json +1 -1
  130. package/template/blocks/trust-strip/mock.json +1 -1
  131. package/template/blocks/trust-strip/preview.json +1 -1
  132. package/template/blocks/trust-strip/preview.png +0 -0
  133. package/template/blocks/video-embed/block.json +2 -0
  134. package/template/blocks/video-embed/preview.png +0 -0
  135. package/template/blocks/wishlist/Block.vue +2 -2
  136. package/template/blocks/wishlist/preview.png +0 -0
  137. package/template/i18n/en-US.json +13 -5
  138. package/template/i18n/is-IS.json +12 -4
  139. package/template/pages/article.page.json +1 -3
  140. package/template/pages/cart.page.json +1 -3
  141. package/template/pages/category.page.json +2 -4
  142. package/template/pages/collection.page.json +1 -3
  143. package/template/pages/home.page.json +7 -18
  144. package/template/pages/product.page.json +62 -131
  145. package/template/pages/products.page.json +1 -3
  146. package/template/pages/search.page.json +1 -3
  147. package/template/pages/wishlist.page.json +1 -3
  148. package/template/stories/generated/footer.stories.ts +6 -0
  149. package/template/stories/generated/navigation.stories.ts +0 -18
  150. package/template/test/inlineEditable.spec.ts +10 -2
  151. package/template/test/localePrefix.spec.ts +2 -19
  152. package/template/test/pages/article.spec.ts +0 -2
  153. package/template/test/pages/category.spec.ts +35 -13
  154. package/template/test/pages/home.spec.ts +33 -17
  155. package/template/test/pages/product.spec.ts +64 -44
  156. package/template/test/pages/ssr.spec.ts +3 -1
  157. package/template/test/prerenderRefresh.browser.spec.ts +30 -25
  158. package/template/test/priceTokens.spec.ts +309 -0
  159. package/template/test/regionalFormat.spec.ts +80 -0
  160. package/template/test/starter.spec.ts +23 -7
  161. package/template/test/storefront/demo.spec.ts +19 -18
  162. package/template/test/storefront/toProductCard.spec.ts +17 -2
  163. package/template/test/structuredData.generate.spec.ts +4 -2
  164. package/template/test/support/mockGateway.ts +21 -1
  165. package/template/test/support/mountBlock.ts +25 -4
  166. package/template/test/support/priceTokens.ts +20 -0
  167. package/template/test/uiMessagesPlugin.spec.ts +34 -1
  168. package/template/tokens.json +8 -8
@@ -2,7 +2,7 @@
2
2
  import { mount, type DOMWrapper } from '@vue/test-utils';
3
3
  import { afterEach, describe, expect, it, vi } from 'vitest';
4
4
  import { ELDRA_KEY, createEldraPreviewState } from '@eldrajs/theme-vue';
5
- import { Badge } from '@eldrajs/ui';
5
+ import { Badge, CurrencyPicker } 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';
@@ -29,7 +29,10 @@ import { createDemoStorefront } from '../../../app/storefront/demo';
29
29
  // rather than whichever demo menu the seed happens to ship; everything else is the real seed, info
30
30
  // strip included. The redesigned seed's own menu (sections with cards, a badge, a dropdown) has its
31
31
  // own specs under "the Northwind menu".
32
- const mock = { ...seed, links: menuFixture.links, searchStyle: 'icon' as const };
32
+ const mock = {
33
+ ...seed,
34
+ links: menuFixture.links,
35
+ };
33
36
 
34
37
  const COLLECTION_TEMPLATE = {
35
38
  id: 'rt-collection',
@@ -65,7 +68,10 @@ function resolveTargets<T extends Record<string, unknown>>(
65
68
  data: T
66
69
  ): {
67
70
  data: T;
68
- links: { templates: (typeof COLLECTION_TEMPLATE)[]; targets: Map<string, unknown> };
71
+ links: {
72
+ templates: (typeof COLLECTION_TEMPLATE)[];
73
+ targets: Map<string, unknown>;
74
+ };
69
75
  } {
70
76
  const targets = new Map<string, unknown>();
71
77
  const rewrite = (link: SeedLink): SeedLink => {
@@ -90,7 +96,10 @@ function resolveTargets<T extends Record<string, unknown>>(
90
96
  const next = { ...data } as Record<string, unknown>;
91
97
  if (Array.isArray(next.links)) next.links = (next.links as SeedLink[]).map(rewrite);
92
98
  if (next.cta !== undefined) next.cta = rewrite(next.cta as SeedLink);
93
- return { data: next as T, links: { templates: [COLLECTION_TEMPLATE], targets } };
99
+ return {
100
+ data: next as T,
101
+ links: { templates: [COLLECTION_TEMPLATE], targets },
102
+ };
94
103
  }
95
104
 
96
105
  const resolved = resolveTargets(mock);
@@ -192,10 +201,16 @@ function mountWithDrawer(data: Record<string, unknown>, opts: { editing?: boolea
192
201
  client: {},
193
202
  designTokens: { colors: {} },
194
203
  links: resolved.links,
195
- preview: Object.assign(createEldraPreviewState(), { active: true, mode: 'edit' }),
204
+ preview: Object.assign(createEldraPreviewState(), {
205
+ active: true,
206
+ mode: 'edit',
207
+ }),
196
208
  };
197
209
  }
198
- const wrapper = mount(Block, { ...base, global: { ...base.global, provide } });
210
+ const wrapper = mount(Block, {
211
+ ...base,
212
+ global: { ...base.global, provide },
213
+ });
199
214
  return { wrapper, storefront };
200
215
  }
201
216
 
@@ -277,7 +292,11 @@ describe('header block (navigation apiId)', () => {
277
292
  const wrapper = mountBlock({
278
293
  ...resolved.data,
279
294
  links: [
280
- { kind: 'collection', target: { _type: 'collection', id: 'id-gone' }, label: 'Gone' },
295
+ {
296
+ kind: 'collection',
297
+ target: { _type: 'collection', id: 'id-gone' },
298
+ label: 'Gone',
299
+ },
281
300
  ],
282
301
  });
283
302
  expect(wrapper.text()).toContain('Gone');
@@ -339,8 +358,14 @@ describe('header block (navigation apiId)', () => {
339
358
  heading: 'Featured',
340
359
  display: 'card',
341
360
  links: [
342
- { kind: 'product', target: { _type: 'product', id: 'p-1' } },
343
- { kind: 'collection', target: { _type: 'collection', id: 'c-1' } },
361
+ {
362
+ kind: 'product',
363
+ target: { _type: 'product', id: 'p-1' },
364
+ },
365
+ {
366
+ kind: 'collection',
367
+ target: { _type: 'collection', id: 'c-1' },
368
+ },
344
369
  ],
345
370
  },
346
371
  {
@@ -364,7 +389,9 @@ describe('header block (navigation apiId)', () => {
364
389
  expect(cards).toHaveLength(2);
365
390
  const image = cards[0]!.get('img');
366
391
  expect(image.attributes('src')).toBe('https://media.test/mug-md.jpg');
367
- expect((image.element as HTMLImageElement).style.aspectRatio).toBe('4 / 5');
392
+ expect(
393
+ (image.element as HTMLImageElement).style.getPropertyValue('--eldra-nav-menu-card-aspect')
394
+ ).toBe('4 / 5');
368
395
  expect(cards[0]!.get('[data-part="cardTitle"]').text()).toBe('Ash glaze mug');
369
396
  expect(cards[0]!.get('[data-part="cardPrice"]').text()).toMatch(/28/);
370
397
  expect(cards[1]!.get('img').attributes('src')).toBe('https://media.test/winter-md.jpg');
@@ -424,13 +451,17 @@ describe('header block (navigation apiId)', () => {
424
451
  });
425
452
 
426
453
  it('labels the primary navigation landmark', () => {
427
- // One landmark in the bar; the drawer's copy stays out of the page inside the closed `<dialog>`.
454
+ // One landmark in the bar; the drawer's copy stays out of the page while the menu is closed
455
+ // (`display: none` on the inline drawer), and the bar's is hidden below 68.8125rem where the
456
+ // drawer's shows, so a browser never exposes both.
428
457
  const wrapper = mountBlock(resolved.data);
429
458
  const navs = wrapper.findAll('nav[aria-label="Primary navigation"]');
430
- expect(navs.filter((nav) => nav.element.closest('dialog') === null)).toHaveLength(1);
431
- for (const nav of navs.filter((nav) => nav.element.closest('dialog') !== null)) {
432
- expect((nav.element.closest('dialog') as HTMLDialogElement).open).toBe(false);
433
- }
459
+ expect(navs).toHaveLength(2);
460
+ const [bar, drawer] = navs;
461
+ expect(bar!.classes()).toContain('@max-[68.8125rem]:hidden');
462
+ expect((drawer!.element.closest('[data-part="drawer"]') as HTMLElement).style.display).toBe(
463
+ 'none'
464
+ );
434
465
  });
435
466
 
436
467
  it('establishes its own @container context on the root, so @tablet:/@content: classes measure the block’s own width', () => {
@@ -495,43 +526,22 @@ describe('header block (navigation apiId)', () => {
495
526
  wrapper.unmount();
496
527
  });
497
528
 
498
- it('hover opens a panel after 150ms, leaving it closes it after 150ms, and a click-opened panel stays', async () => {
529
+ /**
530
+ * The design's header opens a panel on activation only (click, Enter or Space): a pointer resting
531
+ * on a trigger opens nothing, so crossing the bar never springs a panel open over the page
532
+ * (WS-1277; WCAG 1.4.13's hover rules then never apply).
533
+ */
534
+ it('opens nothing when a mouse pointer rests on a trigger, however long', async () => {
499
535
  vi.useFakeTimers();
500
536
  try {
501
537
  const wrapper = mountBlock(resolved.data, { attachTo: document.body });
502
538
  const knitwear = wrapper.findAll('button').find((b) => b.text().includes('Knitwear'))!;
503
- const panel = () => wrapper.find(`#${knitwear.attributes('aria-controls')}`);
504
-
505
539
  mouse(knitwear.element, 'pointerenter');
506
- vi.advanceTimersByTime(160);
507
- await nextTick();
508
- expect(knitwear.attributes('aria-expanded')).toBe('true');
509
-
510
- // Trigger to panel never leaves the menu; straying out and back within the grace keeps it open.
511
- mouse(knitwear.element, 'pointerleave');
512
- mouse(menuRoot(wrapper), 'pointerleave');
513
- vi.advanceTimersByTime(100);
514
- mouse(menuRoot(wrapper), 'pointerenter');
515
- vi.advanceTimersByTime(300);
516
- await nextTick();
517
- expect(panel().isVisible()).toBe(true);
518
- expect(knitwear.attributes('aria-expanded')).toBe('true');
519
-
520
- // Leaving the menu closes what hover opened.
521
- mouse(menuRoot(wrapper), 'pointerleave');
522
- vi.advanceTimersByTime(160);
540
+ vi.advanceTimersByTime(1000);
523
541
  await nextTick();
524
542
  expect(knitwear.attributes('aria-expanded')).toBe('false');
525
-
526
- // A panel opened by a click is not hover-owned: the pointer leaving does not close it.
527
543
  await knitwear.trigger('click');
528
544
  expect(knitwear.attributes('aria-expanded')).toBe('true');
529
- mouse(knitwear.element, 'pointerenter');
530
- mouse(menuRoot(wrapper), 'pointerleave');
531
- vi.advanceTimersByTime(300);
532
- await nextTick();
533
- expect(knitwear.attributes('aria-expanded')).toBe('true');
534
-
535
545
  wrapper.unmount();
536
546
  } finally {
537
547
  vi.useRealTimers();
@@ -592,9 +602,15 @@ describe('header block (navigation apiId)', () => {
592
602
  it('a sticky bar hides on scroll-down, returns on scroll-up or at the top, and never hides while in use', async () => {
593
603
  const wrapper = mountBlock(resolved.data, { attachTo: document.body });
594
604
  const header = wrapper.get('header');
595
- Object.defineProperty(header.element, 'offsetHeight', { value: 72, configurable: true });
605
+ Object.defineProperty(header.element, 'offsetHeight', {
606
+ value: 72,
607
+ configurable: true,
608
+ });
596
609
  const scrollTo = async (y: number) => {
597
- Object.defineProperty(window, 'scrollY', { value: y, configurable: true });
610
+ Object.defineProperty(window, 'scrollY', {
611
+ value: y,
612
+ configurable: true,
613
+ });
598
614
  window.dispatchEvent(new Event('scroll'));
599
615
  await nextTick();
600
616
  };
@@ -639,9 +655,15 @@ describe('header block (navigation apiId)', () => {
639
655
  try {
640
656
  const wrapper = mountBlock(resolved.data, { attachTo: document.body });
641
657
  const header = wrapper.get('header');
642
- Object.defineProperty(header.element, 'offsetHeight', { value: 72, configurable: true });
658
+ Object.defineProperty(header.element, 'offsetHeight', {
659
+ value: 72,
660
+ configurable: true,
661
+ });
643
662
  const scrollTo = async (y: number) => {
644
- Object.defineProperty(window, 'scrollY', { value: y, configurable: true });
663
+ Object.defineProperty(window, 'scrollY', {
664
+ value: y,
665
+ configurable: true,
666
+ });
645
667
  window.dispatchEvent(new Event('scroll'));
646
668
  await nextTick();
647
669
  };
@@ -668,9 +690,15 @@ describe('header block (navigation apiId)', () => {
668
690
  try {
669
691
  const wrapper = mountBlock(resolved.data, { attachTo: document.body });
670
692
  const header = wrapper.get('header');
671
- Object.defineProperty(header.element, 'offsetHeight', { value: 72, configurable: true });
693
+ Object.defineProperty(header.element, 'offsetHeight', {
694
+ value: 72,
695
+ configurable: true,
696
+ });
672
697
  const scrollTo = async (y: number) => {
673
- Object.defineProperty(window, 'scrollY', { value: y, configurable: true });
698
+ Object.defineProperty(window, 'scrollY', {
699
+ value: y,
700
+ configurable: true,
701
+ });
674
702
  window.dispatchEvent(new Event('scroll'));
675
703
  await nextTick();
676
704
  };
@@ -680,7 +708,9 @@ describe('header block (navigation apiId)', () => {
680
708
  await scrollTo(300);
681
709
  expect(header.classes()).not.toContain('-translate-y-full');
682
710
 
683
- await searchButton.trigger('focusout', { relatedTarget: document.body });
711
+ await searchButton.trigger('focusout', {
712
+ relatedTarget: document.body,
713
+ });
684
714
  await scrollTo(600);
685
715
  expect(header.classes()).toContain('-translate-y-full');
686
716
 
@@ -694,13 +724,19 @@ describe('header block (navigation apiId)', () => {
694
724
  it('a non-sticky bar scrolls away with the page and never hides itself', async () => {
695
725
  const wrapper = mountBlock({ ...resolved.data, sticky: false }, { attachTo: document.body });
696
726
  const header = wrapper.get('header');
697
- Object.defineProperty(window, 'scrollY', { value: 800, configurable: true });
727
+ Object.defineProperty(window, 'scrollY', {
728
+ value: 800,
729
+ configurable: true,
730
+ });
698
731
  window.dispatchEvent(new Event('scroll'));
699
732
  await nextTick();
700
733
  expect(header.classes()).not.toContain('sticky');
701
734
  expect(header.classes()).not.toContain('fixed');
702
735
  expect(header.classes()).not.toContain('-translate-y-full');
703
- Object.defineProperty(window, 'scrollY', { value: 0, configurable: true });
736
+ Object.defineProperty(window, 'scrollY', {
737
+ value: 0,
738
+ configurable: true,
739
+ });
704
740
  wrapper.unmount();
705
741
  });
706
742
 
@@ -785,8 +821,8 @@ describe('header block (navigation apiId)', () => {
785
821
 
786
822
  expect(knitwear.attributes('aria-expanded')).toBe('true');
787
823
  const links = panelLinks(wrapper, knitwear);
788
- // The panel's own reading order ends on the "View all" row.
789
- expect(links[links.length - 1]!.attributes('data-eldra-mega-view-all')).toBe('');
824
+ // A panel of sections has no "View all" row: its reading order ends on its last column.
825
+ expect(links[links.length - 1]!.attributes('data-eldra-mega-view-all')).toBeUndefined();
790
826
  expect(document.activeElement).toBe(links[links.length - 1]!.element);
791
827
  wrapper.unmount();
792
828
  });
@@ -827,7 +863,9 @@ describe('header block (navigation apiId)', () => {
827
863
  const links = panelLinks(wrapper, knitwear);
828
864
  wrapper.get('a[data-eldra-header-focus]').element.focus();
829
865
 
830
- await panelFor(wrapper, knitwear).trigger('keydown', { key: 'ArrowUp' });
866
+ await panelFor(wrapper, knitwear).trigger('keydown', {
867
+ key: 'ArrowUp',
868
+ });
831
869
  await nextTick();
832
870
  expect(document.activeElement).toBe(links[links.length - 1]!.element);
833
871
  wrapper.unmount();
@@ -917,7 +955,9 @@ describe('header block (navigation apiId)', () => {
917
955
 
918
956
  // Kitchen has no groups, so it is an ordinary link: it takes focus and the panel closes
919
957
  // behind it rather than one opening that does not exist.
920
- await panelLinks(wrapper, ceramics)[0]!.trigger('keydown', { key: 'ArrowRight' });
958
+ await panelLinks(wrapper, ceramics)[0]!.trigger('keydown', {
959
+ key: 'ArrowRight',
960
+ });
921
961
  await nextTick();
922
962
  expect(ceramics.attributes('aria-expanded')).toBe('false');
923
963
  expect(document.activeElement).toBe(items[2]);
@@ -1028,7 +1068,11 @@ describe('header block (navigation apiId)', () => {
1028
1068
  * `defaultPrevented` is the whole assertion here.
1029
1069
  */
1030
1070
  const press = (el: Element, key: string): boolean => {
1031
- const event = new KeyboardEvent('keydown', { key, bubbles: true, cancelable: true });
1071
+ const event = new KeyboardEvent('keydown', {
1072
+ key,
1073
+ bubbles: true,
1074
+ cancelable: true,
1075
+ });
1032
1076
  el.dispatchEvent(event);
1033
1077
  return event.defaultPrevented;
1034
1078
  };
@@ -1092,61 +1136,6 @@ describe('header block (navigation apiId)', () => {
1092
1136
  wrapper.unmount();
1093
1137
  });
1094
1138
 
1095
- it('drops a pending hover-open when focus leaves the menus', async () => {
1096
- vi.useFakeTimers();
1097
- try {
1098
- const wrapper = mountBlock(resolved.data, { attachTo: document.body });
1099
- const knitwear = triggerFor(wrapper, 'Knitwear');
1100
- const ceramics = triggerFor(wrapper, 'Ceramics');
1101
- await knitwear.trigger('click');
1102
- panelLinks(wrapper, knitwear)[0]!.element.focus();
1103
-
1104
- // The pointer has come to rest on the next trigger: its 150ms open is armed, not fired.
1105
- mouse(ceramics.element, 'pointerenter');
1106
- // Focus leaves the header's menus, which closes the open panel…
1107
- wrapper.get('a[data-eldra-header-focus]').element.focus();
1108
- await nextTick();
1109
- expect(knitwear.attributes('aria-expanded')).toBe('false');
1110
-
1111
- // …and takes the pending hover-open with it, so nothing springs open behind the keyboard.
1112
- vi.advanceTimersByTime(300);
1113
- await nextTick();
1114
- expect(ceramics.attributes('aria-expanded')).toBe('false');
1115
- wrapper.unmount();
1116
- } finally {
1117
- vi.useRealTimers();
1118
- }
1119
- });
1120
-
1121
- it('hands a hover-opened panel over to the keyboard once focus is inside it', async () => {
1122
- vi.useFakeTimers();
1123
- try {
1124
- const wrapper = mountBlock(resolved.data, { attachTo: document.body });
1125
- const knitwear = triggerFor(wrapper, 'Knitwear');
1126
-
1127
- mouse(knitwear.element, 'pointerenter');
1128
- vi.advanceTimersByTime(160);
1129
- await nextTick();
1130
- expect(knitwear.attributes('aria-expanded')).toBe('true');
1131
-
1132
- // Focus has arrived inside what hover opened, so the pointer no longer owns it: closing
1133
- // on the way out would strand that focus on a link the panel has just hidden.
1134
- panelLinks(wrapper, knitwear)[0]!.element.focus();
1135
- mouse(menuRoot(wrapper), 'pointerleave');
1136
- vi.advanceTimersByTime(300);
1137
- await nextTick();
1138
- expect(knitwear.attributes('aria-expanded')).toBe('true');
1139
-
1140
- // Focus leaving is what closes it now.
1141
- wrapper.get('a[data-eldra-header-focus]').element.focus();
1142
- await nextTick();
1143
- expect(knitwear.attributes('aria-expanded')).toBe('false');
1144
- wrapper.unmount();
1145
- } finally {
1146
- vi.useRealTimers();
1147
- }
1148
- });
1149
-
1150
1139
  it("keeps the panel's links in the tab sequence, in DOM order right after the trigger", async () => {
1151
1140
  const wrapper = mountBlock(resolved.data, { attachTo: document.body });
1152
1141
  const knitwear = triggerFor(wrapper, 'Knitwear');
@@ -1164,38 +1153,114 @@ describe('header block (navigation apiId)', () => {
1164
1153
  });
1165
1154
  });
1166
1155
 
1156
+ /**
1157
+ * The phone menu is the design's inline drawer: the header stays, the menu opens directly under
1158
+ * it and the Menu tool becomes Close. A disclosure, not a dialog — so nothing behind it goes
1159
+ * inert, and it closes on Escape, on a press outside it and when focus leaves it.
1160
+ */
1167
1161
  describe('drawer keyboard', () => {
1168
- it('opens as a dialog with the first focusable row focused', async () => {
1169
- const wrapper = mountBlock(resolved.data, { attachTo: document.body });
1170
- const menuButton = wrapper.get('button[aria-haspopup="dialog"][aria-controls]');
1171
- await menuButton.trigger('click');
1172
-
1173
- const dialog = wrapper.get('dialog');
1174
- expect(dialog.attributes('open')).toBe('');
1175
- // The first row of the drawer's own list — an accordion row (Knitwear has a mega-menu).
1176
- const firstRow = wrapper.get(
1177
- 'dialog ul li:first-child summary, dialog ul li:first-child button, dialog ul li:first-child a'
1162
+ const menuButton = (wrapper: ReturnType<typeof mountBlock>) =>
1163
+ wrapper.get('[data-part="toggle"]');
1164
+ const drawer = (wrapper: ReturnType<typeof mountBlock>) =>
1165
+ wrapper.get('[data-part="drawer"]').element as HTMLElement;
1166
+
1167
+ it('opens under the bar as a disclosure, its button reading Close, its rows next in the tab order', async () => {
1168
+ const base = mountOptions(
1169
+ { entry: { id: 'e1', data: resolved.data } },
1170
+ { links: resolved.links }
1178
1171
  );
1179
- expect(document.activeElement).toBe(firstRow.element);
1172
+ // The real `Transition` around the inline drawer: the default stub wraps it in an element of
1173
+ // its own, which would sit between the button and the rows in the tab order.
1174
+ const wrapper = mount(Block, {
1175
+ ...base,
1176
+ attachTo: document.body,
1177
+ global: {
1178
+ ...base.global,
1179
+ stubs: { ...base.global.stubs, transition: false },
1180
+ },
1181
+ });
1182
+ const button = menuButton(wrapper);
1183
+ expect(button.attributes('aria-haspopup')).toBeUndefined();
1184
+ expect(button.attributes('aria-controls')).toBe(drawer(wrapper).id);
1185
+ expect(button.text()).toBe('Menu');
1186
+ button.element.focus();
1187
+ await button.trigger('click');
1188
+
1189
+ expect(button.attributes('aria-expanded')).toBe('true');
1190
+ expect(drawer(wrapper).style.display).toBe('');
1191
+ // The visible label and the name change together (2.5.3), with an × for the icon.
1192
+ expect(button.text()).toBe('Close');
1193
+ expect(button.attributes('aria-label')).toBe('Close');
1194
+ expect(wrapper.find('dialog[aria-label="Menu"]').exists()).toBe(false);
1195
+ // Focus stays on the button; the drawer's first row is the very next tab stop.
1196
+ expect(document.activeElement).toBe(button.element);
1197
+ expect(button.element.nextElementSibling).toBe(drawer(wrapper));
1198
+ const firstRow = drawer(wrapper).querySelector('summary, a')!;
1199
+ expect(firstRow.textContent).toContain('Knitwear');
1200
+ // It hangs from the whole header, under the bar.
1201
+ for (const token of ['eldra:absolute', 'eldra:top-full', 'eldra:inset-x-0']) {
1202
+ expect(drawer(wrapper).className).toContain(token);
1203
+ }
1204
+ wrapper.unmount();
1205
+ });
1206
+
1207
+ it('Close closes it again', async () => {
1208
+ const wrapper = mountBlock(resolved.data, { attachTo: document.body });
1209
+ await menuButton(wrapper).trigger('click');
1210
+ await menuButton(wrapper).trigger('click');
1211
+ expect(menuButton(wrapper).attributes('aria-expanded')).toBe('false');
1212
+ expect(drawer(wrapper).style.display).toBe('none');
1213
+ expect(menuButton(wrapper).text()).toBe('Menu');
1180
1214
  wrapper.unmount();
1181
1215
  });
1182
1216
 
1183
1217
  it('Esc closes the drawer and returns focus to the menu button', async () => {
1184
1218
  const wrapper = mountBlock(resolved.data, { attachTo: document.body });
1185
- const menuButton = wrapper.get('button[aria-haspopup="dialog"][aria-controls]');
1186
- // A real click focuses the button before it fires; `trigger('click')` only dispatches the
1187
- // event, so the opener has to be focused explicitly for `useDialog`'s "return focus to
1188
- // whatever had it before the dialog opened" to have anything correct to return it to.
1189
- menuButton.element.focus();
1190
- await menuButton.trigger('click');
1191
- expect(wrapper.get('dialog').attributes('open')).toBe('');
1192
-
1193
- document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }));
1194
- await new Promise((resolve) => setTimeout(resolve));
1219
+ const button = menuButton(wrapper);
1220
+ button.element.focus();
1221
+ await button.trigger('click');
1222
+ const row = drawer(wrapper).querySelector<HTMLElement>('summary, a')!;
1223
+ row.focus();
1224
+ row.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
1195
1225
  await wrapper.vm.$nextTick();
1196
1226
 
1197
- expect(wrapper.get('dialog').attributes('open')).toBeUndefined();
1198
- expect(document.activeElement).toBe(menuButton.element);
1227
+ expect(button.attributes('aria-expanded')).toBe('false');
1228
+ expect(document.activeElement).toBe(button.element);
1229
+ wrapper.unmount();
1230
+ });
1231
+
1232
+ it('closes when focus leaves it for the rest of the page, so focus never lands behind it', async () => {
1233
+ const outside = document.createElement('a');
1234
+ outside.href = '/elsewhere';
1235
+ document.body.append(outside);
1236
+ const wrapper = mountBlock(resolved.data, { attachTo: document.body });
1237
+ await menuButton(wrapper).trigger('click');
1238
+ const links = drawer(wrapper).querySelectorAll<HTMLElement>('a');
1239
+ const last = links[links.length - 1]!;
1240
+ last.focus();
1241
+ last.dispatchEvent(new FocusEvent('focusout', { bubbles: true, relatedTarget: outside }));
1242
+ outside.focus();
1243
+ await wrapper.vm.$nextTick();
1244
+ expect(menuButton(wrapper).attributes('aria-expanded')).toBe('false');
1245
+ expect(document.activeElement).toBe(outside);
1246
+ wrapper.unmount();
1247
+ outside.remove();
1248
+ });
1249
+
1250
+ it('keeps the bar in place while it is open: the bar never slides away under an open menu', async () => {
1251
+ const wrapper = mountBlock(resolved.data, { attachTo: document.body });
1252
+ await menuButton(wrapper).trigger('click');
1253
+ Object.defineProperty(window, 'scrollY', {
1254
+ value: 600,
1255
+ configurable: true,
1256
+ });
1257
+ window.dispatchEvent(new Event('scroll'));
1258
+ await wrapper.vm.$nextTick();
1259
+ expect(wrapper.get('header').classes()).not.toContain('-translate-y-full');
1260
+ Object.defineProperty(window, 'scrollY', {
1261
+ value: 0,
1262
+ configurable: true,
1263
+ });
1199
1264
  wrapper.unmount();
1200
1265
  });
1201
1266
  });
@@ -1325,7 +1390,9 @@ describe('header block (navigation apiId)', () => {
1325
1390
  * the header is not shopping.
1326
1391
  */
1327
1392
  it('does nothing when the bag is clicked in the editor', async () => {
1328
- const { wrapper, storefront } = mountWithDrawer(resolved.data, { editing: true });
1393
+ const { wrapper, storefront } = mountWithDrawer(resolved.data, {
1394
+ editing: true,
1395
+ });
1329
1396
 
1330
1397
  const bag = findCartButton(wrapper);
1331
1398
  expect(bag.element.tagName).toBe('BUTTON');
@@ -1491,6 +1558,109 @@ describe('header block (navigation apiId)', () => {
1491
1558
  expect(current.classes()).toContain('aria-[current=page]:no-underline');
1492
1559
  });
1493
1560
 
1561
+ describe('one current entry', () => {
1562
+ const SHOP_AND_CERAMICS = {
1563
+ ...resolved.data,
1564
+ links: [
1565
+ {
1566
+ kind: 'url',
1567
+ url: '/shop',
1568
+ label: 'Shop',
1569
+ children: [
1570
+ {
1571
+ kind: 'url',
1572
+ url: '/categories/home/ceramics',
1573
+ label: 'Ceramics',
1574
+ },
1575
+ {
1576
+ kind: 'url',
1577
+ url: '/categories/home/knitwear',
1578
+ label: 'Knitwear',
1579
+ },
1580
+ ],
1581
+ },
1582
+ { kind: 'url', url: '/categories/home/ceramics', label: 'Ceramics' },
1583
+ { kind: 'url', url: '/journal', label: 'Journal' },
1584
+ ],
1585
+ };
1586
+
1587
+ function mountAt(
1588
+ path: string,
1589
+ storefrontOptions: Record<string, string>,
1590
+ storefront = createDemoStorefront(storefrontOptions)
1591
+ ) {
1592
+ window.history.pushState({}, '', path);
1593
+ const base = mountOptions({
1594
+ entry: { id: 'e1', data: SHOP_AND_CERAMICS },
1595
+ });
1596
+ return mount(Block, {
1597
+ ...base,
1598
+ attachTo: document.body,
1599
+ global: {
1600
+ ...base.global,
1601
+ provide: {
1602
+ ...base.global.provide,
1603
+ [STOREFRONT_KEY]: storefront,
1604
+ },
1605
+ },
1606
+ });
1607
+ }
1608
+ const marked = (wrapper: ReturnType<typeof mountAt>) =>
1609
+ wrapper
1610
+ .findAll('[data-part="trigger"], [data-part="link"]')
1611
+ .filter(
1612
+ (el) =>
1613
+ el.attributes('aria-current') !== undefined ||
1614
+ el.attributes('data-current') !== undefined
1615
+ )
1616
+ .map((el) => `${el.text().trim()}:${el.attributes('aria-current') ?? 'trigger'}`);
1617
+
1618
+ it('marks Ceramics, not the Shop menu holding it, on a ceramics product', async () => {
1619
+ const wrapper = mountAt('/products/speckled-latte-mug', {
1620
+ productHandle: 'speckled-latte-mug',
1621
+ });
1622
+ await flushIcons();
1623
+ expect(marked(wrapper)).toEqual(['Ceramics:true']);
1624
+ wrapper.unmount();
1625
+ });
1626
+
1627
+ it('marks only the Shop menu for a category that has no entry of its own', async () => {
1628
+ const wrapper = mountAt('/categories/home/knitwear', {
1629
+ categoryPath: 'home/knitwear',
1630
+ });
1631
+ await flushIcons();
1632
+ expect(marked(wrapper).map((mark) => mark.split(':')[0])).toEqual(['Shop']);
1633
+ wrapper.unmount();
1634
+ });
1635
+
1636
+ it('moves the mark on a client-side navigation, with no popstate', async () => {
1637
+ const storefront = createDemoStorefront({
1638
+ productHandle: 'speckled-latte-mug',
1639
+ path: '/products/speckled-latte-mug',
1640
+ });
1641
+ const wrapper = mountAt('/products/speckled-latte-mug', {}, storefront);
1642
+ await flushIcons();
1643
+ expect(marked(wrapper)).toEqual(['Ceramics:true']);
1644
+ // The router commits /journal: the route changes, `window.location` is never read again.
1645
+ storefront.route.productHandle = null;
1646
+ storefront.route.path = '/journal';
1647
+ await flushIcons();
1648
+ expect(marked(wrapper)).toEqual(['Journal:page']);
1649
+ wrapper.unmount();
1650
+ });
1651
+
1652
+ it('marks Journal as the page itself, and nothing for an unknown page', async () => {
1653
+ const journal = mountAt('/journal', { productHandle: 'no-such-product' });
1654
+ await flushIcons();
1655
+ expect(marked(journal)).toEqual(['Journal:page']);
1656
+ journal.unmount();
1657
+ const none = mountAt('/nowhere', { productHandle: 'no-such-product' });
1658
+ await flushIcons();
1659
+ expect(marked(none)).toEqual([]);
1660
+ none.unmount();
1661
+ });
1662
+ });
1663
+
1494
1664
  it('marks a current page inside a mega-menu on its link and on the trigger that holds it', async () => {
1495
1665
  window.history.pushState({}, '', '/collections/womens-sweaters');
1496
1666
  const wrapper = mountBlock(resolved.data, { attachTo: document.body });
@@ -1560,10 +1730,12 @@ describe('header block (navigation apiId)', () => {
1560
1730
  await knitwear!.trigger('click');
1561
1731
  }
1562
1732
  await wrapper.get('[data-part="toggle"]').trigger('click');
1563
- const dialog = wrapper.get('dialog[open]');
1564
- expect(dialog.attributes('aria-label'), variant).toBe('Menu');
1565
- // The open drawer is modal: everything behind it is inert, so the dialog is what is checked.
1566
- expect(await axe(dialog.element), variant).toHaveNoViolations();
1733
+ expect(wrapper.get('[data-part="toggle"]').attributes('aria-expanded'), variant).toBe('true');
1734
+ // jsdom applies no stylesheet: the bar's own `nav` is `display: none` in a browser wherever
1735
+ // the Menu tool shows, so it is hidden here by hand rather than read as a second landmark.
1736
+ const bar = wrapper.find('[data-part="nav"]');
1737
+ if (bar.exists()) (bar.element as HTMLElement).style.display = 'none';
1738
+ expect(await axe(wrapper.element), variant).toHaveNoViolations();
1567
1739
  wrapper.unmount();
1568
1740
  }
1569
1741
  });
@@ -1626,7 +1798,13 @@ describe('header block (navigation apiId)', () => {
1626
1798
  await knitwear.trigger('click');
1627
1799
  const panel = wrapper.get(`#${knitwear.attributes('aria-controls')}`);
1628
1800
  // Flush under the bar: no offset of its own.
1629
- for (const token of ['eldra:absolute', 'eldra:top-full', 'eldra:inset-x-0', 'pt-0']) {
1801
+ expect(panel.attributes('data-layout')).toBe('mega');
1802
+ for (const token of [
1803
+ 'eldra:absolute',
1804
+ 'eldra:top-full',
1805
+ 'eldra:inset-x-0',
1806
+ 'data-[layout=mega]:pt-0',
1807
+ ]) {
1630
1808
  expect(panel.classes()).toContain(token);
1631
1809
  }
1632
1810
  // A width of its own is exactly what the old panel had, and what made it feel arbitrary.
@@ -1637,15 +1815,15 @@ describe('header block (navigation apiId)', () => {
1637
1815
  // the float shadow, square-cornered, 2rem above and below, the page's own gutters at the sides.
1638
1816
  const sheet = panel.get('[data-part="content"]').classes();
1639
1817
  for (const token of [
1640
- 'rounded-none',
1641
- 'border-0',
1642
- 'border-b',
1818
+ 'data-[layout=mega]:rounded-none',
1819
+ 'data-[layout=mega]:border-0',
1820
+ 'data-[layout=mega]:border-b',
1643
1821
  'border-border',
1644
- 'shadow-(--eldra-shadow-float)',
1645
- 'py-8',
1646
- 'px-(--eldra-gutter-mobile)',
1647
- '@tablet:px-(--eldra-gutter-tablet)',
1648
- '@content:px-(--eldra-gutter-desktop)',
1822
+ 'shadow-md',
1823
+ 'data-[layout=mega]:py-8',
1824
+ 'data-[layout=mega]:px-(--eldra-gutter-mobile)',
1825
+ 'data-[layout=mega]:@tablet:px-(--eldra-gutter-tablet)',
1826
+ 'data-[layout=mega]:@content:px-(--eldra-gutter-desktop)',
1649
1827
  ]) {
1650
1828
  expect(sheet).toContain(token);
1651
1829
  }
@@ -1679,25 +1857,59 @@ describe('header block (navigation apiId)', () => {
1679
1857
  wrapper.unmount();
1680
1858
  });
1681
1859
 
1682
- it("offers the parent's own destination as a View all row, and a heading none", async () => {
1860
+ it('ends a panel of sections on its columns, with no View all row', async () => {
1861
+ // The design's Shop and Ceramics panels: the department's own page is reached through a
1862
+ // column heading or a column's "see all", never a footer row under the columns.
1683
1863
  const wrapper = mountBlock(resolved.data, { attachTo: document.body });
1684
1864
  const knitwear = wrapper.findAll('button').find((b) => b.text().includes('Knitwear'))!;
1685
1865
  await knitwear.trigger('click');
1686
1866
  const panel = wrapper.get(`#${knitwear.attributes('aria-controls')}`);
1867
+ expect(panel.find('[data-eldra-mega-view-all]').exists()).toBe(false);
1868
+ // Nothing follows the columns: the footer row is empty, and `:empty` hides it.
1869
+ const footer = panel.find('[data-part="footer"]');
1870
+ expect(footer.exists() ? footer.element.children.length : 0).toBe(0);
1871
+ expect(await axe(wrapper.element)).toHaveNoViolations();
1872
+ wrapper.unmount();
1873
+ });
1874
+
1875
+ it("offers the parent's own destination as a View all row under a panel of plain children", async () => {
1876
+ // A menu stored before sections existed has no headings to link from, so the parent's page
1877
+ // is offered under its columns.
1878
+ const wrapper = mountBlock(
1879
+ {
1880
+ ...resolved.data,
1881
+ links: [
1882
+ {
1883
+ kind: 'url',
1884
+ url: '/collections/knitwear',
1885
+ label: 'Knitwear',
1886
+ children: [
1887
+ {
1888
+ kind: 'url',
1889
+ url: '/collections/sweaters',
1890
+ label: 'Sweaters',
1891
+ group: 'Women',
1892
+ },
1893
+ ],
1894
+ },
1895
+ ],
1896
+ },
1897
+ { attachTo: document.body }
1898
+ );
1899
+ const knitwear = wrapper.findAll('button').find((b) => b.text().includes('Knitwear'))!;
1900
+ await knitwear.trigger('click');
1901
+ const panel = wrapper.get(`#${knitwear.attributes('aria-controls')}`);
1687
1902
  const viewAll = panel.get('[data-eldra-mega-view-all]');
1688
1903
  // The trigger gave the destination up when it became a disclosure; the panel offers it.
1689
1904
  expect(viewAll.attributes('href')).toBe('/collections/knitwear');
1690
1905
  expect(viewAll.text()).toBe('View all');
1691
1906
  // Self-descriptive out of context (2.4.4), opening with the visible text (2.5.3).
1692
1907
  expect(viewAll.attributes('aria-label')).toBe('View all Knitwear');
1693
- // Right-aligned under a rule across the content width: it follows the columns, outside their grid.
1694
1908
  const row = viewAll.element.parentElement!;
1695
1909
  for (const token of ['justify-end', 'eldra:border-t', 'eldra:border-border', 'eldra:pt-4']) {
1696
1910
  expect([...row.classList]).toContain(token);
1697
1911
  }
1698
1912
  expect(row.previousElementSibling?.getAttribute('data-part')).toBe('columns');
1699
- // The trailing arrow the theme's other "view all" links carry, drawn outside the label so
1700
- // the underline runs under the words only.
1701
1913
  expect(viewAll.find('[data-part="arrow"]').exists()).toBe(true);
1702
1914
  expect(await axe(wrapper.element)).toHaveNoViolations();
1703
1915
  wrapper.unmount();
@@ -1735,7 +1947,10 @@ describe('header block (navigation apiId)', () => {
1735
1947
  const wrapper = mount(Block, {
1736
1948
  ...base,
1737
1949
  attachTo: document.body,
1738
- global: { ...base.global, stubs: { ...base.global.stubs, transition: false } },
1950
+ global: {
1951
+ ...base.global,
1952
+ stubs: { ...base.global.stubs, transition: false },
1953
+ },
1739
1954
  });
1740
1955
  const knitwear = wrapper.findAll('button').find((b) => b.text().includes('Knitwear'))!;
1741
1956
  const panel = (): DOMWrapper<Element> =>
@@ -1744,7 +1959,7 @@ describe('header block (navigation apiId)', () => {
1744
1959
  await knitwear.trigger('click');
1745
1960
  expect(knitwear.attributes('aria-expanded')).toBe('true');
1746
1961
  expect(panel().get('[data-part="content"]').classes(), 'enter').toContain(
1747
- 'eldra:animate-eldra-popover-in'
1962
+ 'eldra:animate-eldra-menu-in'
1748
1963
  );
1749
1964
 
1750
1965
  await knitwear.trigger('click');
@@ -2057,7 +2272,6 @@ describe('header block (navigation apiId)', () => {
2057
2272
  brandText: 'Northwind Goods',
2058
2273
  links: [],
2059
2274
  showSearch: true,
2060
- searchStyle: 'icon',
2061
2275
  sticky: true,
2062
2276
  transparentOverHero: false,
2063
2277
  };
@@ -2078,16 +2292,21 @@ describe('header block (navigation apiId)', () => {
2078
2292
  // and a Menu button that opens an empty sheet is a control that does nothing.
2079
2293
  const wrapper = mountBlock(SEEDED);
2080
2294
  expect(wrapper.find('button[aria-label="Menu"]').exists()).toBe(false);
2081
- // `dialog[aria-label="Menu"]` is the drawer itself; the search overlay's own `<dialog>`
2082
- // renders either way, so the drawer has to be named rather than counted.
2083
- expect(wrapper.find('dialog[aria-label="Menu"]').exists()).toBe(false);
2084
- expect(mountBlock(resolved.data).find('dialog[aria-label="Menu"]').exists()).toBe(true);
2295
+ expect(wrapper.find('[data-part="drawer"]').exists()).toBe(false);
2296
+ expect(mountBlock(resolved.data).find('[data-part="drawer"]').exists()).toBe(true);
2085
2297
  });
2086
2298
 
2087
2299
  it('keeps the Menu button as soon as the drawer has something to show', () => {
2088
2300
  for (const data of [
2089
- { ...SEEDED, links: [{ kind: 'url', url: '/journal', label: 'Journal' }] },
2090
- { ...SEEDED, ctaLabel: 'Shop', cta: { kind: 'url', url: '/collections/all' } },
2301
+ {
2302
+ ...SEEDED,
2303
+ links: [{ kind: 'url', url: '/journal', label: 'Journal' }],
2304
+ },
2305
+ {
2306
+ ...SEEDED,
2307
+ ctaLabel: 'Shop',
2308
+ cta: { kind: 'url', url: '/collections/all' },
2309
+ },
2091
2310
  ]) {
2092
2311
  const wrapper = mountBlock(data);
2093
2312
  expect(wrapper.find('button[aria-label="Menu"]').exists()).toBe(true);
@@ -2125,12 +2344,18 @@ describe('header block (navigation apiId)', () => {
2125
2344
 
2126
2345
  describe('transparentOverHero', () => {
2127
2346
  it('field off renders solid, with no data-eldra-transparent attribute', () => {
2128
- const wrapper = mountBlock({ ...resolved.data, transparentOverHero: false });
2347
+ const wrapper = mountBlock({
2348
+ ...resolved.data,
2349
+ transparentOverHero: false,
2350
+ });
2129
2351
  expect(wrapper.find('header').attributes('data-eldra-transparent')).toBeUndefined();
2130
2352
  });
2131
2353
 
2132
2354
  it('field on sets the transparent attribute (the block only reads its own field)', () => {
2133
- const wrapper = mountBlock({ ...resolved.data, transparentOverHero: true });
2355
+ const wrapper = mountBlock({
2356
+ ...resolved.data,
2357
+ transparentOverHero: true,
2358
+ });
2134
2359
  expect(wrapper.find('header').attributes('data-eldra-transparent')).toBe('true');
2135
2360
  });
2136
2361
  });
@@ -2168,7 +2393,10 @@ describe('header block (navigation apiId)', () => {
2168
2393
  /** Mirrors `trust-strip`'s own `ResizeObserver` stub: jsdom has none at all, so this replaces
2169
2394
  * `globalThis.ResizeObserver` with a fake that only captures the callback the block passes,
2170
2395
  * letting a test call `trigger()` after changing the header's measured height. */
2171
- function stubResizeObserver(): { trigger: () => void; restore: () => void } {
2396
+ function stubResizeObserver(): {
2397
+ trigger: () => void;
2398
+ restore: () => void;
2399
+ } {
2172
2400
  let captured: ResizeObserverCallback | null = null;
2173
2401
  class FakeResizeObserver {
2174
2402
  constructor(callback: ResizeObserverCallback) {
@@ -2255,6 +2483,61 @@ describe('header block (navigation apiId)', () => {
2255
2483
  }
2256
2484
  });
2257
2485
 
2486
+ /**
2487
+ * WS-1277: the variable is the bar's **visible** height. Readers offset a sticky box by it (the
2488
+ * collection grid's filter rail and filter bar), so while the bar is slid away it must be 0 —
2489
+ * the full height left those boxes hanging a header's height below the top over nothing.
2490
+ */
2491
+ it('publishes 0px while the bar is slid away on scroll-down, and the height again when it returns', async () => {
2492
+ const stub = stubResizeObserver();
2493
+ try {
2494
+ const wrapper = mountBlock({ ...resolved.data, sticky: true }, { attachTo: document.body });
2495
+ const header = wrapper.get('header').element as HTMLElement;
2496
+ stubHeaderHeight(header, 72);
2497
+ Object.defineProperty(header, 'offsetHeight', {
2498
+ value: 72,
2499
+ configurable: true,
2500
+ });
2501
+ await nextTick();
2502
+ stub.trigger();
2503
+ const value = () =>
2504
+ document.documentElement.style.getPropertyValue('--eldra-header-height');
2505
+ const scrollTo = async (y: number) => {
2506
+ Object.defineProperty(window, 'scrollY', {
2507
+ value: y,
2508
+ configurable: true,
2509
+ });
2510
+ window.dispatchEvent(new Event('scroll'));
2511
+ await nextTick();
2512
+ };
2513
+ expect(value()).toBe('72px');
2514
+
2515
+ await scrollTo(400); // down past the bar: it slides away
2516
+ expect(wrapper.get('header').classes()).toContain('-translate-y-full');
2517
+ expect(value()).toBe('0px');
2518
+
2519
+ // A resize while hidden is measured (the spacer keeps the bar's room) but not published.
2520
+ stubHeaderHeight(header, 96);
2521
+ stub.trigger();
2522
+ expect(value()).toBe('0px');
2523
+ await nextTick();
2524
+ expect(wrapper.get('[data-eldra-header-spacer]').attributes('style')).toBe('height: 96px;');
2525
+
2526
+ await scrollTo(300); // up: it returns, and so does its height
2527
+ expect(wrapper.get('header').classes()).not.toContain('-translate-y-full');
2528
+ expect(value()).toBe('96px');
2529
+
2530
+ wrapper.unmount();
2531
+ expect(value()).toBe('');
2532
+ } finally {
2533
+ stub.restore();
2534
+ Object.defineProperty(window, 'scrollY', {
2535
+ value: 0,
2536
+ configurable: true,
2537
+ });
2538
+ }
2539
+ });
2540
+
2258
2541
  it('never publishes the variable for a non-sticky header', async () => {
2259
2542
  const stub = stubResizeObserver();
2260
2543
  try {
@@ -2279,7 +2562,11 @@ describe('header block (navigation apiId)', () => {
2279
2562
  describe('the Northwind menu (the seed’s own)', () => {
2280
2563
  const PRODUCT_TEMPLATE = {
2281
2564
  id: 'rt-product',
2282
- data: { schemaApiId: 'catalog:product', routePattern: '/products/:slug', slugField: 'slug' },
2565
+ data: {
2566
+ schemaApiId: 'catalog:product',
2567
+ routePattern: '/products/:slug',
2568
+ slugField: 'slug',
2569
+ },
2283
2570
  };
2284
2571
  const PRODUCT_TARGETS: Record<string, { image: string; price: number }> = {
2285
2572
  'speckled-latte-mug': { image: '/images/mug.webp', price: 28 },
@@ -2329,7 +2616,7 @@ describe('the Northwind menu (the seed’s own)', () => {
2329
2616
  expect(strip.attributes('aria-label')).toBe('Store information');
2330
2617
  const [start, end] = strip.findAll('ul');
2331
2618
  expect(start!.findAll('li').map((li) => li.text())).toEqual([
2332
- 'Free delivery over $80',
2619
+ 'Free delivery over $80.00',
2333
2620
  '30-day returns',
2334
2621
  'Shop open today 10–18',
2335
2622
  ]);
@@ -2376,10 +2663,12 @@ describe('the Northwind menu (the seed’s own)', () => {
2376
2663
  .filter((button) => button.text().trim() === 'Search');
2377
2664
  expect(search).toHaveLength(1);
2378
2665
  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');
2666
+ // The labelled Search tool at every width: no pill field or inline bar takes its place on a
2667
+ // wide bar.
2668
+ expect(wrapper.text()).not.toContain('Search the shop');
2669
+ expect(search[0]!.classes().filter((c) => c.endsWith(':hidden') || c === 'hidden')).toEqual(
2670
+ []
2671
+ );
2383
2672
  for (const tool of [
2384
2673
  wrapper.get('[aria-label^="Saved"]'),
2385
2674
  wrapper.get('[aria-label^="Cart"]'),
@@ -2414,7 +2703,13 @@ describe('the Northwind menu (the seed’s own)', () => {
2414
2703
  width,
2415
2704
  height,
2416
2705
  });
2417
- const mark = { assetId: 'mark', url: '/mark.svg', altText: '', width: 64, height: 64 };
2706
+ const mark = {
2707
+ assetId: 'mark',
2708
+ url: '/mark.svg',
2709
+ altText: '',
2710
+ width: 64,
2711
+ height: 64,
2712
+ };
2418
2713
  const brand = (wrapper: Wrapper) => wrapper.get('[data-eldra-header-brand]');
2419
2714
 
2420
2715
  it('names the link once, so whichever picture a width shows, it reads the same', async () => {
@@ -2522,6 +2817,12 @@ describe('the Northwind menu (the seed’s own)', () => {
2522
2817
  'Mornings with the people who make our goods',
2523
2818
  'Small rituals and slow mornings',
2524
2819
  ]);
2820
+ const first = journal.get('a').element;
2821
+ expect(first.getAttribute('aria-describedby')).toBe(
2822
+ journal.get('[data-part="description"]').attributes('id')
2823
+ );
2824
+ const nameId = first.getAttribute('aria-labelledby')!;
2825
+ expect(document.getElementById(nameId)!.textContent).not.toContain('Washing linen');
2525
2826
  expect(await axe(wrapper.element)).toHaveNoViolations();
2526
2827
  });
2527
2828
 
@@ -2560,3 +2861,336 @@ describe('the Northwind menu (the seed’s own)', () => {
2560
2861
  );
2561
2862
  });
2562
2863
  });
2864
+
2865
+ /**
2866
+ * WS-1277, the design boards `Currency-strip`, `Currency-strip-open`, `Currency-tablet` and
2867
+ * `Currency-phone`: with an info strip the currency is a setting at the strip's end, "Prices in
2868
+ * ISK", from 47.625rem; the bar has no picker of its own then; the phone menu's foot keeps it as a
2869
+ * labelled select; and with no strip the bar keeps the boxed picker.
2870
+ */
2871
+ describe('the currency', () => {
2872
+ const COMMERCE = {
2873
+ currency: 'ISK',
2874
+ currencies: ['ISK', 'EUR', 'USD'],
2875
+ taxInclusivePricing: true,
2876
+ defaultTaxRate: 0.24,
2877
+ };
2878
+ function mountWithCurrencies(data: Record<string, unknown> = {}) {
2879
+ return mount(Block, {
2880
+ ...mountOptions(
2881
+ { entry: { id: 'e1', data: { ...resolved.data, ...data } } },
2882
+ { links: resolved.links, commerce: COMMERCE }
2883
+ ),
2884
+ attachTo: document.body,
2885
+ });
2886
+ }
2887
+ type Wrapper = ReturnType<typeof mountWithCurrencies>;
2888
+ const pickers = (wrapper: Wrapper) => wrapper.findAll('button[role="combobox"]');
2889
+ const stripPicker = (wrapper: Wrapper) => wrapper.find('[data-eldra-header-currency]');
2890
+ const barPicker = (wrapper: Wrapper) =>
2891
+ wrapper
2892
+ .findAllComponents(CurrencyPicker)
2893
+ .find((picker) => picker.element.closest?.('[data-eldra-header-actions]') != null)!;
2894
+
2895
+ afterEach(() => {
2896
+ document.body.innerHTML = '';
2897
+ });
2898
+
2899
+ it('reads "Prices in ISK" at the end of the strip, from 47.625rem, after a rule', async () => {
2900
+ const wrapper = mountWithCurrencies();
2901
+ const strip = stripPicker(wrapper);
2902
+ expect(strip.exists()).toBe(true);
2903
+ expect(strip.element.closest('[data-eldra-header-info]')).not.toBeNull();
2904
+ // Phones have no room for it in the strip: it is in the menu's foot there.
2905
+ expect(strip.classes()).toContain('@max-[47.5625rem]:hidden');
2906
+ // The rule before it, where Help and Order status show beside it.
2907
+ expect(strip.classes()).toContain('@min-[68.8125rem]:border-l');
2908
+ const button = strip.get('button[role="combobox"]');
2909
+ expect(button.text().replace(/\s+/g, ' ').trim()).toBe('Prices in ISK');
2910
+ expect(button.get('b').text()).toBe('ISK');
2911
+ // Named by its own label, which starts with the visible words (2.5.3).
2912
+ const name = document.getElementById(button.attributes('aria-labelledby')!.split(' ')[0]!);
2913
+ expect(name?.textContent).toContain('Prices in');
2914
+ expect(await axe(wrapper.element)).toHaveNoViolations();
2915
+ });
2916
+
2917
+ it('lists each currency by name with its code beside it, and chooses one', async () => {
2918
+ const wrapper = mountWithCurrencies();
2919
+ const button = stripPicker(wrapper).get('button[role="combobox"]');
2920
+ (button.element as HTMLElement).focus();
2921
+ await button.trigger('keydown', { key: 'ArrowDown' });
2922
+ await flushIcons();
2923
+ const rows = [...document.querySelectorAll('[role="option"]')];
2924
+ expect(rows.map((row) => row.querySelector('small')?.textContent)).toEqual([
2925
+ 'ISK',
2926
+ 'EUR',
2927
+ 'USD',
2928
+ ]);
2929
+ expect(rows[1]!.textContent).toContain('Euro');
2930
+ // Lifted over the fixed bar it is teleported out from under.
2931
+ expect(rows[0]!.closest('[data-part="panel"]')!.className).toContain('z-41');
2932
+ (rows[1] as HTMLElement).click();
2933
+ await flushIcons();
2934
+ expect(wrapper.findAllComponents(CurrencyPicker)[0]!.emitted('update:modelValue')).toEqual([
2935
+ ['EUR'],
2936
+ ]);
2937
+ });
2938
+
2939
+ it('puts no picker in the bar while the strip has one', () => {
2940
+ const wrapper = mountWithCurrencies();
2941
+ expect(barPicker(wrapper).classes()).toContain('hidden');
2942
+ });
2943
+
2944
+ it('keeps a labelled select in the phone menu’s foot, the full name showing', async () => {
2945
+ const wrapper = mountWithCurrencies();
2946
+ await wrapper.get('[data-part="toggle"]').trigger('click');
2947
+ const foot = wrapper.get('[data-part="drawer"] [data-eldra-header-drawer-currency]');
2948
+ const label = foot.get('label');
2949
+ expect(label.text()).toBe('Prices in');
2950
+ expect(label.find('svg').exists()).toBe(true);
2951
+ expect(label.classes()).not.toContain('eldra:sr-only');
2952
+ const select = foot.get('button[role="combobox"]');
2953
+ expect(select.text()).toContain('(ISK)');
2954
+ // A rule above it, after Account, Saved items and the strip's own links.
2955
+ expect(foot.classes()).toContain('border-t');
2956
+ const bar = wrapper.find('[data-part="nav"]');
2957
+ if (bar.exists()) (bar.element as HTMLElement).style.display = 'none';
2958
+ expect(await axe(wrapper.element)).toHaveNoViolations();
2959
+ });
2960
+
2961
+ it('falls back to the bar with no info strip', () => {
2962
+ const withMenu = mountWithCurrencies({ infoItems: [] });
2963
+ expect(stripPicker(withMenu).exists()).toBe(false);
2964
+ // Where the links are inline; the drawer's foot holds it below 68.8125rem.
2965
+ expect(barPicker(withMenu).classes()).toContain('@min-[68.8125rem]:block');
2966
+ expect(barPicker(withMenu).classes()).toContain('hidden');
2967
+ const noMenu = mountWithCurrencies({
2968
+ infoItems: [],
2969
+ links: [],
2970
+ ctaLabel: undefined,
2971
+ cta: undefined,
2972
+ });
2973
+ expect(barPicker(noMenu).classes()).toContain('ml-1');
2974
+ expect(barPicker(noMenu).classes()).not.toContain('hidden');
2975
+ });
2976
+
2977
+ it('keeps the bar picker for a phone with a strip but no menu to hold it', () => {
2978
+ const wrapper = mountWithCurrencies({
2979
+ links: [],
2980
+ ctaLabel: undefined,
2981
+ cta: undefined,
2982
+ });
2983
+ expect(stripPicker(wrapper).exists()).toBe(true);
2984
+ expect(barPicker(wrapper).classes()).toContain('@min-[47.625rem]:hidden');
2985
+ expect(barPicker(wrapper).classes()).not.toContain('hidden');
2986
+ });
2987
+
2988
+ it('draws nothing at all with one currency', () => {
2989
+ const wrapper = mount(Block, {
2990
+ ...mountOptions({ entry: { id: 'e1', data: resolved.data } }, { links: resolved.links }),
2991
+ attachTo: document.body,
2992
+ });
2993
+ expect(stripPicker(wrapper).exists()).toBe(false);
2994
+ expect(pickers(wrapper)).toHaveLength(0);
2995
+ });
2996
+ });
2997
+
2998
+ /**
2999
+ * The language picker sits beside the currency picker, wherever that one is: the strip's end, the
3000
+ * phone menu's foot, or the bar. It is there only when the organisation serves more than one
3001
+ * locale, and choosing a language is a navigation to the same page in it (`select`).
3002
+ */
3003
+ describe('the language', () => {
3004
+ const select = vi.fn();
3005
+ const LOCALES = {
3006
+ active: 'en-US',
3007
+ defaultLocale: 'en-US',
3008
+ supported: ['en-US', 'is-IS'],
3009
+ name: (tag: string) => (tag === 'is-IS' ? 'íslenska (Ísland)' : 'American English'),
3010
+ select,
3011
+ };
3012
+ function mountWithLocales(
3013
+ data: Record<string, unknown> = {},
3014
+ locales: Record<string, unknown> = LOCALES
3015
+ ) {
3016
+ return mount(Block, {
3017
+ ...mountOptions(
3018
+ { entry: { id: 'e1', data: { ...resolved.data, ...data } } },
3019
+ { links: resolved.links, locales }
3020
+ ),
3021
+ attachTo: document.body,
3022
+ });
3023
+ }
3024
+ type Wrapper = ReturnType<typeof mountWithLocales>;
3025
+ const localePickers = (wrapper: Wrapper) => wrapper.findAll('[data-eldra-header-locale-picker]');
3026
+
3027
+ afterEach(() => {
3028
+ document.body.innerHTML = '';
3029
+ select.mockClear();
3030
+ });
3031
+
3032
+ it('draws no language picker on a site with one locale, or none', () => {
3033
+ for (const supported of [[], ['en-US']]) {
3034
+ const wrapper = mountWithLocales({}, { ...LOCALES, supported });
3035
+ expect(localePickers(wrapper)).toHaveLength(0);
3036
+ wrapper.unmount();
3037
+ }
3038
+ });
3039
+
3040
+ it('reads the language code at the strip’s end, beside the currency, and is named Language', async () => {
3041
+ const wrapper = mountWithLocales();
3042
+ const strip = wrapper.get('[data-eldra-header-currency]');
3043
+ expect(strip.element.closest('[data-eldra-header-info]')).not.toBeNull();
3044
+ const picker = strip.get('[data-eldra-header-locale-picker]');
3045
+ const button = picker.get('button[role="combobox"]');
3046
+ expect(button.get('b').text()).toBe('EN');
3047
+ const name = document.getElementById(button.attributes('aria-labelledby')!.split(' ')[0]!);
3048
+ expect(name?.textContent).toContain('Language');
3049
+ expect(await axe(wrapper.element)).toHaveNoViolations();
3050
+ });
3051
+
3052
+ it('lists each locale by its own name and goes to the same page in the one chosen', async () => {
3053
+ const wrapper = mountWithLocales();
3054
+ const button = wrapper
3055
+ .get('[data-eldra-header-currency] [data-eldra-header-locale-picker]')
3056
+ .get('button[role="combobox"]');
3057
+ (button.element as HTMLElement).focus();
3058
+ await button.trigger('keydown', { key: 'ArrowDown' });
3059
+ await flushIcons();
3060
+ const rows = [...document.querySelectorAll('[role="option"]')];
3061
+ expect(rows.map((row) => row.querySelector('small')?.textContent)).toEqual(['EN', 'IS']);
3062
+ expect(rows[1]!.textContent).toContain('íslenska (Ísland)');
3063
+ expect(rows[0]!.closest('[data-part="panel"]')!.className).toContain('z-41');
3064
+ (rows[1] as HTMLElement).click();
3065
+ await flushIcons();
3066
+ expect(select).toHaveBeenCalledWith('is-IS');
3067
+ // A navigation, not local state: the picker still shows the page's own locale until it lands.
3068
+ expect(button.get('b').text()).toBe('EN');
3069
+ });
3070
+
3071
+ it('keeps a labelled select in the phone menu’s foot, with a single currency', async () => {
3072
+ const wrapper = mountWithLocales();
3073
+ await wrapper.get('[data-part="toggle"]').trigger('click');
3074
+ const foot = wrapper.get('[data-part="drawer"] [data-eldra-header-drawer-currency]');
3075
+ const picker = foot.get('[data-eldra-header-locale-picker]');
3076
+ expect(picker.get('label').text()).toBe('Language');
3077
+ expect(picker.get('button[role="combobox"]').text()).toContain('American English');
3078
+ const bar = wrapper.find('[data-part="nav"]');
3079
+ if (bar.exists()) (bar.element as HTMLElement).style.display = 'none';
3080
+ expect(await axe(wrapper.element)).toHaveNoViolations();
3081
+ });
3082
+
3083
+ it('falls back to the bar with no info strip, where the currency picker would be', () => {
3084
+ const wrapper = mountWithLocales({ infoItems: [] });
3085
+ expect(wrapper.find('[data-eldra-header-currency]').exists()).toBe(false);
3086
+ const inBar = localePickers(wrapper).filter(
3087
+ (picker) => picker.element.closest('[data-eldra-header-actions]') !== null
3088
+ );
3089
+ expect(inBar).toHaveLength(1);
3090
+ expect(inBar[0]!.classes()).toContain('@min-[68.8125rem]:block');
3091
+ });
3092
+ });
3093
+
3094
+ /** WS-1277: the rest of the design's header — Sale in the accent, Account in the bar, the Journal
3095
+ * dropdown's card, and the phone menu's foot. */
3096
+ describe('the Northwind header details', () => {
3097
+ afterEach(() => {
3098
+ document.body.innerHTML = '';
3099
+ });
3100
+
3101
+ it('draws a link the merchant marked tone: "accent" in the accent colour, in the bar and the menu', async () => {
3102
+ const wrapper = mountBlock(
3103
+ {
3104
+ ...resolved.data,
3105
+ links: [
3106
+ { kind: 'url', url: '/journal', label: 'Journal' },
3107
+ { kind: 'url', url: '/sale', label: 'Sale', tone: 'accent' },
3108
+ ],
3109
+ },
3110
+ { attachTo: document.body }
3111
+ );
3112
+ const [journal, sale] = wrapper.findAll('[data-part="link"]');
3113
+ expect(sale!.attributes('data-tone')).toBe('accent');
3114
+ expect(sale!.classes()).toContain('eldra:text-accent');
3115
+ expect(journal!.attributes('data-tone')).toBeUndefined();
3116
+ const row = wrapper.findAll('[data-part="drawerLink"]').find((r) => r.text() === 'Sale')!;
3117
+ expect(row.attributes('data-tone')).toBe('accent');
3118
+ // The seed's own Sale carries it.
3119
+ expect(seed.links.find((link) => link.label === 'Sale')).toMatchObject({
3120
+ tone: 'accent',
3121
+ });
3122
+ wrapper.unmount();
3123
+ });
3124
+
3125
+ it('shows Account between the links and Saved from 68.8125rem, and in the menu’s foot below', async () => {
3126
+ const wrapper = mountBlock(
3127
+ {
3128
+ ...resolved.data,
3129
+ account: { kind: 'url', url: '/pages/account', label: 'Account' },
3130
+ },
3131
+ { attachTo: document.body }
3132
+ );
3133
+ const actions = wrapper.get('[data-eldra-header-actions]');
3134
+ const tools = actions.findAll('a, button').map((tool) => tool.text().trim());
3135
+ expect(tools.slice(0, 3)).toEqual(['Account', 'Saved', 'Cart']);
3136
+ const account = actions.findAll('a').find((a) => a.text().trim() === 'Account')!;
3137
+ expect(account.attributes('href')).toBe('/pages/account');
3138
+ expect(account.classes()).toContain('@max-[68.8125rem]:hidden');
3139
+ const foot = wrapper.get('[data-part="drawer"] [data-eldra-header-drawer-links]');
3140
+ expect(foot.findAll('a').map((a) => a.text().trim())).toContain('Account');
3141
+ wrapper.unmount();
3142
+ });
3143
+
3144
+ it('draws the Journal dropdown as a 21rem card of titled rows, its "see all" lined up with them', async () => {
3145
+ const wrapper = mount(Block, {
3146
+ ...mountOptions(
3147
+ { entry: { id: 'e1', data: resolveTargets(seed).data } },
3148
+ {
3149
+ links: resolveTargets(seed).links,
3150
+ }
3151
+ ),
3152
+ attachTo: document.body,
3153
+ });
3154
+ const journal = wrapper.findAll('button').find((b) => b.text().includes('Journal'))!;
3155
+ await journal.trigger('click');
3156
+ const panel = wrapper.get(`#${journal.attributes('aria-controls')}`);
3157
+ expect(panel.attributes('data-layout')).toBe('dropdown');
3158
+ const card = panel.get('[data-part="content"]');
3159
+ expect(card.attributes('data-layout')).toBe('dropdown');
3160
+ for (const token of [
3161
+ 'data-[layout=dropdown]:w-[21rem]',
3162
+ 'data-[layout=dropdown]:rounded-lg',
3163
+ 'data-[layout=dropdown]:border',
3164
+ 'shadow-md',
3165
+ ]) {
3166
+ expect(card.classes()).toContain(token);
3167
+ }
3168
+ const rows = panel.findAll('[data-part="panelLink"]');
3169
+ // Every row, the "see all" too, starts its text 0.75rem in.
3170
+ for (const row of rows) expect(row.classes()).toContain('in-data-[layout=dropdown]:px-3');
3171
+ expect(rows[0]!.classes()).toContain('in-data-[layout=dropdown]:hover:bg-surface');
3172
+ expect(rows[0]!.get('[data-part="description"]').text()).toBe(
3173
+ 'Washing linen, seasoning boards, storing wool'
3174
+ );
3175
+ expect(rows[0]!.get('[data-part="panelLabel"]').classes()).toContain(
3176
+ 'in-data-[layout=dropdown]:font-semibold'
3177
+ );
3178
+ expect(rows.at(-1)!.attributes('data-see-all')).toBe('');
3179
+ expect(rows.at(-1)!.text()).toBe('All articles');
3180
+ expect(await axe(wrapper.element)).toHaveNoViolations();
3181
+ wrapper.unmount();
3182
+ });
3183
+
3184
+ it('gives the menu’s foot a phone icon for the strip’s phone number', async () => {
3185
+ const wrapper = mountBlock(resolved.data, { attachTo: document.body });
3186
+ await wrapper.get('[data-part="toggle"]').trigger('click');
3187
+ await flushIcons();
3188
+ const foot = wrapper.get('[data-part="drawer"] [data-eldra-header-drawer-links]');
3189
+ const phone = foot.findAll('a').find((a) => a.attributes('href') === 'tel:+15550142290')!;
3190
+ expect(phone.find('svg').exists()).toBe(true);
3191
+ // Help has no icon of its own and is given none.
3192
+ const help = foot.findAll('a').find((a) => a.text().trim() === 'Help')!;
3193
+ expect(help.find('svg').exists()).toBe(false);
3194
+ wrapper.unmount();
3195
+ });
3196
+ });