@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
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
3
|
+
import { flushPromises } from "@vue/test-utils";
|
|
4
|
+
import { defineComponent, h, onMounted, ref } from "vue";
|
|
5
|
+
import Summary from "~/components/Checkout/Summary.vue";
|
|
6
|
+
|
|
7
|
+
// One-page checkout of a shop with a style preset (#443).
|
|
8
|
+
const { state, mocks } = vi.hoisted(() => ({
|
|
9
|
+
state: { guest: true },
|
|
10
|
+
mocks: {
|
|
11
|
+
createOrder: vi.fn(),
|
|
12
|
+
},
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
mockNuxtImport("useThemePreset", () => () => ({
|
|
16
|
+
preset: "trattoria",
|
|
17
|
+
menuView: "bon",
|
|
18
|
+
colorMode: "light",
|
|
19
|
+
}));
|
|
20
|
+
mockNuxtImport("useOpeningHoursData", () => () => ({
|
|
21
|
+
isLoading: ref(false),
|
|
22
|
+
hasFailed: ref(false),
|
|
23
|
+
}));
|
|
24
|
+
mockNuxtImport("useCheckout", () => () => ({
|
|
25
|
+
createOrder: mocks.createOrder,
|
|
26
|
+
selectedPaymentMethod: ref({ id: "pm1" }),
|
|
27
|
+
selectedShippingMethod: ref({ id: "sm1" }),
|
|
28
|
+
}));
|
|
29
|
+
mockNuxtImport("useCart", () => () => ({
|
|
30
|
+
refreshCart: vi.fn().mockResolvedValue(undefined),
|
|
31
|
+
}));
|
|
32
|
+
mockNuxtImport("useUser", () => () => ({
|
|
33
|
+
isLoggedIn: ref(false),
|
|
34
|
+
isGuestSession: ref(state.guest),
|
|
35
|
+
refreshUser: vi.fn(),
|
|
36
|
+
}));
|
|
37
|
+
mockNuxtImport("useShopBiteConfig", () => () => ({
|
|
38
|
+
isCheckoutEnabled: ref(true),
|
|
39
|
+
refresh: vi.fn(),
|
|
40
|
+
}));
|
|
41
|
+
mockNuxtImport("useTrackEvent", () => () => ({ trackOrder: vi.fn() }));
|
|
42
|
+
mockNuxtImport("useCheckoutMethodGuard", () => () => ({
|
|
43
|
+
isShippingMethodBlocked: ref(false),
|
|
44
|
+
isPaymentMethodBlocked: ref(false),
|
|
45
|
+
ensureAvailableCheckoutMethods: vi.fn().mockResolvedValue(true),
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
vi.mock("@shopware/composables", async (importOriginal) => ({
|
|
49
|
+
...(await importOriginal<typeof import("@shopware/composables")>()),
|
|
50
|
+
useOrderPayment: () => ({ handlePayment: vi.fn(), paymentUrl: ref(null) }),
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
const ValidTime = defineComponent({
|
|
54
|
+
emits: ["update:valid"],
|
|
55
|
+
setup(_, { emit }) {
|
|
56
|
+
onMounted(() => emit("update:valid", true));
|
|
57
|
+
return () => h("div");
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
async function mountOnePage() {
|
|
62
|
+
const wrapper = await mountSuspended(Summary, {
|
|
63
|
+
global: {
|
|
64
|
+
stubs: {
|
|
65
|
+
UserDetail: true,
|
|
66
|
+
CheckoutLoginOrRegister: true,
|
|
67
|
+
CheckoutPaymentAndDelivery: true,
|
|
68
|
+
CheckoutDeliveryTimeSelect: ValidTime,
|
|
69
|
+
CheckoutVoucherInput: true,
|
|
70
|
+
QuickView: true,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
await flushPromises();
|
|
75
|
+
return wrapper;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
describe("one-page checkout (#443)", () => {
|
|
79
|
+
beforeEach(() => {
|
|
80
|
+
vi.clearAllMocks();
|
|
81
|
+
state.guest = true;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("shows the four numbered sections and the order", async () => {
|
|
85
|
+
const wrapper = await mountOnePage();
|
|
86
|
+
expect(
|
|
87
|
+
wrapper.findAll("h2").map((h2) => h2.text().replace(/\s+/g, " ")),
|
|
88
|
+
).toEqual([
|
|
89
|
+
"1 Lieferung oder Abholung",
|
|
90
|
+
"2 Wann?",
|
|
91
|
+
"3 Ihre Angaben",
|
|
92
|
+
"4 Bezahlung",
|
|
93
|
+
"Ihre Bestellung",
|
|
94
|
+
]);
|
|
95
|
+
expect(wrapper.get("button").text()).toBe("Zahlungspflichtig bestellen");
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("asks for the customer data first", async () => {
|
|
99
|
+
state.guest = false;
|
|
100
|
+
const wrapper = await mountOnePage();
|
|
101
|
+
const button = wrapper.get("button");
|
|
102
|
+
expect(button.text()).toBe("Bitte zuerst Ihre Angaben speichern");
|
|
103
|
+
expect(button.attributes("disabled")).toBeDefined();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("shows a failed order in the form", async () => {
|
|
107
|
+
mocks.createOrder.mockRejectedValue(new Error("invalid cart"));
|
|
108
|
+
const wrapper = await mountOnePage();
|
|
109
|
+
await wrapper.get("button").trigger("click");
|
|
110
|
+
await flushPromises();
|
|
111
|
+
|
|
112
|
+
const alert = wrapper.get('[role="alert"]');
|
|
113
|
+
expect(alert.text()).toContain("Bestellung fehlgeschlagen");
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -66,8 +66,8 @@ async function mountSummary() {
|
|
|
66
66
|
global: {
|
|
67
67
|
stubs: {
|
|
68
68
|
UserDetail: true,
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
CheckoutLoginOrRegister: true,
|
|
70
|
+
CheckoutPaymentAndDelivery: true,
|
|
71
71
|
CheckoutDeliveryTimeSelect: DeliveryTimeSelectStub,
|
|
72
72
|
CheckoutVoucherInput: true,
|
|
73
73
|
QuickView: true,
|
|
@@ -91,7 +91,7 @@ describe("Checkout Summary order button", () => {
|
|
|
91
91
|
|
|
92
92
|
expect(button.text()).toBe("Lade Öffnungszeiten …");
|
|
93
93
|
expect(button.attributes("disabled")).toBeDefined();
|
|
94
|
-
expect(button.
|
|
94
|
+
expect(button.attributes("aria-busy")).toBe("true");
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
it("says the opening hours could not be loaded when loading failed", async () => {
|
|
@@ -102,7 +102,7 @@ describe("Checkout Summary order button", () => {
|
|
|
102
102
|
|
|
103
103
|
expect(button.text()).toBe("Öffnungszeiten konnten nicht geladen werden");
|
|
104
104
|
expect(button.attributes("disabled")).toBeDefined();
|
|
105
|
-
expect(button.
|
|
105
|
+
expect(button.attributes("aria-busy")).toBeUndefined();
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
it("says the shop is closed once loaded without a valid time", async () => {
|
|
@@ -112,7 +112,7 @@ describe("Checkout Summary order button", () => {
|
|
|
112
112
|
|
|
113
113
|
expect(button.text()).toBe("Wir haben aktuell leider geschlossen");
|
|
114
114
|
expect(button.attributes("disabled")).toBeDefined();
|
|
115
|
-
expect(button.
|
|
115
|
+
expect(button.attributes("aria-busy")).toBeUndefined();
|
|
116
116
|
});
|
|
117
117
|
|
|
118
118
|
it("allows ordering once loaded with a valid time", async () => {
|
|
@@ -121,7 +121,7 @@ describe("Checkout Summary order button", () => {
|
|
|
121
121
|
|
|
122
122
|
const button = await mountSummary();
|
|
123
123
|
|
|
124
|
-
expect(button.text()).toBe("
|
|
124
|
+
expect(button.text()).toBe("Zahlungspflichtig bestellen");
|
|
125
125
|
expect(button.attributes("disabled")).toBeUndefined();
|
|
126
126
|
});
|
|
127
127
|
});
|
|
@@ -18,11 +18,6 @@ mockNuxtImport("useCart", () => () => ({
|
|
|
18
18
|
removeItem: mockRemoveItem,
|
|
19
19
|
}));
|
|
20
20
|
|
|
21
|
-
const mockToastAdd = vi.fn();
|
|
22
|
-
mockNuxtImport("useToast", () => () => ({
|
|
23
|
-
add: mockToastAdd,
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
21
|
describe("CheckoutVoucherInput", () => {
|
|
27
22
|
beforeEach(() => {
|
|
28
23
|
vi.clearAllMocks();
|
|
@@ -63,14 +58,12 @@ describe("CheckoutVoucherInput", () => {
|
|
|
63
58
|
await wrapper.find("input").setValue("SAVE10");
|
|
64
59
|
await nextTick();
|
|
65
60
|
|
|
66
|
-
// First invocation
|
|
67
|
-
wrapper.find("
|
|
61
|
+
// First invocation, in flight
|
|
62
|
+
wrapper.find("form").trigger("submit");
|
|
68
63
|
await nextTick();
|
|
69
64
|
|
|
70
65
|
// Second invocation while still loading
|
|
71
|
-
wrapper.find("
|
|
72
|
-
await nextTick();
|
|
73
|
-
await wrapper.find("input").trigger("keyup.enter");
|
|
66
|
+
await wrapper.find("form").trigger("submit");
|
|
74
67
|
await nextTick();
|
|
75
68
|
|
|
76
69
|
resolvePromotion();
|
|
@@ -92,7 +85,7 @@ describe("CheckoutVoucherInput", () => {
|
|
|
92
85
|
await wrapper.find("input").setValue("SAVE10");
|
|
93
86
|
await nextTick();
|
|
94
87
|
|
|
95
|
-
wrapper.find("
|
|
88
|
+
wrapper.find("form").trigger("submit");
|
|
96
89
|
await nextTick();
|
|
97
90
|
|
|
98
91
|
// While the request is in-flight both button and input must be disabled
|
|
@@ -109,15 +102,15 @@ describe("CheckoutVoucherInput", () => {
|
|
|
109
102
|
expect(wrapper.find("input").attributes("disabled")).toBeUndefined();
|
|
110
103
|
});
|
|
111
104
|
|
|
112
|
-
it("clears the input and
|
|
105
|
+
it("clears the input and shows no error on successful voucher apply", async () => {
|
|
113
106
|
mockCart.value = { errors: {} };
|
|
114
107
|
const wrapper = await mountSuspended(CheckoutVoucherInput);
|
|
115
108
|
await wrapper.find("input").setValue("SAVE10");
|
|
116
|
-
await wrapper.find("
|
|
109
|
+
await wrapper.find("form").trigger("submit");
|
|
117
110
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
118
111
|
|
|
119
112
|
expect(mockAddPromotionCode).toHaveBeenCalledWith("SAVE10");
|
|
120
|
-
expect(
|
|
113
|
+
expect(wrapper.find('[role="alert"]').exists()).toBe(false);
|
|
121
114
|
expect(wrapper.find("input").element.value).toBe("");
|
|
122
115
|
});
|
|
123
116
|
|
|
@@ -132,39 +125,34 @@ describe("CheckoutVoucherInput", () => {
|
|
|
132
125
|
};
|
|
133
126
|
const wrapper = await mountSuspended(CheckoutVoucherInput);
|
|
134
127
|
await wrapper.find("input").setValue("INVALID");
|
|
135
|
-
await wrapper.find("
|
|
128
|
+
await wrapper.find("form").trigger("submit");
|
|
136
129
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
137
130
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
color: "error",
|
|
143
|
-
}),
|
|
131
|
+
const alert = wrapper.find('[role="alert"]');
|
|
132
|
+
expect(alert.text()).toBe('Gutscheincode "INVALID" existiert nicht.');
|
|
133
|
+
expect(wrapper.find("input").attributes("aria-describedby")).toBe(
|
|
134
|
+
alert.attributes("id"),
|
|
144
135
|
);
|
|
145
136
|
expect(wrapper.find("input").element.value).toBe("INVALID");
|
|
146
137
|
});
|
|
147
138
|
|
|
148
|
-
it("shows a generic error
|
|
139
|
+
it("shows a generic error at the field when addPromotionCode throws", async () => {
|
|
149
140
|
mockAddPromotionCode.mockRejectedValueOnce(new Error("network error"));
|
|
150
141
|
const wrapper = await mountSuspended(CheckoutVoucherInput);
|
|
151
142
|
await wrapper.find("input").setValue("SAVE10");
|
|
152
|
-
await wrapper.find("
|
|
143
|
+
await wrapper.find("form").trigger("submit");
|
|
153
144
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
154
145
|
|
|
155
|
-
expect(
|
|
156
|
-
|
|
157
|
-
title: "Gutschein ungültig",
|
|
158
|
-
color: "error",
|
|
159
|
-
}),
|
|
146
|
+
expect(wrapper.find('[role="alert"]').text()).toBe(
|
|
147
|
+
"Der Gutscheincode ist ungültig oder abgelaufen.",
|
|
160
148
|
);
|
|
161
149
|
});
|
|
162
150
|
|
|
163
|
-
it("submits
|
|
151
|
+
it("submits the trimmed code with the form", async () => {
|
|
164
152
|
mockCart.value = { errors: {} };
|
|
165
153
|
const wrapper = await mountSuspended(CheckoutVoucherInput);
|
|
166
|
-
await wrapper.find("input").setValue("ENTER10");
|
|
167
|
-
await wrapper.find("
|
|
154
|
+
await wrapper.find("input").setValue(" ENTER10 ");
|
|
155
|
+
await wrapper.find("form").trigger("submit");
|
|
168
156
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
169
157
|
|
|
170
158
|
expect(mockAddPromotionCode).toHaveBeenCalledWith("ENTER10");
|
|
@@ -186,7 +174,7 @@ describe("CheckoutVoucherInput", () => {
|
|
|
186
174
|
const wrapper = await mountSuspended(CheckoutVoucherInput);
|
|
187
175
|
|
|
188
176
|
const removeButtons = wrapper.findAll(
|
|
189
|
-
'button[aria-label="Gutschein entfernen"]',
|
|
177
|
+
'button[aria-label="Gutschein 10% Rabatt entfernen"]',
|
|
190
178
|
);
|
|
191
179
|
expect(removeButtons).toHaveLength(1);
|
|
192
180
|
await removeButtons[0]!.trigger("click");
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
3
|
+
import { flushPromises } from "@vue/test-utils";
|
|
4
|
+
import ContactForm from "~/components/Contact/Form.vue";
|
|
5
|
+
|
|
6
|
+
// Contact form of the presets (#445).
|
|
7
|
+
const mocks = vi.hoisted(() => ({ invoke: vi.fn() }));
|
|
8
|
+
|
|
9
|
+
mockNuxtImport("useShopwareContext", () => () => ({
|
|
10
|
+
apiClient: { invoke: mocks.invoke },
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
const salutations = {
|
|
14
|
+
data: { elements: [{ id: "sal-none", displayName: "Keine Angabe" }] },
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** Answers the salutation request and lets `send` handle the contact mail. */
|
|
18
|
+
function mockSend(send: () => Promise<unknown>) {
|
|
19
|
+
mocks.invoke.mockImplementation(async (operation: string) =>
|
|
20
|
+
operation.includes("salutation") ? salutations : send(),
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const sendCalls = () =>
|
|
25
|
+
mocks.invoke.mock.calls.filter(
|
|
26
|
+
([operation]) => operation === "sendContactMail post /contact-form",
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
async function fill(wrapper: Awaited<ReturnType<typeof mountSuspended>>) {
|
|
30
|
+
await wrapper.find('input[name="email"]').setValue("gast@example.de");
|
|
31
|
+
await wrapper.find('input[name="subject"]').setValue("Allergene");
|
|
32
|
+
await wrapper
|
|
33
|
+
.find('textarea[name="comment"]')
|
|
34
|
+
.setValue("Ist der Teig ohne Ei gemacht?");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe("contact form with a preset (#445)", () => {
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
mocks.invoke.mockReset();
|
|
40
|
+
mockSend(async () => ({ data: {} }));
|
|
41
|
+
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("checks the fields before sending", async () => {
|
|
45
|
+
const wrapper = await mountSuspended(ContactForm);
|
|
46
|
+
await wrapper.find("form").trigger("submit");
|
|
47
|
+
await flushPromises();
|
|
48
|
+
expect(wrapper.text()).toContain("Bitte geben Sie eine gültige E-Mail");
|
|
49
|
+
expect(wrapper.text()).toContain("Bitte geben Sie einen Betreff an.");
|
|
50
|
+
expect(wrapper.text()).toContain("mindestens 10 Zeichen");
|
|
51
|
+
expect(sendCalls()).toHaveLength(0);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("sends the message and shows the shop's success text", async () => {
|
|
55
|
+
mockSend(async () => ({
|
|
56
|
+
data: { individualSuccessMessage: "Danke, wir melden uns." },
|
|
57
|
+
}));
|
|
58
|
+
const wrapper = await mountSuspended(ContactForm);
|
|
59
|
+
await fill(wrapper);
|
|
60
|
+
await wrapper.find("form").trigger("submit");
|
|
61
|
+
await flushPromises();
|
|
62
|
+
expect(mocks.invoke).toHaveBeenCalledWith(
|
|
63
|
+
"sendContactMail post /contact-form",
|
|
64
|
+
expect.objectContaining({
|
|
65
|
+
body: expect.objectContaining({
|
|
66
|
+
email: "gast@example.de",
|
|
67
|
+
subject: "Allergene",
|
|
68
|
+
}),
|
|
69
|
+
}),
|
|
70
|
+
);
|
|
71
|
+
expect(wrapper.find('[role="status"]').text()).toContain(
|
|
72
|
+
"Danke, wir melden uns.",
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("falls back to the default text and offers another message", async () => {
|
|
77
|
+
mockSend(async () => ({ data: { individualSuccessMessage: " " } }));
|
|
78
|
+
const wrapper = await mountSuspended(ContactForm);
|
|
79
|
+
await fill(wrapper);
|
|
80
|
+
await wrapper.find("form").trigger("submit");
|
|
81
|
+
await flushPromises();
|
|
82
|
+
const status = wrapper.find('[role="status"]');
|
|
83
|
+
expect(status.text()).toContain(
|
|
84
|
+
"Vielen Dank, Ihre Nachricht ist bei uns angekommen.",
|
|
85
|
+
);
|
|
86
|
+
expect(wrapper.find("form").exists()).toBe(false);
|
|
87
|
+
|
|
88
|
+
await status.find("button").trigger("click");
|
|
89
|
+
expect(wrapper.find("form").exists()).toBe(true);
|
|
90
|
+
expect(
|
|
91
|
+
(wrapper.find('input[name="email"]').element as HTMLInputElement).value,
|
|
92
|
+
).toBe("");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("ignores a filled honeypot without sending", async () => {
|
|
96
|
+
const wrapper = await mountSuspended(ContactForm);
|
|
97
|
+
await fill(wrapper);
|
|
98
|
+
await wrapper.find('input[name="hp"]').setValue("bot");
|
|
99
|
+
await wrapper.find("form").trigger("submit");
|
|
100
|
+
await flushPromises();
|
|
101
|
+
expect(sendCalls()).toHaveLength(0);
|
|
102
|
+
expect(wrapper.find('[role="status"]').exists()).toBe(true);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("reports a failed send in the form", async () => {
|
|
106
|
+
mockSend(() => Promise.reject(new Error("500")));
|
|
107
|
+
const wrapper = await mountSuspended(ContactForm);
|
|
108
|
+
await fill(wrapper);
|
|
109
|
+
await wrapper.find("form").trigger("submit");
|
|
110
|
+
await flushPromises();
|
|
111
|
+
expect(wrapper.find('[role="alert"]').text()).toContain(
|
|
112
|
+
"konnte nicht gesendet werden",
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -24,7 +24,7 @@ describe("FooterStoreStatus", () => {
|
|
|
24
24
|
const status = wrapper.find('[role="status"]');
|
|
25
25
|
|
|
26
26
|
expect(status.text()).toBe("Geöffnet bis 23:00 Uhr");
|
|
27
|
-
expect(status.find(".bg-
|
|
27
|
+
expect(status.find(".bg-sb-primary").exists()).toBe(true);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
it("shows the next opening while closed", async () => {
|
|
@@ -36,7 +36,7 @@ describe("FooterStoreStatus", () => {
|
|
|
36
36
|
expect(status.text()).toBe(
|
|
37
37
|
"Geschlossen, wir öffnen wieder morgen um 11:30 Uhr",
|
|
38
38
|
);
|
|
39
|
-
expect(status.find(".bg-
|
|
39
|
+
expect(status.find(".bg-sb-danger").exists()).toBe(true);
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
it("renders a placeholder while the status is unknown", async () => {
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
3
|
+
import { computed, reactive, ref } from "vue";
|
|
4
|
+
import Header from "~/components/Header.vue";
|
|
5
|
+
import Footer from "~/components/Footer.vue";
|
|
6
|
+
|
|
7
|
+
// Header and footer of a shop with a style preset (#455).
|
|
8
|
+
const mocks = vi.hoisted(() => ({
|
|
9
|
+
show: vi.fn(),
|
|
10
|
+
logout: vi.fn(),
|
|
11
|
+
}));
|
|
12
|
+
const state = reactive({ cartCount: 2, wishlistCount: 0, loggedIn: false });
|
|
13
|
+
|
|
14
|
+
mockNuxtImport("useThemePreset", () => () => ({
|
|
15
|
+
preset: "trattoria",
|
|
16
|
+
menuView: "bon",
|
|
17
|
+
colorMode: "light",
|
|
18
|
+
}));
|
|
19
|
+
mockNuxtImport("useNavigation", () => () => ({
|
|
20
|
+
mainMenu: ref([
|
|
21
|
+
{ label: "Speisekarte", to: "/speisekarte/" },
|
|
22
|
+
{ label: "Kontakt", to: "/kontakt" },
|
|
23
|
+
]),
|
|
24
|
+
footerMenu: ref([
|
|
25
|
+
{
|
|
26
|
+
label: "Rechtliches",
|
|
27
|
+
children: [
|
|
28
|
+
{ label: "Impressum", to: "/impressum" },
|
|
29
|
+
{ label: "Datenschutz", to: "/datenschutz" },
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
{ label: "Leer", children: [] },
|
|
33
|
+
]),
|
|
34
|
+
}));
|
|
35
|
+
mockNuxtImport("useCartQuickView", () => () => ({
|
|
36
|
+
open: ref(false),
|
|
37
|
+
mounted: ref(false),
|
|
38
|
+
show: mocks.show,
|
|
39
|
+
}));
|
|
40
|
+
mockNuxtImport("useCart", () => () => ({
|
|
41
|
+
count: computed(() => state.cartCount),
|
|
42
|
+
}));
|
|
43
|
+
mockNuxtImport("useWishlist", () => () => ({
|
|
44
|
+
count: computed(() => state.wishlistCount),
|
|
45
|
+
}));
|
|
46
|
+
mockNuxtImport("useShopBiteConfig", () => () => ({
|
|
47
|
+
isCheckoutEnabled: ref(true),
|
|
48
|
+
}));
|
|
49
|
+
mockNuxtImport("useUser", () => () => ({
|
|
50
|
+
isLoggedIn: computed(() => state.loggedIn),
|
|
51
|
+
isGuestSession: computed(() => false),
|
|
52
|
+
logout: mocks.logout,
|
|
53
|
+
}));
|
|
54
|
+
mockNuxtImport("useStoreStatus", () => () => ({ status: ref(null) }));
|
|
55
|
+
mockNuxtImport("useBusinessHours", () => () => ({
|
|
56
|
+
businessHours: ref([]),
|
|
57
|
+
refresh: vi.fn(),
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
describe("header and footer with a preset (#455)", () => {
|
|
61
|
+
beforeEach(() => {
|
|
62
|
+
vi.clearAllMocks();
|
|
63
|
+
state.cartCount = 2;
|
|
64
|
+
state.wishlistCount = 0;
|
|
65
|
+
state.loggedIn = false;
|
|
66
|
+
Object.assign(useRuntimeConfig().public.site, {
|
|
67
|
+
name: "La Fattoria",
|
|
68
|
+
telephone: "06104 71427",
|
|
69
|
+
address: {
|
|
70
|
+
street: "Kantstraße 6",
|
|
71
|
+
postalCode: "63179",
|
|
72
|
+
city: "Obertshausen",
|
|
73
|
+
country: "DE",
|
|
74
|
+
},
|
|
75
|
+
googleBusinessProfileUrl: "",
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("names the logo link and the icon-only controls", async () => {
|
|
80
|
+
const wrapper = await mountSuspended(Header);
|
|
81
|
+
expect(
|
|
82
|
+
wrapper.find('a[aria-label="La Fattoria, zur Startseite"]').exists(),
|
|
83
|
+
).toBe(true);
|
|
84
|
+
expect(
|
|
85
|
+
wrapper.find('a[href="tel:0610471427"]').attributes("aria-label"),
|
|
86
|
+
).toBe("Anrufen: 06104 71427");
|
|
87
|
+
expect(wrapper.find('a[href="/anmelden"]').attributes("aria-label")).toBe(
|
|
88
|
+
"Anmelden",
|
|
89
|
+
);
|
|
90
|
+
expect(wrapper.find('button[aria-label="Menü öffnen"]').exists()).toBe(
|
|
91
|
+
true,
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("lists the main navigation in a labelled nav", async () => {
|
|
96
|
+
const wrapper = await mountSuspended(Header);
|
|
97
|
+
const nav = wrapper.find('nav[aria-label="Hauptnavigation"]');
|
|
98
|
+
expect(nav.findAll("a").map((link) => link.text())).toEqual([
|
|
99
|
+
"Speisekarte",
|
|
100
|
+
"Kontakt",
|
|
101
|
+
]);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("opens the cart sheet from the cart button with the count in its name", async () => {
|
|
105
|
+
const wrapper = await mountSuspended(Header);
|
|
106
|
+
const cart = wrapper.find('button[aria-label="Warenkorb, 2 Artikel"]');
|
|
107
|
+
expect(cart.attributes("aria-haspopup")).toBe("dialog");
|
|
108
|
+
await cart.trigger("click");
|
|
109
|
+
expect(mocks.show).toHaveBeenCalled();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("links the account button to the account when logged in", async () => {
|
|
113
|
+
state.loggedIn = true;
|
|
114
|
+
const wrapper = await mountSuspended(Header);
|
|
115
|
+
expect(wrapper.find('a[href="/konto"]').attributes("aria-label")).toBe(
|
|
116
|
+
"Mein Konto",
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("shows contact data and the footer columns without a colour switch", async () => {
|
|
121
|
+
const wrapper = await mountSuspended(Footer);
|
|
122
|
+
expect(wrapper.find("address").text()).toContain("Kantstraße 6");
|
|
123
|
+
expect(wrapper.find("address").text()).toContain("63179 Obertshausen");
|
|
124
|
+
const navs = wrapper.findAll("nav");
|
|
125
|
+
expect(navs.map((nav) => nav.attributes("aria-label"))).toEqual([
|
|
126
|
+
"Rechtliches",
|
|
127
|
+
]);
|
|
128
|
+
expect(navs[0]!.findAll("a").map((link) => link.text())).toEqual([
|
|
129
|
+
"Impressum",
|
|
130
|
+
"Datenschutz",
|
|
131
|
+
]);
|
|
132
|
+
expect(wrapper.text()).not.toContain("Dark");
|
|
133
|
+
});
|
|
134
|
+
});
|
|
@@ -8,12 +8,13 @@ const items = [
|
|
|
8
8
|
];
|
|
9
9
|
|
|
10
10
|
describe("HomeFaq", () => {
|
|
11
|
-
it("renders every answer in the markup,
|
|
11
|
+
it("renders every answer in the markup, only the first one open", async () => {
|
|
12
12
|
const wrapper = await mountSuspended(HomeFaq, { props: { items } });
|
|
13
13
|
|
|
14
14
|
const details = wrapper.findAll("details");
|
|
15
15
|
expect(details).toHaveLength(2);
|
|
16
|
-
expect(details
|
|
16
|
+
expect(details[0]!.attributes("open")).toBeDefined();
|
|
17
|
+
expect(details[1]!.attributes("open")).toBeUndefined();
|
|
17
18
|
expect(wrapper.find("summary").text()).toBe("Wohin liefern Sie?");
|
|
18
19
|
expect(wrapper.text()).toContain("Bar oder mit EC-Karte.");
|
|
19
20
|
expect(wrapper.text()).toContain("Häufige Fragen");
|