@shopbite-de/storefront 1.24.0 → 1.25.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 (77) hide show
  1. package/.env.example +3 -0
  2. package/CLAUDE.md +9 -2
  3. package/app/app.config.ts +3 -2
  4. package/app/app.vue +4 -1
  5. package/app/assets/css/main.css +16 -0
  6. package/app/components/AddToWishlist.vue +13 -6
  7. package/app/components/Cart/Bar.vue +102 -0
  8. package/app/components/Cart/QuickView.vue +4 -0
  9. package/app/components/Cart/Upsell.vue +106 -0
  10. package/app/components/Category/Listing.vue +11 -3
  11. package/app/components/Checkout/Summary.vue +5 -1
  12. package/app/components/DemoBanner.vue +13 -0
  13. package/app/components/Feature/Card.vue +121 -0
  14. package/app/components/Features.vue +14 -9
  15. package/app/components/Footer/Contact.vue +5 -1
  16. package/app/components/Header/Right.vue +44 -15
  17. package/app/components/Hero.vue +126 -36
  18. package/app/components/Product/Card.vue +102 -50
  19. package/app/components/Product/CardCompact.vue +72 -0
  20. package/app/components/Product/CardDietBadges.vue +38 -31
  21. package/app/components/Product/CardIngredients.vue +35 -0
  22. package/app/components/Product/CardSkeleton.vue +10 -18
  23. package/app/components/Product/Category.vue +9 -2
  24. package/app/components/Product/Configurator.vue +11 -7
  25. package/app/components/Product/CrossSelling.vue +45 -34
  26. package/app/components/Product/DeselectIngredient.vue +37 -31
  27. package/app/components/Product/Detail.vue +73 -13
  28. package/app/components/Product/QuickView.vue +77 -0
  29. package/app/components/Topseller.vue +44 -34
  30. package/app/composables/useAddToCart.ts +3 -30
  31. package/app/composables/useCartQuickView.ts +19 -0
  32. package/app/composables/useCartUpsell.ts +100 -0
  33. package/app/composables/useCategorySeo.ts +5 -4
  34. package/app/composables/useProductCartQuantity.ts +15 -0
  35. package/app/composables/useProductCrossSelling.ts +1 -0
  36. package/app/composables/useProductDetail.ts +15 -1
  37. package/app/composables/useProductEvents.ts +30 -0
  38. package/app/composables/useProductQuickView.ts +65 -0
  39. package/app/composables/useTopSellers.ts +22 -0
  40. package/app/composables/useTrackEvent.ts +7 -0
  41. package/app/pages/index.vue +3 -1
  42. package/app/pages/suche.vue +18 -5
  43. package/app/types/Association.d.ts +1 -0
  44. package/app/utils/openingHours.ts +31 -8
  45. package/app/utils/product.ts +31 -0
  46. package/content/index.yml +16 -11
  47. package/content.config.ts +13 -0
  48. package/docs/notes/2026-09-12-issue-319-stylesheet-cost.md +154 -0
  49. package/docs/notes/2026-09-12-issue-325-product-card.md +100 -0
  50. package/docs/notes/2026-09-12-issue-327-home-hero.md +64 -0
  51. package/docs/notes/2026-09-13-demo-banner.md +32 -0
  52. package/docs/notes/2026-09-13-issue-332-home-info-cards.md +46 -0
  53. package/docs/notes/2026-09-13-quick-view-flicker.md +65 -0
  54. package/docs/notes/2026-09-14-cart-upsell.md +105 -0
  55. package/docs/notes/2026-09-14-demo-noindex.md +57 -0
  56. package/nuxt.config.ts +24 -0
  57. package/package.json +1 -1
  58. package/scripts/perf/first-render.mjs +30 -0
  59. package/scripts/perf/h2-proxy.cjs +49 -0
  60. package/scripts/perf/lighthouse.sh +22 -0
  61. package/scripts/perf/quick-view-layout.mjs +126 -0
  62. package/server/api/listing/[categoryId].get.ts +2 -0
  63. package/server/api/search.get.ts +2 -0
  64. package/test/e2e/simple-checkout-as-recurring-customer.test.ts +13 -17
  65. package/test/nuxt/CartBar.test.ts +110 -0
  66. package/test/nuxt/CartUpsell.test.ts +125 -0
  67. package/test/nuxt/DemoBanner.test.ts +12 -0
  68. package/test/nuxt/useAddToCart.test.ts +6 -19
  69. package/test/nuxt/useCartUpsell.test.ts +126 -0
  70. package/test/nuxt/useTrackEvent.test.ts +15 -0
  71. package/test/unit/openingHours.spec.ts +32 -1
  72. package/test/unit/product.spec.ts +72 -0
  73. package/test/unit/useCategorySeo.spec.ts +2 -1
  74. package/test/visual/playwright.config.ts +33 -0
  75. package/test/visual/visual.spec.ts +87 -0
  76. package/app/components/Product/CardDescription.vue +0 -27
  77. package/app/components/Product/CardFooter.vue +0 -61
