@eldrajs/theme-cli 0.2.6 → 0.2.8

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 (61) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/package.json +3 -3
  3. package/template/.eldra/block-types.d.ts +1 -1
  4. package/template/.eldra/manifest.json +162 -132
  5. package/template/.eldra/previews.json +35 -35
  6. package/template/app/storefront/commerce.ts +12 -8
  7. package/template/app/storefront/currency.ts +94 -27
  8. package/template/app/storefront/feedback.ts +1 -0
  9. package/template/blocks/announcement-bar/preview.png +0 -0
  10. package/template/blocks/article/preview.png +0 -0
  11. package/template/blocks/article-list/preview.png +0 -0
  12. package/template/blocks/breadcrumbs/preview.png +0 -0
  13. package/template/blocks/cart/__tests__/notSold.spec.ts +41 -0
  14. package/template/blocks/cart/parts/NotSoldNotice.vue +7 -2
  15. package/template/blocks/cart/preview.png +0 -0
  16. package/template/blocks/collection-grid/preview.png +0 -0
  17. package/template/blocks/collection-header/preview.png +0 -0
  18. package/template/blocks/contact/preview.png +0 -0
  19. package/template/blocks/cta/preview.png +0 -0
  20. package/template/blocks/faq/preview.png +0 -0
  21. package/template/blocks/feature-grid/preview.png +0 -0
  22. package/template/blocks/footer/preview.png +0 -0
  23. package/template/blocks/form/preview.png +0 -0
  24. package/template/blocks/gallery/preview.png +0 -0
  25. package/template/blocks/hero/preview.png +0 -0
  26. package/template/blocks/image/preview.png +0 -0
  27. package/template/blocks/logo-cloud/preview.png +0 -0
  28. package/template/blocks/navigation/Block.vue +54 -11
  29. package/template/blocks/navigation/__tests__/Block.spec.ts +91 -8
  30. package/template/blocks/navigation/block.json +11 -3
  31. package/template/blocks/navigation/mock.json +134 -129
  32. package/template/blocks/navigation/preview.png +0 -0
  33. package/template/blocks/newsletter/preview.png +0 -0
  34. package/template/blocks/order-status/preview.png +0 -0
  35. package/template/blocks/pricing-table/preview.png +0 -0
  36. package/template/blocks/product-carousel/preview.png +0 -0
  37. package/template/blocks/product-detail/Block.vue +29 -7
  38. package/template/blocks/product-detail/__tests__/Block.spec.ts +112 -1
  39. package/template/blocks/product-detail/preview.png +0 -0
  40. package/template/blocks/quote/preview.png +0 -0
  41. package/template/blocks/rich-text/preview.png +0 -0
  42. package/template/blocks/search/preview.png +0 -0
  43. package/template/blocks/split-content/preview.png +0 -0
  44. package/template/blocks/stats/preview.png +0 -0
  45. package/template/blocks/tabs/preview.png +0 -0
  46. package/template/blocks/team/preview.png +0 -0
  47. package/template/blocks/testimonials/preview.png +0 -0
  48. package/template/blocks/timeline/preview.png +0 -0
  49. package/template/blocks/trust-strip/preview.png +0 -0
  50. package/template/blocks/video-embed/preview.png +0 -0
  51. package/template/blocks/wishlist/preview.png +0 -0
  52. package/template/i18n/en-US.json +1 -0
  53. package/template/i18n/is-IS.json +1 -0
  54. package/template/package.json +1 -1
  55. package/template/public/images/bowl.webp +0 -0
  56. package/template/test/prerenderFailure.spec.ts +4 -3
  57. package/template/test/previewParity.browser.spec.ts +1152 -0
  58. package/template/test/starter.spec.ts +6 -1
  59. package/template/test/storefront/currencyDefault.spec.ts +475 -0
  60. package/template/test/support/previewParity.ts +302 -0
  61. package/template/test/support/previewParityContent.ts +726 -0
