@shopbite-de/storefront 1.26.0 → 1.27.0

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 (44) hide show
  1. package/.github/workflows/build.yaml +1 -1
  2. package/.github/workflows/ci.yaml +3 -3
  3. package/.gitignore +40 -0
  4. package/CLAUDE.md +10 -3
  5. package/app/app.vue +4 -1
  6. package/app/components/Hero.vue +17 -7
  7. package/app/components/Product/CrossSelling.vue +137 -24
  8. package/app/components/Product/DeselectIngredient.vue +9 -2
  9. package/app/components/Product/Detail.vue +16 -18
  10. package/app/components/Product/QuickView.vue +5 -4
  11. package/app/components/User/RegistrationForm.vue +73 -29
  12. package/app/composables/useStoreStatus.ts +12 -7
  13. package/app/composables/useSyncWishlist.ts +119 -0
  14. package/app/pages/[...all].vue +9 -3
  15. package/app/pages/index.vue +1 -5
  16. package/app/pages/kontakt.vue +1 -5
  17. package/app/pages/registrierung/bestaetigen.vue +100 -27
  18. package/app/pages/registrierung/index.vue +20 -1
  19. package/app/utils/notFound.ts +14 -0
  20. package/content/index.yml +9 -9
  21. package/docs/notes/2026-09-17-quick-view-compact-options.md +63 -0
  22. package/docs/notes/2026-09-21-dependency-update.md +89 -0
  23. package/docs/notes/2026-09-21-issue-273-cache-and-demo-video.md +49 -0
  24. package/docs/notes/2026-09-21-issue-363-non-fatal-404.md +43 -0
  25. package/docs/notes/2026-09-21-issue-365-home-hydration-mismatch.md +47 -0
  26. package/docs/notes/2026-09-21-issue-366-wishlist-404.md +41 -0
  27. package/docs/notes/2026-09-21-issue-369-register-confirm.md +35 -0
  28. package/modules/public-cache.ts +44 -0
  29. package/node.dockerfile +3 -3
  30. package/nuxt.config.ts +6 -0
  31. package/package.json +26 -26
  32. package/patches/@shopware__nuxt-module@1.5.2.patch +13 -0
  33. package/pnpm-workspace.yaml +3 -1
  34. package/shopware.d.ts +1 -1
  35. package/test/nuxt/Hero.test.ts +60 -2
  36. package/test/nuxt/ProductCrossSelling.test.ts +99 -0
  37. package/test/nuxt/RegisterConfirmPage.test.ts +117 -0
  38. package/test/nuxt/RegistrationForm.test.ts +132 -2
  39. package/test/nuxt/notFound.test.ts +13 -0
  40. package/test/nuxt/useSearchTracking.test.ts +3 -0
  41. package/test/nuxt/useStoreStatus.test.ts +40 -10
  42. package/test/nuxt/useSyncWishlist.test.ts +85 -0
  43. package/test/unit/publicCache.spec.ts +64 -0
  44. package/patches/@shopware__nuxt-module@1.5.1.patch +0 -32
