@shopbite-de/storefront 1.29.0 → 1.31.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 (60) hide show
  1. package/.env.example +9 -0
  2. package/CLAUDE.md +5 -1
  3. package/app/components/Category/Listing.vue +1 -0
  4. package/app/components/Home/Faq.vue +58 -0
  5. package/app/components/Home/Highlights.vue +1 -0
  6. package/app/components/Product/Card.vue +46 -10
  7. package/app/components/Product/CardDietBadges.vue +7 -13
  8. package/app/components/Product/CrossSelling.vue +18 -2
  9. package/app/components/Product/DeselectIngredient.vue +10 -3
  10. package/app/components/Product/Detail.vue +33 -2
  11. package/app/components/Product/QuickView.vue +20 -1
  12. package/app/composables/useMenuSectionSchema.ts +21 -8
  13. package/app/composables/useProductCrossSelling.ts +1 -0
  14. package/app/composables/useProductQuickView.ts +151 -9
  15. package/app/composables/useRestaurantSchema.ts +40 -3
  16. package/app/composables/useSeoUrlRoute.ts +50 -5
  17. package/app/composables/useShareLink.ts +61 -0
  18. package/app/composables/useTopSellers.ts +4 -1
  19. package/app/composables/useTrackEvent.ts +19 -0
  20. package/app/pages/[...all].vue +38 -10
  21. package/app/pages/index.vue +7 -0
  22. package/app/types/Association.d.ts +2 -0
  23. package/app/utils/product.ts +28 -0
  24. package/app/utils/productUrl.ts +87 -0
  25. package/app/utils/schema.ts +82 -1
  26. package/app/utils/seo.ts +13 -0
  27. package/app/utils/seoPath.ts +13 -2
  28. package/content/index.yml +18 -0
  29. package/content.config.ts +13 -0
  30. package/docs/notes/2026-10-05-issue-289-product-deep-links.md +28 -0
  31. package/docs/notes/2026-10-05-issue-400-menu-item-ingredients-diet.md +18 -0
  32. package/docs/notes/2026-10-05-issue-401-restaurant-schema-ordering.md +21 -0
  33. package/docs/notes/2026-10-05-issue-402-llms-txt.md +17 -0
  34. package/docs/notes/2026-10-05-issue-403-ai-crawlers.md +15 -0
  35. package/docs/notes/2026-10-05-issue-404-faq.md +21 -0
  36. package/docs/notes/2026-10-05-issue-411-quick-view-share.md +22 -0
  37. package/docs/notes/2026-10-06-old-seo-url-redirect.md +30 -0
  38. package/nuxt.config.ts +20 -0
  39. package/package.json +3 -3
  40. package/server/api/listing/[categoryId].get.ts +3 -0
  41. package/server/api/product/[productId]/cross-selling.get.ts +2 -1
  42. package/server/plugins/ai-crawlers.ts +27 -0
  43. package/server/routes/llms.txt.ts +213 -0
  44. package/server/utils/aiCrawlers.ts +79 -0
  45. package/server/utils/llmsTxt.ts +207 -0
  46. package/test/nuxt/HomeFaq.test.ts +34 -0
  47. package/test/nuxt/ProductCrossSelling.test.ts +20 -0
  48. package/test/nuxt/ProductDeselectIngredient.test.ts +34 -0
  49. package/test/nuxt/useSeoUrlRoute.test.ts +88 -5
  50. package/test/nuxt/useShareLink.test.ts +103 -0
  51. package/test/nuxt/useTrackEvent.test.ts +16 -0
  52. package/test/unit/aiCrawlers.spec.ts +48 -0
  53. package/test/unit/llmsTxt.spec.ts +149 -0
  54. package/test/unit/product.spec.ts +20 -0
  55. package/test/unit/productUrl.spec.ts +90 -0
  56. package/test/unit/schema.spec.ts +123 -0
  57. package/test/unit/seo.spec.ts +13 -0
  58. package/test/unit/seoPath.spec.ts +45 -0
  59. package/app/pages/c/[...all].vue +0 -20
  60. package/app/pages/speisekarte/[...all].vue +0 -20