@@ -9,114 +9,117 @@
9
9
  "slug": "knitwear"
10
10
  },
11
11
  "label": "Knitwear",
12
- "children": [
12
+ "sections": [
13
13
  {
14
- "kind": "collection",
15
- "target": {
16
- "_type": "collection",
17
- "slug": "womens-sweaters"
18
- },
19
- "group": "Women",
20
- "label": "Sweaters"
14
+ "heading": "Women",
15
+ "links": [
16
+ {
17
+ "kind": "collection",
18
+ "target": {
19
+ "_type": "collection",
20
+ "slug": "womens-sweaters"
21
+ },
22
+ "label": "Sweaters"
23
+ },
24
+ {
25
+ "kind": "collection",
26
+ "target": {
27
+ "_type": "collection",
28
+ "slug": "womens-cardigans"
29
+ },
30
+ "label": "Cardigans"
31
+ },
32
+ {
33
+ "kind": "collection",
34
+ "target": {
35
+ "_type": "collection",
36
+ "slug": "scarves-wraps"
37
+ },
38
+ "label": "Scarves & wraps"
39
+ },
40
+ {
41
+ "kind": "collection",
42
+ "target": {
43
+ "_type": "collection",
44
+ "slug": "hats-gloves"
45
+ },
46
+ "label": "Hats & gloves"
47
+ }
48
+ ]
21
49
  },
22
50
  {
23
- "kind": "collection",
24
- "target": {
25
- "_type": "collection",
26
- "slug": "womens-cardigans"
27
- },
28
- "group": "Women",
29
- "label": "Cardigans"
51
+ "heading": "Men",
52
+ "links": [
53
+ {
54
+ "kind": "collection",
55
+ "target": {
56
+ "_type": "collection",
57
+ "slug": "mens-sweaters"
58
+ },
59
+ "label": "Sweaters"
60
+ },
61
+ {
62
+ "kind": "collection",
63
+ "target": {
64
+ "_type": "collection",
65
+ "slug": "mens-cardigans"
66
+ },
67
+ "label": "Cardigans"
68
+ },
69
+ {
70
+ "kind": "collection",
71
+ "target": {
72
+ "_type": "collection",
73
+ "slug": "mens-scarves"
74
+ },
75
+ "label": "Scarves"
76
+ },
77
+ {
78
+ "kind": "collection",
79
+ "target": {
80
+ "_type": "collection",
81
+ "slug": "socks"
82
+ },
83
+ "label": "Socks"
84
+ }
85
+ ]
30
86
  },
31
87
  {
32
- "kind": "collection",
33
- "target": {
34
- "_type": "collection",
35
- "slug": "scarves-wraps"
36
- },
37
- "group": "Women",
38
- "label": "Scarves & wraps"
39
- },
40
- {
41
- "kind": "collection",
42
- "target": {
43
- "_type": "collection",
44
- "slug": "hats-gloves"
45
- },
46
- "group": "Women",
47
- "label": "Hats & gloves"
48
- },
49
- {
50
- "kind": "collection",
51
- "target": {
52
- "_type": "collection",
53
- "slug": "mens-sweaters"
54
- },
55
- "group": "Men",
56
- "label": "Sweaters"
57
- },
58
- {
59
- "kind": "collection",
60
- "target": {
61
- "_type": "collection",
62
- "slug": "mens-cardigans"
63
- },
64
- "group": "Men",
65
- "label": "Cardigans"
66
- },
67
- {
68
- "kind": "collection",
69
- "target": {
70
- "_type": "collection",
71
- "slug": "mens-scarves"
72
- },
73
- "group": "Men",
74
- "label": "Scarves"
75
- },
76
- {
77
- "kind": "collection",
78
- "target": {
79
- "_type": "collection",
80
- "slug": "socks"
81
- },
82
- "group": "Men",
83
- "label": "Socks"
84
- },
85
- {
86
- "kind": "collection",
87
- "target": {
88
- "_type": "collection",
89
- "slug": "merino-essentials"
90
- },
91
- "group": "Collections",
92
- "label": "Merino essentials"
93
- },
94
- {
95
- "kind": "collection",
96
- "target": {
97
- "_type": "collection",
98
- "slug": "heavy-winter-knits"
99
- },
100
- "group": "Collections",
101
- "label": "Heavy winter knits"
102
- },
103
- {
104
- "kind": "collection",
105
- "target": {
106
- "_type": "collection",
107
- "slug": "undyed-wool"
108
- },
109
- "group": "Collections",
110
- "label": "Undyed wool"
111
- },
112
- {
113
- "kind": "collection",
114
- "target": {
115
- "_type": "collection",
116
- "slug": "knitwear"
117
- },
118
- "group": "Collections",
119
- "label": "Shop all knitwear"
88
+ "heading": "Collections",
89
+ "links": [
90
+ {
91
+ "kind": "collection",
92
+ "target": {
93
+ "_type": "collection",
94
+ "slug": "merino-essentials"
95
+ },
96
+ "label": "Merino essentials"
97
+ },
98
+ {
99
+ "kind": "collection",
100
+ "target": {
101
+ "_type": "collection",
102
+ "slug": "heavy-winter-knits"
103
+ },
104
+ "label": "Heavy winter knits"
105
+ },
106
+ {
107
+ "kind": "collection",
108
+ "target": {
109
+ "_type": "collection",
110
+ "slug": "undyed-wool"
111
+ },
112
+ "label": "Undyed wool"
113
+ },
114
+ {
115
+ "kind": "collection",
116
+ "target": {
117
+ "_type": "collection",
118
+ "slug": "knitwear"
119
+ },
120
+ "label": "Shop all knitwear"
121
+ }
122
+ ]
120
123
  }
121
124
  ]
122
125
  },
