@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
@@ -1597,6 +1597,28 @@ describe('createGatewayStorefront', () => {
1597
1597
  expect(product?.stock).toBe('in');
1598
1598
  });
1599
1599
 
1600
+ it('reads a variant the store does not track as in stock with no count, not sold out', async () => {
1601
+ // The public contract (web-gateway 6.18.0, `POST /inventory/v1/stock/availability`) answers an
1602
+ // untracked variant with `tracked: false`, `available: true` and `availableQuantity: 0`.
1603
+ const untracked = productClient(
1604
+ {
1605
+ items: [
1606
+ {
1607
+ variantId: 'var-only',
1608
+ available: true,
1609
+ allowBackorder: false,
1610
+ availableQuantity: 0,
1611
+ tracked: false,
1612
+ },
1613
+ ],
1614
+ },
1615
+ { variants: [{ id: 'var-only', status: 'ACTIVE', price: 96 }] }
1616
+ );
1617
+ const product = await read(untracked.client);
1618
+ expect(product?.inventory).toBeNull();
1619
+ expect(product?.stock).toBe('in');
1620
+ });
1621
+
1600
1622
  it('reads sold out for a published variant with nothing on the shelf', async () => {
1601
1623
  const { client } = productClient({
1602
1624
  items: [
@@ -1,12 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
- import { formatCurrency } from '@eldrajs/ui';
3
- import {
4
- currencyLabel,
5
- DEFAULT_LOCALE,
6
- formatMoney,
7
- roundMoney,
8
- toMinorUnits,
9
- } from '../../app/storefront/money';
2
+ import { formatCurrency, toMinorUnits } from '@eldrajs/ui';
3
+ import { currencyLabel, DEFAULT_LOCALE, formatMoney, roundMoney } from '../../app/storefront/money';
10
4
 
11
5
  describe('formatMoney', () => {
12
6
  it('formats a major-unit amount as itself', () => {
@@ -154,6 +154,51 @@ describe('pageStructuredData', () => {
154
154
  expect(offers.offers[1].availability).toBe('https://schema.org/OutOfStock');
155
155
  });
156
156
 
157
+ it('sends the priceCurrency of the price the page shows, never the store currency over it', () => {
158
+ const entries = pageStructuredData(
159
+ parts({
160
+ kind: 'product',
161
+ currency: 'ISK',
162
+ product: product({
163
+ price: { amount: 19.9, compareAt: null, currency: 'EUR' },
164
+ variants: [
165
+ { sku: 'S', barcode: null, price: 19.9, compareAt: null, currency: 'EUR', stock: 'in' },
166
+ {
167
+ sku: 'L',
168
+ barcode: null,
169
+ price: 3400,
170
+ compareAt: null,
171
+ currency: 'ISK',
172
+ soldInCurrency: false,
173
+ stock: 'in',
174
+ },
175
+ ],
176
+ }),
177
+ })
178
+ );
179
+ const offers = entries[1]!.node.offers as Record<string, any>;
180
+ expect(offers).toMatchObject({ '@type': 'Offer', price: 19.9, priceCurrency: 'EUR', sku: 'S' });
181
+ });
182
+
183
+ it('4662896736: writes no offer for a product not sold in the shown currency', () => {
184
+ const node = pageStructuredData(
185
+ parts({
186
+ kind: 'product',
187
+ product: product({
188
+ price: { amount: 2800, compareAt: null, currency: 'ISK', soldInCurrency: false },
189
+ }),
190
+ })
191
+ )[1]!.node as Record<string, unknown>;
192
+ expect(node.offers).toBeUndefined();
193
+ });
194
+
195
+ it('keeps the store currency for a price that carries none', () => {
196
+ const offers = pageStructuredData(
197
+ parts({ kind: 'product', currency: 'ISK', product: product() })
198
+ )[1]!.node.offers as Record<string, any>;
199
+ expect(offers.priceCurrency).toBe('ISK');
200
+ });
201
+
157
202
  it('writes an ItemList on a listing page only when it shows products', () => {
158
203
  const listing = (items: PageLdParts['items']) =>
159
204
  types(pageStructuredData(parts({ kind: 'collection', items })));
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from 'vitest';
2
- import { toMinorUnits } from '../../app/storefront/money';
2
+ import { toMinorUnits } from '@eldrajs/ui';
3
3
  import { toProductCard, toProductCardEntries } from '../../app/storefront/toProductCard';
4
4
  import type { StorefrontProductListItem } from '../../app/storefront/types';
5
5
 
@@ -282,3 +282,14 @@ describe('chunkIds', () => {
282
282
  expect(VOLATILE_CHUNK_SIZE).toBe(50);
283
283
  });
284
284
  });
285
+
286
+ describe('applyVolatileSnapshots across currencies', () => {
287
+ it('takes a price in another currency whole, so an amount never keeps the old currency', () => {
288
+ const card = listItem({ price: { amount: 2900, compareAt: null, from: true } });
289
+ const [next] = applyVolatileSnapshots(
290
+ [card],
291
+ [snapshot({ price: { amount: 19.9, compareAt: null, currency: 'EUR' } })]
292
+ );
293
+ expect(next!.price).toEqual({ amount: 19.9, compareAt: null, currency: 'EUR' });
294
+ });
295
+ });