@@ -3,16 +3,23 @@ import { mockNuxtImport } from "@nuxt/test-utils/runtime";
3
3
  import { ref } from "vue";
4
4
  import { useSeoUrlRoute } from "~/composables/useSeoUrlRoute";
5
5
 
6
- const { mockResolvePath, mockNavigateTo, routeState } = vi.hoisted(() => ({
7
- mockResolvePath: vi.fn(),
8
- mockNavigateTo: vi.fn(),
9
- routeState: { path: "/c/Pizza/", query: {} as Record<string, string> },
10
- }));
6
+ const { mockResolvePath, mockInvoke, mockNavigateTo, routeState } = vi.hoisted(
7
+ () => ({
8
+ mockResolvePath: vi.fn(),
9
+ mockInvoke: vi.fn(),
10
+ mockNavigateTo: vi.fn(),
11
+ routeState: { path: "/c/Pizza/", query: {} as Record<string, string> },
12
+ }),
13
+ );
11
14
 
12
15
  mockNuxtImport("useNavigationSearch", () => () => ({
13
16
  resolvePath: mockResolvePath,
14
17
  }));
15
18
 
19
+ mockNuxtImport("useShopwareContext", () => () => ({
20
+ apiClient: { invoke: mockInvoke },
21
+ }));
22
+
16
23
  mockNuxtImport("useRoute", () => () => routeState);
17
24
 
18
25
  mockNuxtImport("navigateTo", () => mockNavigateTo);
@@ -48,6 +55,8 @@ describe("useSeoUrlRoute", () => {
48
55
  mockResolvePath.mockImplementation(async (path: string) =>
49
56
  path.toLowerCase() === "/c/pizza/" ? pizza : null,
50
57
  );
58
+ // no old SEO URLs unless a test says so
59
+ mockInvoke.mockResolvedValue({ data: { elements: [] } });
51
60
  });
52
61
 