@@ -127,33 +130,35 @@
127
130
  "slug": "ceramics"
128
131
  },
129
132
  "label": "Ceramics",
130
- "children": [
131
- {
132
- "kind": "collection",
133
- "target": {
134
- "_type": "collection",
135
- "slug": "plates"
136
- },
137
- "group": "Tableware",
138
- "label": "Plates"
139
- },
140
- {
141
- "kind": "collection",
142
- "target": {
143
- "_type": "collection",
144
- "slug": "bowls"
145
- },
146
- "group": "Tableware",
147
- "label": "Bowls"
148
- },
133
+ "sections": [
149
134
  {
150
- "kind": "collection",
151
- "target": {
152
- "_type": "collection",
153
- "slug": "mugs-cups"
154
- },
155
- "group": "Tableware",
156
- "label": "Mugs & cups"
135
+ "heading": "Tableware",
136
+ "links": [
137
+ {
138
+ "kind": "collection",
139
+ "target": {
140
+ "_type": "collection",
141
+ "slug": "plates"
142
+ },
143
+ "label": "Plates"
144
+ },
145
+ {
146
+ "kind": "collection",
147
+ "target": {
148
+ "_type": "collection",
149
+ "slug": "bowls"
150
+ },
151
+ "label": "Bowls"
152
+ },
153
+ {
154
+ "kind": "collection",
155
+ "target": {
156
+ "_type": "collection",
157
+ "slug": "mugs-cups"
158
+ },
159
+ "label": "Mugs & cups"
160
+ }
161
+ ]
157
162
  }
158
163
  ]
159
164
  },
@@ -263,11 +263,30 @@ const formattedPrice = computed(() =>
263
263
  : money.format(product.value.price.amount, product.value.price.currency)
264
264
  );
265
265
 
266
- /** No price in the visitor's currency: shown, but not for sale until they shop in the store's own. */
266
+ /** No price in the visitor's currency: shown, but not for sale until they shop in the default. */
267
267
  const notSold = computed(() => product.value?.price.soldInCurrency === false);
268
268
  const shopperCurrency = computed(() => storefront.currency.active.value ?? '');
