@shopbite-de/storefront 2.2.0 → 2.3.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.
- package/CLAUDE.md +11 -6
- package/app/app.vue +9 -6
- package/app/components/Category/Breadcrumb.vue +9 -10
- package/app/components/Category/Listing.vue +0 -1
- package/app/components/Checkout/Summary.vue +27 -2
- package/app/components/Header.vue +2 -2
- package/app/components/Menu/BonCard.vue +0 -13
- package/app/components/Product/FoodLabels.vue +47 -20
- package/app/components/Product/QuickView.vue +1 -1
- package/app/components/Sb/Icon.vue +3 -1
- package/app/composables/useBusinessHours.ts +35 -14
- package/app/composables/useHolidays.ts +31 -11
- package/app/composables/useHomeMenuCategories.ts +6 -34
- package/app/composables/useLiveShopData.ts +17 -0
- package/app/composables/useNavigation.ts +14 -66
- package/app/composables/useNavigationSearch.ts +8 -31
- package/app/composables/useRestaurantSchema.ts +2 -13
- package/app/composables/useSeoUrlRoute.ts +21 -0
- package/app/composables/useShopBiteConfig.ts +50 -6
- package/app/composables/useTopSellers.ts +2 -43
- package/app/error.vue +4 -0
- package/app/utils/product.ts +1 -62
- package/docs/notes/2026-09-10-issue-275-accessibility.md +2 -2
- package/docs/notes/2026-09-12-issue-327-home-hero.md +1 -1
- package/docs/notes/2026-09-13-issue-332-home-info-cards.md +1 -3
- package/docs/notes/2026-09-21-issue-273-cache-and-demo-video.md +1 -1
- package/docs/notes/2026-09-21-issue-363-non-fatal-404.md +1 -1
- package/docs/notes/2026-09-23-issue-388-home-sections.md +2 -2
- package/docs/notes/2026-10-05-issue-401-restaurant-schema-ordering.md +1 -1
- package/modules/theme.ts +1 -1
- package/nuxt.config.ts +13 -0
- package/package.json +5 -5
- package/server/api/_cache/purge.post.ts +6 -3
- package/server/api/breadcrumb/[categoryId].get.ts +31 -0
- package/server/api/navigation/[type].get.ts +97 -0
- package/server/api/payment-methods.get.ts +29 -0
- package/server/api/seo-url/index.get.ts +17 -0
- package/server/api/seo-url/known.get.ts +33 -0
- package/server/api/shopbite/business-hours.get.ts +22 -0
- package/server/api/shopbite/config.get.ts +6 -0
- package/server/api/shopbite/holidays.get.ts +20 -0
- package/server/api/top-sellers.get.ts +59 -0
- package/server/utils/backoff.ts +67 -0
- package/server/utils/cachePurge.ts +45 -12
- package/server/utils/menuRoot.ts +24 -18
- package/server/utils/seoPaths.ts +130 -0
- package/server/utils/seoUrlCache.ts +98 -0
- package/server/utils/shopBiteConfig.ts +30 -0
- package/server/utils/storeApi.ts +22 -0
- package/test/layer/nuxt.config.ts +1 -1
- package/test/nuxt/CheckoutSummary.test.ts +38 -2
- package/test/nuxt/ProductFoodLabels.test.ts +70 -0
- package/test/nuxt/liveShopData.test.ts +114 -0
- package/test/nuxt/useShopBiteConfig.test.ts +22 -0
- package/test/nuxt/useTopSellers.test.ts +10 -27
- package/test/unit/cachePurge.spec.ts +41 -0
- package/test/unit/layoutCacheRoutes.spec.ts +566 -0
- package/test/unit/nitroStubs.ts +99 -0
- package/test/unit/product.spec.ts +1 -23
- package/test/unit/seoPaths.spec.ts +117 -0
- package/app/components/Menu/FoodLabelLegend.vue +0 -28
|
@@ -2,8 +2,6 @@ import { describe, expect, it } from "vitest";
|
|
|
2
2
|
import type { Schemas } from "#shopware";
|
|
3
3
|
import {
|
|
4
4
|
allergensChecked,
|
|
5
|
-
foodLabelCodes,
|
|
6
|
-
foodLabelLegend,
|
|
7
5
|
foodLabelText,
|
|
8
6
|
getDiets,
|
|
9
7
|
getFoodLabels,
|
|
@@ -141,9 +139,8 @@ describe("food labels (#485)", () => {
|
|
|
141
139
|
expect(getFoodLabels(undefined)).toEqual({ allergens: [], additives: [] });
|
|
142
140
|
});
|
|
143
141
|
|
|
144
|
-
it("
|
|
142
|
+
it("writes plain text", () => {
|
|
145
143
|
const labels = getFoodLabels(withLabels());
|
|
146
|
-
expect(foodLabelCodes(labels)).toEqual(["A", "G", "2"]);
|
|
147
144
|
expect(foodLabelText(labels)).toBe(
|
|
148
145
|
"Enthält: Weizen, Dinkel, Milch (inkl. Laktose). Zusatzstoffe: mit Konservierungsstoff.",
|
|
149
146
|
);
|
|
@@ -160,23 +157,4 @@ describe("food labels (#485)", () => {
|
|
|
160
157
|
).toBe(true);
|
|
161
158
|
expect(allergensChecked(product())).toBe(false);
|
|
162
159
|
});
|
|
163
|
-
|
|
164
|
-
it("builds a legend of the used codes, allergens by allergen name", () => {
|
|
165
|
-
const legend = foodLabelLegend([
|
|
166
|
-
product({ sortedProperties: withLabels() } as unknown as Partial<
|
|
167
|
-
Schemas["Product"]
|
|
168
|
-
>),
|
|
169
|
-
product({
|
|
170
|
-
sortedProperties: [
|
|
171
|
-
labelGroup("Zusatzstoffe", [["11", "koffeinhaltig"]]),
|
|
172
|
-
],
|
|
173
|
-
} as unknown as Partial<Schemas["Product"]>),
|
|
174
|
-
]);
|
|
175
|
-
expect(legend).toEqual([
|
|
176
|
-
{ code: "A", name: "Glutenhaltiges Getreide" },
|
|
177
|
-
{ code: "G", name: "Milch" },
|
|
178
|
-
{ code: "2", name: "mit Konservierungsstoff" },
|
|
179
|
-
{ code: "11", name: "koffeinhaltig" },
|
|
180
|
-
]);
|
|
181
|
-
});
|
|
182
160
|
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { createBackoff } from "../../server/utils/backoff";
|
|
3
|
+
import { mayBeSeoPath, seoPathKey } from "../../server/utils/seoPaths";
|
|
4
|
+
|
|
5
|
+
const KNOWN = new Set(
|
|
6
|
+
[
|
|
7
|
+
"Speisekarte/Pizza/",
|
|
8
|
+
"Speisekarte/Gemüse-Gerichte/",
|
|
9
|
+
"c/Old-Name/",
|
|
10
|
+
"c/Straße/",
|
|
11
|
+
"c/A&B/",
|
|
12
|
+
].map(seoPathKey),
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
describe("seoPathKey", () => {
|
|
16
|
+
it("compares paths like Shopware's lookup", () => {
|
|
17
|
+
expect(seoPathKey("/Speisekarte/Pizza/")).toBe("speisekarte/pizza");
|
|
18
|
+
expect(seoPathKey("Speisekarte/Pizza")).toBe("speisekarte/pizza");
|
|
19
|
+
expect(seoPathKey("/speisekarte/gem%C3%BCse-gerichte/")).toBe(
|
|
20
|
+
"speisekarte/gemuse-gerichte",
|
|
21
|
+
);
|
|
22
|
+
expect(seoPathKey("/c/STRASSE/")).toBe(seoPathKey("/c/Straße/"));
|
|
23
|
+
expect(seoPathKey("/c/a%26b/")).toBe("c/a&b");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("keeps a path that is not valid URI encoding", () => {
|
|
27
|
+
expect(seoPathKey("/a%E0%A4%A/")).toBe("a%e0%a4%a");
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe("mayBeSeoPath", () => {
|
|
32
|
+
it("accepts known paths in every casing, with or without slash", () => {
|
|
33
|
+
expect(mayBeSeoPath("/Speisekarte/Pizza/", KNOWN)).toBe(true);
|
|
34
|
+
expect(mayBeSeoPath("/speisekarte/pizza", KNOWN)).toBe(true);
|
|
35
|
+
expect(mayBeSeoPath("/Speisekarte/Gem%C3%BCse-Gerichte/", KNOWN)).toBe(
|
|
36
|
+
true,
|
|
37
|
+
);
|
|
38
|
+
expect(mayBeSeoPath("/c/old-name/", KNOWN)).toBe(true);
|
|
39
|
+
expect(mayBeSeoPath("/c/strasse/", KNOWN)).toBe(true);
|
|
40
|
+
expect(mayBeSeoPath("/c/a%26b/", KNOWN)).toBe(true);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("rejects ASCII paths no category had", () => {
|
|
44
|
+
expect(mayBeSeoPath("/wp-admin/", KNOWN)).toBe(false);
|
|
45
|
+
expect(mayBeSeoPath("/.git/HEAD", KNOWN)).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("lets through what it cannot compare like the database", () => {
|
|
49
|
+
expect(mayBeSeoPath("/c/%C3%B8l/", KNOWN)).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("leaves technical URLs and an unknown list to the lookup", () => {
|
|
53
|
+
expect(
|
|
54
|
+
mayBeSeoPath("/navigation/0123456789abcdef0123456789abcdef", KNOWN),
|
|
55
|
+
).toBe(true);
|
|
56
|
+
expect(mayBeSeoPath("/wp-admin/", null)).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe("createBackoff", () => {
|
|
61
|
+
it("is active for the given time after a failure", () => {
|
|
62
|
+
const now = vi.fn(() => 1000);
|
|
63
|
+
const backoff = createBackoff(30_000, now);
|
|
64
|
+
expect(backoff.active()).toBe(false);
|
|
65
|
+
backoff.trip();
|
|
66
|
+
now.mockReturnValue(30_999);
|
|
67
|
+
expect(backoff.active()).toBe(true);
|
|
68
|
+
now.mockReturnValue(31_000);
|
|
69
|
+
expect(backoff.active()).toBe(false);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe("hostile paths", () => {
|
|
74
|
+
const HOSTILE = [
|
|
75
|
+
"/%c0%ae%c0%ae/etc/passwd",
|
|
76
|
+
"/%252e%252e/etc/passwd",
|
|
77
|
+
"/..%252f..%252fetc%252fpasswd",
|
|
78
|
+
"/../etc/passwd",
|
|
79
|
+
"/%2e%2e/etc/passwd",
|
|
80
|
+
"/%ff",
|
|
81
|
+
"/navigation/zzz",
|
|
82
|
+
"/detail/abc",
|
|
83
|
+
"/landingPage/x",
|
|
84
|
+
"/navigation/0123456789abcdef0123456789abcdef/x",
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
it("are rejected, even without a list of known paths", () => {
|
|
88
|
+
for (const path of HOSTILE) {
|
|
89
|
+
expect(mayBeSeoPath(path, KNOWN), path).toBe(false);
|
|
90
|
+
expect(mayBeSeoPath(path, null), path).toBe(false);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("leave real technical URLs and non-ASCII paths to the lookup", () => {
|
|
95
|
+
const id = "0123456789ABCDEF0123456789abcdef";
|
|
96
|
+
expect(mayBeSeoPath(`/navigation/${id}`, KNOWN)).toBe(true);
|
|
97
|
+
expect(mayBeSeoPath(`/detail/${id}/`, KNOWN)).toBe(true);
|
|
98
|
+
expect(mayBeSeoPath(`/landingPage/${id}`, null)).toBe(true);
|
|
99
|
+
expect(mayBeSeoPath("/c/%C3%B8l/", KNOWN)).toBe(true);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe("isOutage", () => {
|
|
104
|
+
it("counts fetch errors without a response and 5xx, not bugs or 4xx", async () => {
|
|
105
|
+
const { isOutage } = await import("../../server/utils/backoff");
|
|
106
|
+
const fetchError = (status?: number) =>
|
|
107
|
+
Object.assign(new Error("[GET] fetch failed"), {
|
|
108
|
+
name: "FetchError",
|
|
109
|
+
...(status ? { status, statusCode: status } : {}),
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
expect(isOutage(fetchError())).toBe(true);
|
|
113
|
+
expect(isOutage(fetchError(503))).toBe(true);
|
|
114
|
+
expect(isOutage(fetchError(404))).toBe(false);
|
|
115
|
+
expect(isOutage(new TypeError("x is undefined"))).toBe(false);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import type { Schemas } from "#shopware";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Explains the allergen and additive codes on the cards of the list
|
|
6
|
-
* (#485). Native <details>, so the legend is in the SSR HTML.
|
|
7
|
-
*/
|
|
8
|
-
const props = defineProps<{ products: Schemas["Product"][] }>();
|
|
9
|
-
|
|
10
|
-
const legend = computed(() => foodLabelLegend(props.products));
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<template>
|
|
14
|
-
<details
|
|
15
|
-
v-if="legend.length"
|
|
16
|
-
class="mt-6 rounded-sb-card bg-sb-surface px-4 py-3 text-sm text-sb-ink"
|
|
17
|
-
>
|
|
18
|
-
<summary class="min-h-11 cursor-pointer py-2.5 font-semibold">
|
|
19
|
-
Allergene und Zusatzstoffe
|
|
20
|
-
</summary>
|
|
21
|
-
<dl class="grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 pb-2">
|
|
22
|
-
<template v-for="entry in legend" :key="entry.code">
|
|
23
|
-
<dt class="font-semibold tabular-nums">{{ entry.code }}</dt>
|
|
24
|
-
<dd class="text-sb-ink-muted">{{ entry.name }}</dd>
|
|
25
|
-
</template>
|
|
26
|
-
</dl>
|
|
27
|
-
</details>
|
|
28
|
-
</template>
|