53
62
  it("resolves the route and does not redirect on the SEO URL", async () => {
@@ -71,6 +80,56 @@ describe("useSeoUrlRoute", () => {
71
80
  );
72
81
  });
73
82
 
83
+ it("redirects permanently from an old SEO URL to the current one", async () => {
84
+ routeState.path = "/c/Pizzen/";
85
+ const oldPizza = {
86
+ ...pizza,
87
+ seoPathInfo: "c/Pizzen/",
88
+ languageId: "lang-de",
89
+ isCanonical: null,
90
+ };
91
+ mockInvoke
92
+ .mockResolvedValueOnce({ data: { elements: [oldPizza] } })
93
+ .mockResolvedValueOnce({ data: { elements: [pizza] } });
94
+
95
+ const { seoUrl } = await useSeoUrlRoute();
96
+
97
+ expect(mockInvoke).toHaveBeenNthCalledWith(1, "readSeoUrl post /seo-url", {
98
+ body: {
99
+ limit: 1,
100
+ filter: [
101
+ { type: "equals", field: "seoPathInfo", value: "c/Pizzen/" },
102
+ {
103
+ type: "equals",
104
+ field: "routeName",
105
+ value: "frontend.navigation.page",
106
+ },
107
+ { type: "equals", field: "isCanonical", value: null },
108
+ ],
109
+ },
110
+ });
111
+ expect(mockInvoke).toHaveBeenNthCalledWith(2, "readSeoUrl post /seo-url", {
112
+ body: {
113
+ limit: 1,
114
+ filter: [
115
+ { type: "equals", field: "foreignKey", value: "cat-pizza" },
116
+ {
117
+ type: "equals",
118
+ field: "routeName",
119
+ value: "frontend.navigation.page",
120
+ },
121
+ { type: "equals", field: "languageId", value: "lang-de" },
122
+ { type: "equals", field: "isCanonical", value: true },
123
+ ],
124
+ },
125
+ });
126
+ expect(seoUrl.value).toEqual(pizza);
127
+ expect(mockNavigateTo).toHaveBeenCalledWith(
128
+ { path: "/c/Pizza/", query: {} },
129
+ { redirectCode: 301, replace: true },
130
+ );
131
+ });
132
+
74
133
  it("throws a 404 when the path cannot be resolved", async () => {
75
134
  routeState.path = "/c/Unbekannt/";
76
135
 
@@ -78,6 +137,30 @@ describe("useSeoUrlRoute", () => {
78
137
  expect(mockNavigateTo).not.toHaveBeenCalled();
79
138
  });
80
139
 
140
+ it("throws a 404 for a product SEO URL (no product pages)", async () => {
141
+ routeState.path = "/Pizza-Margherita/21";
142
+ mockResolvePath.mockResolvedValue({
143
+ seoPathInfo: "Pizza-Margherita/21",
144
+ foreignKey: "p21",
145
+ routeName: "frontend.detail.page",
146
+ });
147
+
148
+ await expect(useSeoUrlRoute()).rejects.toMatchObject({ statusCode: 404 });
149
+ expect(mockNavigateTo).not.toHaveBeenCalled();
150
+ });
151
+
152
+ it("throws a 404 when an old SEO URL has no current one", async () => {
153
+ routeState.path = "/c/Geloescht/";
154
+ mockInvoke
155
+ .mockResolvedValueOnce({
156
+ data: { elements: [{ ...pizza, seoPathInfo: "c/Geloescht/" }] },
157
+ })
158
+ .mockResolvedValue({ data: { elements: [] } });
159
+
160
+ await expect(useSeoUrlRoute()).rejects.toMatchObject({ statusCode: 404 });
161
+ expect(mockNavigateTo).not.toHaveBeenCalled();
162
+ });
163
+
81
164
  it("uses the history state from client-side navigation without a request", async () => {
82
165
  history.replaceState(
83
166
  { routeName: "frontend.navigation.page", foreignKey: "cat-from-link" },
@@ -0,0 +1,103 @@
1
+ import { afterEach, describe, expect, it, vi } from "vitest";
2
+ import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
3
+ import { defineComponent, h } from "vue";
4
+
5
+ const { add, trackShare } = vi.hoisted(() => ({
6
+ add: vi.fn(),
7
+ trackShare: vi.fn(),
8
+ }));
9
+ mockNuxtImport("useToast", () => () => ({ add }));
10
+ mockNuxtImport("useTrackEvent", () => () => ({ trackShare }));
11
+
12
+ const sharedPath = () =>
13
+ window.location.pathname + window.location.search + window.location.hash;
14
+
15
+ async function mountShare() {
16
+ let api!: ReturnType<typeof useShareLink>;
17
+ await mountSuspended(
18
+ defineComponent({
19
+ setup() {
20
+ api = useShareLink();
21
+ return () => h("div");
22
+ },
23
+ }),
24
+ );
25
+ return api;
26
+ }
27
+
28
+ describe("useShareLink", () => {
29
+ afterEach(() => {
30
+ vi.unstubAllGlobals();
31
+ add.mockReset();
32
+ trackShare.mockReset();
33
+ });
34
+
35
+ it("uses the native share sheet when available", async () => {
36
+ const share = vi.fn().mockResolvedValue(undefined);
37
+ vi.stubGlobal("navigator", { ...navigator, share });
38
+
39
+ const api = await mountShare();
40
+ expect(api.canShare.value).toBe(true);
41
+ await api.share({ title: "Pizza", productNumber: "P1" });
42
+
43
+ expect(share).toHaveBeenCalledWith({
44
+ title: "Pizza",
45
+ url: window.location.href,
46
+ });
47
+ expect(add).not.toHaveBeenCalled();
48
+ expect(trackShare).toHaveBeenCalledWith("share", "P1", sharedPath());
49
+ });
50
+
51
+ it("copies the link without share sheet", async () => {
52
+ const writeText = vi.fn().mockResolvedValue(undefined);
53
+ vi.stubGlobal("navigator", {
54
+ ...navigator,
55
+ share: undefined,
56
+ clipboard: { writeText },
57
+ });
58
+
59
+ const api = await mountShare();
60
+ await api.share({ productNumber: "P1" });
61
+
62
+ expect(writeText).toHaveBeenCalledWith(window.location.href);
63
+ expect(add).toHaveBeenCalledWith(
64
+ expect.objectContaining({ title: "Link kopiert" }),
65
+ );
66
+ expect(trackShare).toHaveBeenCalledWith("copy", "P1", sharedPath());
67
+ });
68
+
69
+ it("does not track without product number or when copying fails", async () => {
70
+ const writeText = vi.fn().mockResolvedValue(undefined);
71
+ vi.stubGlobal("navigator", {
72
+ ...navigator,
73
+ share: undefined,
74
+ clipboard: { writeText },
75
+ });
76
+
77
+ const api = await mountShare();
78
+ await api.share();
79
+ writeText.mockRejectedValue(new Error("denied"));
80
+ await api.share({ productNumber: "P1" });
81
+
82
+ expect(trackShare).not.toHaveBeenCalled();
83
+ });
84
+
85
+ it("does nothing when the share sheet is closed", async () => {
86
+ const share = vi
87
+ .fn()
88
+ .mockRejectedValue(new DOMException("closed", "AbortError"));
89
+ const writeText = vi.fn();
90
+ vi.stubGlobal("navigator", {
91
+ ...navigator,
92
+ share,
93
+ clipboard: { writeText },
94
+ });
95
+
96
+ const api = await mountShare();
97
+ await api.share({ productNumber: "P1" });
98
+
99
+ expect(writeText).not.toHaveBeenCalled();
100
+ expect(add).not.toHaveBeenCalled();
101
+ expect(trackShare).not.toHaveBeenCalled();
102
+ });
103
+ });
@@ -111,6 +111,22 @@ describe("useTrackEvent", () => {
111
111
  ]);
112
112
  });
113
113
 
114
+ it("tracks a shared product with the shared path as page URL", () => {
115
+ setMatomoConfig("https://analytics.example.com/", 3);
116
+ const path = "/Speisekarte/Pizza/?produkt=P1&ohne=Zwiebeln&extras=E1";
117
+
118
+ const { trackShare } = useTrackEvent();
119
+ trackShare("share", "P1", path);
120
+ trackShare("copy", "P1", path);
121
+
122
+ expect(matomoWindow._paq).toEqual([
123
+ ["setCustomUrl", path],
124
+ ["trackEvent", "Product", "Share", "P1"],
125
+ ["setCustomUrl", path],
126
+ ["trackEvent", "Product", "CopyLink", "P1"],
127
+ ]);
128
+ });
129
+
114
130
  it("appends to an existing _paq queue", () => {
115
131
  setMatomoConfig("https://analytics.example.com/", 3);
116
132
  matomoWindow._paq = [["setSiteId", "3"]];
@@ -0,0 +1,48 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import {
3
+ AI_SEARCH_USER_AGENTS,
4
+ AI_TRAINING_USER_AGENTS,
5
+ buildAiCrawlerGroups,
6
+ } from "../../server/utils/aiCrawlers";
7
+
8
+ const disallow = ["/merkliste", "/passwort-vergessen"];
9
+
10
+ describe("buildAiCrawlerGroups", () => {
11
+ it("allows both kinds and repeats the disallow rules by default", () => {
12
+ const [search, training] = buildAiCrawlerGroups(
13
+ { search: true, training: true },
14
+ disallow,
15
+ );
16
+
17
+ expect(search).toMatchObject({
18
+ userAgent: AI_SEARCH_USER_AGENTS,
19
+ allow: ["/"],
20
+ disallow,
21
+ });
22
+ expect(training).toMatchObject({
23
+ userAgent: AI_TRAINING_USER_AGENTS,
24
+ allow: ["/"],
25
+ disallow,
26
+ });
27
+ });
28
+
29
+ it("blocks training crawlers only", () => {
30
+ const [search, training] = buildAiCrawlerGroups(
31
+ { search: true, training: false },
32
+ disallow,
33
+ );
34
+
35
+ expect(search).toMatchObject({ allow: ["/"], disallow });
36
+ expect(training).toMatchObject({ allow: [], disallow: ["/"] });
37
+ });
38
+
39
+ it("does not copy a site-wide Disallow: / into an allowed group", () => {
40
+ const [search] = buildAiCrawlerGroups({ search: true, training: true }, [
41
+ "/",
42
+ "",
43
+ "/konto",
44
+ ]);
45
+
46
+ expect(search!.disallow).toEqual(["/konto"]);
47
+ });
48
+ });
@@ -0,0 +1,149 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { buildLlmsTxt } from "../../server/utils/llmsTxt";
3
+
4
+ const now = new Date("2026-10-05T12:00:00Z");
5
+
6
+ describe("buildLlmsTxt", () => {
7
+ it("renders shop, hours, ordering, menu and pages as Markdown", () => {
8
+ const text = buildLlmsTxt({
9
+ name: "Pizzeria La Fattoria",
10
+ description: "Italienisch-deutsche Küche seit 1997.",
11
+ url: "https://www.pizzeria-lafattoria.de",
12
+ cuisine: "Italienische Küche",
13
+ address: {
14
+ street: "Kantstraße 6",
15
+ postalCode: "63179",
16
+ city: "Obertshausen",
17
+ },
18
+ telephone: "+49 6104 71427",
19
+ deliveryAreas: ["63179 Obertshausen", "63165 Lämmerspiel"],
20
+ businessHours: [1, 2, 3, 4, 5].map((dayOfWeek) => ({
21
+ dayOfWeek,
22
+ openingTime: "11:30:00",
23
+ closingTime: "22:00:00",
24
+ })),
25
+ holidays: [
26
+ // ended before `now`: left out
27
+ { start: "2026-07-12T21:00:00Z", end: "2026-08-05T22:00:00Z" },
28
+ { start: "2026-12-24T00:00:00Z", end: "2026-12-26T00:00:00Z" },
29
+ ],
30
+ isCheckoutEnabled: true,
31
+ deliveryTime: 30,
32
+ menuUrl: "https://www.pizzeria-lafattoria.de/speisekarte",
33
+ menu: [
34
+ {
35
+ name: "Pizza",
36
+ url: "https://www.pizzeria-lafattoria.de/c/Pizza/",
37
+ items: [
38
+ {
39
+ name: "Pizza Margherita",
40
+ price: 7,
41
+ fromPrice: true,
42
+ ingredients: ["Tomatensoße", "Mozzarella"],
43
+ diets: ["vegetarian"],
44
+ },
45
+ {
46
+ name: "Pizza Salami",
47
+ price: 8.5,
48
+ url: "https://www.pizzeria-lafattoria.de/c/Pizza/?produkt=22",
49
+ },
50
+ ],
51
+ },
52
+ {
53
+ name: "Nudeln",
54
+ items: [],
55
+ sections: [
56
+ {
57
+ name: "Spaghetti",
58
+ items: [
59
+ {
60
+ name: "Spaghetti Aglio e Olio",
61
+ price: 9,
62
+ diets: ["vegetarian", "vegan"],
63
+ },
64
+ ],
65
+ },
66
+ ],
67
+ },
68
+ // no products: left out
69
+ { name: "Saisonales", items: [] },
70
+ ],
71
+ pages: [
72
+ {
73
+ title: "Zahlungs- und Lieferinformationen",
74
+ url: "https://www.pizzeria-lafattoria.de/zahlung-und-versand",
75
+ description: "Zahlungs- und Lieferinformationen",
76
+ },
77
+ ],
78
+ faq: [
79
+ {
80
+ question: "Wohin liefern Sie?",
81
+ answer: "Nach Obertshausen und Lämmerspiel.",
82
+ },
83
+ ],
84
+ currency: "EUR",
85
+ now,
86
+ });
87
+
88
+ expect(text).toBe(`# Pizzeria La Fattoria
89
+
90
+ > Pizzeria La Fattoria: Italienische Küche in Obertshausen. Online bestellen zur Lieferung oder Abholung unter https://www.pizzeria-lafattoria.de.
91
+
92
+ Italienisch-deutsche Küche seit 1997.
93
+
94
+ ## Kontakt
95
+
96
+ - Adresse: Kantstraße 6, 63179 Obertshausen
97
+ - Telefon: +49 6104 71427
98
+ - Website: https://www.pizzeria-lafattoria.de
99
+
100
+ ## Öffnungszeiten
101
+
102
+ - Mo–Fr: 11:30–22:00
103
+ - Sa–So: Ruhetag
104
+ - Geschlossen: 24.12.2026 – 26.12.2026
105
+
106
+ ## Bestellen
107
+
108
+ - Online bestellen: https://www.pizzeria-lafattoria.de/speisekarte
109
+ - Liefergebiet: 63179 Obertshausen, 63165 Lämmerspiel
110
+ - Lieferzeit: ca. 30 Minuten
111
+ - Abholung im Restaurant möglich
112
+
113
+ ## Häufige Fragen
114
+
115
+ ### Wohin liefern Sie?
116
+
117
+ Nach Obertshausen und Lämmerspiel.
118
+
119
+ ## Speisekarte
120
+
121
+ ### [Pizza](https://www.pizzeria-lafattoria.de/c/Pizza/)
122
+
123
+ - Pizza Margherita: ab 7,00 € (Tomatensoße, Mozzarella; vegetarisch)
124
+ - [Pizza Salami](https://www.pizzeria-lafattoria.de/c/Pizza/?produkt=22): 8,50 €
125
+
126
+ ### Nudeln
127
+
128
+ #### Spaghetti
129
+
130
+ - Spaghetti Aglio e Olio: 9,00 € (vegan)
131
+
132
+ ## Weitere Informationen
133
+
134
+ - [Zahlungs- und Lieferinformationen](https://www.pizzeria-lafattoria.de/zahlung-und-versand)
135
+ `);
136
+ });
137
+
138
+ it("leaves out what is not configured", () => {
139
+ expect(buildLlmsTxt({ name: "ShopBite", url: "https://example.com", now }))
140
+ .toBe(`# ShopBite
141
+
142
+ > ShopBite.
143
+
144
+ ## Kontakt
145
+
146
+ - Website: https://example.com
147
+ `);
148
+ });
149
+ });
@@ -1,7 +1,9 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
  import type { Schemas } from "#shopware";
3
3
  import {
4
+ getDiets,
4
5
  getMainIngredients,
6
+ hasYesOption,
5
7
  lineItemHoldsProduct,
6
8
  productIsAvailable,
7
9
  } from "../../app/utils/product";
@@ -70,3 +72,21 @@ describe("getMainIngredients", () => {
70
72
  expect(getMainIngredients([group("Küche", ["Italienisch"])])).toEqual([]);
71
73
  });
72
74
  });
75
+
76
+ describe("hasYesOption", () => {
77
+ it("needs the option Ja in the named group", () => {
78
+ const properties = [group("Vegetarisch", ["Ja"]), group("Vegan", ["Nein"])];
79
+ expect(hasYesOption(properties, "Vegetarisch")).toBe(true);
80
+ expect(hasYesOption(properties, "Vegan")).toBe(false);
81
+ expect(hasYesOption(undefined, "Vegetarisch")).toBe(false);
82
+ });
83
+ });
84
+
85
+ describe("getDiets", () => {
86
+ it("returns the marked diets", () => {
87
+ expect(
88
+ getDiets([group("Vegetarisch", ["Ja"]), group("Vegan", ["Ja"])]),
89
+ ).toEqual(["vegetarian", "vegan"]);
90
+ expect(getDiets([group("Hauptzutaten", ["Salami"])])).toEqual([]);
91
+ });
92
+ });
@@ -0,0 +1,90 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import {
3
+ parseListParam,
4
+ productDeepLink,
5
+ withQuickViewConfiguration,
6
+ } from "../../app/utils/productUrl";
7
+
8
+ describe("productDeepLink", () => {
9
+ it("uses the canonical product SEO URL when it is a deep link", () => {
10
+ expect(
11
+ productDeepLink(
12
+ {
13
+ productNumber: "LF-21",
14
+ seoUrls: [
15
+ { seoPathInfo: "Pizza-Margherita/LF-21", isCanonical: false },
16
+ {
17
+ seoPathInfo: "Speisekarte/Pizza/?produkt=LF-21",
18
+ isCanonical: true,
19
+ },
20
+ ],
21
+ },
22
+ "/Speisekarte/Nudeln/",
23
+ ),
24
+ ).toBe("/Speisekarte/Pizza/?produkt=LF-21");
25
+ });
26
+
27
+ it("builds the link from the category without a deep link SEO URL", () => {
28
+ expect(
29
+ productDeepLink(
30
+ {
31
+ productNumber: "LF-21",
32
+ seoUrls: [
33
+ { seoPathInfo: "Pizza-Margherita/LF-21", isCanonical: true },
34
+ ],
35
+ },
36
+ "/Speisekarte/Pizza/",
37
+ ),
38
+ ).toBe("/Speisekarte/Pizza/?produkt=LF-21");
39
+ expect(productDeepLink({ productNumber: "A 1/2" }, "c/Pizza/")).toBe(
40
+ "/c/Pizza/?produkt=A+1%2F2",
41
+ );
42
+ });
43
+
44
+ it("is undefined without SEO URL and category", () => {
45
+ expect(productDeepLink({ productNumber: "LF-21" })).toBeUndefined();
46
+ expect(productDeepLink({}, "/c/Pizza/")).toBeUndefined();
47
+ });
48
+ });
49
+
50
+ describe("parseListParam", () => {
51
+ it("splits comma-separated and repeated values", () => {
52
+ expect(parseListParam("Zwiebeln, Oliven,")).toEqual(["Zwiebeln", "Oliven"]);
53
+ expect(parseListParam(["LF-500", "LF-501,LF-502"])).toEqual([
54
+ "LF-500",
55
+ "LF-501",
56
+ "LF-502",
57
+ ]);
58
+ expect(parseListParam(undefined)).toEqual([]);
59
+ expect(parseListParam([null])).toEqual([]);
60
+ });
61
+ });
62
+
63
+ describe("withQuickViewConfiguration", () => {
64
+ const query = {
65
+ properties: "a|b",
66
+ produkt: "LF-21",
67
+ ohne: "Zwiebeln",
68
+ extras: "LF-500",
69
+ };
70
+
71
+ it("replaces the configuration and keeps other parameters", () => {
72
+ expect(
73
+ withQuickViewConfiguration(query, {
74
+ productNumber: "LF-21-groß",
75
+ without: ["Zwiebeln", "Oliven"],
76
+ extras: [],
77
+ }),
78
+ ).toEqual({
79
+ properties: "a|b",
80
+ produkt: "LF-21-groß",
81
+ ohne: "Zwiebeln,Oliven",
82
+ });
83
+ });
84
+
85
+ it("removes all three parameters without a configuration", () => {
86
+ expect(withQuickViewConfiguration(query, undefined)).toEqual({
87
+ properties: "a|b",
88
+ });
89
+ });
90
+ });