@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
|
@@ -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
|
+
});
|
|
@@ -27,7 +27,7 @@ describe('EldraIcon', () => {
|
|
|
27
27
|
const wrapper = mount(EldraIcon, { props: { name: 'lock' } });
|
|
28
28
|
await flushPromises();
|
|
29
29
|
const svg = wrapper.find('svg');
|
|
30
|
-
expect(svg.classes()).toContain('size-8');
|
|
30
|
+
expect(svg.classes()).toContain('eldra:size-8');
|
|
31
31
|
expect(svg.attributes('stroke-width')).toBe('1.75');
|
|
32
32
|
expect(svg.attributes('aria-hidden')).toBe('true');
|
|
33
33
|
});
|
|
@@ -41,6 +41,13 @@ describe('main.css', () => {
|
|
|
41
41
|
expect(mainCss).toMatch(/^@source\s+'\.\.\/\.\.\/blocks';/m);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
+
it("ships the package's components prebuilt, below this file's own utilities", async () => {
|
|
45
|
+
const css = await build(['w-full']);
|
|
46
|
+
expect(mainCss).toMatch(/^@import '@eldrajs\/ui\/components\.css';$/m);
|
|
47
|
+
expect(css).toMatch(/@layer components\s*\{[^]*\.eldra\\:inline-flex/);
|
|
48
|
+
expect(css).toMatch(/^@layer theme, base, components, utilities;$/m);
|
|
49
|
+
});
|
|
50
|
+
|
|
44
51
|
it('emits the dialog backdrop from the overlay token', async () => {
|
|
45
52
|
const css = await build(['backdrop:bg-overlay']);
|
|
46
53
|
expect(css).toContain('::backdrop');
|
|
@@ -120,11 +120,11 @@ describe('article sample page', () => {
|
|
|
120
120
|
const roots = pageBlockRoots(wrapper);
|
|
121
121
|
const articleEl = roots[2]!;
|
|
122
122
|
|
|
123
|
-
const contentContainers = articleEl.querySelectorAll('.eldra-container-content');
|
|
124
|
-
const narrowContainers = articleEl.querySelectorAll('.eldra-container-narrow');
|
|
123
|
+
const contentContainers = articleEl.querySelectorAll('.eldra\\:eldra-container-content');
|
|
124
|
+
const narrowContainers = articleEl.querySelectorAll('.eldra\\:eldra-container-narrow');
|
|
125
125
|
expect(contentContainers.length).toBeGreaterThan(0);
|
|
126
126
|
expect(narrowContainers.length).toBeGreaterThan(0);
|
|
127
|
-
expect(articleEl.querySelectorAll('.eldra-container-wide')).toHaveLength(0);
|
|
127
|
+
expect(articleEl.querySelectorAll('.eldra\\:eldra-container-wide')).toHaveLength(0);
|
|
128
128
|
|
|
129
129
|
// The content container (header + cover) precedes the narrow one (body + author card).
|
|
130
130
|
const firstContent = contentContainers[0]!;
|
|
@@ -134,8 +134,8 @@ describe('article sample page', () => {
|
|
|
134
134
|
).toBeTruthy();
|
|
135
135
|
|
|
136
136
|
// The header/breadcrumbs stay on the 80rem wide container.
|
|
137
|
-
expect(roots[0]!.querySelector('.eldra-container-wide')).not.toBeNull();
|
|
138
|
-
expect(roots[1]!.querySelector('.eldra-container-wide')).not.toBeNull();
|
|
137
|
+
expect(roots[0]!.querySelector('.eldra\\:eldra-container-wide')).not.toBeNull();
|
|
138
|
+
expect(roots[1]!.querySelector('.eldra\\:eldra-container-wide')).not.toBeNull();
|
|
139
139
|
});
|
|
140
140
|
|
|
141
141
|
it('wraps the body table in a named, focusable region and marks its code block focusable', async () => {
|
|
@@ -125,12 +125,12 @@ describe('collection sample page', () => {
|
|
|
125
125
|
expect(grounds).toEqual([null, null, 'none', 'none', 'surface', 'surface-strong']);
|
|
126
126
|
|
|
127
127
|
// The grid starts directly under the collection header with its own short 1.5rem top padding
|
|
128
|
-
// (`pt-6
|
|
129
|
-
// padding on its `surface`
|
|
130
|
-
//
|
|
131
|
-
//
|
|
128
|
+
// (`pt-6`, hand-rolled rather than read from `Section`'s `spacing` prop — see the block's own
|
|
129
|
+
// top-of-file comment), and the call to action keeps a full band of padding on its `surface`
|
|
130
|
+
// ground (`Section`'s own `eldra:pt-[var(--eldra-section-md)]`), so this is what proves the
|
|
131
|
+
// page actually renders those values.
|
|
132
132
|
expect(gridEl!.classList.contains('pt-6')).toBe(true);
|
|
133
|
-
expect(ctaEl!.classList.contains('pt-[var(--eldra-section-md)]')).toBe(true);
|
|
133
|
+
expect(ctaEl!.classList.contains('eldra:pt-[var(--eldra-section-md)]')).toBe(true);
|
|
134
134
|
});
|
|
135
135
|
|
|
136
136
|
it('has exactly one h1 (the collection title) and one breadcrumb nav on the page', async () => {
|
|
@@ -144,15 +144,15 @@ const SUBJECTS: Subject[] = [
|
|
|
144
144
|
/**
|
|
145
145
|
* `@eldrajs/ui`'s `Carousel` decorates its slides **imperatively after mount** — `useCarousel.ts`
|
|
146
146
|
* `setAttribute`s `data-part="slide"`, `role="group"`, `aria-roledescription="slide"` and an
|
|
147
|
-
* "n of total" label onto whatever children the consumer passed, adds the
|
|
148
|
-
* sizing class, and writes the roving tab stop's `tabindex` (one stop
|
|
149
|
-
* active slide; every other slide's controls parked at `-1`) — precisely
|
|
150
|
-
* plain elements. That is a deliberate progressive enhancement of the
|
|
151
|
-
* server disagreed with (Vue reports no mismatch for any of it), and
|
|
152
|
-
* `product-carousel`'s row both go through it. The `tabindex` pass
|
|
153
|
-
* labelling: the server renders the pre-enhancement shape, the
|
|
154
|
-
* exactly, and the model only moves in `onMounted` afterwards —
|
|
155
|
-
* sides leaves the comparison below an honest one.
|
|
147
|
+
* "n of total" label onto whatever children the consumer passed, adds the
|
|
148
|
+
* `eldra:eldra-carousel-slide` sizing class, and writes the roving tab stop's `tabindex` (one stop
|
|
149
|
+
* for the whole row, on the active slide; every other slide's controls parked at `-1`) — precisely
|
|
150
|
+
* so a block can hand it plain elements. That is a deliberate progressive enhancement of the
|
|
151
|
+
* package's, not a render the server disagreed with (Vue reports no mismatch for any of it), and
|
|
152
|
+
* `product-detail`'s gallery and `product-carousel`'s row both go through it. The `tabindex` pass
|
|
153
|
+
* is the same kind of thing as the labelling: the server renders the pre-enhancement shape, the
|
|
154
|
+
* first client render matches it exactly, and the model only moves in `onMounted` afterwards —
|
|
155
|
+
* which is why removing it from both sides leaves the comparison below an honest one.
|
|
156
156
|
*
|
|
157
157
|
* **The `tabindex` removal is scoped to the carousel's own track**, through a parse rather than the
|
|
158
158
|
* regex the other four tokens use: `tabindex` is an ordinary attribute a block writes for itself —
|
|
@@ -163,7 +163,7 @@ const SUBJECTS: Subject[] = [
|
|
|
163
163
|
* Nothing in `blocks/**` writes any of the other four.
|
|
164
164
|
*/
|
|
165
165
|
const CAROUSEL_ENHANCEMENT =
|
|
166
|
-
/\s(?:data-part="slide"|role="group"|aria-roledescription="slide"|aria-label="\d+ of \d+")|\
|
|
166
|
+
/\s(?:data-part="slide"|role="group"|aria-roledescription="slide"|aria-label="\d+ of \d+")|\s(?:eldra:)?eldra-carousel-slide|(?:eldra:)?eldra-carousel-slide\s/g;
|
|
167
167
|
|
|
168
168
|
function withoutPackageEnhancement(html: string): string {
|
|
169
169
|
// Both halves go through the same parse, so any normalisation the parser does of its own
|
|
@@ -154,7 +154,7 @@ async function visit(path: string): Promise<Visit> {
|
|
|
154
154
|
samples.push(
|
|
155
155
|
await page.evaluate(() => ({
|
|
156
156
|
busy: document.querySelectorAll('[aria-busy="true"]').length,
|
|
157
|
-
dimmed: document.querySelectorAll('.eldra-revalidating').length,
|
|
157
|
+
dimmed: document.querySelectorAll('.eldra\\:eldra-revalidating').length,
|
|
158
158
|
spinners: document.querySelectorAll('[data-part="spinner"]').length,
|
|
159
159
|
announced: [...document.querySelectorAll('[role="status"]')].filter((node) =>
|
|
160
160
|
/Updating/i.test((node as HTMLElement).textContent ?? '')
|
|
@@ -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
|
|
378
|
-
|
|
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 () => {
|