@shopbite-de/storefront 1.24.0 → 1.26.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 (96) hide show
  1. package/.env.example +3 -0
  2. package/CLAUDE.md +10 -3
  3. package/README.md +0 -1
  4. package/app/app.config.ts +3 -2
  5. package/app/app.vue +4 -1
  6. package/app/assets/css/main.css +16 -0
  7. package/app/components/AddToWishlist.vue +13 -6
  8. package/app/components/Cart/Bar.vue +102 -0
  9. package/app/components/Cart/QuickView.vue +4 -0
  10. package/app/components/Cart/Upsell.vue +106 -0
  11. package/app/components/Category/Listing.vue +11 -3
  12. package/app/components/Checkout/DeliveryTimeSelect.vue +28 -2
  13. package/app/components/Checkout/Summary.vue +25 -3
  14. package/app/components/DemoBanner.vue +13 -0
  15. package/app/components/Feature/Card.vue +121 -0
  16. package/app/components/Features.vue +14 -9
  17. package/app/components/Footer/Contact.vue +5 -1
  18. package/app/components/Header/Right.vue +44 -15
  19. package/app/components/Hero.vue +126 -36
  20. package/app/components/Product/Card.vue +102 -50
  21. package/app/components/Product/CardCompact.vue +72 -0
  22. package/app/components/Product/CardDietBadges.vue +38 -31
  23. package/app/components/Product/CardIngredients.vue +35 -0
  24. package/app/components/Product/CardSkeleton.vue +10 -18
  25. package/app/components/Product/Category.vue +9 -2
  26. package/app/components/Product/Configurator.vue +11 -7
  27. package/app/components/Product/CrossSelling.vue +45 -34
  28. package/app/components/Product/DeselectIngredient.vue +37 -31
  29. package/app/components/Product/Detail.vue +73 -13
  30. package/app/components/Product/QuickView.vue +77 -0
  31. package/app/components/Topseller.vue +44 -34
  32. package/app/composables/useAddToCart.ts +3 -30
  33. package/app/composables/useBusinessHours.ts +10 -3
  34. package/app/composables/useCartQuickView.ts +19 -0
  35. package/app/composables/useCartUpsell.ts +100 -0
  36. package/app/composables/useCategorySeo.ts +5 -4
  37. package/app/composables/useHolidays.ts +7 -3
  38. package/app/composables/useOpeningHoursData.ts +53 -0
  39. package/app/composables/useProductCartQuantity.ts +15 -0
  40. package/app/composables/useProductCrossSelling.ts +1 -0
  41. package/app/composables/useProductDetail.ts +15 -1
  42. package/app/composables/useProductEvents.ts +30 -0
  43. package/app/composables/useProductQuickView.ts +65 -0
  44. package/app/composables/useTopSellers.ts +22 -0
  45. package/app/composables/useTrackEvent.ts +7 -0
  46. package/app/pages/bestellung/bestaetigen.vue +0 -3
  47. package/app/pages/bestellung/warenkorb.vue +0 -3
  48. package/app/pages/bestellung/zahlung-versand.vue +0 -3
  49. package/app/pages/bestellung.vue +22 -14
  50. package/app/pages/index.vue +3 -1
  51. package/app/pages/suche.vue +18 -5
  52. package/app/types/Association.d.ts +1 -0
  53. package/app/utils/openingHours.ts +31 -8
  54. package/app/utils/product.ts +31 -0
  55. package/app/utils/retry.ts +17 -0
  56. package/content/index.yml +16 -11
  57. package/content.config.ts +13 -0
  58. package/docs/notes/2026-09-12-issue-319-stylesheet-cost.md +154 -0
  59. package/docs/notes/2026-09-12-issue-325-product-card.md +100 -0
  60. package/docs/notes/2026-09-12-issue-327-home-hero.md +64 -0
  61. package/docs/notes/2026-09-13-demo-banner.md +32 -0
  62. package/docs/notes/2026-09-13-issue-332-home-info-cards.md +46 -0
  63. package/docs/notes/2026-09-13-quick-view-flicker.md +65 -0
  64. package/docs/notes/2026-09-14-cart-upsell.md +105 -0
  65. package/docs/notes/2026-09-14-demo-noindex.md +57 -0
  66. package/docs/notes/2026-09-16-issue-339-checkout-hydration.md +49 -0
  67. package/docs/notes/2026-09-16-issue-349-order-button-loading.md +39 -0
  68. package/docs/notes/2026-09-16-issue-350-remove-pinia.md +41 -0
  69. package/docs/notes/2026-09-16-issue-355-opening-hours-error.md +57 -0
  70. package/nuxt.config.ts +25 -2
  71. package/package.json +2 -3
  72. package/scripts/perf/first-render.mjs +30 -0
  73. package/scripts/perf/h2-proxy.cjs +49 -0
  74. package/scripts/perf/lighthouse.sh +22 -0
  75. package/scripts/perf/quick-view-layout.mjs +126 -0
  76. package/server/api/listing/[categoryId].get.ts +2 -0
  77. package/server/api/search.get.ts +2 -0
  78. package/test/e2e/simple-checkout-as-recurring-customer.test.ts +13 -17
  79. package/test/nuxt/CartBar.test.ts +110 -0
  80. package/test/nuxt/CartUpsell.test.ts +125 -0
  81. package/test/nuxt/CheckoutSummary.test.ts +127 -0
  82. package/test/nuxt/DemoBanner.test.ts +12 -0
  83. package/test/nuxt/useAddToCart.test.ts +6 -19
  84. package/test/nuxt/useCartUpsell.test.ts +126 -0
  85. package/test/nuxt/useOpeningHoursData.test.ts +120 -0
  86. package/test/nuxt/useTrackEvent.test.ts +15 -0
  87. package/test/unit/openingHours.spec.ts +32 -1
  88. package/test/unit/product.spec.ts +72 -0
  89. package/test/unit/retry.spec.ts +58 -0
  90. package/test/unit/useCategorySeo.spec.ts +2 -1
  91. package/test/visual/playwright.config.ts +33 -0
  92. package/test/visual/visual.spec.ts +87 -0
  93. package/app/components/Product/CardDescription.vue +0 -27
  94. package/app/components/Product/CardFooter.vue +0 -61
  95. package/app/composables/useCheckoutStore.ts +0 -1
  96. package/app/stores/checkout.ts +0 -22