269
- const baseCurrency = computed(() => storefront.currency.base ?? '');
270
- const cartWillSwitch = computed(() => notSold.value && storefront.cart.lines.value.length > 0);
269
+ const defaultCurrency = computed(() => storefront.currency.defaultCurrency ?? '');
270
+ const inDefault = computed(() => shopperCurrency.value === defaultCurrency.value);
271
+ // A read that failed keeps the last currency's answer on screen; only one made in this currency can say it is sold nowhere.
272
+ const readIn = ref(shopperCurrency.value);
273
+ watch(
274
+ () => productResult.data.value,
275
+ () => {
276
+ readIn.value = shopperCurrency.value;
277
+ }
278
+ );
279
+ // Every product has a price in the store's own currency, so only a default that is not it can lack one for real.
280
+ const notSoldAnywhere = computed(
281
+ () =>
282
+ notSold.value &&
283
+ inDefault.value &&
284
+ readIn.value === shopperCurrency.value &&
285
+ defaultCurrency.value !== storefront.currency.base
286
+ );
287
+ const cartWillSwitch = computed(
288
+ () => notSold.value && !notSoldAnywhere.value && storefront.cart.lines.value.length > 0
289
+ );
271
290
 
272
291
  /** Spec States, Sale row: 'The saving badge ("Save $32") is calculated from the two prices, never
273
292
  * typed in.' Only a real sale counts — a `compareAt` at or below the current price is ignored, the
@@ -427,7 +446,8 @@ const cartBusy = computed(
427
446
  );
428
447
 
429
448
  const addToCartLabel = computed(() => {
430
- if (notSold.value) return t('currency.shopIn', { currency: baseCurrency.value });
449
+ if (notSoldAnywhere.value) return t('currency.notSoldIn', { currency: defaultCurrency.value });
450
+ if (notSold.value) return t('currency.shopIn', { currency: defaultCurrency.value });
431
451
  if (soldOut.value) return t('product.notifyMe');
432
452
  if (isBackorder.value) return t('product.backorder');
433
453
  return t('product.addToCart', { price: formattedPrice.value });
@@ -514,8 +534,9 @@ watch(
514
534
  */
515
535
  async function primaryAction(): Promise<void> {
516
536
  if (notSold.value) {
517
- // Already in the store currency (its product read failed): read the product again.
518
- if (storefront.currency.active.value === storefront.currency.base) void productResult.refresh();
537
+ if (notSoldAnywhere.value) return;
538
+ // Already in the default (its product read failed): read the product again.
539
+ if (inDefault.value) void productResult.refresh();
519
540
  else storefront.currency.chooseBase();
520
541
  return;
521
542
  }
@@ -780,6 +801,7 @@ function tabValue(index: number): string {
780
801
  size="lg"
781
802
  block
782
803
  :loading="cartBusy"
804
+ :disabled="notSoldAnywhere"
783
805
  :label="addToCartLabel"
784
806
  >
785
807
  <template v-if="soldOut" #leadingIcon>
@@ -804,7 +826,7 @@ function tabValue(index: number): string {
804
826
  </Button>
805
827
  </div>
806
828
  <p v-if="cartWillSwitch" class="text-muted text-body-sm -mt-2">
807
- {{ t('currency.cartWillSwitch', { currency: baseCurrency }) }}
829
+ {{ t('currency.cartWillSwitch', { currency: defaultCurrency }) }}
808
830
  </p>
809
831
  </form>
810
832
 
@@ -1,6 +1,6 @@
1
1
  // @vitest-environment jsdom
2
2
  import { flushPromises, mount } from '@vue/test-utils';
3
- import { computed, defineComponent, h, nextTick, ref } from 'vue';
3
+ import { computed, defineComponent, h, nextTick, ref, watch } 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';
@@ -1567,3 +1567,114 @@ describe('product-detail block', () => {
1567
1567
  });
1568
1568
  });
1569
1569
  });