@@ -56,8 +56,8 @@ mockNuxtImport("useRuntimeConfig", () => () => ({
56
56
  // UCheckbox renders the clickable control as `button[role="checkbox"]` next to
57
57
  // an aria-hidden native input that only mirrors the state, so the button is
58
58
  // what has to be clicked to toggle the v-model.
59
- async function acceptDataProtection(wrapper: VueWrapper) {
60
- const hiddenInput = wrapper.find('input[name="acceptedDataProtection"]');
59
+ async function toggleCheckbox(wrapper: VueWrapper, name: string) {
60
+ const hiddenInput = wrapper.find(`input[name="${name}"]`);
61
61
  const button = hiddenInput.element.parentElement!.querySelector(
62
62
  'button[role="checkbox"]',
63
63
  )!;
@@ -65,6 +65,31 @@ async function acceptDataProtection(wrapper: VueWrapper) {
65
65
  await new Promise((resolve) => setTimeout(resolve, 0));
66
66
  }
67
67
 
68
+ async function acceptDataProtection(wrapper: VueWrapper) {
69
+ await toggleCheckbox(wrapper, "acceptedDataProtection");
70
+ }
71
+
72
+ // Fills everything the schema requires except the password fields.
73
+ async function fillRequiredFields(wrapper: VueWrapper) {
74
+ await wrapper.find('input[name="firstName"]').setValue("John");
75
+ await wrapper.find('input[name="lastName"]').setValue("Doe");
76
+ await wrapper.find('input[name="email"]').setValue("john@example.com");
77
+ const state = (
78
+ wrapper.vm as unknown as {
79
+ state: {
80
+ billingAddress: { street: string; zipcode: string; city: string };
81
+ };
82
+ }
83
+ ).state;
84
+ state.billingAddress.street = "Musterstr 1";
85
+ state.billingAddress.zipcode = "12345";
86
+ state.billingAddress.city = "Musterstadt";
87
+ await wrapper
88
+ .find('input[name="billingAddress.phoneNumber"]')
89
+ .setValue("12345678");
90
+ await acceptDataProtection(wrapper);
91
+ }
92
+
68
93
  describe("RegistrationForm", () => {
69
94
  beforeEach(() => {
70
95
  vi.clearAllMocks();
@@ -321,4 +346,109 @@ describe("RegistrationForm", () => {
321
346
  "Meinten Sie: Corrected Street 123, 54321 Corrected City?",
322
347
  );
323
348
  });
349
+
350
+ it("orders as a guest by default and reveals the password fields on opt-in", async () => {
351
+ const wrapper = await mountSuspended(RegistrationForm);
352
+
353
+ expect(wrapper.text()).toContain("Kundenkonto anlegen");
354
+ expect(
355
+ (wrapper.vm as unknown as { state: { guest: boolean } }).state.guest,
356
+ ).toBe(true);
357
+ expect(wrapper.find('input[name="password"]').exists()).toBe(false);
358
+
359
+ await toggleCheckbox(wrapper, "guest");
360
+ await nextTick();
361
+
362
+ expect(
363
+ (wrapper.vm as unknown as { state: { guest: boolean } }).state.guest,
364
+ ).toBe(false);
365
+ expect(wrapper.find('input[name="password"]').exists()).toBe(true);
366
+ expect(wrapper.find('input[name="passwordConfirm"]').exists()).toBe(true);
367
+ });
368
+
369
+ it("never offers a guest account when allowGuest is false", async () => {
370
+ const wrapper = await mountSuspended(RegistrationForm, {
371
+ props: { allowGuest: false },
372
+ });
373
+
374
+ expect(wrapper.text()).not.toContain("Kundenkonto anlegen");
375
+ expect(
376
+ (wrapper.vm as unknown as { state: { guest: boolean } }).state.guest,
377
+ ).toBe(false);
378
+ expect(wrapper.find('input[name="password"]').exists()).toBe(true);
379
+ expect(wrapper.find('input[name="passwordConfirm"]').exists()).toBe(true);
380
+ });
381
+
382
+ it("does not register without a password when allowGuest is false", async () => {
383
+ const wrapper = await mountSuspended(RegistrationForm, {
384
+ props: { allowGuest: false },
385
+ });
386
+
387
+ await fillRequiredFields(wrapper);
388
+ await wrapper.find("form").trigger("submit");
389
+ await new Promise((resolve) => setTimeout(resolve, 100));
390
+
391
+ expect(mockRegister).not.toHaveBeenCalled();
392
+ expect(wrapper.text()).toContain(
393
+ "Das Passwort muss mindestens 8 Zeichen lang sein.",
394
+ );
395
+ });
396
+
397
+ it("registers a real customer account when allowGuest is false", async () => {
398
+ mockRegister.mockResolvedValueOnce({
399
+ id: "customer-id",
400
+ active: true,
401
+ doubleOptInRegistration: false,
402
+ });
403
+ const wrapper = await mountSuspended(RegistrationForm, {
404
+ props: { allowGuest: false },
405
+ });
406
+
407
+ await fillRequiredFields(wrapper);
408
+ await wrapper.find('input[name="password"]').setValue("supersecret");
409
+ await wrapper.find('input[name="passwordConfirm"]').setValue("supersecret");
410
+
411
+ await wrapper.find("form").trigger("submit");
412
+ await new Promise((resolve) => setTimeout(resolve, 100));
413
+
414
+ expect(mockRegister).toHaveBeenCalled();
415
+ const calledData = mockRegister.mock.calls[0]![0];
416
+ expect(calledData.guest).toBe(false);
417
+ expect(calledData.password).toBe("supersecret");
418
+ expect(mockToastAdd).toHaveBeenCalledWith(
419
+ expect.objectContaining({
420
+ title: "Konto erfolgreich erstellt",
421
+ color: "success",
422
+ }),
423
+ );
424
+ });
425
+
426
+ it("asks for the e-mail confirmation on double opt-in registrations", async () => {
427
+ const customer = {
428
+ id: "customer-id",
429
+ active: false,
430
+ doubleOptInRegistration: true,
431
+ };
432
+ mockRegister.mockResolvedValueOnce(customer);
433
+ const wrapper = await mountSuspended(RegistrationForm, {
434
+ props: { allowGuest: false },
435
+ });
436
+
437
+ await fillRequiredFields(wrapper);
438
+ await wrapper.find('input[name="password"]').setValue("supersecret");
439
+ await wrapper.find('input[name="passwordConfirm"]').setValue("supersecret");
440
+
441
+ await wrapper.find("form").trigger("submit");
442
+ await new Promise((resolve) => setTimeout(resolve, 100));
443
+
444
+ expect(mockToastAdd).toHaveBeenCalledWith(
445
+ expect.objectContaining({
446
+ title: "Fast geschafft!",
447
+ color: "info",
448
+ }),
449
+ );
450
+ const emitted = wrapper.emitted("registration-success");
451
+ expect(emitted).toBeTruthy();
452
+ expect(emitted![0]![1]).toEqual(customer);
453
+ });
324
454
  });
@@ -0,0 +1,13 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { createNotFoundError } from "../../app/utils/notFound";
3
+
4
+ describe("createNotFoundError", () => {
5
+ it("is a 404 that stays fatal in the browser, so navigation shows the error page", () => {
6
+ const error = createNotFoundError("Page /x not found!");
7
+
8
+ expect(error.statusCode).toBe(404);
9
+ expect(error.statusMessage).toBe("Page /x not found!");
10
+ // The test environment runs as client; on the server `fatal` is false.
11
+ expect(error.fatal).toBe(import.meta.client);
12
+ });
13
+ });
@@ -6,8 +6,11 @@ import { useSearchTracking } from "../../app/composables/useSearchTracking";
6
6
 
7
7
  const { mockTrackSearch } = vi.hoisted(() => ({ mockTrackSearch: vi.fn() }));
8
8
 
9
+ // plugins/matomo.ts calls trackPageView when Matomo is configured in the
10
+ // test environment; without it the plugin rejects outside the test (#323).
9
11
  mockNuxtImport("useTrackEvent", () => () => ({
10
12
  trackSearch: mockTrackSearch,
13
+ trackPageView: vi.fn(),
11
14
  }));
12
15
 
13
16
  const products = (...numbers: string[]) =>
@@ -1,7 +1,11 @@
1
1
  import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2
- import { mockNuxtImport } from "@nuxt/test-utils/runtime";
3
- import { ref } from "vue";
4
- import { useStoreStatus } from "../../app/composables/useStoreStatus";
2
+ import { mockNuxtImport, mountSuspended } from "@nuxt/test-utils/runtime";
3
+ import { defineComponent, ref } from "vue";
4
+ import type { Ref } from "vue";
5
+ import {
6
+ useStoreStatus,
7
+ type StoreStatus,
8
+ } from "../../app/composables/useStoreStatus";
5
9
 
6
10
  const { state } = vi.hoisted(() => ({
7
11
  state: {
@@ -31,6 +35,22 @@ const at = (hours: number, minutes = 0) => {
31
35
  return date;
32
36
  };
33
37
 
38
+ // The status needs a mounted component: the clock starts in onMounted.
39
+ async function mountStatus() {
40
+ let status!: Ref<StoreStatus | null>;
41
+ let statusDuringSetup: StoreStatus | null | undefined;
42
+ await mountSuspended(
43
+ defineComponent({
44
+ setup() {
45
+ status = useStoreStatus().status;
46
+ statusDuringSetup = status.value;
47
+ return () => null;
48
+ },
49
+ }),
50
+ );
51
+ return { status, statusDuringSetup };
52
+ }
53
+
34
54
  describe("useStoreStatus", () => {
35
55
  beforeEach(() => {
36
56
  vi.useFakeTimers();
@@ -43,33 +63,43 @@ describe("useStoreStatus", () => {
43
63
  vi.useRealTimers();
44
64
  });
45
65
 
46
- it("is unknown until business hours and holidays are loaded", () => {
66
+ it("is unknown until business hours and holidays are loaded", async () => {
47
67
  state.businessHours = null;
48
- expect(useStoreStatus().status.value).toBeNull();
68
+ expect((await mountStatus()).status.value).toBeNull();
49
69
 
50
70
  state.businessHours = [{}];
51
71
  state.holidays = null;
52
- expect(useStoreStatus().status.value).toBeNull();
72
+ expect((await mountStatus()).status.value).toBeNull();
73
+ });
74
+
75
+ it("is unknown before the component is mounted, like on the server", async () => {
76
+ state.open = true;
77
+ state.intervals = [{ start: at(11, 30), end: at(14, 30) }];
78
+
79
+ const { status, statusDuringSetup } = await mountStatus();
80
+
81
+ expect(statusDuringSetup).toBeNull();
82
+ expect(status.value).toEqual({ open: true, closesAt: "14:30" });
53
83
  });
54
84
 
55
- it("reports the closing time of the current interval when open", () => {
85
+ it("reports the closing time of the current interval when open", async () => {
56
86
  state.open = true;
57
87
  state.intervals = [
58
88
  { start: at(11, 30), end: at(14, 30) },
59
89
  { start: at(17, 30), end: at(23, 0) },
60
90
  ];
61
91
 
62
- expect(useStoreStatus().status.value).toEqual({
92
+ expect((await mountStatus()).status.value).toEqual({
63
93
  open: true,
64
94
  closesAt: "14:30",
65
95
  });
66
96
  });
67
97
 
68
- it("reports the next opening when closed", () => {
98
+ it("reports the next opening when closed", async () => {
69
99
  state.open = false;
70
100
  state.nextOpening = "17:30 Uhr";
71
101
 
72
- expect(useStoreStatus().status.value).toEqual({
102
+ expect((await mountStatus()).status.value).toEqual({
73
103
  open: false,
74
104
  nextOpening: "17:30 Uhr",
75
105
  });
@@ -0,0 +1,85 @@
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2
+ import { mockNuxtImport } from "@nuxt/test-utils/runtime";
3
+ import { useSyncWishlist } from "../../app/composables/useSyncWishlist";
4
+
5
+ const { ApiClientErrorMock } = vi.hoisted(() => ({
6
+ ApiClientErrorMock: class extends Error {
7
+ details: unknown;
8
+ constructor(details: unknown) {
9
+ super("ApiClientError");
10
+ this.details = details;
11
+ }
12
+ },
13
+ }));
14
+
15
+ vi.mock("@shopware/api-client", () => ({
16
+ ApiClientError: ApiClientErrorMock,
17
+ }));
18
+
19
+ const invokeMock = vi.fn();
20
+ mockNuxtImport("useShopwareContext", () => () => ({
21
+ apiClient: { invoke: invokeMock },
22
+ }));
23
+
24
+ function apiError(code: string) {
25
+ return new ApiClientErrorMock({ errors: [{ code }] });
26
+ }
27
+
28
+ describe("useSyncWishlist", () => {
29
+ let consoleErrorSpy: ReturnType<typeof vi.spyOn>;
30
+
31
+ beforeEach(() => {
32
+ vi.clearAllMocks();
33
+ consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
34
+ });
35
+
36
+ afterEach(() => {
37
+ consoleErrorSpy.mockRestore();
38
+ });
39
+
40
+ it("loads the wishlist products", async () => {
41
+ invokeMock.mockResolvedValueOnce({
42
+ data: {
43
+ products: {
44
+ elements: [{ id: "p1" }, { id: "p2" }],
45
+ total: 2,
46
+ page: 1,
47
+ limit: 15,
48
+ },
49
+ },
50
+ });
51
+
52
+ const { getWishlistProducts, items, count } = useSyncWishlist();
53
+ await getWishlistProducts();
54
+
55
+ expect(items.value).toEqual(["p1", "p2"]);
56
+ expect(count.value).toBe(2);
57
+ });
58
+
59
+ it.each([
60
+ "CHECKOUT__WISHLIST_NOT_FOUND",
61
+ "CHECKOUT__WISHLIST_IS_NOT_ACTIVATED",
62
+ ])("treats %s as an empty wishlist without logging", async (code) => {
63
+ invokeMock.mockRejectedValueOnce(apiError(code));
64
+
65
+ const { getWishlistProducts, items, count } = useSyncWishlist();
66
+ await getWishlistProducts();
67
+
68
+ expect(items.value).toEqual([]);
69
+ expect(count.value).toBe(0);
70
+ expect(consoleErrorSpy).not.toHaveBeenCalled();
71
+ });
72
+
73
+ it("logs unexpected errors", async () => {
74
+ invokeMock.mockRejectedValueOnce(new Error("Network down"));
75
+
76
+ const { getWishlistProducts, items } = useSyncWishlist();
77
+ await getWishlistProducts();
78
+
79
+ expect(items.value).toEqual([]);
80
+ expect(consoleErrorSpy).toHaveBeenCalledWith(
81
+ "[useSyncWishlist][getWishlistProducts][error]:",
82
+ expect.any(Error),
83
+ );
84
+ });
85
+ });
@@ -0,0 +1,64 @@
1
+ import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { describe, it, expect } from "vitest";
5
+ import type { Nuxt } from "nuxt/schema";
6
+ import publicCache, { PUBLIC_CACHE_CONTROL } from "../../modules/public-cache";
7
+
8
+ function layer(files: string[]) {
9
+ const root = mkdtempSync(join(tmpdir(), "public-cache-"));
10
+ for (const file of files) {
11
+ const path = join(root, "public", file);
12
+ mkdirSync(join(path, ".."), { recursive: true });
13
+ writeFileSync(path, "x");
14
+ }
15
+ return { cwd: root, config: { srcDir: root, rootDir: root } };
16
+ }
17
+
18
+ function run(layers: ReturnType<typeof layer>[], routeRules = {}) {
19
+ const nuxt = { options: { _layers: layers, routeRules } } as unknown as Nuxt;
20
+ publicCache(undefined, nuxt);
21
+ return nuxt.options.routeRules as Record<
22
+ string,
23
+ { headers?: Record<string, string> }
24
+ >;
25
+ }
26
+
27
+ describe("public-cache module", () => {
28
+ it("adds Cache-Control for the public files of every layer", () => {
29
+ const rules = run([
30
+ layer(["brand/logo.png"]),
31
+ layer(["hero-poster.webp", "light/Logo.png"]),
32
+ ]);
33
+
34
+ for (const path of [
35
+ "/brand/logo.png",
36
+ "/hero-poster.webp",
37
+ "/light/Logo.png",
38
+ ]) {
39
+ expect(rules[path]?.headers?.["cache-control"]).toBe(
40
+ PUBLIC_CACHE_CONTROL,
41
+ );
42
+ }
43
+ expect(rules["/"]).toBeUndefined();
44
+ });
45
+
46
+ it("keeps headers a shop configured itself", () => {
47
+ const rules = run([layer(["favicon.ico"])], {
48
+ "/favicon.ico": { headers: { "cache-control": "no-cache", "x-a": "1" } },
49
+ });
50
+
51
+ expect(rules["/favicon.ico"]?.headers).toEqual({
52
+ "cache-control": "no-cache",
53
+ "x-a": "1",
54
+ });
55
+ });
56
+
57
+ it("skips layers without a public directory", () => {
58
+ const root = mkdtempSync(join(tmpdir(), "public-cache-"));
59
+
60
+ expect(
61
+ run([{ cwd: root, config: { srcDir: root, rootDir: root } }]),
62
+ ).toEqual({});
63
+ });
64
+ });
@@ -1,32 +0,0 @@
1
- diff --git a/plugin.ts b/plugin.ts
2
- index 5b9cdef440df1eb477ffea4d66180bc65b33835a..c23d08a8af61875b55e192d108d009bc5ddd7b07 100644
3
- --- a/plugin.ts
4
- +++ b/plugin.ts
5
- @@ -14,7 +14,8 @@ import {
6
- } from "#imports";
7
- import type { ApiClient } from "#shopware";
8
-
9
- -import type { ShopwareNuxtOptions } from "./src";
10
- +import type { ShopwareNuxtOptions } from "./dist/index";
11
- +import type { Plugin } from "#app";
12
-
13
- declare module "#app" {
14
- interface NuxtApp {
15
- @@ -28,7 +29,10 @@ declare module "vue" {
16
- }
17
- }
18
-
19
- -export default defineNuxtPlugin((NuxtApp) => {
20
- +// Explicit type keeps Nuxt's generated NuxtApp augmentation from
21
- +// recursively depending on this plugin's inferred return type.
22
- +const shopwarePlugin: Plugin<{ shopwareApiClient: ApiClient }> =
23
- + defineNuxtPlugin((NuxtApp) => {
24
- const runtimeConfig = useRuntimeConfig();
25
-
26
- const shopwareRuntimeConfigPublic = runtimeConfig.public
27
- @@ -143,3 +147,5 @@ export default defineNuxtPlugin((NuxtApp) => {
28
- },
29
- };
30
- });
31
- +
32
- +export default shopwarePlugin;