@@ -0,0 +1,127 @@
1
+ import { describe, it, expect, vi, beforeEach } from "vitest";
2
+ import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
3
+ import { defineComponent, h, onMounted, ref } from "vue";
4
+ import Summary from "~/components/Checkout/Summary.vue";
5
+
6
+ const { state } = vi.hoisted(() => ({
7
+ state: {
8
+ isLoading: true,
9
+ hasFailed: false,
10
+ validTime: false,
11
+ },
12
+ }));
13
+
14
+ mockNuxtImport("useOpeningHoursData", () => () => ({
15
+ isLoading: ref(state.isLoading),
16
+ hasFailed: ref(state.hasFailed),
17
+ }));
18
+
19
+ mockNuxtImport("useCheckout", () => () => ({
20
+ createOrder: vi.fn(),
21
+ selectedPaymentMethod: ref({ id: "pm1" }),
22
+ selectedShippingMethod: ref({ id: "sm1" }),
23
+ }));
24
+
25
+ mockNuxtImport("useCart", () => () => ({
26
+ refreshCart: vi.fn(),
27
+ }));
28
+
29
+ mockNuxtImport("useUser", () => () => ({
30
+ isLoggedIn: ref(false),
31
+ isGuestSession: ref(true),
32
+ refreshUser: vi.fn(),
33
+ }));
34
+
35
+ mockNuxtImport("useShopBiteConfig", () => () => ({
36
+ isCheckoutEnabled: ref(true),
37
+ refresh: vi.fn(),
38
+ }));
39
+
40
+ mockNuxtImport("useTrackEvent", () => () => ({
41
+ trackOrder: vi.fn(),
42
+ }));
43
+
44
+ mockNuxtImport("useCheckoutMethodGuard", () => () => ({
45
+ isShippingMethodBlocked: ref(false),
46
+ isPaymentMethodBlocked: ref(false),
47
+ ensureAvailableCheckoutMethods: vi.fn().mockResolvedValue(true),
48
+ }));
49
+
50
+ vi.mock("@shopware/composables", async (importOriginal) => ({
51
+ ...(await importOriginal<typeof import("@shopware/composables")>()),
52
+ useOrderPayment: () => ({ handlePayment: vi.fn(), paymentUrl: ref(null) }),
53
+ }));
54
+
55
+ // Reports the time as DeliveryTimeSelect does once a time is selected.
56
+ const DeliveryTimeSelectStub = defineComponent({
57
+ emits: ["update:valid"],
58
+ setup(_, { emit }) {
59
+ onMounted(() => emit("update:valid", state.validTime));
60
+ return () => h("div");
61
+ },
62
+ });
63
+
64
+ async function mountSummary() {
65
+ const wrapper = await mountSuspended(Summary, {
66
+ global: {
67
+ stubs: {
68
+ UserDetail: true,
69
+ CheckoutPaymentMethod: true,
70
+ CheckoutShippingMethod: true,
71
+ CheckoutDeliveryTimeSelect: DeliveryTimeSelectStub,
72
+ CheckoutVoucherInput: true,
73
+ QuickView: true,
74
+ },
75
+ },
76
+ });
77
+ await new Promise((resolve) => setTimeout(resolve, 0));
78
+ // The order button is the only button besides the stubbed children.
79
+ return wrapper.get("button");
80
+ }
81
+
82
+ describe("Checkout Summary order button", () => {
83
+ beforeEach(() => {
84
+ state.isLoading = true;
85
+ state.hasFailed = false;
86
+ state.validTime = false;
87
+ });
88
+
89
+ it("shows a loading state while the opening hours are not loaded", async () => {
90
+ const button = await mountSummary();
91
+
92
+ expect(button.text()).toBe("Lade Öffnungszeiten …");
93
+ expect(button.attributes("disabled")).toBeDefined();
94
+ expect(button.find(".animate-spin").exists()).toBe(true);
95
+ });
96
+
97
+ it("says the opening hours could not be loaded when loading failed", async () => {
98
+ state.isLoading = false;
99
+ state.hasFailed = true;
100
+
101
+ const button = await mountSummary();
102
+
103
+ expect(button.text()).toBe("Öffnungszeiten konnten nicht geladen werden");
104
+ expect(button.attributes("disabled")).toBeDefined();
105
+ expect(button.find(".animate-spin").exists()).toBe(false);
106
+ });
107
+
108
+ it("says the shop is closed once loaded without a valid time", async () => {
109
+ state.isLoading = false;
110
+
111
+ const button = await mountSummary();
112
+
113
+ expect(button.text()).toBe("Wir haben aktuell leider geschlossen");
114
+ expect(button.attributes("disabled")).toBeDefined();
115
+ expect(button.find(".animate-spin").exists()).toBe(false);
116
+ });
117
+
118
+ it("allows ordering once loaded with a valid time", async () => {
119
+ state.isLoading = false;
120
+ state.validTime = true;
121
+
122
+ const button = await mountSummary();
123
+
124
+ expect(button.text()).toBe("Jetzt bestellen!");
125
+ expect(button.attributes("disabled")).toBeUndefined();
126
+ });
127
+ });
@@ -0,0 +1,12 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { mountSuspended } from "@nuxt/test-utils/runtime";
3
+ import DemoBanner from "~/components/DemoBanner.vue";
4
+
5
+ describe("DemoBanner", () => {
6
+ it("renders the demo notice", async () => {
7
+ const wrapper = await mountSuspended(DemoBanner);
8
+
9
+ expect(wrapper.text()).toContain("Demo-Shop");
10
+ expect(wrapper.text()).toContain("nicht ausgeliefert");
11
+ });
12
+ });
@@ -9,14 +9,12 @@ import { nextTick } from "vue";
9
9
  const {
10
10
  mockAddProducts,
11
11
  mockRefreshCart,
12
- mockToastAdd,
13
- mockTriggerProductAdded,
12
+ mockTriggerCartItemAdded,
14
13
  mockTrackEvent,
15
14
  } = vi.hoisted(() => ({
16
15
  mockAddProducts: vi.fn(),
17
16
  mockRefreshCart: vi.fn(),
18
- mockToastAdd: vi.fn(),
19
- mockTriggerProductAdded: vi.fn(),
17
+ mockTriggerCartItemAdded: vi.fn(),
20
18
  mockTrackEvent: vi.fn(),
21
19
  }));