1570
+
1571
+ describe('with the store currency turned off (WS-1399)', () => {
1572
+ function storefrontOffering(patch: Partial<StorefrontProduct>) {
1573
+ const source = createDemoStorefront({
1574
+ commerce: {
1575
+ currency: 'USD',
1576
+ taxInclusivePricing: false,
1577
+ defaultTaxRate: 0,
1578
+ currencies: ['EUR', 'GBP'],
1579
+ defaultCurrency: 'EUR',
1580
+ },
1581
+ });
1582
+ return {
1583
+ ...source,
1584
+ catalog: {
1585
+ ...source.catalog,
1586
+ product: (handle: Parameters<typeof source.catalog.product>[0]) => {
1587
+ const result = source.catalog.product(handle);
1588
+ return {
1589
+ ...result,
1590
+ data: computed(() => (result.data.value ? { ...result.data.value, ...patch } : null)),
1591
+ };
1592
+ },
1593
+ },
1594
+ } as ReturnType<typeof storefrontWith>;
1595
+ }
1596
+ const notSoldPrice = { amount: 96, compareAt: null, currency: 'USD', soldInCurrency: false };
1597
+
1598
+ it('offers the default currency, not the store currency, as the way out', async () => {
1599
+ const storefront = storefrontOffering({ price: notSoldPrice });
1600
+ storefront.currency.started.value = true;
1601
+ storefront.currency.choose('GBP');
1602
+ await vi.waitFor(() => expect(storefront.currency.active.value).toBe('GBP'));
1603
+ const wrapper = await mountReady(mock, { storefront });
1604
+
1605
+ expect(addToCart(wrapper).text()).toBe('Shop in EUR');
1606
+ await wrapper.get('form').trigger('submit');
1607
+ await flushPromises();
1608
+ expect(storefront.currency.active.value).toBe('EUR');
1609
+ });
1610
+
1611
+ it('shows no way out in the default currency, and holds the button', async () => {
1612
+ const storefront = storefrontOffering({ price: notSoldPrice });
1613
+ storefront.currency.started.value = true;
1614
+ const wrapper = await mountReady(mock, { storefront });
1615
+
1616
+ expect(storefront.currency.active.value).toBe('EUR');
1617
+ expect(wrapper.get('[data-eldra-not-sold]').text()).toBe('Not available in EUR.');
1618
+ expect(addToCart(wrapper).text()).toBe('Not available in EUR');
1619
+ expect(addToCart(wrapper).attributes('disabled')).toBeDefined();
1620
+ expect(wrapper.text()).not.toContain('Shop in');
1621
+ expect(await axe(wrapper.element)).toHaveNoViolations();
1622
+ });
1623
+ });
1624
+
1625
+ describe('a product read that failed after a currency change (WS-1399)', () => {
1626
+ it("does not take the last currency's availability for the new one", async () => {
1627
+ const source = createDemoStorefront({
1628
+ commerce: {
1629
+ currency: 'USD',
1630
+ taxInclusivePricing: false,
1631
+ defaultTaxRate: 0,
1632
+ currencies: ['EUR', 'GBP'],
1633
+ defaultCurrency: 'EUR',
1634
+ },
1635
+ });
1636
+ const refreshes: number[] = [];
1637
+ const storefront = {
1638
+ ...source,
1639
+ catalog: {
1640
+ ...source.catalog,
1641
+ product: (handle: Parameters<typeof source.catalog.product>[0]) => {
1642
+ const result = source.catalog.product(handle);
1643
+ const kept = ref<StorefrontProduct | null>(null);
1644
+ // The read in GBP answered; the one in EUR failed and left it on screen.
1645
+ watch(
1646
+ result.data,
1647
+ (loaded) => {
1648
+ if (loaded !== null && kept.value === null) {
1649
+ kept.value = {
1650
+ ...loaded,
1651
+ price: { amount: 96, compareAt: null, currency: 'USD', soldInCurrency: false },
1652
+ };
1653
+ }
1654
+ },
1655
+ { immediate: true }
1656
+ );
1657
+ return {
1658
+ ...result,
1659
+ data: kept,
1660
+ refresh: async () => {
1661
+ refreshes.push(1);
1662
+ },
1663
+ };
1664
+ },
1665
+ },
1666
+ } as ReturnType<typeof storefrontWith>;
1667
+ storefront.currency.started.value = true;
1668
+ storefront.currency.choose('GBP');
1669
+ await vi.waitFor(() => expect(storefront.currency.active.value).toBe('GBP'));
1670
+ const wrapper = await mountReady(mock, { storefront });
1671
+
1672
+ storefront.currency.choose('EUR');
1673
+ await flushPromises();
1674
+ expect(storefront.currency.active.value).toBe('EUR');
1675
+ expect(addToCart(wrapper).attributes('disabled')).toBeUndefined();
1676
+ await wrapper.get('form').trigger('submit');
1677
+ await flushPromises();
1678
+ expect(refreshes).toHaveLength(1);
1679
+ });
1680
+ });
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -95,6 +95,7 @@
95
95
  "outOfStock": "This item is out of stock.",
