@shopbite-de/storefront 1.31.3 → 2.0.1
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/.github/workflows/ci.yaml +87 -0
- package/.gitignore +5 -0
- package/CLAUDE.md +27 -8
- package/app/app.vue +10 -6
- package/app/assets/css/main.css +103 -61
- package/app/components/AddToWishlist.vue +15 -25
- package/app/components/Address/Card.vue +6 -11
- package/app/components/Address/Detail.vue +23 -23
- package/app/components/Address/Fields.vue +175 -73
- package/app/components/Address/Form.vue +107 -106
- package/app/components/Cart/Bar.vue +6 -9
- package/app/components/Cart/Item.vue +48 -63
- package/app/components/Cart/QuickView.vue +38 -25
- package/app/components/Cart/Upsell.vue +24 -62
- package/app/components/Category/Breadcrumb.vue +29 -3
- package/app/components/Category/FilterGroup.vue +20 -41
- package/app/components/Category/Listing.vue +100 -130
- package/app/components/Category/SearchInput.vue +22 -19
- package/app/components/Checkout/DeliveryTimeSelect.vue +55 -77
- package/app/components/Checkout/LoginOrRegister.vue +28 -29
- package/app/components/Checkout/PaymentAndDelivery.vue +114 -86
- package/app/components/Checkout/Summary.vue +90 -60
- package/app/components/Checkout/VoucherInput.vue +40 -27
- package/app/components/Contact/Form.vue +164 -192
- package/app/components/DemoBanner.vue +5 -5
- package/app/components/Footer/StoreStatus.vue +2 -2
- package/app/components/Footer.vue +125 -57
- package/app/components/Header.vue +283 -18
- package/app/components/Home/Categories.vue +116 -0
- package/app/components/Home/Facts.vue +71 -0
- package/app/components/Home/Faq.vue +34 -16
- package/app/components/Home/Hero.vue +172 -0
- package/app/components/Home/Highlights.vue +29 -37
- package/app/components/Home/Restaurant.vue +102 -0
- package/app/components/Menu/BonCard.vue +180 -0
- package/app/components/Menu/CartPanel.vue +24 -0
- package/app/components/Menu/CategoryIndex.vue +54 -0
- package/app/components/Menu/OrderMode.vue +20 -0
- package/app/components/Menu/SectionHeader.vue +38 -0
- package/app/components/Navigation/MobileTop.vue +23 -15
- package/app/components/Order/Confirmation.vue +119 -0
- package/app/components/Order/Detail.vue +80 -88
- package/app/components/Product/CardSkeleton.vue +8 -12
- package/app/components/Product/Configurator.vue +8 -16
- package/app/components/Product/CrossSelling.vue +75 -83
- package/app/components/Product/DeselectIngredient.vue +17 -22
- package/app/components/Product/Detail.vue +35 -27
- package/app/components/Product/QuickView.vue +80 -51
- package/app/components/SalesChannelSwitch.vue +14 -28
- package/app/components/Sb/Button.vue +70 -0
- package/app/components/Sb/Checkbox.vue +73 -0
- package/app/components/Sb/Chip.vue +51 -0
- package/app/components/Sb/ChoiceGroup.vue +82 -0
- package/app/components/Sb/ConfirmDialog.vue +60 -0
- package/app/components/Sb/Field.vue +77 -0
- package/app/components/Sb/Icon.vue +66 -0
- package/app/components/Sb/IconButton.vue +55 -0
- package/app/components/Sb/Input.vue +23 -0
- package/app/components/Sb/SegmentedControl.vue +34 -0
- package/app/components/Sb/Select.vue +49 -0
- package/app/components/Sb/Sheet.vue +83 -0
- package/app/components/Sb/Stars.vue +60 -0
- package/app/components/Sb/StatusPill.vue +38 -0
- package/app/components/Sb/Stepper.vue +72 -0
- package/app/components/User/AccountHeader.vue +16 -0
- package/app/components/User/AuthPanel.vue +41 -0
- package/app/components/User/Detail.vue +32 -29
- package/app/components/User/LoginForm.vue +92 -98
- package/app/components/User/RegistrationForm.vue +285 -249
- package/app/components/Wishlist.vue +55 -155
- package/app/composables/useCartMutations.ts +9 -27
- package/app/composables/useCheckoutMethodGuard.ts +2 -24
- package/app/composables/useContactForm.ts +66 -0
- package/app/composables/useHomeMenuCategories.ts +41 -0
- package/app/composables/useNavigation.ts +10 -2
- package/app/composables/useOrderMode.ts +65 -0
- package/app/composables/useRegistrationForm.ts +161 -0
- package/app/composables/useRestaurantSchema.ts +1 -1
- package/app/composables/useShareLink.ts +3 -13
- package/app/composables/useSortingSelection.ts +13 -0
- package/app/composables/useThemePreset.ts +24 -0
- package/app/composables/useVoucherCode.ts +7 -16
- package/app/composables/useWishlistActions.ts +0 -51
- package/app/error.vue +31 -9
- package/app/layouts/account.vue +45 -50
- package/app/layouts/default.vue +2 -3
- package/app/layouts/listing.vue +3 -5
- package/app/pages/[...all].vue +8 -4
- package/app/pages/account/recover/password/index.vue +113 -80
- package/app/pages/anmelden.vue +11 -10
- package/app/pages/bestellung/[id]/erfolg.vue +1 -15
- package/app/pages/bestellung/[id]/fehler.vue +63 -51
- package/app/pages/bestellung/[id]/index.vue +3 -85
- package/app/pages/bestellung/kasse.vue +29 -0
- package/app/pages/bestellung.vue +8 -60
- package/app/pages/index.vue +12 -52
- package/app/pages/kontakt.vue +27 -7
- package/app/pages/konto/adressen.vue +106 -102
- package/app/pages/konto/bestellung/[id].vue +9 -43
- package/app/pages/konto/bestellungen.vue +55 -33
- package/app/pages/konto/index.vue +47 -62
- package/app/pages/konto/profil.vue +162 -100
- package/app/pages/maintenance.vue +8 -6
- package/app/pages/merkliste.vue +7 -8
- package/app/pages/passwort-vergessen.vue +92 -75
- package/app/pages/registrierung/bestaetigen.vue +20 -48
- package/app/pages/registrierung/index.vue +16 -7
- package/app/pages/suche.vue +94 -95
- package/app/plugins/theme-preset.ts +9 -0
- package/app/utils/highlight.ts +25 -0
- package/app/utils/product.ts +9 -0
- package/app/validation/registrationSchema.ts +1 -1
- package/modules/theme.ts +123 -0
- package/nuxt.config.ts +30 -16
- package/package.json +6 -8
- package/playwright.config.ts +11 -0
- package/server/api/listing/[categoryId].get.ts +3 -0
- package/shared/theme/presets.ts +303 -0
- package/test/a11y/presets.test.ts +225 -0
- package/test/layer/nuxt.config.ts +8 -0
- package/test/nuxt/AccountPagesPreset.test.ts +191 -0
- package/test/nuxt/AuthPagesPreset.test.ts +87 -0
- package/test/nuxt/CartCheckoutPreset.test.ts +154 -0
- package/test/nuxt/CartItem.test.ts +18 -3
- package/test/nuxt/CartUpsell.test.ts +1 -2
- package/test/nuxt/CheckoutFormsPreset.test.ts +120 -0
- package/test/nuxt/CheckoutOnePage.test.ts +115 -0
- package/test/nuxt/CheckoutSummary.test.ts +6 -6
- package/test/nuxt/CheckoutVoucherInput.test.ts +20 -32
- package/test/nuxt/ContactFormPreset.test.ts +115 -0
- package/test/nuxt/FooterStoreStatus.test.ts +2 -2
- package/test/nuxt/HeaderFooterPreset.test.ts +134 -0
- package/test/nuxt/HomeFaq.test.ts +3 -2
- package/test/nuxt/MenuBonCard.test.ts +122 -0
- package/test/nuxt/OrderPagesPreset.test.ts +132 -0
- package/test/nuxt/PaymentAndDelivery.test.ts +0 -4
- package/test/nuxt/ProductCrossSelling.test.ts +2 -1
- package/test/nuxt/ProductDeselectIngredient.test.ts +5 -3
- package/test/nuxt/ProductSheetPreset.test.ts +105 -0
- package/test/nuxt/RegisterConfirmPage.test.ts +0 -8
- package/test/nuxt/RegistrationForm.test.ts +89 -270
- package/test/nuxt/SbBaseComponents.test.ts +170 -0
- package/test/nuxt/SbStars.test.ts +25 -0
- package/test/nuxt/useCartMutations.test.ts +3 -17
- package/test/nuxt/useCartUpsell.test.ts +1 -1
- package/test/nuxt/useCheckoutMethodGuard.test.ts +0 -27
- package/test/nuxt/useShareLink.test.ts +1 -9
- package/test/nuxt/useWishlistActions.test.ts +3 -26
- package/test/unit/highlight.spec.ts +31 -0
- package/test/unit/product.spec.ts +12 -0
- package/test/unit/themePresets.spec.ts +61 -0
- package/app/app.config.ts +0 -19
- package/app/components/AnimatedSection.vue +0 -74
- package/app/components/BottomNavi.vue +0 -70
- package/app/components/Category/Header.vue +0 -48
- package/app/components/Checkout/PaymentMethod.vue +0 -30
- package/app/components/Checkout/ShippingMethod.vue +0 -30
- package/app/components/Cta.vue +0 -30
- package/app/components/Feature/Card.vue +0 -121
- package/app/components/Features.vue +0 -42
- package/app/components/Footer/Contact.vue +0 -82
- package/app/components/Header/Body.vue +0 -82
- package/app/components/Header/Right.vue +0 -187
- package/app/components/Header/Title.vue +0 -10
- package/app/components/Hero.vue +0 -233
- package/app/components/Home/MenuCategories.vue +0 -148
- package/app/components/ImageGallery.vue +0 -63
- package/app/components/Loading.vue +0 -29
- package/app/components/Navigation/DesktopLeft.vue +0 -39
- package/app/components/Product/Card.vue +0 -177
- package/app/components/Product/CardCompact.vue +0 -72
- package/app/components/Product/CardDietBadges.vue +0 -43
- package/app/components/Product/CardIngredients.vue +0 -35
- package/app/components/Product/CardKitchen.vue +0 -34
- package/app/components/Product/SearchBar.vue +0 -95
- package/app/components/PublicAnnouncement.vue +0 -17
- package/app/pages/bestellung/bestaetigen.vue +0 -16
- package/app/pages/bestellung/warenkorb.vue +0 -49
- package/app/pages/bestellung/zahlung-versand.vue +0 -25
- package/test/nuxt/AddressFields.test.ts +0 -222
- package/test/nuxt/AnimatedSection.test.ts +0 -67
- package/test/nuxt/ContactForm.test.ts +0 -207
- package/test/nuxt/FooterContact.test.ts +0 -102
- package/test/nuxt/HeaderRight.test.ts +0 -142
- package/test/nuxt/Hero.test.ts +0 -126
- package/test/nuxt/HomeMenuCategories.test.ts +0 -94
- package/test/nuxt/LoginForm.test.ts +0 -159
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
3
|
-
import ContactForm from "~/components/Contact/Form.vue";
|
|
4
|
-
|
|
5
|
-
type ContactFormVm = {
|
|
6
|
-
submitted: boolean;
|
|
7
|
-
successMessage: string;
|
|
8
|
-
onSubmit: (arg: {
|
|
9
|
-
data: Record<string, string | undefined>;
|
|
10
|
-
}) => Promise<void>;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const { mockInvoke } = vi.hoisted(() => {
|
|
14
|
-
return {
|
|
15
|
-
mockInvoke: vi.fn(),
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
mockNuxtImport("useShopwareContext", () => () => ({
|
|
20
|
-
apiClient: {
|
|
21
|
-
invoke: mockInvoke,
|
|
22
|
-
},
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
mockNuxtImport("useSalutations", () => () => ({
|
|
26
|
-
getSalutations: ref([
|
|
27
|
-
{ id: "1", displayName: "Herr" },
|
|
28
|
-
{ id: "2", displayName: "Frau" },
|
|
29
|
-
]),
|
|
30
|
-
}));
|
|
31
|
-
|
|
32
|
-
const mockToastAdd = vi.fn();
|
|
33
|
-
mockNuxtImport("useToast", () => () => ({
|
|
34
|
-
add: mockToastAdd,
|
|
35
|
-
}));
|
|
36
|
-
|
|
37
|
-
describe("ContactForm", () => {
|
|
38
|
-
beforeEach(() => {
|
|
39
|
-
vi.clearAllMocks();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("submits the form and shows success message component with custom individualSuccessMessage", async () => {
|
|
43
|
-
const customMessage = "Vielen Dank für deine Nachricht!";
|
|
44
|
-
mockInvoke.mockResolvedValueOnce({
|
|
45
|
-
data: {
|
|
46
|
-
individualSuccessMessage: customMessage,
|
|
47
|
-
apiAlias: "contact_form_result",
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const wrapper = await mountSuspended(ContactForm);
|
|
52
|
-
|
|
53
|
-
const validData = {
|
|
54
|
-
salutationId: "1",
|
|
55
|
-
firstName: "Max",
|
|
56
|
-
lastName: "Mustermann",
|
|
57
|
-
email: "max@example.com",
|
|
58
|
-
phone: "01234 567890",
|
|
59
|
-
subject: "Frage zum Produkt",
|
|
60
|
-
comment: "Ich habe eine Frage zu Ihrem Produkt.",
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
await (wrapper.vm as unknown as ContactFormVm).onSubmit({
|
|
64
|
-
data: validData,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
expect(mockInvoke).toHaveBeenCalled();
|
|
68
|
-
expect(mockToastAdd).toHaveBeenCalledWith(
|
|
69
|
-
expect.objectContaining({
|
|
70
|
-
description: customMessage,
|
|
71
|
-
color: "success",
|
|
72
|
-
}),
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
// Verify submitted state
|
|
76
|
-
expect((wrapper.vm as unknown as ContactFormVm).submitted).toBe(true);
|
|
77
|
-
expect((wrapper.vm as unknown as ContactFormVm).successMessage).toBe(
|
|
78
|
-
customMessage,
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
// Wait for DOM update
|
|
82
|
-
await nextTick();
|
|
83
|
-
|
|
84
|
-
// Check if success message is displayed in the template
|
|
85
|
-
expect(wrapper.text()).toContain(customMessage);
|
|
86
|
-
expect(wrapper.text()).toContain("Weiteres Formular senden");
|
|
87
|
-
expect(wrapper.find("form").exists()).toBe(false);
|
|
88
|
-
|
|
89
|
-
// Click on "Weiteres Formular senden"
|
|
90
|
-
await wrapper.find("button").trigger("click");
|
|
91
|
-
expect((wrapper.vm as unknown as ContactFormVm).submitted).toBe(false);
|
|
92
|
-
|
|
93
|
-
await nextTick();
|
|
94
|
-
expect(wrapper.find("form").exists()).toBe(true);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("submits the form and shows default success message if individualSuccessMessage is empty", async () => {
|
|
98
|
-
mockInvoke.mockResolvedValueOnce({
|
|
99
|
-
data: {
|
|
100
|
-
individualSuccessMessage: "",
|
|
101
|
-
apiAlias: "contact_form_result",
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
const wrapper = await mountSuspended(ContactForm);
|
|
106
|
-
|
|
107
|
-
const validData = {
|
|
108
|
-
salutationId: "1",
|
|
109
|
-
firstName: "Max",
|
|
110
|
-
lastName: "Mustermann",
|
|
111
|
-
email: "max@example.com",
|
|
112
|
-
phone: "01234 567890",
|
|
113
|
-
subject: "Frage zum Produkt",
|
|
114
|
-
comment: "Ich habe eine Frage zu Ihrem Produkt.",
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
await (wrapper.vm as unknown as ContactFormVm).onSubmit({
|
|
118
|
-
data: validData,
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
const defaultMessage = "Deine Nachricht wurde erfolgreich versendet.";
|
|
122
|
-
expect((wrapper.vm as unknown as ContactFormVm).successMessage).toBe(
|
|
123
|
-
defaultMessage,
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
await nextTick();
|
|
127
|
-
expect(wrapper.text()).toContain(defaultMessage);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it("submits the form with only mandatory fields", async () => {
|
|
131
|
-
mockInvoke.mockResolvedValueOnce({
|
|
132
|
-
data: {
|
|
133
|
-
individualSuccessMessage: "",
|
|
134
|
-
apiAlias: "contact_form_result",
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
const wrapper = await mountSuspended(ContactForm);
|
|
139
|
-
|
|
140
|
-
const mandatoryDataOnly = {
|
|
141
|
-
email: "test@example.com",
|
|
142
|
-
subject: "Nur Betreff",
|
|
143
|
-
comment: "Dies ist ein Test mit nur Pflichtfeldern.",
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
await (wrapper.vm as unknown as ContactFormVm).onSubmit({
|
|
147
|
-
data: mandatoryDataOnly,
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
expect(mockInvoke).toHaveBeenCalledWith(
|
|
151
|
-
"sendContactMail post /contact-form",
|
|
152
|
-
{
|
|
153
|
-
body: expect.objectContaining({
|
|
154
|
-
email: "test@example.com",
|
|
155
|
-
subject: "Nur Betreff",
|
|
156
|
-
comment: "Dies ist ein Test mit nur Pflichtfeldern.",
|
|
157
|
-
}),
|
|
158
|
-
},
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
expect((wrapper.vm as unknown as ContactFormVm).submitted).toBe(true);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it("shows error toast when submission fails", async () => {
|
|
165
|
-
mockInvoke.mockRejectedValueOnce(new Error("Network error"));
|
|
166
|
-
|
|
167
|
-
const wrapper = await mountSuspended(ContactForm);
|
|
168
|
-
|
|
169
|
-
const validData = {
|
|
170
|
-
salutationId: "2",
|
|
171
|
-
firstName: "Erika",
|
|
172
|
-
lastName: "Musterfrau",
|
|
173
|
-
email: "erika@example.com",
|
|
174
|
-
phone: "09876 54321",
|
|
175
|
-
subject: "Supportanfrage",
|
|
176
|
-
comment: "Bitte um Unterstützung.",
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
await (wrapper.vm as unknown as ContactFormVm).onSubmit({
|
|
180
|
-
data: validData,
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
expect(mockInvoke).toHaveBeenCalled();
|
|
184
|
-
|
|
185
|
-
expect(mockToastAdd).toHaveBeenCalledWith(
|
|
186
|
-
expect.objectContaining({
|
|
187
|
-
title: "Fehler!",
|
|
188
|
-
color: "error",
|
|
189
|
-
}),
|
|
190
|
-
);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
it("does not call API but marks form as submitted when honeypot is filled", async () => {
|
|
194
|
-
mockInvoke.mockClear();
|
|
195
|
-
mockToastAdd.mockClear();
|
|
196
|
-
const wrapper = await mountSuspended(ContactForm);
|
|
197
|
-
const botData = {
|
|
198
|
-
email: "bot@example.com",
|
|
199
|
-
subject: "Bot request",
|
|
200
|
-
comment: "This is spam.",
|
|
201
|
-
hp: "I am a bot",
|
|
202
|
-
};
|
|
203
|
-
await (wrapper.vm as unknown as ContactFormVm).onSubmit({ data: botData });
|
|
204
|
-
expect(mockInvoke).not.toHaveBeenCalled();
|
|
205
|
-
expect((wrapper.vm as unknown as ContactFormVm).submitted).toBe(true);
|
|
206
|
-
});
|
|
207
|
-
});
|
|
@@ -1,102 +0,0 @@
|
|
|
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 FooterContact from "~/components/Footer/Contact.vue";
|
|
5
|
-
|
|
6
|
-
const { businessHours } = vi.hoisted(() => ({
|
|
7
|
-
businessHours: {
|
|
8
|
-
value: [] as Array<{
|
|
9
|
-
dayOfWeek: number;
|
|
10
|
-
openingTime: string;
|
|
11
|
-
closingTime: string;
|
|
12
|
-
}>,
|
|
13
|
-
},
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
mockNuxtImport("useBusinessHours", () => () => ({
|
|
17
|
-
businessHours: ref(businessHours.value),
|
|
18
|
-
refresh: vi.fn(),
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
mockNuxtImport("useStoreStatus", () => () => ({
|
|
22
|
-
status: ref(null),
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
// A useRuntimeConfig mock would also have to provide `app.baseURL` for the
|
|
26
|
-
// router setup of the test environment; setting the real config is simpler.
|
|
27
|
-
function setSite(site: {
|
|
28
|
-
street?: string;
|
|
29
|
-
postalCode?: string;
|
|
30
|
-
city?: string;
|
|
31
|
-
telephone?: string;
|
|
32
|
-
googleBusinessProfileUrl?: string;
|
|
33
|
-
}) {
|
|
34
|
-
const config = useRuntimeConfig().public.site;
|
|
35
|
-
Object.assign(config, {
|
|
36
|
-
name: "Pizzeria Test",
|
|
37
|
-
telephone: site.telephone ?? "",
|
|
38
|
-
googleBusinessProfileUrl: site.googleBusinessProfileUrl ?? "",
|
|
39
|
-
});
|
|
40
|
-
Object.assign(config.address, {
|
|
41
|
-
street: site.street ?? "",
|
|
42
|
-
postalCode: site.postalCode ?? "",
|
|
43
|
-
city: site.city ?? "",
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
describe("FooterContact", () => {
|
|
48
|
-
beforeEach(() => {
|
|
49
|
-
businessHours.value = [];
|
|
50
|
-
setSite({});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("renders address, phone link, Google link and grouped opening hours", async () => {
|
|
54
|
-
setSite({
|
|
55
|
-
street: "Kantstr. 6",
|
|
56
|
-
postalCode: "63179",
|
|
57
|
-
city: "Obertshausen",
|
|
58
|
-
telephone: "+49 6104 71427",
|
|
59
|
-
googleBusinessProfileUrl: "https://maps.google.com/?cid=123",
|
|
60
|
-
});
|
|
61
|
-
businessHours.value = [
|
|
62
|
-
{ dayOfWeek: 1, openingTime: "11:30:00", closingTime: "14:30:00" },
|
|
63
|
-
{ dayOfWeek: 3, openingTime: "11:30:00", closingTime: "14:30:00" },
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
const wrapper = await mountSuspended(FooterContact);
|
|
67
|
-
const text = wrapper.text();
|
|
68
|
-
|
|
69
|
-
expect(wrapper.find("address").exists()).toBe(true);
|
|
70
|
-
expect(text).toContain("Pizzeria Test");
|
|
71
|
-
expect(text).toContain("Kantstr. 6");
|
|
72
|
-
expect(text).toContain("63179 Obertshausen");
|
|
73
|
-
expect(wrapper.find('a[href="tel:+49610471427"]').text()).toContain(
|
|
74
|
-
"+49 6104 71427",
|
|
75
|
-
);
|
|
76
|
-
expect(
|
|
77
|
-
wrapper.find('a[href="https://maps.google.com/?cid=123"]').exists(),
|
|
78
|
-
).toBe(true);
|
|
79
|
-
expect(text).toContain("Öffnungszeiten");
|
|
80
|
-
expect(text).toContain("Di");
|
|
81
|
-
expect(text).toContain("Ruhetag");
|
|
82
|
-
expect(text).toContain("11:30–14:30");
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("hides empty contact values", async () => {
|
|
86
|
-
setSite({ city: "Obertshausen" });
|
|
87
|
-
|
|
88
|
-
const wrapper = await mountSuspended(FooterContact);
|
|
89
|
-
|
|
90
|
-
expect(wrapper.text()).toContain("Obertshausen");
|
|
91
|
-
expect(wrapper.find('a[href^="tel:"]').exists()).toBe(false);
|
|
92
|
-
expect(wrapper.text()).not.toContain("Auf Google ansehen");
|
|
93
|
-
expect(wrapper.text()).not.toContain("Öffnungszeiten");
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("renders nothing without contact data and opening hours", async () => {
|
|
97
|
-
const wrapper = await mountSuspended(FooterContact);
|
|
98
|
-
|
|
99
|
-
expect(wrapper.find("address").exists()).toBe(false);
|
|
100
|
-
expect(wrapper.text()).toBe("");
|
|
101
|
-
});
|
|
102
|
-
});
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
3
|
-
import HeaderRight from "~/components/Header/Right.vue";
|
|
4
|
-
import { ref, reactive, computed } from "vue";
|
|
5
|
-
|
|
6
|
-
const mocks = vi.hoisted(() => ({
|
|
7
|
-
state: {
|
|
8
|
-
isLoggedIn: false,
|
|
9
|
-
isGuestSession: false,
|
|
10
|
-
user: null as { firstName: string; lastName: string } | null,
|
|
11
|
-
telephone: "+49 6104 71427",
|
|
12
|
-
},
|
|
13
|
-
toastAddCalled: { value: false },
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
const reactiveState = reactive(mocks.state);
|
|
17
|
-
|
|
18
|
-
mockNuxtImport("useUser", () => () => ({
|
|
19
|
-
isLoggedIn: computed(() => reactiveState.isLoggedIn),
|
|
20
|
-
isGuestSession: computed(() => reactiveState.isGuestSession),
|
|
21
|
-
user: computed(() => reactiveState.user),
|
|
22
|
-
logout: () => {
|
|
23
|
-
reactiveState.isLoggedIn = false;
|
|
24
|
-
reactiveState.user = null;
|
|
25
|
-
},
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
mockNuxtImport("useToast", () => () => ({
|
|
29
|
-
add: (_payload: unknown) => {
|
|
30
|
-
mocks.toastAddCalled.value = true;
|
|
31
|
-
},
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
mockNuxtImport("useShopBiteConfig", () => () => ({
|
|
35
|
-
isCheckoutEnabled: ref(true),
|
|
36
|
-
}));
|
|
37
|
-
|
|
38
|
-
mockNuxtImport("useCart", () => () => ({
|
|
39
|
-
count: ref(5),
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
mockNuxtImport("useRuntimeConfig", () => () => ({
|
|
43
|
-
app: { baseURL: "/" },
|
|
44
|
-
public: { shopware: {}, site: { telephone: mocks.state.telephone } },
|
|
45
|
-
}));
|
|
46
|
-
|
|
47
|
-
mockNuxtImport("useWishlist", () => () => ({
|
|
48
|
-
count: ref(0),
|
|
49
|
-
}));
|
|
50
|
-
|
|
51
|
-
// Mock Nuxt Content queryCollection
|
|
52
|
-
mockNuxtImport("queryCollection", () => (_collection: string) => ({
|
|
53
|
-
first: () =>
|
|
54
|
-
Promise.resolve({
|
|
55
|
-
account: {
|
|
56
|
-
loggedIn: [
|
|
57
|
-
[{ label: "Mein Konto", type: "label" }],
|
|
58
|
-
[
|
|
59
|
-
{
|
|
60
|
-
label: "Bestellungen",
|
|
61
|
-
icon: "i-lucide-pizza",
|
|
62
|
-
to: "/konto/bestellungen",
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
[{ label: "Abmelden", icon: "i-lucide-log-out", action: "logout" }],
|
|
66
|
-
],
|
|
67
|
-
loggedOut: [
|
|
68
|
-
[{ label: "Jetzt anmelden", type: "label" }],
|
|
69
|
-
[{ label: "Zur Anmeldung", icon: "i-lucide-user", to: "/anmelden" }],
|
|
70
|
-
],
|
|
71
|
-
},
|
|
72
|
-
}),
|
|
73
|
-
}));
|
|
74
|
-
|
|
75
|
-
describe("HeaderRight", () => {
|
|
76
|
-
beforeEach(() => {
|
|
77
|
-
reactiveState.isLoggedIn = false;
|
|
78
|
-
reactiveState.isGuestSession = false;
|
|
79
|
-
reactiveState.user = null;
|
|
80
|
-
mocks.toastAddCalled.value = false;
|
|
81
|
-
vi.clearAllMocks();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("renders the phone link from the site config", async () => {
|
|
85
|
-
const component = await mountSuspended(HeaderRight);
|
|
86
|
-
const phoneButton = component.find('a[href="tel:+49610471427"]');
|
|
87
|
-
expect(phoneButton.exists()).toBe(true);
|
|
88
|
-
expect(phoneButton.attributes("aria-label")).toBe(
|
|
89
|
-
"Anrufen: +49 6104 71427",
|
|
90
|
-
);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("hides the phone link without a configured number", async () => {
|
|
94
|
-
mocks.state.telephone = "";
|
|
95
|
-
const component = await mountSuspended(HeaderRight);
|
|
96
|
-
expect(component.find('a[href^="tel:"]').exists()).toBe(false);
|
|
97
|
-
mocks.state.telephone = "+49 6104 71427";
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it("shows logged out dropdown items when not logged in", async () => {
|
|
101
|
-
const component = await mountSuspended(HeaderRight);
|
|
102
|
-
const dropdown = component.findComponent({ name: "UDropdownMenu" });
|
|
103
|
-
const items = dropdown.props("items");
|
|
104
|
-
|
|
105
|
-
expect(items[0][0].label).toBe("Mein Konto");
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("shows logged in dropdown items when logged in", async () => {
|
|
109
|
-
reactiveState.isLoggedIn = true;
|
|
110
|
-
reactiveState.user = { firstName: "Jane", lastName: "Doe" };
|
|
111
|
-
|
|
112
|
-
const component = await mountSuspended(HeaderRight);
|
|
113
|
-
const dropdown = component.findComponent({ name: "UDropdownMenu" });
|
|
114
|
-
const items = dropdown.props("items");
|
|
115
|
-
|
|
116
|
-
expect(items[0][0].label).toBe("Mein Konto");
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("calls logout and updates state when logout is selected", async () => {
|
|
120
|
-
reactiveState.isLoggedIn = true;
|
|
121
|
-
const component = await mountSuspended(HeaderRight);
|
|
122
|
-
const dropdown = component.findComponent({ name: "UDropdownMenu" });
|
|
123
|
-
const items = dropdown.props("items");
|
|
124
|
-
|
|
125
|
-
// Find the item with logout handler
|
|
126
|
-
let logoutItem;
|
|
127
|
-
for (const group of items) {
|
|
128
|
-
for (const item of group) {
|
|
129
|
-
if (item.label === "Abmelden") {
|
|
130
|
-
logoutItem = item;
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
expect(logoutItem).toBeDefined();
|
|
137
|
-
logoutItem.onSelect();
|
|
138
|
-
|
|
139
|
-
expect(reactiveState.isLoggedIn).toBe(false);
|
|
140
|
-
expect(mocks.toastAddCalled.value).toBe(true);
|
|
141
|
-
});
|
|
142
|
-
});
|
package/test/nuxt/Hero.test.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, afterEach } from "vitest";
|
|
2
|
-
import { mockNuxtImport, mountSuspended } from "@nuxt/test-utils/runtime";
|
|
3
|
-
import { computed, nextTick, ref } from "vue";
|
|
4
|
-
import Hero from "~/components/Hero.vue";
|
|
5
|
-
import type { StoreStatus } from "~/composables/useStoreStatus";
|
|
6
|
-
|
|
7
|
-
const { liveState } = vi.hoisted(() => ({
|
|
8
|
-
liveState: {
|
|
9
|
-
status: null as StoreStatus | null,
|
|
10
|
-
isCheckoutEnabled: true,
|
|
11
|
-
},
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
mockNuxtImport("useStoreStatus", () => () => ({
|
|
15
|
-
status: ref(liveState.status),
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
|
-
mockNuxtImport("useShopBiteConfig", () => () => ({
|
|
19
|
-
deliveryTime: computed(() => 30),
|
|
20
|
-
isCheckoutEnabled: computed(() => liveState.isCheckoutEnabled),
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
const props = {
|
|
24
|
-
title: "Pizzeria",
|
|
25
|
-
links: [],
|
|
26
|
-
backgroundVideo: "https://cdn.example.com/hero.mp4",
|
|
27
|
-
poster: "/hero-poster.webp",
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
function stubMatchMedia(matches: boolean) {
|
|
31
|
-
const listeners: Array<(event: { matches: boolean }) => void> = [];
|
|
32
|
-
vi.stubGlobal("matchMedia", (query: string) => ({
|
|
33
|
-
matches,
|
|
34
|
-
media: query,
|
|
35
|
-
addEventListener: (_: string, listener: (typeof listeners)[number]) =>
|
|
36
|
-
listeners.push(listener),
|
|
37
|
-
}));
|
|
38
|
-
return (next: boolean) =>
|
|
39
|
-
listeners.forEach((listener) => listener({ matches: next }));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
describe("Hero", () => {
|
|
43
|
-
afterEach(() => {
|
|
44
|
-
vi.unstubAllGlobals();
|
|
45
|
-
liveState.status = null;
|
|
46
|
-
liveState.isCheckoutEnabled = true;
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("shows the delivery time before the store status is known", async () => {
|
|
50
|
-
stubMatchMedia(false);
|
|
51
|
-
|
|
52
|
-
const wrapper = await mountSuspended(Hero, { props });
|
|
53
|
-
|
|
54
|
-
expect(wrapper.find('[data-testid="hero-status"]').exists()).toBe(false);
|
|
55
|
-
const delivery = wrapper.find('[data-testid="hero-delivery"]');
|
|
56
|
-
expect(delivery.text()).toBe("Lieferung ca. 30 Min");
|
|
57
|
-
// Phones show it in its own row; from sm it waits for the status.
|
|
58
|
-
expect(delivery.classes()).toContain("sm:hidden");
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("shows status and delivery time side by side once the status is known", async () => {
|
|
62
|
-
stubMatchMedia(false);
|
|
63
|
-
liveState.status = { open: false, nextOpening: "17:30 Uhr" };
|
|
64
|
-
|
|
65
|
-
const wrapper = await mountSuspended(Hero, { props });
|
|
66
|
-
|
|
67
|
-
expect(wrapper.find('[data-testid="hero-status"]').text()).toBe(
|
|
68
|
-
"Geschlossen · öffnet 17:30 Uhr",
|
|
69
|
-
);
|
|
70
|
-
expect(
|
|
71
|
-
wrapper.find('[data-testid="hero-delivery"]').classes(),
|
|
72
|
-
).not.toContain("sm:hidden");
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("hides the delivery time when the checkout is disabled", async () => {
|
|
76
|
-
stubMatchMedia(false);
|
|
77
|
-
liveState.status = { open: true, closesAt: "23:00" };
|
|
78
|
-
liveState.isCheckoutEnabled = false;
|
|
79
|
-
|
|
80
|
-
const wrapper = await mountSuspended(Hero, { props });
|
|
81
|
-
|
|
82
|
-
expect(wrapper.find('[data-testid="hero-status"]').text()).toBe(
|
|
83
|
-
"Geöffnet bis 23:00",
|
|
84
|
-
);
|
|
85
|
-
expect(wrapper.find('[data-testid="hero-delivery"]').exists()).toBe(false);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it("renders the poster as high-priority image and no video on narrow screens", async () => {
|
|
89
|
-
stubMatchMedia(false);
|
|
90
|
-
|
|
91
|
-
const wrapper = await mountSuspended(Hero, { props });
|
|
92
|
-
|
|
93
|
-
const poster = wrapper.find("img");
|
|
94
|
-
expect(poster.attributes("src")).toBe("/hero-poster.webp");
|
|
95
|
-
expect(poster.attributes("fetchpriority")).toBe("high");
|
|
96
|
-
expect(wrapper.find("video").exists()).toBe(false);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it("adds the video on wide screens, with the poster and without eager loading", async () => {
|
|
100
|
-
const changeViewport = stubMatchMedia(true);
|
|
101
|
-
|
|
102
|
-
const wrapper = await mountSuspended(Hero, { props });
|
|
103
|
-
|
|
104
|
-
const video = wrapper.find("video");
|
|
105
|
-
expect(video.exists()).toBe(true);
|
|
106
|
-
expect(video.attributes("poster")).toBe("/hero-poster.webp");
|
|
107
|
-
expect(video.attributes("preload")).toBe("metadata");
|
|
108
|
-
expect(video.attributes("fetchpriority")).toBeUndefined();
|
|
109
|
-
expect(video.find("source").attributes("src")).toBe(props.backgroundVideo);
|
|
110
|
-
|
|
111
|
-
changeViewport(false);
|
|
112
|
-
await nextTick();
|
|
113
|
-
expect(wrapper.find("video").exists()).toBe(false);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("renders neither poster nor video without media", async () => {
|
|
117
|
-
stubMatchMedia(true);
|
|
118
|
-
|
|
119
|
-
const wrapper = await mountSuspended(Hero, {
|
|
120
|
-
props: { title: "Pizzeria", links: [] },
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
expect(wrapper.find("img").exists()).toBe(false);
|
|
124
|
-
expect(wrapper.find("video").exists()).toBe(false);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
import { mockNuxtImport, mountSuspended } from "@nuxt/test-utils/runtime";
|
|
3
|
-
import HomeMenuCategories from "~/components/Home/MenuCategories.vue";
|
|
4
|
-
|
|
5
|
-
const { mockInvoke } = vi.hoisted(() => ({
|
|
6
|
-
mockInvoke: vi.fn(),
|
|
7
|
-
}));
|
|
8
|
-
|
|
9
|
-
mockNuxtImport("useShopwareContext", () => () => ({
|
|
10
|
-
apiClient: { invoke: mockInvoke },
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
function category(
|
|
14
|
-
id: string,
|
|
15
|
-
name: string,
|
|
16
|
-
extra: Record<string, unknown> = {},
|
|
17
|
-
) {
|
|
18
|
-
return {
|
|
19
|
-
id,
|
|
20
|
-
name,
|
|
21
|
-
translated: { name },
|
|
22
|
-
seoUrl: `/Speisekarte/${name}/`,
|
|
23
|
-
customFields: { shopbite_category_icon: "i-lucide-pizza" },
|
|
24
|
-
media: null,
|
|
25
|
-
...extra,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
describe("HomeMenuCategories", () => {
|
|
30
|
-
beforeEach(() => {
|
|
31
|
-
mockInvoke.mockReset();
|
|
32
|
-
// useAsyncData keeps the last answer under its key across the cases
|
|
33
|
-
clearNuxtData("home-menu-categories");
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("renders one tile per menu section with its photo or icon", async () => {
|
|
37
|
-
mockInvoke.mockResolvedValue({
|
|
38
|
-
data: [
|
|
39
|
-
category("1", "Pizza", {
|
|
40
|
-
media: {
|
|
41
|
-
url: "https://cdn.example.com/pizza.jpg",
|
|
42
|
-
thumbnails: [
|
|
43
|
-
{ url: "https://cdn.example.com/pizza-400.jpg", width: 400 },
|
|
44
|
-
],
|
|
45
|
-
metaData: { width: 800, height: 600 },
|
|
46
|
-
},
|
|
47
|
-
}),
|
|
48
|
-
category("2", "Pasta"),
|
|
49
|
-
],
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const wrapper = await mountSuspended(HomeMenuCategories, {
|
|
53
|
-
props: { title: "Unsere Speisekarte" },
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const tiles = wrapper.findAll("[data-testid=menu-categories] li");
|
|
57
|
-
expect(tiles).toHaveLength(2);
|
|
58
|
-
expect(tiles[0]?.find("a").attributes("href")).toBe("/Speisekarte/Pizza/");
|
|
59
|
-
expect(tiles[0]?.find("img").attributes("srcset")).toContain("400w");
|
|
60
|
-
expect(tiles[1]?.find("img").exists()).toBe(false);
|
|
61
|
-
expect(wrapper.text()).toContain("Pasta");
|
|
62
|
-
|
|
63
|
-
const [operation, options] = mockInvoke.mock.calls[0] ?? [];
|
|
64
|
-
expect(operation).toBe(
|
|
65
|
-
"readNavigation post /navigation/{activeId}/{rootId}",
|
|
66
|
-
);
|
|
67
|
-
expect(options.body.includes.category).toContain("media");
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("caps the tiles and links to the whole menu", async () => {
|
|
71
|
-
mockInvoke.mockResolvedValue({
|
|
72
|
-
data: Array.from({ length: 4 }, (_, i) =>
|
|
73
|
-
category(String(i), `Bereich ${i}`),
|
|
74
|
-
),
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const wrapper = await mountSuspended(HomeMenuCategories, {
|
|
78
|
-
props: { limit: 3 },
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
const tiles = wrapper.findAll("[data-testid=menu-categories] li");
|
|
82
|
-
expect(tiles).toHaveLength(4);
|
|
83
|
-
expect(tiles[3]?.find("a").attributes("href")).toBe("/speisekarte/");
|
|
84
|
-
expect(tiles[3]?.text()).toContain("4 Bereiche");
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("renders nothing without menu sections", async () => {
|
|
88
|
-
mockInvoke.mockResolvedValue({ data: [] });
|
|
89
|
-
|
|
90
|
-
const wrapper = await mountSuspended(HomeMenuCategories);
|
|
91
|
-
|
|
92
|
-
expect(wrapper.find("[data-testid=menu-categories]").exists()).toBe(false);
|
|
93
|
-
});
|
|
94
|
-
});
|