22
20
 
@@ -33,15 +31,9 @@ mockNuxtImport("useCart", () => {
33
31
  });
34
32
  });
35
33
 
36
- mockNuxtImport("useToast", () => {
37
- return () => ({
38
- add: mockToastAdd,
39
- });
40
- });
41
-
42
34
  mockNuxtImport("useProductEvents", () => {
43
35
  return () => ({
44
- triggerProductAdded: mockTriggerProductAdded,
36
+ triggerCartItemAdded: mockTriggerCartItemAdded,
45
37
  });
46
38
  });
47
39
 
@@ -59,11 +51,8 @@ vi.stubGlobal("useCart", () => ({
59
51
  addProducts: mockAddProducts,
60
52
  refreshCart: mockRefreshCart,
61
53
  }));
62
- vi.stubGlobal("useToast", () => ({
63
- add: mockToastAdd,
64
- }));
65
54
  vi.stubGlobal("useProductEvents", () => ({
66
- triggerProductAdded: mockTriggerProductAdded,
55
+ triggerCartItemAdded: mockTriggerCartItemAdded,
67
56
  }));
68
57
  vi.stubGlobal("useTrackEvent", () => ({
69
58
  trackAddToCart: mockTrackEvent,
@@ -142,8 +131,7 @@ describe("useAddToCart", () => {
142
131
  type: "product",
143
132
  },
144
133
  ]);
145
- expect(mockToastAdd).toHaveBeenCalled();
146
- expect(mockTriggerProductAdded).toHaveBeenCalled();
134
+ expect(mockTriggerCartItemAdded).toHaveBeenCalledWith(mockProduct, 1);
147
135
  expect(mockTrackEvent).toHaveBeenCalledWith(mockProduct, 1);
148
136
  });