96
96
  "unavailable": "This item is no longer available.",
97
97
  "cartOutOfDate": "Your cart is out of date. Reload the page and try again.",
98
+ "businessOwnCurrency": "Business customers shop in ISK.",
98
99
  "unresolvedCollectionLabel": "Publish to load products",
99
100
  "unresolvedCollectionHelp": "The collection is picked. Its products appear here once this page is published.",
100
101
  "orderStatus": {
@@ -95,6 +95,7 @@
95
95
  "outOfStock": "Þessi vara er ekki til á lager.",
96
96
  "unavailable": "Þessi vara er ekki lengur í boði.",
97
97
  "cartOutOfDate": "Karfan þín er ekki uppfærð. Endurnýjaðu síðuna og prófaðu aftur.",
98
+ "businessOwnCurrency": "Fyrirtæki versla í krónum.",
98
99
  "unresolvedCollectionLabel": "Birtu síðuna til að hlaða vörum",
99
100
  "unresolvedCollectionHelp": "Vörulistinn er valinn. Vörurnar úr honum birtast hér þegar síðan hefur verið birt.",
100
101
  "orderStatus": {
@@ -22,7 +22,7 @@
22
22
  "@eldrajs/theme-vue": "workspace:*",
23
23
  "@eldrajs/ui": "workspace:*",
24
24
  "@tabler/icons": "^3.34.0",
25
- "nuxt": "^4.0.0",
25
+ "nuxt": "^4.7.0",
26
26
  "tailwind-merge": "^3.0.0",
27
27
  "vue-i18n": "11.4.16"
28
28
  },
Binary file
@@ -111,10 +111,11 @@ describe('a prerendered route whose resolution failed', () => {
111
111
  it('fails the build over it, rather than exiting 0 with the page missing', () => {
112
112
  // `nitro.prerender.failOnError` (`nuxt.config.ts`) is the half that makes the *absence* loud:
113
113
  // without it the generate still exits 0 and an artifact with a hole in its catalogue is
114
- // deployable. The route itself is named in the prerender list Nitro prints, which is on the
115
- // build's console rather than in what `nuxi generate` hands back here.
114
+ // deployable. Nitro 2.14 (Nuxt 4.7) names each failed route in the output, with its status.
116
115
  expect(generated.exitCode).not.toBe(0);
117
- expect(`${generated.stdout}\n${generated.stderr}`).toContain('prerender errors');
116
+ const printed = `${generated.stdout}\n${generated.stderr}`;
117
+ expect(printed).toMatch(/Failed to prerender \d+ routes?/);
118
+ expect(printed).toContain('/collections/the-winter-edit (500 Eldra route resolution failed)');
118
119
  });
119
120
 
120
121
  it('still writes every route the gateway could answer', () => {