@eldrajs/theme-cli 0.2.5 → 0.2.6

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 (90) hide show
  1. package/package.json +3 -3
  2. package/template/.eldra/block-types.d.ts +1 -1
  3. package/template/.eldra/manifest.json +30 -2
  4. package/template/.eldra/previews.json +35 -35
  5. package/template/app/app.vue +15 -0
  6. package/template/app/composables/useStorefront.ts +7 -2
  7. package/template/app/plugins/eldra-storefront.ts +9 -0
  8. package/template/app/storefront/analytics.ts +15 -7
  9. package/template/app/storefront/cart.ts +228 -51
  10. package/template/app/storefront/commerce.ts +8 -2
  11. package/template/app/storefront/currency.ts +205 -0
  12. package/template/app/storefront/demo.ts +10 -2
  13. package/template/app/storefront/feedback.ts +2 -0
  14. package/template/app/storefront/gateway.ts +153 -35
  15. package/template/app/storefront/money.ts +6 -18
  16. package/template/app/storefront/structuredData.ts +16 -5
  17. package/template/app/storefront/toProductCard.ts +14 -14
  18. package/template/app/storefront/types.ts +13 -0
  19. package/template/app/storefront/volatile.ts +4 -0
  20. package/template/app/utils/seoInput.ts +4 -3
  21. package/template/blocks/announcement-bar/preview.png +0 -0
  22. package/template/blocks/article/preview.png +0 -0
  23. package/template/blocks/article-list/preview.png +0 -0
  24. package/template/blocks/breadcrumbs/preview.png +0 -0
  25. package/template/blocks/cart/Block.vue +41 -22
  26. package/template/blocks/cart/__tests__/Block.spec.ts +2 -3
  27. package/template/blocks/cart/__tests__/loadFailed.spec.ts +135 -0
  28. package/template/blocks/cart/__tests__/notSold.spec.ts +109 -0
  29. package/template/blocks/cart/parts/CartLines.vue +14 -2
  30. package/template/blocks/cart/parts/CheckoutButton.vue +45 -0
  31. package/template/blocks/cart/parts/LoadFailed.vue +37 -0
  32. package/template/blocks/cart/parts/NotSoldNotice.vue +69 -0
  33. package/template/blocks/cart/parts/Summary.vue +9 -21
  34. package/template/blocks/cart/parts/notSold.ts +19 -0
  35. package/template/blocks/cart/preview.png +0 -0
  36. package/template/blocks/collection-grid/Block.vue +15 -2
  37. package/template/blocks/collection-grid/__tests__/Block.spec.ts +14 -0
  38. package/template/blocks/collection-grid/preview.png +0 -0
  39. package/template/blocks/collection-header/preview.png +0 -0
  40. package/template/blocks/contact/preview.png +0 -0
  41. package/template/blocks/cta/preview.png +0 -0
  42. package/template/blocks/faq/preview.png +0 -0
  43. package/template/blocks/feature-grid/preview.png +0 -0
  44. package/template/blocks/footer/Block.vue +20 -45
  45. package/template/blocks/footer/preview.png +0 -0
  46. package/template/blocks/form/preview.png +0 -0
  47. package/template/blocks/gallery/preview.png +0 -0
  48. package/template/blocks/hero/preview.png +0 -0
  49. package/template/blocks/image/preview.png +0 -0
  50. package/template/blocks/logo-cloud/preview.png +0 -0
  51. package/template/blocks/navigation/Block.vue +39 -3
  52. package/template/blocks/navigation/preview.png +0 -0
  53. package/template/blocks/newsletter/preview.png +0 -0
  54. package/template/blocks/order-status/Block.vue +15 -6
  55. package/template/blocks/order-status/preview.png +0 -0
  56. package/template/blocks/pricing-table/preview.png +0 -0
  57. package/template/blocks/product-carousel/Block.vue +5 -2
  58. package/template/blocks/product-carousel/preview.png +0 -0
  59. package/template/blocks/product-detail/Block.vue +46 -10
  60. package/template/blocks/product-detail/__tests__/Block.spec.ts +78 -1
  61. package/template/blocks/product-detail/preview.png +0 -0
  62. package/template/blocks/quote/preview.png +0 -0
  63. package/template/blocks/rich-text/preview.png +0 -0
  64. package/template/blocks/search/Block.vue +8 -2
  65. package/template/blocks/search/TypeSection.vue +8 -2
  66. package/template/blocks/search/preview.png +0 -0
  67. package/template/blocks/search/results.ts +5 -2
  68. package/template/blocks/split-content/preview.png +0 -0
  69. package/template/blocks/stats/preview.png +0 -0
  70. package/template/blocks/tabs/preview.png +0 -0
  71. package/template/blocks/team/preview.png +0 -0
  72. package/template/blocks/testimonials/preview.png +0 -0
  73. package/template/blocks/timeline/preview.png +0 -0
  74. package/template/blocks/trust-strip/preview.png +0 -0
  75. package/template/blocks/video-embed/preview.png +0 -0
  76. package/template/blocks/wishlist/Block.vue +5 -1
  77. package/template/blocks/wishlist/preview.png +0 -0
  78. package/template/i18n/en-US.json +19 -3
  79. package/template/i18n/is-IS.json +19 -3
  80. package/template/test/currencyPicker.spec.ts +66 -0
  81. package/template/test/seoInput.spec.ts +22 -0
  82. package/template/test/storefront/analytics.spec.ts +15 -0
  83. package/template/test/storefront/cart.spec.ts +4 -4
  84. package/template/test/storefront/currency.spec.ts +549 -0
  85. package/template/test/storefront/currencyStore.spec.ts +845 -0
  86. package/template/test/storefront/gateway.spec.ts +22 -0
  87. package/template/test/storefront/money.spec.ts +2 -8
  88. package/template/test/storefront/structuredData.spec.ts +45 -0
  89. package/template/test/storefront/toProductCard.spec.ts +1 -1
  90. package/template/test/storefront/volatile.spec.ts +11 -0
