@shopbite-de/storefront 2.4.0 → 2.6.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/.env.example +13 -1
- package/CLAUDE.md +7 -4
- package/api-types/storeApiSchema.json +62 -6
- package/api-types/storeApiTypes.d.ts +23 -4
- package/app/components/Checkout/DeliveryTimeSelect.vue +39 -18
- package/app/components/Checkout/Summary.vue +5 -1
- package/app/components/Home/Categories.vue +2 -2
- package/app/components/Home/Facts.vue +9 -4
- package/app/components/Home/Hero.vue +8 -2
- package/app/components/Navigation/MobileTop.vue +1 -1
- package/app/components/Order/Detail.vue +3 -4
- package/app/composables/useAddressAutocomplete.ts +3 -11
- package/app/composables/useCheckoutMethodGuard.ts +1 -1
- package/app/composables/useDeliveryTime.ts +8 -5
- package/app/composables/useShippingLeadTime.ts +17 -0
- package/app/composables/useShippingMethodChoice.ts +2 -2
- package/app/composables/useShopBiteConfig.ts +10 -1
- package/app/composables/useTrackEvent.ts +4 -3
- package/app/pages/account/recover/password/index.vue +10 -0
- package/app/pages/registrierung/bestaetigen.vue +4 -0
- package/app/utils/leadTime.ts +97 -0
- package/app/utils/openingHours.ts +1 -1
- package/app/utils/schema.ts +2 -2
- package/app/utils/trackingUrl.ts +39 -0
- package/content/index.yml +16 -16
- package/content/zahlung-und-versand.md +3 -3
- package/content.config.ts +2 -2
- package/docs/notes/2026-07-04-issue-239-hydration-mismatches.md +1 -1
- package/docs/notes/2026-09-08-issue-244-category-url-trailing-slash.md +2 -2
- package/docs/notes/2026-09-10-issue-251-shop-data-in-base-layer.md +4 -4
- package/docs/notes/2026-09-10-issue-272-restaurant-schema.md +3 -3
- package/docs/notes/2026-09-10-issue-273-performance-media.md +4 -4
- package/docs/notes/2026-09-10-issue-274-seo-basics.md +6 -6
- package/docs/notes/2026-09-10-issue-275-accessibility.md +3 -3
- package/docs/notes/2026-09-10-issue-290-footer-nap.md +5 -5
- package/docs/notes/2026-09-10-issue-294-matomo-without-config.md +1 -1
- package/docs/notes/2026-09-10-issue-296-track-direct-search.md +1 -1
- package/docs/notes/2026-09-10-issue-312-store-api-criteria-post.md +3 -3
- package/docs/notes/2026-09-10-issue-313-wishlist-scoped-tailwind.md +1 -1
- package/docs/notes/2026-09-10-issue-314-mobile-js-cost.md +1 -1
- package/docs/notes/2026-09-12-issue-319-stylesheet-cost.md +1 -1
- package/docs/notes/2026-09-12-issue-325-product-card.md +2 -2
- package/docs/notes/2026-09-12-issue-327-home-hero.md +2 -2
- package/docs/notes/2026-09-13-issue-332-home-info-cards.md +1 -1
- package/docs/notes/2026-09-13-quick-view-flicker.md +1 -1
- package/docs/notes/2026-09-14-demo-noindex.md +2 -2
- package/docs/notes/2026-09-17-quick-view-compact-options.md +1 -1
- 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 +2 -2
- package/docs/notes/2026-09-21-issue-366-wishlist-404.md +1 -1
- package/docs/notes/2026-09-21-issue-378-dev-modules.md +1 -1
- package/docs/notes/2026-10-05-issue-289-product-deep-links.md +1 -1
- package/docs/notes/2026-10-05-issue-400-menu-item-ingredients-diet.md +1 -1
- package/docs/notes/2026-10-05-issue-401-restaurant-schema-ordering.md +1 -1
- package/docs/notes/2026-10-05-issue-402-llms-txt.md +1 -1
- package/docs/notes/2026-10-05-issue-403-ai-crawlers.md +1 -1
- package/docs/notes/2026-10-05-issue-404-faq.md +1 -1
- package/docs/notes/2026-10-06-old-seo-url-redirect.md +5 -5
- package/docs/notes/2026-10-07-issue-434-property-group-projection.md +1 -1
- package/nuxt.config.ts +56 -8
- package/package.json +3 -2
- package/server/api/address/autocomplete.get.ts +79 -14
- package/server/api/listing/[categoryId].get.ts +5 -28
- package/server/api/search.get.ts +4 -18
- package/server/api/shopbite/config.get.ts +1 -1
- package/server/plugins/bounded-cache.ts +28 -0
- package/server/plugins/security-headers.ts +54 -0
- package/server/routes/llms.txt.ts +6 -5
- package/server/utils/addressAutocomplete.ts +181 -0
- package/server/utils/listingParams.ts +117 -0
- package/server/utils/llmsTxt.ts +7 -3
- package/server/utils/securityHeaders.ts +165 -0
- package/server/utils/shopBiteConfig.ts +1 -1
- package/test/layer/nuxt.config.ts +2 -2
- package/test/nuxt/AccountPagesPreset.test.ts +10 -10
- package/test/nuxt/AuthPagesPreset.test.ts +3 -0
- package/test/nuxt/CheckoutFormsPreset.test.ts +5 -5
- package/test/nuxt/CheckoutOnePage.test.ts +4 -1
- package/test/nuxt/CheckoutSummary.test.ts +42 -3
- package/test/nuxt/DeliveryTimeSelect.test.ts +181 -0
- package/test/nuxt/HeaderFooterPreset.test.ts +10 -10
- package/test/nuxt/HomeFaq.test.ts +1 -1
- package/test/nuxt/HomeLeadTimes.test.ts +78 -0
- package/test/nuxt/NavigationMobileTop.test.ts +1 -1
- package/test/nuxt/OrderPagesPreset.test.ts +22 -2
- package/test/nuxt/RegisterConfirmPage.test.ts +12 -0
- package/test/nuxt/useAddressAutocomplete.test.ts +7 -22
- package/test/nuxt/useCheckoutMethodGuard.test.ts +1 -1
- package/test/nuxt/useDeliveryTime.test.ts +30 -6
- package/test/nuxt/useShippingLeadTime.test.ts +66 -0
- package/test/nuxt/useShippingMethodChoice.test.ts +1 -1
- package/test/nuxt/useShopBiteConfig.test.ts +57 -3
- package/test/nuxt/useTrackEvent.test.ts +16 -0
- package/test/unit/addressAutocomplete.spec.ts +247 -0
- package/test/unit/boundedCache.spec.ts +231 -0
- package/test/unit/highlight.spec.ts +2 -2
- package/test/unit/leadTime.spec.ts +86 -0
- package/test/unit/llmsTxt.spec.ts +30 -29
- package/test/unit/openingHours.spec.ts +3 -3
- package/test/unit/schema.spec.ts +29 -32
- package/test/unit/securityHeaders.spec.ts +254 -0
- package/test/unit/seo.spec.ts +23 -29
- package/test/unit/sitemap.spec.ts +1 -1
- package/test/unit/trackingUrl.spec.ts +48 -0
|
@@ -36,10 +36,13 @@ mockNuxtImport("useUser", () => () => ({
|
|
|
36
36
|
}));
|
|
37
37
|
mockNuxtImport("useShopBiteConfig", () => () => ({
|
|
38
38
|
isCheckoutEnabled: ref(true),
|
|
39
|
-
deliveryTime: ref(30),
|
|
40
39
|
refresh: vi.fn(),
|
|
41
40
|
checkCheckoutEnabled: vi.fn().mockResolvedValue(true),
|
|
42
41
|
}));
|
|
42
|
+
mockNuxtImport("useShippingLeadTime", () => () => ({
|
|
43
|
+
fulfillment: ref("delivery"),
|
|
44
|
+
leadTime: ref(30),
|
|
45
|
+
}));
|
|
43
46
|
mockNuxtImport("useTrackEvent", () => () => ({ trackOrder: vi.fn() }));
|
|
44
47
|
mockNuxtImport("useCheckoutMethodGuard", () => () => ({
|
|
45
48
|
isShippingMethodBlocked: ref(false),
|
|
@@ -14,9 +14,15 @@ const { state, mocks } = vi.hoisted(() => ({
|
|
|
14
14
|
validTime: false,
|
|
15
15
|
shippingBlocked: false,
|
|
16
16
|
customer: true,
|
|
17
|
+
fulfillment: "delivery" as "delivery" | "pickup",
|
|
17
18
|
},
|
|
18
19
|
}));
|
|
19
20
|
|
|
21
|
+
mockNuxtImport("useShippingLeadTime", () => () => ({
|
|
22
|
+
fulfillment: ref(state.fulfillment),
|
|
23
|
+
leadTime: ref(30),
|
|
24
|
+
}));
|
|
25
|
+
|
|
20
26
|
mockNuxtImport("useOpeningHoursData", () => () => ({
|
|
21
27
|
isLoading: ref(state.isLoading),
|
|
22
28
|
hasFailed: ref(state.hasFailed),
|
|
@@ -44,6 +50,10 @@ mockNuxtImport("useShopBiteConfig", () => () => ({
|
|
|
44
50
|
checkCheckoutEnabled: mocks.checkCheckoutEnabled,
|
|
45
51
|
}));
|
|
46
52
|
|
|
53
|
+
// A successful order navigates to the confirmation page; loading that
|
|
54
|
+
// route after the test environment is torn down is an unhandled error.
|
|
55
|
+
mockNuxtImport("navigateTo", () => vi.fn());
|
|
56
|
+
|
|
47
57
|
mockNuxtImport("useTrackEvent", () => () => ({
|
|
48
58
|
trackOrder: vi.fn(),
|
|
49
59
|
}));
|
|
@@ -61,9 +71,12 @@ vi.mock("@shopware/composables", async (importOriginal) => ({
|
|
|
61
71
|
|
|
62
72
|
// Reports the time as DeliveryTimeSelect does once a time is selected.
|
|
63
73
|
const DeliveryTimeSelectStub = defineComponent({
|
|
64
|
-
emits: ["update:valid"],
|
|
74
|
+
emits: ["update:valid", "update:modelValue"],
|
|
65
75
|
setup(_, { emit }) {
|
|
66
|
-
onMounted(() =>
|
|
76
|
+
onMounted(() => {
|
|
77
|
+
emit("update:modelValue", "19:15");
|
|
78
|
+
emit("update:valid", state.validTime);
|
|
79
|
+
});
|
|
67
80
|
return () => h("div");
|
|
68
81
|
},
|
|
69
82
|
});
|
|
@@ -93,6 +106,9 @@ describe("Checkout Summary order button", () => {
|
|
|
93
106
|
state.validTime = false;
|
|
94
107
|
state.shippingBlocked = false;
|
|
95
108
|
state.customer = true;
|
|
109
|
+
state.fulfillment = "delivery";
|
|
110
|
+
mocks.createOrder.mockReset();
|
|
111
|
+
mocks.checkCheckoutEnabled.mockReset();
|
|
96
112
|
});
|
|
97
113
|
|
|
98
114
|
it("shows a loading state while the opening hours are not loaded", async () => {
|
|
@@ -134,7 +150,7 @@ describe("Checkout Summary order button", () => {
|
|
|
134
150
|
expect(button.attributes("disabled")).toBeUndefined();
|
|
135
151
|
});
|
|
136
152
|
|
|
137
|
-
//
|
|
153
|
+
// e.g. "Lieferung" needs a shipping city in the delivery area
|
|
138
154
|
it("says delivery is not possible once the address is known", async () => {
|
|
139
155
|
state.isLoading = false;
|
|
140
156
|
state.validTime = true;
|
|
@@ -196,4 +212,27 @@ describe("Checkout Summary order button", () => {
|
|
|
196
212
|
"konnte nicht geprüft werden",
|
|
197
213
|
);
|
|
198
214
|
});
|
|
215
|
+
|
|
216
|
+
// shopbite#6: the comment names the kind of time
|
|
217
|
+
it.each([
|
|
218
|
+
["delivery", "Wunschlieferzeit: 19:15"],
|
|
219
|
+
["pickup", "Wunschabholzeit: 19:15"],
|
|
220
|
+
] as const)(
|
|
221
|
+
"stores the wished time of a %s order",
|
|
222
|
+
async (fulfillment, comment) => {
|
|
223
|
+
state.isLoading = false;
|
|
224
|
+
state.validTime = true;
|
|
225
|
+
state.fulfillment = fulfillment;
|
|
226
|
+
mocks.checkCheckoutEnabled.mockResolvedValue(true);
|
|
227
|
+
mocks.createOrder.mockResolvedValue({ id: "order-1" });
|
|
228
|
+
|
|
229
|
+
const button = await mountSummary();
|
|
230
|
+
await button.trigger("click");
|
|
231
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
232
|
+
|
|
233
|
+
expect(mocks.createOrder).toHaveBeenCalledWith({
|
|
234
|
+
customerComment: comment,
|
|
235
|
+
});
|
|
236
|
+
},
|
|
237
|
+
);
|
|
199
238
|
});
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
3
|
+
import { nextTick, ref, type Ref } from "vue";
|
|
4
|
+
import DeliveryTimeSelect from "~/components/Checkout/DeliveryTimeSelect.vue";
|
|
5
|
+
|
|
6
|
+
// The time field follows the selected shipping method (shopbite#6):
|
|
7
|
+
// lead time and wording of delivery or pickup.
|
|
8
|
+
const { lead, hours } = vi.hoisted(() => ({
|
|
9
|
+
lead: {
|
|
10
|
+
fulfillment: "delivery" as "delivery" | "pickup",
|
|
11
|
+
leadTime: 45 as number | null,
|
|
12
|
+
// the refs of the mounted component, to switch the method
|
|
13
|
+
current: null as null | {
|
|
14
|
+
fulfillment: Ref<"delivery" | "pickup">;
|
|
15
|
+
leadTime: Ref<number | null>;
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
// "past": today's only interval has ended; "open": 11:00 to 22:00
|
|
19
|
+
hours: { mode: "past" as "past" | "open" },
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
mockNuxtImport("useShippingLeadTime", () => () => {
|
|
23
|
+
lead.current = {
|
|
24
|
+
fulfillment: ref(lead.fulfillment),
|
|
25
|
+
leadTime: ref(lead.leadTime),
|
|
26
|
+
};
|
|
27
|
+
return lead.current;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
mockNuxtImport("useOpeningHoursData", () => () => ({
|
|
31
|
+
isLoaded: ref(true),
|
|
32
|
+
hasFailed: ref(false),
|
|
33
|
+
retry: vi.fn(),
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
mockNuxtImport("useHolidays", () => () => ({
|
|
37
|
+
isClosedHoliday: () => false,
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
// "past": today's only interval ended an hour ago, no times are left.
|
|
41
|
+
mockNuxtImport("useBusinessHours", () => () => {
|
|
42
|
+
const interval = (date: Date) => {
|
|
43
|
+
if (hours.mode === "open") {
|
|
44
|
+
const start = new Date(date);
|
|
45
|
+
start.setHours(11, 0, 0, 0);
|
|
46
|
+
const end = new Date(date);
|
|
47
|
+
end.setHours(22, 0, 0, 0);
|
|
48
|
+
return { start, end };
|
|
49
|
+
}
|
|
50
|
+
const end = new Date(Date.now() - 60 * 60_000);
|
|
51
|
+
return { start: new Date(end.getTime() - 60 * 60_000), end };
|
|
52
|
+
};
|
|
53
|
+
const getEarliestSelectableTime = (now: Date, minutes: number | null) => {
|
|
54
|
+
const earliest = new Date(now.getTime() + (minutes ?? 30) * 60_000);
|
|
55
|
+
earliest.setSeconds(0, 0);
|
|
56
|
+
return earliest;
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
businessHours: ref([
|
|
60
|
+
{
|
|
61
|
+
dayOfWeek: new Date().getDay(),
|
|
62
|
+
openingTime: "00:00",
|
|
63
|
+
closingTime: "00:01",
|
|
64
|
+
},
|
|
65
|
+
]),
|
|
66
|
+
getServiceIntervals: (date: Date) => [interval(date)],
|
|
67
|
+
getEarliestSelectableTime,
|
|
68
|
+
findActiveInterval: (now: Date, minutes: number | null) => {
|
|
69
|
+
if (hours.mode === "past") return null;
|
|
70
|
+
const current = interval(now);
|
|
71
|
+
return getEarliestSelectableTime(now, minutes) <= current.end
|
|
72
|
+
? current
|
|
73
|
+
: null;
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
async function mountSelect() {
|
|
79
|
+
return await mountSuspended(DeliveryTimeSelect);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
describe("DeliveryTimeSelect wording per fulfillment", () => {
|
|
83
|
+
beforeEach(() => {
|
|
84
|
+
lead.fulfillment = "delivery";
|
|
85
|
+
lead.leadTime = 45;
|
|
86
|
+
hours.mode = "past";
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("asks for the delivery time with the delivery lead time", async () => {
|
|
90
|
+
const wrapper = await mountSelect();
|
|
91
|
+
const text = wrapper.text();
|
|
92
|
+
|
|
93
|
+
expect(wrapper.get("label").text()).toContain("Wunschlieferzeit");
|
|
94
|
+
expect(text).toContain("Lieferzeit ca. 45 Minuten");
|
|
95
|
+
expect(text).toContain("Heute sind keine Lieferzeiten mehr verfügbar.");
|
|
96
|
+
expect(text).not.toContain("Abhol");
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("asks for the pickup time with the pickup lead time", async () => {
|
|
100
|
+
lead.fulfillment = "pickup";
|
|
101
|
+
lead.leadTime = 20;
|
|
102
|
+
|
|
103
|
+
const wrapper = await mountSelect();
|
|
104
|
+
const text = wrapper.text();
|
|
105
|
+
|
|
106
|
+
expect(wrapper.get("label").text()).toContain("Wunschabholzeit");
|
|
107
|
+
expect(text).toContain("Abholbereit in ca. 20 Minuten");
|
|
108
|
+
expect(text).toContain("Heute sind keine Abholzeiten mehr verfügbar.");
|
|
109
|
+
expect(text).not.toContain("Lieferzeit");
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("leaves out the lead time hint while it is unknown", async () => {
|
|
113
|
+
lead.leadTime = null;
|
|
114
|
+
|
|
115
|
+
const wrapper = await mountSelect();
|
|
116
|
+
|
|
117
|
+
expect(wrapper.text()).not.toContain("ca.");
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Switching the shipping method moves the time to a valid 5-minute slot.
|
|
122
|
+
describe("DeliveryTimeSelect after a shipping method switch", () => {
|
|
123
|
+
beforeEach(() => {
|
|
124
|
+
vi.useFakeTimers({ toFake: ["Date"] });
|
|
125
|
+
vi.setSystemTime(new Date(2026, 10, 19, 16, 13, 20));
|
|
126
|
+
hours.mode = "open";
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
afterEach(() => {
|
|
130
|
+
vi.useRealTimers();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
async function switchTo(fulfillment: "delivery" | "pickup", minutes: number) {
|
|
134
|
+
lead.current!.fulfillment.value = fulfillment;
|
|
135
|
+
lead.current!.leadTime.value = minutes;
|
|
136
|
+
await nextTick();
|
|
137
|
+
await nextTick();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function timeInput(wrapper: Awaited<ReturnType<typeof mountSelect>>) {
|
|
141
|
+
return wrapper.get<HTMLInputElement>('input[type="time"]');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
it("moves a chosen pickup time to the next delivery slot", async () => {
|
|
145
|
+
lead.fulfillment = "pickup";
|
|
146
|
+
lead.leadTime = 15;
|
|
147
|
+
const wrapper = await mountSelect();
|
|
148
|
+
expect(timeInput(wrapper).element.value).toBe("16:30");
|
|
149
|
+
await timeInput(wrapper).setValue("16:30");
|
|
150
|
+
|
|
151
|
+
await switchTo("delivery", 30);
|
|
152
|
+
|
|
153
|
+
expect(timeInput(wrapper).element.value).toBe("16:45");
|
|
154
|
+
expect(wrapper.text()).not.toContain("5-Minuten-Schritten");
|
|
155
|
+
expect(wrapper.emitted("update:valid")!.at(-1)).toEqual([true]);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("moves the prefilled delivery time to the earlier pickup slot", async () => {
|
|
159
|
+
lead.fulfillment = "delivery";
|
|
160
|
+
lead.leadTime = 30;
|
|
161
|
+
const wrapper = await mountSelect();
|
|
162
|
+
expect(timeInput(wrapper).element.value).toBe("16:45");
|
|
163
|
+
|
|
164
|
+
await switchTo("pickup", 15);
|
|
165
|
+
|
|
166
|
+
expect(timeInput(wrapper).element.value).toBe("16:30");
|
|
167
|
+
expect(wrapper.emitted("update:valid")!.at(-1)).toEqual([true]);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("keeps a later time the guest chose", async () => {
|
|
171
|
+
lead.fulfillment = "delivery";
|
|
172
|
+
lead.leadTime = 30;
|
|
173
|
+
const wrapper = await mountSelect();
|
|
174
|
+
await timeInput(wrapper).setValue("18:00");
|
|
175
|
+
|
|
176
|
+
await switchTo("pickup", 15);
|
|
177
|
+
expect(timeInput(wrapper).element.value).toBe("18:00");
|
|
178
|
+
await switchTo("delivery", 30);
|
|
179
|
+
expect(timeInput(wrapper).element.value).toBe("18:00");
|
|
180
|
+
});
|
|
181
|
+
});
|
|
@@ -73,12 +73,12 @@ describe("header and footer with a preset (#455)", () => {
|
|
|
73
73
|
state.wishlistCount = 0;
|
|
74
74
|
state.loggedIn = false;
|
|
75
75
|
Object.assign(useRuntimeConfig().public.site, {
|
|
76
|
-
name: "
|
|
77
|
-
telephone: "
|
|
76
|
+
name: "Esempio",
|
|
77
|
+
telephone: "0123 456789",
|
|
78
78
|
address: {
|
|
79
|
-
street: "
|
|
80
|
-
postalCode: "
|
|
81
|
-
city: "
|
|
79
|
+
street: "Musterstraße 1",
|
|
80
|
+
postalCode: "12345",
|
|
81
|
+
city: "Musterstadt",
|
|
82
82
|
country: "DE",
|
|
83
83
|
},
|
|
84
84
|
googleBusinessProfileUrl: "",
|
|
@@ -88,11 +88,11 @@ describe("header and footer with a preset (#455)", () => {
|
|
|
88
88
|
it("names the logo link and the icon-only controls", async () => {
|
|
89
89
|
const wrapper = await mountSuspended(Header);
|
|
90
90
|
expect(
|
|
91
|
-
wrapper.find('a[aria-label="
|
|
91
|
+
wrapper.find('a[aria-label="Esempio, zur Startseite"]').exists(),
|
|
92
92
|
).toBe(true);
|
|
93
93
|
expect(
|
|
94
|
-
wrapper.find('a[href="tel:
|
|
95
|
-
).toBe("Anrufen:
|
|
94
|
+
wrapper.find('a[href="tel:0123456789"]').attributes("aria-label"),
|
|
95
|
+
).toBe("Anrufen: 0123 456789");
|
|
96
96
|
expect(wrapper.find('a[href="/anmelden"]').attributes("aria-label")).toBe(
|
|
97
97
|
"Anmelden",
|
|
98
98
|
);
|
|
@@ -128,8 +128,8 @@ describe("header and footer with a preset (#455)", () => {
|
|
|
128
128
|
|
|
129
129
|
it("shows contact data and the footer columns without a colour switch", async () => {
|
|
130
130
|
const wrapper = await mountSuspended(Footer);
|
|
131
|
-
expect(wrapper.find("address").text()).toContain("
|
|
132
|
-
expect(wrapper.find("address").text()).toContain("
|
|
131
|
+
expect(wrapper.find("address").text()).toContain("Musterstraße 1");
|
|
132
|
+
expect(wrapper.find("address").text()).toContain("12345 Musterstadt");
|
|
133
133
|
const navs = wrapper.findAll("nav");
|
|
134
134
|
expect(navs.map((nav) => nav.attributes("aria-label"))).toEqual([
|
|
135
135
|
"Rechtliches",
|
|
@@ -3,7 +3,7 @@ import { mountSuspended } from "@nuxt/test-utils/runtime";
|
|
|
3
3
|
import HomeFaq from "~/components/Home/Faq.vue";
|
|
4
4
|
|
|
5
5
|
const items = [
|
|
6
|
-
{ question: "Wohin liefern Sie?", answer: "Nach
|
|
6
|
+
{ question: "Wohin liefern Sie?", answer: "Nach Musterstadt." },
|
|
7
7
|
{ question: "Wie kann ich bezahlen?", answer: "Bar oder mit EC-Karte." },
|
|
8
8
|
];
|
|
9
9
|
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
3
|
+
import { ref } from "vue";
|
|
4
|
+
import Hero from "~/components/Home/Hero.vue";
|
|
5
|
+
import Facts from "~/components/Home/Facts.vue";
|
|
6
|
+
|
|
7
|
+
// The home page shows the lead times of the delivery and pickup methods
|
|
8
|
+
// (shopbite#6) and leaves out a time no shipping method has.
|
|
9
|
+
const { times } = vi.hoisted(() => ({
|
|
10
|
+
times: {
|
|
11
|
+
delivery: 45 as number | null,
|
|
12
|
+
pickup: 20 as number | null,
|
|
13
|
+
},
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
mockNuxtImport("useShopBiteConfig", () => () => ({
|
|
17
|
+
deliveryTime: ref(times.delivery),
|
|
18
|
+
pickupTime: ref(times.pickup),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
mockNuxtImport("useStoreStatus", () => () => ({
|
|
22
|
+
status: ref({ open: true, closesAt: "22:00" }),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
mockNuxtImport("useBusinessHours", () => () => ({
|
|
26
|
+
businessHours: ref(null),
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
const features = [
|
|
30
|
+
{
|
|
31
|
+
title: "Lieferung",
|
|
32
|
+
kind: "delivery" as const,
|
|
33
|
+
description: "Liefergebiet",
|
|
34
|
+
},
|
|
35
|
+
{ title: "Abholung", kind: "pickup" as const, description: "Im Restaurant" },
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
describe("lead times on the home page", () => {
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
times.delivery = 45;
|
|
41
|
+
times.pickup = 20;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("shows delivery and pickup time in the hero", async () => {
|
|
45
|
+
const wrapper = await mountSuspended(Hero, { props: { title: "Pizza" } });
|
|
46
|
+
const text = wrapper.text();
|
|
47
|
+
expect(text).toContain("Lieferung ca. 45 Min");
|
|
48
|
+
expect(text).toContain("Abholung ca. 20 Min");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("leaves out a time without a shipping method of that kind", async () => {
|
|
52
|
+
times.delivery = null;
|
|
53
|
+
const wrapper = await mountSuspended(Hero, { props: { title: "Pizza" } });
|
|
54
|
+
const text = wrapper.text();
|
|
55
|
+
expect(text).not.toContain("Lieferung ca.");
|
|
56
|
+
expect(text).toContain("Abholung ca. 20 Min");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("fills the delivery and pickup facts", async () => {
|
|
60
|
+
const wrapper = await mountSuspended(Facts, { props: { features } });
|
|
61
|
+
const text = wrapper.text();
|
|
62
|
+
expect(text).toContain("In ca. 45 Minuten bei Ihnen");
|
|
63
|
+
expect(text).toContain("Abholbereit in ca. 20 Minuten");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("keeps the content lead without a lead time", async () => {
|
|
67
|
+
times.delivery = null;
|
|
68
|
+
times.pickup = null;
|
|
69
|
+
const wrapper = await mountSuspended(Facts, {
|
|
70
|
+
props: {
|
|
71
|
+
features: [{ ...features[0]!, lead: "Frei Haus ab 15 €" }],
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
const text = wrapper.text();
|
|
75
|
+
expect(text).toContain("Frei Haus ab 15 €");
|
|
76
|
+
expect(text).not.toContain("Minuten");
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -4,7 +4,7 @@ import type { VueWrapper } from "@vue/test-utils";
|
|
|
4
4
|
import { ref } from "vue";
|
|
5
5
|
import MobileTop from "~/components/Navigation/MobileTop.vue";
|
|
6
6
|
|
|
7
|
-
//
|
|
7
|
+
// A menu where Fleischgerichte has sub-categories, Pizza has none.
|
|
8
8
|
vi.mock("~/composables/useNavigation", () => ({
|
|
9
9
|
useNavigation: () => ({
|
|
10
10
|
menuCardNavigation: ref([
|
|
@@ -62,10 +62,30 @@ describe("order pages with a preset (#445)", () => {
|
|
|
62
62
|
vi.clearAllMocks();
|
|
63
63
|
order.value = undefined;
|
|
64
64
|
Object.assign(useRuntimeConfig().public.site, {
|
|
65
|
-
telephone: "
|
|
65
|
+
telephone: "0123 456789",
|
|
66
66
|
});
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
+
// shopbite#6: pickup orders store "Wunschabholzeit"
|
|
70
|
+
it("shows the wished pickup time", async () => {
|
|
71
|
+
mocks.loadOrderDetails.mockImplementation(async () => {
|
|
72
|
+
order.value = {
|
|
73
|
+
...sampleOrder,
|
|
74
|
+
customerComment: "Wunschabholzeit: 18:40",
|
|
75
|
+
} as Schemas["Order"];
|
|
76
|
+
});
|
|
77
|
+
const wrapper = await mountSuspended(ConfirmationPreset, {
|
|
78
|
+
props: { orderId: "order-1", kind: "success" },
|
|
79
|
+
});
|
|
80
|
+
await flushPromises();
|
|
81
|
+
|
|
82
|
+
const facts = wrapper
|
|
83
|
+
.findAll("dl")[0]!
|
|
84
|
+
.findAll("div")
|
|
85
|
+
.map((row) => row.text());
|
|
86
|
+
expect(facts).toContain("Wunschzeit18:40");
|
|
87
|
+
});
|
|
88
|
+
|
|
69
89
|
it("thanks the guest and shows the order after loading", async () => {
|
|
70
90
|
mocks.loadOrderDetails.mockImplementation(async () => {
|
|
71
91
|
order.value = sampleOrder;
|
|
@@ -95,7 +115,7 @@ describe("order pages with a preset (#445)", () => {
|
|
|
95
115
|
|
|
96
116
|
const call = wrapper.find('a[href^="tel:"]');
|
|
97
117
|
expect(call.text()).toContain("Anrufen:");
|
|
98
|
-
expect(call.text()).toContain("
|
|
118
|
+
expect(call.text()).toContain("0123 456789");
|
|
99
119
|
});
|
|
100
120
|
|
|
101
121
|
it("titles the order page with the order number", async () => {
|
|
@@ -63,6 +63,18 @@ describe("registrierung/bestaetigen", () => {
|
|
|
63
63
|
expect(navigateToMock).toHaveBeenCalledWith({ path: "/konto" });
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
+
it("removes the confirmation hashes from the address bar", async () => {
|
|
67
|
+
invokeMock.mockResolvedValueOnce({ data: {} });
|
|
68
|
+
const replaceMock = vi.spyOn(useRouter(), "replace");
|
|
69
|
+
|
|
70
|
+
await mountPage();
|
|
71
|
+
|
|
72
|
+
expect(replaceMock).toHaveBeenCalledWith({ query: {} });
|
|
73
|
+
expect(replaceMock.mock.invocationCallOrder[0]).toBeLessThan(
|
|
74
|
+
invokeMock.mock.invocationCallOrder[0]!,
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
|
|
66
78
|
it("shows an error and stays on the page when the link is invalid", async () => {
|
|
67
79
|
invokeMock.mockRejectedValueOnce(
|
|
68
80
|
new ApiClientErrorMock({
|
|
@@ -16,16 +16,6 @@ mockNuxtImport("useRuntimeConfig", () => () => ({
|
|
|
16
16
|
geoapifyApiKey: "test-api-key",
|
|
17
17
|
}));
|
|
18
18
|
|
|
19
|
-
// Mock useAddressSuggestionArea
|
|
20
|
-
const { mockBoundingBoxCoordinates } = vi.hoisted(() => ({
|
|
21
|
-
mockBoundingBoxCoordinates: {
|
|
22
|
-
value: "8.822251,50.055026,8.899077,50.104327",
|
|
23
|
-
},
|
|
24
|
-
}));
|
|
25
|
-
mockNuxtImport("useAddressSuggestionArea", () => () => ({
|
|
26
|
-
boundingBoxCoordinates: mockBoundingBoxCoordinates,
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
19
|
describe("useAddressAutocomplete", () => {
|
|
30
20
|
beforeEach(() => {
|
|
31
21
|
vi.clearAllMocks();
|
|
@@ -45,9 +35,9 @@ describe("useAddressAutocomplete", () => {
|
|
|
45
35
|
properties: {
|
|
46
36
|
street: "Main St",
|
|
47
37
|
housenumber: "1",
|
|
48
|
-
city: "
|
|
49
|
-
postcode: "
|
|
50
|
-
formatted: "Main St 1,
|
|
38
|
+
city: "Musterstadt",
|
|
39
|
+
postcode: "12345",
|
|
40
|
+
formatted: "Main St 1, 12345 Musterstadt, Germany",
|
|
51
41
|
},
|
|
52
42
|
},
|
|
53
43
|
],
|
|
@@ -67,7 +57,6 @@ describe("useAddressAutocomplete", () => {
|
|
|
67
57
|
text: "Main St 1",
|
|
68
58
|
lang: "de",
|
|
69
59
|
limit: 5,
|
|
70
|
-
filter: "rect:8.822251,50.055026,8.899077,50.104327",
|
|
71
60
|
}),
|
|
72
61
|
}),
|
|
73
62
|
expect.any(String),
|
|
@@ -75,9 +64,9 @@ describe("useAddressAutocomplete", () => {
|
|
|
75
64
|
expect(suggestions).toHaveLength(1);
|
|
76
65
|
expect(suggestions[0]).toEqual({
|
|
77
66
|
street: "Main St 1",
|
|
78
|
-
city: "
|
|
79
|
-
zipcode: "
|
|
80
|
-
label: "Main St 1,
|
|
67
|
+
city: "Musterstadt",
|
|
68
|
+
zipcode: "12345",
|
|
69
|
+
label: "Main St 1, 12345 Musterstadt, Germany",
|
|
81
70
|
});
|
|
82
71
|
});
|
|
83
72
|
|
|
@@ -102,8 +91,7 @@ describe("useAddressAutocomplete", () => {
|
|
|
102
91
|
expect(consoleSpy).toHaveBeenCalled();
|
|
103
92
|
consoleSpy.mockRestore();
|
|
104
93
|
});
|
|
105
|
-
it("
|
|
106
|
-
mockBoundingBoxCoordinates.value = "";
|
|
94
|
+
it("leaves the area filter to the server route", async () => {
|
|
107
95
|
mockUseFetch.mockResolvedValue({
|
|
108
96
|
data: ref({ features: [] }),
|
|
109
97
|
});
|
|
@@ -120,8 +108,5 @@ describe("useAddressAutocomplete", () => {
|
|
|
120
108
|
}),
|
|
121
109
|
expect.any(String),
|
|
122
110
|
);
|
|
123
|
-
|
|
124
|
-
// Reset for other tests
|
|
125
|
-
mockBoundingBoxCoordinates.value = "8.822251,50.055026,8.899077,50.104327";
|
|
126
111
|
});
|
|
127
112
|
});
|
|
@@ -155,7 +155,7 @@ describe("useCheckoutMethodGuard", () => {
|
|
|
155
155
|
});
|
|
156
156
|
|
|
157
157
|
it("never switches a blocked shipping method, it only reports it", async () => {
|
|
158
|
-
//
|
|
158
|
+
// e.g. "Lieferung" is blocked until the guest has entered an
|
|
159
159
|
// address in the delivery area; switching made every order a pickup
|
|
160
160
|
cart.value = cartWith({ [shippingBlocked.key]: shippingBlocked });
|
|
161
161
|
|
|
@@ -3,9 +3,10 @@ import { mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
|
3
3
|
import { ref } from "vue";
|
|
4
4
|
import { useDeliveryTime } from "~/composables/useDeliveryTime";
|
|
5
5
|
|
|
6
|
-
const { mockDeliveryTime, mockBusinessHours, mockHolidays } =
|
|
7
|
-
() => ({
|
|
6
|
+
const { mockDeliveryTime, mockFulfillment, mockBusinessHours, mockHolidays } =
|
|
7
|
+
vi.hoisted(() => ({
|
|
8
8
|
mockDeliveryTime: { value: 45 },
|
|
9
|
+
mockFulfillment: { value: "delivery" as "delivery" | "pickup" },
|
|
9
10
|
mockBusinessHours: {
|
|
10
11
|
value: [
|
|
11
12
|
{ dayOfWeek: 1, openingTime: "11:30", closingTime: "14:30" },
|
|
@@ -22,11 +23,11 @@ const { mockDeliveryTime, mockBusinessHours, mockHolidays } = vi.hoisted(
|
|
|
22
23
|
],
|
|
23
24
|
},
|
|
24
25
|
mockHolidays: { value: [] as { start: string; end: string }[] | null },
|
|
25
|
-
})
|
|
26
|
-
);
|
|
26
|
+
}));
|
|
27
27
|
|
|
28
|
-
mockNuxtImport("
|
|
29
|
-
|
|
28
|
+
mockNuxtImport("useShippingLeadTime", () => () => ({
|
|
29
|
+
leadTime: mockDeliveryTime,
|
|
30
|
+
fulfillment: mockFulfillment,
|
|
30
31
|
}));
|
|
31
32
|
|
|
32
33
|
mockNuxtImport("useBusinessHours", () => () => ({
|
|
@@ -120,6 +121,29 @@ describe("useDeliveryTime", () => {
|
|
|
120
121
|
|
|
121
122
|
beforeEach(() => {
|
|
122
123
|
vi.clearAllMocks();
|
|
124
|
+
mockFulfillment.value = "delivery";
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// shopbite#6: the lead time of the selected shipping method
|
|
128
|
+
it("uses the lead time of the selected shipping method", () => {
|
|
129
|
+
mockDeliveryTime.value = 20;
|
|
130
|
+
mockFulfillment.value = "pickup";
|
|
131
|
+
const { earliest } = useDeliveryTime(now);
|
|
132
|
+
expect(earliest.value.getHours()).toBe(12);
|
|
133
|
+
expect(earliest.value.getMinutes()).toBe(20);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("speaks of pickup times for a pickup method", () => {
|
|
137
|
+
mockDeliveryTime.value = 30;
|
|
138
|
+
const late = ref(new Date("2023-10-27T22:45:00"));
|
|
139
|
+
mockFulfillment.value = "pickup";
|
|
140
|
+
expect(useDeliveryTime(late).helperText.value).toBe(
|
|
141
|
+
"Heute sind keine Abholzeiten mehr verfügbar.",
|
|
142
|
+
);
|
|
143
|
+
mockFulfillment.value = "delivery";
|
|
144
|
+
expect(useDeliveryTime(late).helperText.value).toBe(
|
|
145
|
+
"Heute sind keine Lieferzeiten mehr verfügbar.",
|
|
146
|
+
);
|
|
123
147
|
});
|
|
124
148
|
|
|
125
149
|
it("should calculate earliest selectable time", () => {
|