@@ -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
+ });
@@ -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
+ });
@@ -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
+ });
@@ -0,0 +1,87 @@
1
+ // Screenshot comparison of the pages the stylesheet work touches (#319).
2
+ // Run against the production build behind scripts/perf/h2-proxy.cjs:
3
+ // pnpm playwright test --config test/visual/playwright.config.ts --update-snapshots # baseline
4
+ // pnpm playwright test --config test/visual/playwright.config.ts # compare
5
+ import { test, expect, type Page } from "@playwright/test";
6
+
7
+ const modes = ["light", "dark"] as const;
8
+
9
+ async function settle(page: Page) {
10
+ // hydrate scroll-based sections and reveal AnimatedSection blocks
11
+ const h = await page.evaluate(() => document.body.scrollHeight);
12
+ for (let y = 0; y < h + 800; y += 500) {
13
+ await page.evaluate((y) => window.scrollTo(0, y), y);
14
+ await page.waitForTimeout(80);
15
+ }
16
+ await page.evaluate(() => window.scrollTo(0, 0));
17
+ await page.waitForTimeout(400);
18
+ }
19
+
20
+ async function open(page: Page, path: string, mode: string) {
21
+ await page.addInitScript((m) => {
22
+ try {
23
+ localStorage.setItem("nuxt-color-mode", m);
24
+ } catch {
25
+ // storage can be unavailable in the sandboxed init script
26
+ }
27
+ }, mode);
28
+ await page.emulateMedia({ reducedMotion: "reduce" });
29
+ await page.goto(path, { waitUntil: "networkidle" });
30
+ await page.addStyleTag({
31
+ content:
32
+ "*,*::before,*::after{animation:none!important;transition:none!important;caret-color:transparent!important}",
33
+ });
34
+ await settle(page);
35
+ }
36
+
37
+ for (const mode of modes) {
38
+ test.describe(mode, () => {
39
+ test("home", async ({ page }) => {
40
+ await open(page, "/", mode);
41
+ await expect(page).toHaveScreenshot(`home-${mode}.png`, {
42
+ fullPage: true,
43
+ });
44
+ await expect(page.locator("footer").first()).toHaveScreenshot(
45
+ `footer-${mode}.png`,
46
+ );
47
+ });
48
+
49
+ test("category", async ({ page }) => {
50
+ await open(page, "/c/Pizza/", mode);
51
+ await expect(page).toHaveScreenshot(`category-${mode}.png`, {
52
+ fullPage: true,
53
+ });
54
+ });
55
+
56
+ test("cart drawer and checkout", async ({ page }) => {
57
+ await open(page, "/c/Pizza/", mode);
58
+ const card = page.locator('[id^="product-card-"]').first();
59
+ await card.scrollIntoViewIfNeeded();
60
+ await card.locator("button .i-lucide\\:shopping-cart").click();
61
+ const add = page.getByRole("button", { name: "In den Warenkorb" });
62
+ await expect(add).toBeVisible({ timeout: 10000 });
63
+ await page.waitForTimeout(300);
64
+ await expect(page).toHaveScreenshot(`card-options-${mode}.png`);
65
+ await add.click();
66
+ await expect(add).not.toBeVisible({ timeout: 10000 });
67
+ await page
68
+ .locator("button .i-lucide\\:shopping-bag")
69
+ .locator("..")
70
+ .first()
71
+ .click();
72
+ const drawer = page.locator('[data-vaul-drawer][data-state="open"]');
73
+ await expect(drawer).toBeVisible({ timeout: 10000 });
74
+ await page.waitForTimeout(800);
75
+ await expect(page).toHaveScreenshot(`cart-drawer-${mode}.png`);
76
+ await page.goto("/bestellung/warenkorb", { waitUntil: "networkidle" });
77
+ await page.addStyleTag({
78
+ content:
79
+ "*,*::before,*::after{animation:none!important;transition:none!important;caret-color:transparent!important}",
80
+ });
81
+ await settle(page);
82
+ await expect(page).toHaveScreenshot(`checkout-${mode}.png`, {
83
+ fullPage: true,
84
+ });
85
+ });
86
+ });
87
+ }
@@ -1,27 +0,0 @@
1
- <script setup lang="ts">
2
- import type { Schemas } from "#shopware";
3
-
4
- const props = defineProps<{
5
- description: string | null | undefined;
6
- sortedProperties: Schemas["PropertyGroup"][] | undefined;
7
- }>();
8
-
9
- const mainIngredients = computed<Schemas["PropertyGroupOption"][]>(() => {
10
- const group = props.sortedProperties?.find(
11
- (propertyGroup) => propertyGroup.translated.name === "Hauptzutaten",
12
- );
13
- return group?.options ?? [];
14
- });
15
- </script>
16
-
17
- <template>
18
- <div class="flex flex-col gap-2">
19
- <div>{{ description }}</div>
20
- <div
21
- v-if="mainIngredients.length > 0"
22
- class="font-extralight text-sm text-pretty"
23
- >
24
- {{ mainIngredients.map((i) => i.translated.name).join(", ") }}
25
- </div>
26
- </div>
27
- </template>
@@ -1,61 +0,0 @@
1
- <script setup lang="ts">
2
- import type { Schemas } from "#shopware";
3
-
4
- defineProps<{
5
- price: number;
6
- product: Schemas["Product"];
7
- withFavoriteButton: boolean;
8
- withAddToCartButton: boolean;
9
- }>();
10
-
11
- const emit = defineEmits<{
12
- variantSelected: [variant: Schemas["Product"]];
13
- }>();
14
-
15
- const { isCheckoutEnabled } = useShopBiteConfig();
16
-
17
- const { getFormattedPrice } = useCommercePrice();
18
-
19
- const openDetails = ref(false);
20
- // The collapsible is created on the first toggle: mounting one per card
21
- // (with its height measurement) was a large part of the listing's
22
- // hydration cost (#314). Never rendered on the server.
23
- const detailsMounted = ref(false);
24
-
25
- async function toggleDetails() {
26
- if (!detailsMounted.value) {
27
- detailsMounted.value = true;
28
- await nextTick();
29
- }
30
- openDetails.value = !openDetails.value;
31
- }
32
- </script>
33
-
34
- <template>
35
- <div class="flex flex-row justify-between content-center w-full">
36
- <p>{{ getFormattedPrice(price) }}</p>
37
- <div class="flex flex-row gap-2">
38
- <AddToWishlist v-if="withFavoriteButton" :product="product" />
39
- <UButton
40
- v-if="withAddToCartButton && isCheckoutEnabled"
41
- icon="i-lucide-shopping-cart"
42
- variant="subtle"
43
- aria-label="Öffnet Produkt-Optionen"
44
- @click="toggleDetails"
45
- />
46
- </div>
47
- </div>
48
- <UCollapsible
49
- v-if="detailsMounted"
50
- v-model:open="openDetails"
51
- class="flex flex-col gap-2"
52
- >
53
- <template #content>
54
- <LazyProductDetail
55
- :product-id="product.id"
56
- @product-added="toggleDetails"
57
- @variant-selected="emit('variantSelected', $event)"
58
- />
59
- </template>
60
- </UCollapsible>
61
- </template>