@eldrajs/theme-cli 0.2.4 → 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/CHANGELOG.md +4 -0
- package/README.md +6 -0
- package/dist/cli.js +8 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -1
- package/dist/{validate-FjQ-5_ne.js → validate-CC6Mp5i_.js} +2 -1
- 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/README.md +3 -1
- package/template/app/app.vue +16 -3
- package/template/app/assets/main.css +13 -15
- package/template/app/components/ui/UiImage.vue +29 -17
- package/template/app/components/ui/__tests__/UiImage.spec.ts +24 -15
- package/template/app/composables/useStorefront.ts +7 -2
- package/template/app/pages/[...slug].vue +1 -1
- 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/Block.vue +3 -2
- package/template/blocks/announcement-bar/__tests__/Block.spec.ts +1 -1
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/Block.vue +3 -4
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/Block.vue +18 -9
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/Block.vue +1 -1
- package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +9 -9
- package/template/blocks/breadcrumbs/preview.png +0 -0
- package/template/blocks/cart/Block.vue +42 -23
- 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 +16 -3
- 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/ShippingBar.vue +1 -1
- package/template/blocks/cart/parts/Summary.vue +14 -30
- package/template/blocks/cart/parts/notSold.ts +19 -0
- package/template/blocks/cart/preview.png +0 -0
- package/template/blocks/collection-grid/Block.vue +26 -16
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +26 -14
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/Block.vue +5 -5
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/Block.vue +1 -1
- package/template/blocks/contact/__tests__/Block.spec.ts +2 -2
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/Block.vue +16 -18
- package/template/blocks/cta/__tests__/Block.spec.ts +8 -12
- package/template/blocks/cta/preview.png +0 -0
- package/template/blocks/faq/Block.vue +3 -13
- package/template/blocks/faq/__tests__/Block.spec.ts +2 -2
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/Block.vue +1 -1
- package/template/blocks/feature-grid/__tests__/Block.spec.ts +1 -1
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +33 -55
- package/template/blocks/footer/__tests__/Block.spec.ts +5 -5
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/form/Block.vue +1 -1
- package/template/blocks/form/preview.png +0 -0
- package/template/blocks/gallery/__tests__/Block.spec.ts +1 -1
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/Block.vue +8 -11
- package/template/blocks/hero/__tests__/Block.spec.ts +9 -7
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/Block.vue +4 -4
- package/template/blocks/image/__tests__/Block.spec.ts +5 -6
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/__tests__/Block.spec.ts +1 -1
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +55 -29
- package/template/blocks/navigation/__tests__/Block.spec.ts +22 -20
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/newsletter/__tests__/Block.spec.ts +1 -1
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/Block.vue +23 -15
- package/template/blocks/order-status/__tests__/Block.spec.ts +1 -2
- package/template/blocks/order-status/preview.png +0 -0
- package/template/blocks/pricing-table/__tests__/Block.spec.ts +1 -1
- package/template/blocks/pricing-table/preview.png +0 -0
- package/template/blocks/product-carousel/Block.vue +11 -8
- package/template/blocks/product-carousel/__tests__/Block.spec.ts +26 -8
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/Block.vue +54 -18
- package/template/blocks/product-detail/__tests__/Block.spec.ts +79 -2
- package/template/blocks/product-detail/parts/Gallery.vue +1 -1
- package/template/blocks/product-detail/preview.png +0 -0
- package/template/blocks/quote/Block.vue +1 -1
- package/template/blocks/quote/__tests__/Block.spec.ts +7 -4
- package/template/blocks/quote/preview.png +0 -0
- package/template/blocks/rich-text/preview.png +0 -0
- package/template/blocks/search/Block.vue +10 -4
- package/template/blocks/search/PopularChips.vue +1 -1
- 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/Block.vue +2 -3
- package/template/blocks/split-content/__tests__/Block.spec.ts +2 -2
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/__tests__/Block.spec.ts +1 -1
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/Block.vue +4 -5
- package/template/blocks/tabs/__tests__/Block.spec.ts +2 -2
- package/template/blocks/tabs/preview.png +0 -0
- package/template/blocks/team/preview.png +0 -0
- package/template/blocks/testimonials/Block.vue +10 -9
- package/template/blocks/testimonials/__tests__/Block.spec.ts +1 -1
- package/template/blocks/testimonials/preview.png +0 -0
- package/template/blocks/timeline/__tests__/Block.spec.ts +2 -2
- package/template/blocks/timeline/preview.png +0 -0
- package/template/blocks/trust-strip/Block.vue +1 -1
- package/template/blocks/trust-strip/__tests__/Block.spec.ts +1 -1
- package/template/blocks/trust-strip/preview.png +0 -0
- package/template/blocks/video-embed/Block.vue +3 -3
- package/template/blocks/video-embed/__tests__/Block.spec.ts +1 -1
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/Block.vue +6 -2
- 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/nuxt.config.ts +5 -4
- package/template/package.json +1 -0
- package/template/stories/pages/article.stories.ts +2 -3
- package/template/stories/pages/cart.stories.ts +2 -3
- package/template/stories/pages/category.stories.ts +2 -3
- package/template/stories/pages/collection.stories.ts +2 -3
- package/template/stories/pages/home.stories.ts +2 -3
- package/template/stories/pages/product.stories.ts +3 -4
- package/template/stories/pages/products.stories.ts +2 -3
- package/template/stories/pages/search.stories.ts +2 -3
- package/template/stories/pages/wishlist.stories.ts +2 -3
- package/template/test/carouselKeyboard.spec.ts +2 -2
- package/template/test/carouselRing.browser.spec.ts +2 -2
- package/template/test/carouselSlideWidth.browser.spec.ts +9 -9
- package/template/test/currencyPicker.spec.ts +66 -0
- package/template/test/eldraIcon.spec.ts +1 -1
- package/template/test/mainCss.spec.ts +7 -0
- package/template/test/pages/article.spec.ts +5 -5
- package/template/test/pages/collection.spec.ts +5 -5
- package/template/test/pages/hydration.spec.ts +10 -10
- package/template/test/prerenderRefresh.browser.spec.ts +1 -1
- 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
- package/template/test/support/mountPage.ts +2 -3
|
@@ -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
|
+
});
|
|
@@ -91,9 +91,8 @@ export async function mountPageWithSkipLink(
|
|
|
91
91
|
href: '#main',
|
|
92
92
|
as: EldraRouterLink,
|
|
93
93
|
variant: 'standalone',
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
},
|
|
94
|
+
class:
|
|
95
|
+
'bg-primary text-primary-contrast rounded-md sr-only px-4 py-2 focus:not-sr-only focus:fixed focus:top-4 focus:left-4 focus:z-50',
|
|
97
96
|
},
|
|
98
97
|
() => t('nav.skipToContent')
|
|
99
98
|
),
|