149
137
 
@@ -157,8 +145,7 @@ describe("useAddToCart", () => {
157
145
  await addToCart();
158
146
 
159
147
  expect(isLoading.value).toBe(false);
160
- expect(mockToastAdd).not.toHaveBeenCalled();
161
- expect(mockTriggerProductAdded).not.toHaveBeenCalled();
148
+ expect(mockTriggerCartItemAdded).not.toHaveBeenCalled();
162
149
  expect(mockTrackEvent).not.toHaveBeenCalled();
163
150
  });
164
151
 
@@ -0,0 +1,126 @@
1
+ import { describe, it, expect, vi, beforeEach } from "vitest";
2
+ import { mockNuxtImport } from "@nuxt/test-utils/runtime";
3
+ import { useCartUpsell } from "~/composables/useCartUpsell";
4
+ import type { Schemas } from "#shopware";
5
+
6
+ const {
7
+ mockInvoke,
8
+ mockAddLineItems,
9
+ mockTriggerCartItemAdded,
10
+ mockTrackUpsellAdd,
11
+ } = vi.hoisted(() => ({
12
+ mockInvoke: vi.fn(),
13
+ mockAddLineItems: vi.fn(),
14
+ mockTriggerCartItemAdded: vi.fn(),
15
+ mockTrackUpsellAdd: vi.fn(),
16
+ }));
17
+
18
+ mockNuxtImport("useShopwareContext", () => () => ({
19
+ apiClient: { invoke: mockInvoke },
20
+ }));
21
+ mockNuxtImport("useCartMutations", () => () => ({
22
+ addLineItems: mockAddLineItems,
23
+ }));
24
+ mockNuxtImport("useProductEvents", () => () => ({
25
+ triggerCartItemAdded: mockTriggerCartItemAdded,
26
+ }));
27
+ mockNuxtImport("useTrackEvent", () => () => ({
28
+ trackUpsellAdd: mockTrackUpsellAdd,
29
+ }));
30
+
31
+ const tiramisu = {
32
+ id: "tiramisu",
33
+ productNumber: "D1",
34
+ translated: { name: "Tiramisu" },
35
+ } as unknown as Schemas["Product"];
36
+
37
+ describe("useCartUpsell", () => {
38
+ beforeEach(() => {
39
+ vi.clearAllMocks();
40
+ });
41
+
42
+ it("loads the flagged products without variant parents", async () => {
43
+ mockInvoke.mockResolvedValue({ data: { elements: [tiramisu] } });
44
+
45
+ const result = await useCartUpsell().loadUpsellProducts();
46
+
47
+ expect(result).toEqual([tiramisu]);
48
+ expect(mockInvoke).toHaveBeenCalledWith(
49
+ "readProduct post /product",
50
+ expect.objectContaining({
51
+ headers: { "sw-inheritance": "true" },
52
+ body: expect.objectContaining({
53
+ limit: 6,
54
+ filter: [
55
+ {
56
+ type: "equals",
57
+ field: "customFields.shopbite_cart_upsell",
58
+ value: true,
59
+ },
60
+ // Variants have no child count (null), main products 0.
61
+ {
62
+ type: "multi",
63
+ operator: "or",
64
+ queries: [
65
+ { type: "equals", field: "childCount", value: 0 },
66
+ { type: "equals", field: "childCount", value: null },
67
+ ],
68
+ },
69
+ ],
70
+ }),
71
+ }),
72
+ );
73
+ });
74
+
75
+ it("returns an empty list when the request fails", async () => {
76
+ mockInvoke.mockRejectedValue(new Error("Network error"));
77
+ const consoleSpy = vi.spyOn(console, "error").mockImplementation(() => {});
78
+
79
+ expect(await useCartUpsell().loadUpsellProducts()).toEqual([]);
80
+ expect(consoleSpy).toHaveBeenCalled();
81
+ consoleSpy.mockRestore();
82
+ });
83
+
84
+ it("adds the product with quantity 1 and reports the add", async () => {
85
+ mockAddLineItems.mockResolvedValue({ id: "cart" });
86
+
87
+ await useCartUpsell().addUpsellProduct(tiramisu);
88
+
89
+ expect(mockAddLineItems).toHaveBeenCalledWith([
90
+ { id: "tiramisu", quantity: 1, type: "product" },
91
+ ]);
92
+ expect(mockTriggerCartItemAdded).toHaveBeenCalledWith(tiramisu, 1);
93
+ expect(mockTrackUpsellAdd).toHaveBeenCalledWith(tiramisu, 1);
94
+ });
95
+
96
+ it("reports nothing when the add failed", async () => {
97
+ // useCartMutations shows the error toast itself and resolves undefined.
98
+ mockAddLineItems.mockResolvedValue(undefined);
99
+
100
+ await useCartUpsell().addUpsellProduct(tiramisu);
101
+
102
+ expect(mockTriggerCartItemAdded).not.toHaveBeenCalled();
103
+ expect(mockTrackUpsellAdd).not.toHaveBeenCalled();
104
+ });
105
+
106
+ it("marks the product as pending while the add is queued", async () => {
107
+ let resolveAdd: (cart: unknown) => void = () => {};
108
+ mockAddLineItems.mockReturnValue(
109
+ new Promise((resolve) => {
110
+ resolveAdd = resolve;
111
+ }),
112
+ );
113
+ const { addUpsellProduct, isAdding } = useCartUpsell();
114
+
115
+ const adding = addUpsellProduct(tiramisu);
116
+ expect(isAdding("tiramisu")).toBe(true);
117
+
118
+ // A second click while queued does not add the product twice.
119
+ await addUpsellProduct(tiramisu);
120
+ expect(mockAddLineItems).toHaveBeenCalledTimes(1);
121
+
122
+ resolveAdd({ id: "cart" });
123
+ await adding;
124
+ expect(isAdding("tiramisu")).toBe(false);
125
+ });
126
+ });
@@ -0,0 +1,120 @@
1
+ import { describe, it, expect, vi, beforeEach } from "vitest";
2
+ import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
3
+ import { defineComponent, h, nextTick, ref, type Ref } from "vue";
4
+
5
+ // Refs are created per test in beforeEach; the mocks read them lazily.
6
+ const { state } = vi.hoisted(() => ({
7
+ state: {
8
+ refreshBusinessHours: vi.fn(),
9
+ refreshHolidays: vi.fn(),
10
+ } as {
11
+ businessHours: Ref<unknown>;
12
+ businessHoursStatus: Ref<string>;
13
+ holidays: Ref<unknown>;
14
+ holidaysStatus: Ref<string>;
15
+ refreshBusinessHours: ReturnType<typeof vi.fn>;
16
+ refreshHolidays: ReturnType<typeof vi.fn>;
17
+ },
18
+ }));
19
+
20
+ mockNuxtImport("useBusinessHours", () => () => ({
21
+ businessHours: state.businessHours,
22
+ status: state.businessHoursStatus,
23
+ refresh: state.refreshBusinessHours,
24
+ }));
25
+
26
+ mockNuxtImport("useHolidays", () => () => ({
27
+ holidays: state.holidays,
28
+ status: state.holidaysStatus,
29
+ refresh: state.refreshHolidays,
30
+ }));
31
+
32
+ /** Also returns `hasFailed` as the first render (server, hydration) saw it. */
33
+ async function mountComposable() {
34
+ let result!: ReturnType<typeof useOpeningHoursData>;
35
+ let hasFailedOnRender!: boolean;
36
+ await mountSuspended(
37
+ defineComponent({
38
+ setup() {
39
+ result = useOpeningHoursData();
40
+ hasFailedOnRender = result.hasFailed.value;
41
+ return () => h("div");
42
+ },
43
+ }),
44
+ );
45
+ return { ...result, hasFailedOnRender };
46
+ }
47
+
48
+ describe("useOpeningHoursData", () => {
49
+ beforeEach(() => {
50
+ vi.clearAllMocks();
51
+ state.businessHours = ref(null);
52
+ state.businessHoursStatus = ref("idle");
53
+ state.holidays = ref(null);
54
+ state.holidaysStatus = ref("idle");
55
+ });
56
+
57
+ it("is loading until business hours and holidays are there", async () => {
58
+ state.businessHours.value = [];
59
+ state.businessHoursStatus.value = "success";
60
+ state.holidaysStatus.value = "pending";
61
+
62
+ const { isLoaded, isLoading, hasFailed } = await mountComposable();
63
+
64
+ expect(isLoaded.value).toBe(false);
65
+ expect(isLoading.value).toBe(true);
66
+ expect(hasFailed.value).toBe(false);
67
+
68
+ state.holidays.value = [];
69
+ state.holidaysStatus.value = "success";
70
+ await nextTick();
71
+
72
+ expect(isLoaded.value).toBe(true);
73
+ expect(isLoading.value).toBe(false);
74
+ });
75
+
76
+ it("has failed when a request failed and none is running", async () => {
77
+ state.businessHoursStatus.value = "error";
78
+ state.holidaysStatus.value = "pending";
79
+
80
+ const { isLoading, hasFailed } = await mountComposable();
81
+
82
+ expect(hasFailed.value).toBe(false);
83
+
84
+ state.holidays.value = [];
85
+ state.holidaysStatus.value = "success";
86
+ await nextTick();
87
+
88
+ expect(hasFailed.value).toBe(true);
89
+ expect(isLoading.value).toBe(false);
90
+ });
91
+
92
+ it("does not report a failure before mounting (hydration)", async () => {
93
+ state.businessHoursStatus.value = "error";
94
+ state.holidaysStatus.value = "error";
95
+
96
+ const { hasFailed, hasFailedOnRender } = await mountComposable();
97
+
98
+ expect(hasFailedOnRender).toBe(false);
99
+ expect(hasFailed.value).toBe(true);
100
+ });
101
+
102
+ it("loads again when retrying", async () => {
103
+ state.businessHours.value = [];
104
+ state.businessHoursStatus.value = "success";
105
+ state.holidaysStatus.value = "error";
106
+
107
+ const { hasFailed, isLoading, retry } = await mountComposable();
108
+ expect(hasFailed.value).toBe(true);
109
+
110
+ state.refreshHolidays.mockImplementation(async () => {
111
+ state.holidaysStatus.value = "pending";
112
+ });
113
+ await retry();
114
+
115
+ expect(state.refreshHolidays).toHaveBeenCalledTimes(1);
116
+ expect(state.refreshBusinessHours).not.toHaveBeenCalled();
117
+ expect(hasFailed.value).toBe(false);
118
+ expect(isLoading.value).toBe(true);
119
+ });
120
+ });
@@ -96,6 +96,21 @@ describe("useTrackEvent", () => {
96
96
  ]);
