@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.
- package/package.json +3 -3
- package/template/.eldra/block-types.d.ts +1 -1
- package/template/.eldra/manifest.json +30 -2
- package/template/.eldra/previews.json +35 -35
- package/template/app/app.vue +15 -0
- package/template/app/composables/useStorefront.ts +7 -2
- package/template/app/plugins/eldra-storefront.ts +9 -0
- package/template/app/storefront/analytics.ts +15 -7
- package/template/app/storefront/cart.ts +228 -51
- package/template/app/storefront/commerce.ts +8 -2
- package/template/app/storefront/currency.ts +205 -0
- package/template/app/storefront/demo.ts +10 -2
- package/template/app/storefront/feedback.ts +2 -0
- package/template/app/storefront/gateway.ts +153 -35
- package/template/app/storefront/money.ts +6 -18
- package/template/app/storefront/structuredData.ts +16 -5
- package/template/app/storefront/toProductCard.ts +14 -14
- package/template/app/storefront/types.ts +13 -0
- package/template/app/storefront/volatile.ts +4 -0
- package/template/app/utils/seoInput.ts +4 -3
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/preview.png +0 -0
- package/template/blocks/cart/Block.vue +41 -22
- package/template/blocks/cart/__tests__/Block.spec.ts +2 -3
- package/template/blocks/cart/__tests__/loadFailed.spec.ts +135 -0
- package/template/blocks/cart/__tests__/notSold.spec.ts +109 -0
- package/template/blocks/cart/parts/CartLines.vue +14 -2
- package/template/blocks/cart/parts/CheckoutButton.vue +45 -0
- package/template/blocks/cart/parts/LoadFailed.vue +37 -0
- package/template/blocks/cart/parts/NotSoldNotice.vue +69 -0
- package/template/blocks/cart/parts/Summary.vue +9 -21
- package/template/blocks/cart/parts/notSold.ts +19 -0
- package/template/blocks/cart/preview.png +0 -0
- package/template/blocks/collection-grid/Block.vue +15 -2
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +14 -0
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/preview.png +0 -0
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +20 -45
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/form/preview.png +0 -0
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +39 -3
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/Block.vue +15 -6
- package/template/blocks/order-status/preview.png +0 -0
- package/template/blocks/pricing-table/preview.png +0 -0
- package/template/blocks/product-carousel/Block.vue +5 -2
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/Block.vue +46 -10
- package/template/blocks/product-detail/__tests__/Block.spec.ts +78 -1
- package/template/blocks/product-detail/preview.png +0 -0
- package/template/blocks/quote/preview.png +0 -0
- package/template/blocks/rich-text/preview.png +0 -0
- package/template/blocks/search/Block.vue +8 -2
- package/template/blocks/search/TypeSection.vue +8 -2
- package/template/blocks/search/preview.png +0 -0
- package/template/blocks/search/results.ts +5 -2
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/preview.png +0 -0
- package/template/blocks/team/preview.png +0 -0
- package/template/blocks/testimonials/preview.png +0 -0
- package/template/blocks/timeline/preview.png +0 -0
- package/template/blocks/trust-strip/preview.png +0 -0
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/Block.vue +5 -1
- package/template/blocks/wishlist/preview.png +0 -0
- package/template/i18n/en-US.json +19 -3
- package/template/i18n/is-IS.json +19 -3
- package/template/test/currencyPicker.spec.ts +66 -0
- package/template/test/seoInput.spec.ts +22 -0
- package/template/test/storefront/analytics.spec.ts +15 -0
- package/template/test/storefront/cart.spec.ts +4 -4
- package/template/test/storefront/currency.spec.ts +549 -0
- package/template/test/storefront/currencyStore.spec.ts +845 -0
- package/template/test/storefront/gateway.spec.ts +22 -0
- package/template/test/storefront/money.spec.ts +2 -8
- package/template/test/storefront/structuredData.spec.ts +45 -0
- package/template/test/storefront/toProductCard.spec.ts +1 -1
- 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 '
|
|
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
|
+
});
|