@@ -4,7 +4,7 @@ import { computed, defineComponent, h, nextTick, ref } from 'vue';
4
4
  import { ELDRA_KEY, type EldraLocaleState } from '@eldrajs/theme-vue';
5
5
  import { EldraHttpError } from '@eldrajs/sdk';
6
6
  import { useToast, type ToastAction } from '@eldrajs/ui';
7
- import { afterEach, describe, expect, it } from 'vitest';
7
+ import { afterEach, describe, expect, it, vi } from 'vitest';
8
8
  import { axe } from '../../../test/support/axe';
9
9
  import { mountOptions } from '../../../test/support/mountBlock';
10
10
  import { createDemoStorefront } from '../../../app/storefront/demo';
@@ -1046,6 +1046,83 @@ describe('product-detail block', () => {
1046
1046
  expect(storefront.cart.lines.value[0]!.quantity).toBe(2);
1047
1047
  });
1048
1048
 
1049
+ it('offers the store currency in place of adding a product with no price in the chosen one', async () => {
1050
+ const storefront = storefrontWith({
1051
+ price: { amount: 96, compareAt: null, currency: 'USD', soldInCurrency: false },
1052
+ });
1053
+ storefront.currency.offered.value = ['USD', 'EUR'];
1054
+ storefront.currency.started.value = true;
1055
+ storefront.currency.choose('EUR');
1056
+ await vi.waitFor(() => expect(storefront.currency.active.value).toBe('EUR'));
1057
+ const wrapper = await mountReady(mock, { storefront });
1058
+
1059
+ expect(wrapper.get('[data-eldra-not-sold]').text()).toBe('Not available in EUR.');
1060
+ expect(addToCart(wrapper).attributes('disabled')).toBeUndefined();
1061
+ expect(addToCart(wrapper).text()).toBe('Shop in USD');
1062
+ expect(wrapper.find('[data-part="quantity"]').exists()).toBe(false);
1063
+ expect(await axe(wrapper.element)).toHaveNoViolations();
1064
+
1065
+ await wrapper.get('form').trigger('submit');
1066
+ await flushPromises();
1067
+ expect(storefront.cart.lines.value).toHaveLength(0);
1068
+ expect(storefront.currency.active.value).toBe('USD');
1069
+ });
1070
+
1071
+ it('4662896775: reads the product again when it is already in the store currency', async () => {
1072
+ const storefront = storefrontWith({
1073
+ price: { amount: 96, compareAt: null, currency: 'USD', soldInCurrency: false },
1074
+ });
1075
+ const refreshes: number[] = [];
1076
+ const product = storefront.catalog.product;
1077
+ storefront.catalog.product = (handle) => {
1078
+ const result = product(handle);
1079
+ return {
1080
+ ...result,
1081
+ refresh: async () => {
1082
+ refreshes.push(1);
1083
+ },
1084
+ };
1085
+ };
1086
+ storefront.currency.started.value = true;
1087
+ const wrapper = await mountReady(mock, { storefront });
1088
+ expect(storefront.currency.active.value).toBe('USD');
1089
+ await wrapper.get('form').trigger('submit');
1090
+ await flushPromises();
1091
+ expect(refreshes).toHaveLength(1);
1092
+ });
1093
+
1094
+ it('says the cart will switch when there is one', async () => {
1095
+ const storefront = storefrontWith({
1096
+ price: { amount: 96, compareAt: null, currency: 'USD', soldInCurrency: false },
1097
+ });
1098
+ storefront.currency.offered.value = ['USD', 'EUR'];
1099
+ storefront.currency.started.value = true;
1100
+ storefront.currency.choose('EUR');
1101
+ await vi.waitFor(() => expect(storefront.currency.active.value).toBe('EUR'));
1102
+ await storefront.cart.add({ productId: 'p', variantId: 'v', quantity: 1 });
1103
+ const wrapper = await mountReady(mock, { storefront });
1104
+ expect(wrapper.text()).toContain('Your cart will switch to USD.');
1105
+ });
1106
+
1107
+ it("holds Add to cart while the visitor's currency is still being applied", async () => {
1108
+ const storefront = storefrontWith();
1109
+ storefront.currency.offered.value = ['USD', 'EUR'];
1110
+ const wrapper = await mountReady(mock, { storefront });
1111
+ expect(storefront.currency.pending.value).toBe(true);
1112
+ await wrapper.get('form').trigger('submit');
1113
+ await flushPromises();
1114
+ expect(storefront.cart.lines.value).toHaveLength(0);
1115
+ expect(addToCart(wrapper).attributes('aria-busy')).toBe('true');
1116
+ });
1117
+
1118
+ it('formats the price in the currency it carries', async () => {
1119
+ const storefront = storefrontWith({
1120
+ price: { amount: 19.9, compareAt: null, currency: 'EUR' },
1121
+ });
1122
+ const wrapper = await mountReady(mock, { storefront });
1123
+ expect(addToCart(wrapper).text()).toContain('€19.90');
1124
+ });
1125
+
1049
1126
  it('toggles the wishlist button aria-pressed', async () => {
1050
1127
  const wrapper = await mountReady(mock);
1051
1128
  const button = wrapper.get('button[aria-pressed]');
Binary file
@@ -275,6 +275,7 @@ const isLoading = computed(() => response.value === null && searchResult.loading
275
275
  /** The store's currency and the page's locale, for the suggestion prices below and the
276
276
  * `<ProductCard>`s the no-results state renders (`money.minor`). */
277
277
  const money = useMoney();
278
+ const shopperCurrency = useStorefront().currency.active;
278
279
 
279
280
  const barResults = computed(() =>
280
281
  toSearchBarResults(response.value, suggestionsPerGroup.value, money.format)
@@ -289,7 +290,11 @@ const barResults = computed(() =>
289
290
  * would head a tab "Products (3)" over a grid showing fewer, or, when the pricing read failed, none.
290
291
  */
291
292
  const productCards = computed(() =>
292
- toProductCardEntries(response.value?.products ?? [], { ratio: '4x5', minorUnits: money.minor })
293
+ toProductCardEntries(response.value?.products ?? [], {
294
+ ratio: '4x5',
295
+ minorUnits: money.minor,
296
+ shopperCurrency: shopperCurrency.value,
297
+ })
293
298
  );
294
299
 
295
300
  function countFor(type: ResultTypeId): number {
@@ -380,6 +385,7 @@ const noResultsProducts = computed(() =>
380
385
  toProductCardEntries((noResultsCollection.data.value?.items ?? []).slice(0, 4), {
381
386
  ratio: '4x5',
382
387
  minorUnits: money.minor,
388
+ shopperCurrency: shopperCurrency.value,
383
389
  })
384
390
  );
385
391
  const hasNoResultsProducts = computed(() => noResultsProducts.value.length > 0);
@@ -500,7 +506,7 @@ const headingClass =
500
506
  ratio="4x5"
501
507
  :heading-level="2"
502
508
  :link-as="entry.internal ? EldraRouterLink : undefined"
503
- :currency="currency"
509
+ :currency="entry.currency ?? currency"
504
510
  :locale="locale"
505
511
  />
506
512
  </div>
@@ -13,6 +13,7 @@ import EldraRouterLink from '../../app/components/EldraRouterLink.vue';
13
13
  import { isInternalHref, safeHref } from '../../app/utils/links';
14
14
  import { toProductCardEntries } from '../../app/storefront/toProductCard';
15
15
  import { useMoney } from '../../app/storefront/money';
16
+ import { useStorefront } from '../../app/composables/useStorefront';
16
17
  import type { StorefrontSearchProduct, StorefrontSearchResponse } from '../../app/storefront/types';
17
18
 
18
19
  type ResultTypeId = 'products' | 'journal' | 'pages';
@@ -52,8 +53,13 @@ const props = defineProps<{
52
53
 
53
54
  /** See the `products` prop: sanitised, unusable rows dropped, `internal` per card. */
54
55
  const money = useMoney();
56
+ const shopperCurrency = useStorefront().currency.active;
55
57
  const productCards = computed(() =>
56
- toProductCardEntries(props.products, { ratio: '4x5', minorUnits: money.minor })
58
+ toProductCardEntries(props.products, {
59
+ ratio: '4x5',
60
+ minorUnits: money.minor,
61
+ shopperCurrency: shopperCurrency.value,
62
+ })
57
63
  );
58
64
 
59
65
  /** The journal rows that have a usable link, with the sanitised href and whether it routes. */
@@ -97,7 +103,7 @@ const JOURNAL_GRID_CLASS = 'grid grid-cols-1 gap-6 @tablet:grid-cols-3 @tablet:g
97
103
  ratio="4x5"
98
104
  :heading-level="3"
99
105
  :link-as="entry.internal ? EldraRouterLink : undefined"
100
- :currency="currency"
106
+ :currency="entry.currency ?? currency"
101
107
  :locale="locale"
102
108
  />
103
109
  </div>
Binary file
@@ -45,7 +45,7 @@ function rankProducts(products: StorefrontSearchProduct[]): StorefrontSearchProd
45
45
  export function toSearchBarResults(
46
46
  response: StorefrontSearchResponse | null,
47
47
  suggestionsPerGroup: number,
48
- formatPrice: (amount: number) => string
48
+ formatPrice: (amount: number, currency?: string) => string
49
49
  ): SearchResults | undefined {
50
50
  if (response === null) return undefined;
51
51
 
@@ -58,7 +58,10 @@ export function toSearchBarResults(
58
58
  // `SearchResultItem.price` is optional, so a product this storefront could not price keeps its
59
59
  // row and loses only the price. Formatting a `null` as a number would print the store's own
60
60
  // "$0.00" — a real price, and the wrong one (`StorefrontSearchProduct`).
61
- price: product.price === null ? undefined : formatPrice(product.price.amount),
61
+ price:
62
+ product.price === null || product.price.soldInCurrency === false
63
+ ? undefined
64
+ : formatPrice(product.price.amount, product.price.currency),
62
65
  image: product.featuredImage?.src,
63
66
  imageAlt: product.featuredImage?.alt,
64
67
  }));
Binary file
Binary file
Binary file
@@ -67,6 +67,7 @@ const storefront = useStorefront();
67
67
  /** Hydrated in `onMounted`, never before — see the module comment. */
68
68
  const wishlist = useWishlist();
69
69
  const money = useMoney();
70
+ const shopperCurrency = useStorefront().currency.active;
70
71
  const resolveLink = useEldraLink();
71
72
 
72
73
  const headingId = `wishlist-heading-${useUiId()}`;
@@ -166,13 +167,15 @@ const products = computed<StorefrontProductListItem[]>(() =>
166
167
  * own doc comment has the reasoning, and it is the same one the gate on the wishlist has. */
167
168
  const { any: cardsRevalidating, refreshing } = useRevalidating({
168
169
  keys: () => result.revalidating.value,
169
- refreshing: () => result.loading.value && result.data.value !== null,
170
+ refreshing: () =>
171
+ (result.loading.value && result.data.value !== null) || storefront.currency.pending.value,
170
172
  });
171
173
 
172
174
  const cards = computed(() =>
173
175
  toProductCardEntries(products.value, {
174
176
  ratio: '4x5',
175
177
  minorUnits: money.minor,
178
+ shopperCurrency: shopperCurrency.value,
176
179
  revalidating: cardsRevalidating.value,
177
180
  })
178
181
  );
@@ -305,6 +308,7 @@ async function removeCard(handle: string): Promise<void> {
305
308
  the product page, and the one control this card owns is the heart. -->
306
309
  <ProductCard
307
310
  :product="entry.product"
311
+ :currency="entry.currency"
308
312
  ratio="4x5"
309
313
  :heading-level="2"
310
314
  :quick-add="false"
@@ -124,7 +124,8 @@
124
124
  "wishlistOne": "Wishlist, 1 item",
125
125
  "wishlistMany": "Wishlist, {count} items",
126
126
  "viewAll": "View all",
127
- "viewAllOf": "View all {label}"
127
+ "viewAllOf": "View all {label}",
128
+ "cart": "Cart"
128
129
  },
129
130
  "editor": {
130
131
  "addLink": "Add a link"
@@ -502,7 +503,9 @@
502
503
  "emptyFallbackTitle": "Your cart is empty",
503
504
  "drawerHintLabel": "The cart drawer opens from the header",
504
505
  "drawerHintHelp": "Shoppers open it with the bag button; nothing shows here until they do.",
505
- "drawerHintHosted": "The theme already opens one on every page, so this block adds nothing and can be removed."
506
+ "drawerHintHosted": "The theme already opens one on every page, so this block adds nothing and can be removed.",
507
+ "loadFailed": "We couldn't load your cart.",
508
+ "tryAgain": "Try again"
506
509
  },
507
510
  "wishlist": {
508
511
  "saved": "Saved to wishlist",
@@ -547,6 +550,18 @@
547
550
  "trackingNumber": "Tracking number",
548
551
  "carrierEta": "Estimated delivery {eta} with {carrier}."
549
552
  },
553
+ "currency": {
554
+ "label": "Currency",
555
+ "notSoldIn": "Not available in {currency}",
556
+ "notSoldInLong": "Not available in {currency}.",
557
+ "shopIn": "Shop in {currency}",
558
+ "cartNotSold": "{items} can't be bought in {currency}.",
559
+ "checkoutWithout": "Remove and check out",
560
+ "cartWillSwitch": "Your cart will switch to {currency}.",
561
+ "notIncludedOne": "1 item not included",
562
+ "notIncludedMany": "{count} items not included",
563
+ "movedTo": "Prices are now in {currency}."
564
+ },
550
565
  "ui": {
551
566
  "clear": "Clear",
552
567
  "close": "Close",
@@ -628,6 +643,7 @@
628
643
  "filterPanelMin": "Min",
629
644
  "filterPanelMax": "Max",
630
645
  "filterPanelOrMore": " or more",
631
- "filterPanelShowProducts": "Show products"
646
+ "filterPanelShowProducts": "Show products",
647
+ "currencyPickerLabel": "Currency"
632
648
  }
633
649
  }
@@ -124,7 +124,8 @@
124
124
  "wishlistOne": "Óskalisti, 1 vara",
125
125
  "wishlistMany": "Óskalisti, {count} vörur",
126
126
  "viewAll": "Sjá allt",
127
- "viewAllOf": "Sjá allt: {label}"
127
+ "viewAllOf": "Sjá allt: {label}",
128
+ "cart": "Karfa"
128
129
  },
129
130
  "editor": {
130
131
  "addLink": "Bæta við tengli"
@@ -502,7 +503,9 @@
502
503
  "emptyFallbackTitle": "Karfan þín er tóm",
503
504
  "drawerHintLabel": "Karfan opnast úr hausnum",
504
505
  "drawerHintHelp": "Kaupendur opna hana með töskuhnappnum; hér sést ekkert fyrr en þeir gera það.",
505
- "drawerHintHosted": "Þemað opnar hana þegar á öllum síðum, svo þessi hluti gerir ekkert og má fjarlægja."
506
+ "drawerHintHosted": "Þemað opnar hana þegar á öllum síðum, svo þessi hluti gerir ekkert og má fjarlægja.",
507
+ "loadFailed": "Ekki tókst að sækja körfuna.",
508
+ "tryAgain": "Reyna aftur"
506
509
  },
507
510
  "wishlist": {
508
511
  "saved": "Vistað á óskalista",
@@ -547,6 +550,18 @@
547
550
  "trackingNumber": "Sendingarnúmer",
548
551
  "carrierEta": "Áætlaður afhendingartími {eta} með {carrier}."
549
552
  },
553
+ "currency": {
554
+ "label": "Gjaldmiðill",
555
+ "notSoldIn": "Ekki til sölu í {currency}",
556
+ "notSoldInLong": "Ekki til sölu í {currency}.",
557
+ "shopIn": "Skipta yfir í {currency}",
558
+ "cartNotSold": "Þetta fæst ekki keypt í {currency}: {items}.",
559
+ "checkoutWithout": "Fjarlægja og ganga frá kaupum",
560
+ "cartWillSwitch": "Karfan færist yfir í {currency}.",
561
+ "notIncludedOne": "1 vara ekki talin með",
562
+ "notIncludedMany": "{count} vörur ekki taldar með",
563
+ "movedTo": "Verð eru nú í {currency}."
564
+ },
550
565
  "ui": {
551
566
  "clear": "Hreinsa",
552
567
  "close": "Loka",
@@ -628,6 +643,7 @@
628
643
  "filterPanelMin": "Lágm.",
629
644
  "filterPanelMax": "Hám.",
630
645
  "filterPanelOrMore": " eða meira",
631
- "filterPanelShowProducts": "Sýna vörur"
646
+ "filterPanelShowProducts": "Sýna vörur",
647
+ "currencyPickerLabel": "Gjaldmiðill"
632
648
  }
633
649
  }
@@ -0,0 +1,66 @@
1
+ // @vitest-environment jsdom
2
+ import { flushPromises, mount } from '@vue/test-utils';
3
+ import { afterEach, describe, expect, it, vi } from 'vitest';
4
+ import Navigation from '../blocks/navigation/Block.vue';
5
+ import navigationMock from '../blocks/navigation/mock.json';
6
+ import Footer from '../blocks/footer/Block.vue';
7
+ import footerMock from '../blocks/footer/mock.json';
8
+ import { STOREFRONT_KEY, type StorefrontSource } from '../app/storefront/types';
9
+ import { axe } from './support/axe';
10
+ import { mountOptions } from './support/mountBlock';
11
+
12
+ const MULTI = {
13
+ currency: 'ISK',
14
+ taxInclusivePricing: true,
15
+ defaultTaxRate: 0.24,
16
+ currencies: ['ISK', 'EUR', 'USD'],
17
+ };
18
+ const ONE = { currency: 'ISK', taxInclusivePricing: true, defaultTaxRate: 0.24 };
19
+
20
+ afterEach(() => {
21
+ document.body.innerHTML = '';
22
+ localStorage.clear();
23
+ });
24
+
25
+ function mountWith(component: object, commerce: typeof MULTI | typeof ONE, data = {}) {
26
+ const options = mountOptions({ entry: { id: 'c', data } }, { commerce });
27
+ const storefront = options.global.provide[STOREFRONT_KEY] as StorefrontSource;
28
+ storefront.currency.started.value = true;
29
+ const wrapper = mount(component, { ...options, attachTo: document.body });
30
+ return { wrapper, storefront };
31
+ }
32
+
33
+ describe('the currency picker in the starter', () => {
34
+ it('sits in the header of a store that shows more than one currency and moves the visitor', async () => {
35
+ const { wrapper, storefront } = mountWith(Navigation, MULTI, navigationMock);
36
+ const trigger = wrapper.get('[data-eldra-header-actions] button[role="combobox"]');
37
+ expect(trigger.text()).toContain('ISK');
38
+ (trigger.element as HTMLElement).focus();
39
+ await trigger.trigger('keydown', { key: 'ArrowDown' });
40
+ await flushPromises();
41
+ const euro = [...document.querySelectorAll('[role="option"]')].find((node) =>
42
+ node.textContent?.includes('(EUR)')
43
+ ) as HTMLElement;
44
+ euro.click();
45
+ await flushPromises();
46
+ expect(storefront.currency.active.value).toBe('EUR');
47
+ expect(localStorage.getItem('eldra.currency')).toBe('EUR');
48
+ expect(await axe(wrapper.element)).toHaveNoViolations();
49
+ });
50
+
51
+ it('is not in the header of a one-currency store', () => {
52
+ const { wrapper } = mountWith(Navigation, ONE, navigationMock);
53
+ expect(wrapper.find('[data-eldra-header-actions] [role="combobox"]').exists()).toBe(false);
54
+ });
55
+
56
+ it("drives the footer's currency selector too", async () => {
57
+ const { wrapper, storefront } = mountWith(Footer, MULTI, footerMock);
58
+ storefront.currency.choose('USD');
59
+ await vi.waitFor(() => expect(storefront.currency.active.value).toBe('USD'));
60
+ await flushPromises();
61
+ expect(
62
+ wrapper.findAll('button[role="combobox"]').some((node) => node.text().includes('USD'))
63
+ ).toBe(true);
64
+ expect(await axe(wrapper.element)).toHaveNoViolations();
65
+ });
66
+ });
@@ -50,6 +50,28 @@ describe('seoInput', () => {
50
50
  expect(input.options.contentImage).toMatch(/\/lg$/);
51
51
  });
52
52
 
53
+ it("passes a catalog record's own seo value as the entry, beside the template's", () => {
54
+ const own = {
55
+ title: 'The mug',
56
+ canonicalUrl: 'https://shop.example/mugs/the-mug',
57
+ imageUrl: 'https://media.example/share.jpg',
58
+ noindex: true,
59
+ };
60
+ const input = seoInput({
61
+ ...base,
62
+ catalog: { kind: 'product', slug: 'mug' },
63
+ template: { data: { title: 'Product', seo: { description: 'From the template' } } },
64
+ entry: { data: { title: 'Mug', variants: [], seo: own } },
65
+ });
66
+ expect(input.options.entry).toEqual(own);
67
+ expect(input.options.template).toEqual({ description: 'From the template' });
68
+ // A record with none leaves the template's alone.
69
+ expect(
70
+ seoInput({ ...base, catalog: { kind: 'collection', slug: 'mugs' }, entry: { data: {} } })
71
+ .options.entry
72
+ ).toBeNull();
73
+ });
74
+
53
75
  it('sets product.category from the resolved name and no product.brand, even from a record that has one', () => {
54
76
  const input = seoInput({
55
77
  ...base,
@@ -169,6 +169,21 @@ describe('withAnalytics', () => {
169
169
  });
170
170
  });
171
171
 
172
+ it('4662896652: reports a removal in the currency its price was in, though the cart moved meanwhile', async () => {
173
+ const { source, cart } = makeSource();
174
+ const track = vi.fn();
175
+ const wrapped = withAnalytics(source, track);
176
+ await cart.add({ productId: 'p1', variantId: 'v1', quantity: 2 });
177
+ cart.currency.value = 'ISK';
178
+ const removing = wrapped.cart.remove('line-1');
179
+ cart.currency.value = 'EUR';
180
+ await removing;
181
+ expect(track).toHaveBeenLastCalledWith(
182
+ 'remove_from_cart',
183
+ expect.objectContaining({ value: '25', currency: 'ISK' })
184
+ );
185
+ });
186
+
172
187
  it('tracks begin_checkout from the cart state when the shopper follows the link', async () => {
173
188
  const { source, cart } = makeSource();
174
189
  const track = vi.fn();
@@ -172,13 +172,14 @@ describe('createCartStore', () => {
172
172
  },
173
173
  add: async (input) => {
174
174
  addInputs.push(input);
175
- return { lines: [a, c], totals: totalsFor([a, b, c]) };
175
+ return { lines: [a, c, b], totals: totalsFor([a, b, c]) };
176
176
  },
177
177
  })
178
178
  );
179
179
  await settle();
180
180
  await store.remove('b');
181
181
  await store.undoRemove();
182
+ // The server's answer, with the restored line put back where it was.
182
183
  expect(store.lines.value).toEqual([a, b, c]);
183
184
  expect(store.lastRemoved.value).toBeNull();
184
185
  // The re-add is the removed line's own pair — a line id is not something `ops.add` can take.
@@ -374,9 +375,8 @@ describe('createCartStore', () => {
374
375
  await store.undoRemove();
375
376
 
376
377
  expect(store.lastFailure.value?.errorId).toBe('CART_INSUFFICIENT_STOCK');
377
- // The line is still back on screen — the restore is local and deliberate (see `undoRemove`),
378
- // which is exactly why a shopper has to be told the shop could not take it back.
379
- expect(store.lines.value).toEqual([a]);
378
+ // The cart shows what the shop holds: the line it could not take back stays out.
379
+ expect(store.lines.value).toEqual([]);
380
380
  });
381
381
 
382
382
  it('records the failure of an applyDiscount that threw, and still answers an ack', async () => {