97
97
  });
98
98
 
99
+ it("tracks an add from the cart suggestions as its own action", () => {
100
+ setMatomoConfig("https://analytics.example.com/", 3);
101
+
102
+ useTrackEvent().trackUpsellAdd(
103
+ {
104
+ productNumber: "D1",
105
+ } as Parameters<ReturnType<typeof useTrackEvent>["trackUpsellAdd"]>[0],
106
+ 1,
107
+ );
108
+
109
+ expect(matomoWindow._paq).toEqual([
110
+ ["trackEvent", "Cart", "UpsellAdd", "D1", 1],
111
+ ]);
112
+ });
113
+
99
114
  it("appends to an existing _paq queue", () => {
100
115
  setMatomoConfig("https://analytics.example.com/", 3);
101
116
  matomoWindow._paq = [["setSiteId", "3"]];
@@ -1,5 +1,9 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { groupOpeningHours, toTelHref } from "../../app/utils/openingHours";
2
+ import {
3
+ formatTodayHours,
4
+ groupOpeningHours,
5
+ toTelHref,
6
+ } from "../../app/utils/openingHours";
3
7
 
4
8
  const lunch = (dayOfWeek: number) => ({
5
9
  dayOfWeek,
@@ -57,3 +61,30 @@ describe("toTelHref", () => {
57
61
  expect(toTelHref("06104 / 71-427")).toBe("tel:0610471427");
58
62
  });
59
63
  });
64
+
65
+ describe("formatTodayHours", () => {
66
+ const hours = [
67
+ { dayOfWeek: 1, openingTime: "17:30:00", closingTime: "23:00:00" },
68
+ { dayOfWeek: 1, openingTime: "11:30:00", closingTime: "14:30:00" },
69
+ { dayOfWeek: 7, openingTime: "11:30:00", closingTime: "23:00:00" },
70
+ ];
71
+
72
+ it("joins the intervals of the weekday in order", () => {
73
+ // 2026-09-14 is a Monday
74
+ expect(formatTodayHours(hours, new Date(2026, 8, 14, 10))).toBe(
75
+ "Heute 11:30–14:30 und 17:30–23:00",
76
+ );
77
+ });
78
+
79
+ it("maps Sunday to day 7", () => {
80
+ expect(formatTodayHours(hours, new Date(2026, 8, 13, 10))).toBe(
81
+ "Heute 11:30–23:00",
82
+ );
83
+ });
84
+
85
+ it("names a closed day", () => {
86
+ expect(formatTodayHours(hours, new Date(2026, 8, 15, 10))).toBe(
87
+ "Heute Ruhetag",
88
+ );
89
+ });
90
+ });
@@ -0,0 +1,72 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import type { Schemas } from "#shopware";
3
+ import {
4
+ getMainIngredients,
5
+ lineItemHoldsProduct,
6
+ productIsAvailable,
7
+ } from "../../app/utils/product";
8
+
9
+ const product = (overrides: Partial<Schemas["Product"]> = {}) =>
10
+ ({ id: "p1", ...overrides }) as Schemas["Product"];
11
+
12
+ const group = (name: string, options: string[]) =>
13
+ ({
14
+ translated: { name },
15
+ options: options.map((option, i) => ({
16
+ id: `o${i}`,
17
+ translated: { name: option },
18
+ })),
19
+ }) as unknown as Schemas["PropertyGroup"];
20
+
21
+ describe("productIsAvailable", () => {
22
+ it("treats a missing flag as available", () => {
23
+ expect(productIsAvailable(product())).toBe(true);
24
+ expect(productIsAvailable(product({ available: true }))).toBe(true);
25
+ });
26
+
27
+ it("is false when the flag is false", () => {
28
+ expect(productIsAvailable(product({ available: false }))).toBe(false);
29
+ });
30
+ });
31
+
32
+ describe("lineItemHoldsProduct", () => {
33
+ const lineItem = (overrides: Partial<Schemas["LineItem"]>) =>
34
+ ({ id: "li", type: "product", ...overrides }) as Schemas["LineItem"];
35
+
36
+ it("matches a plain line item of the product", () => {
37
+ expect(lineItemHoldsProduct(lineItem({ referencedId: "p1" }), "p1")).toBe(
38
+ true,
39
+ );
40
+ expect(lineItemHoldsProduct(lineItem({ referencedId: "p2" }), "p1")).toBe(
41
+ false,
42
+ );
43
+ });
44
+
45
+ it("matches a container item carrying the product", () => {
46
+ const container = {
47
+ id: "li",
48
+ type: "container",
49
+ children: [{ id: "child", type: "product", referencedId: "p1" }],
50
+ } as unknown as Schemas["LineItem"];
51
+ expect(lineItemHoldsProduct(container, "p1")).toBe(true);
52
+ expect(lineItemHoldsProduct(container, "p2")).toBe(false);
53
+ });
54
+ });
55
+
56
+ describe("getMainIngredients", () => {
57
+ it("returns the options of the Hauptzutaten group", () => {
58
+ const options = getMainIngredients([
59
+ group("Vegetarisch", ["Ja"]),
60
+ group("Hauptzutaten", ["Tomatensoße", "Mozzarella"]),
61
+ ]);
62
+ expect(options.map((o) => o.translated.name)).toEqual([
63
+ "Tomatensoße",
64
+ "Mozzarella",
65
+ ]);
66
+ });
67
+
68
+ it("is empty without the group", () => {
69
+ expect(getMainIngredients(undefined)).toEqual([]);
70
+ expect(getMainIngredients([group("Küche", ["Italienisch"])])).toEqual([]);
71
+ });
72
+ });
@@ -0,0 +1,58 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
+ import { withRetries } from "../../app/utils/retry";
3
+
4
+ describe("withRetries", () => {
5
+ beforeEach(() => {
6
+ vi.useFakeTimers();
7
+ });
8
+
9
+ afterEach(() => {
10
+ vi.useRealTimers();
11
+ });
12
+
13
+ it("returns the first successful result without waiting", async () => {
14
+ const request = vi.fn().mockResolvedValue("ok");
15
+
16
+ await expect(withRetries(request, [1000, 3000])).resolves.toBe("ok");
17
+ expect(request).toHaveBeenCalledTimes(1);
18
+ });
19
+
20
+ it("tries again after each delay until a request succeeds", async () => {
21
+ const request = vi
22
+ .fn()
23
+ .mockRejectedValueOnce(new Error("first"))
24
+ .mockRejectedValueOnce(new Error("second"))
25
+ .mockResolvedValue("ok");
26
+
27
+ const result = withRetries(request, [1000, 3000]);
28
+
29
+ await vi.advanceTimersByTimeAsync(999);
30
+ expect(request).toHaveBeenCalledTimes(1);
31
+ await vi.advanceTimersByTimeAsync(1);
32
+ expect(request).toHaveBeenCalledTimes(2);
33
+ await vi.advanceTimersByTimeAsync(3000);
34
+ await expect(result).resolves.toBe("ok");
35
+ expect(request).toHaveBeenCalledTimes(3);
36
+ });
37
+
38
+ it("throws the error of the last attempt", async () => {
39
+ const request = vi
40
+ .fn()
41
+ .mockRejectedValueOnce(new Error("first"))
42
+ .mockRejectedValueOnce(new Error("last"));
43
+
44
+ const result = withRetries(request, [1000]);
45
+ const assertion = expect(result).rejects.toThrow("last");
46
+
47
+ await vi.advanceTimersByTimeAsync(1000);
48
+ await assertion;
49
+ expect(request).toHaveBeenCalledTimes(2);
50
+ });
51
+
52
+ it("does not retry without delays", async () => {
53
+ const request = vi.fn().mockRejectedValue(new Error("down"));
54
+
55
+ await expect(withRetries(request, [])).rejects.toThrow("down");
56
+ expect(request).toHaveBeenCalledTimes(1);
57
+ });
58
+ });
@@ -103,7 +103,8 @@ describe("useCategorySeo", () => {
103
103
  "Pizza & Pasta | My Store – Online bestellen",
104
104
  );
105
105
  expect(result.canonicalUrl.value).toBe("https://example.com/c/pasta/");
106
- expect(result.robots.value).toBe("index,follow");
106
+ // Active categories leave the robots rule to @nuxtjs/robots
107
+ expect(result.robots.value).toBeUndefined();
107
108
 
108
109
  // useSeoMeta should be called once with expected keys
109
110
  expect(
@@ -0,0 +1,33 @@
1
+ import { defineConfig } from "@playwright/test";
2
+ export default defineConfig({
3
+ testDir: ".",
4
+ outputDir: "./results",
5
+ snapshotPathTemplate: "{testDir}/__snapshots__/{projectName}/{arg}{ext}",
6
+ timeout: 90_000,
7
+ workers: 1,
8
+ retries: 0,
9
+ reporter: [["list"]],
10
+ use: {
11
+ baseURL: process.env.BASE_URL || "https://localhost:3443",
12
+ ignoreHTTPSErrors: true,
13
+ deviceScaleFactor: 1,
14
+ },
15
+ expect: {
16
+ toHaveScreenshot: {
17
+ maxDiffPixels: 0,
18
+ threshold: 0.01,
19
+ animations: "disabled",
20
+ },
21
+ },
22
+ projects: [
23
+ {
24
+ name: "mobile",
25
+ use: {
26
+ viewport: { width: 390, height: 844 },
27
+ isMobile: true,
28
+ hasTouch: true,
29
+ },
30
+ },
31
+ { name: "desktop", use: { viewport: { width: 1280, height: 800 } } },
32
+ ],
33
+ });