@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,7 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
import {
|
|
2
|
+
import { nextTick } from "vue";
|
|
3
3
|
import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
4
|
-
import {
|
|
4
|
+
import { flushPromises, type VueWrapper } from "@vue/test-utils";
|
|
5
5
|
import RegistrationForm from "~/components/User/RegistrationForm.vue";
|
|
6
6
|
import { ApiClientError } from "@shopware/api-client";
|
|
7
7
|
|
|
@@ -15,195 +15,114 @@ vi.mock("@shopware/api-client", () => ({
|
|
|
15
15
|
},
|
|
16
16
|
}));
|
|
17
17
|
|
|
18
|
-
const { mockRegister,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
mockGetSuggestions: vi.fn().mockResolvedValue([]),
|
|
23
|
-
};
|
|
24
|
-
});
|
|
18
|
+
const { mockRegister, mockGetSuggestions } = vi.hoisted(() => ({
|
|
19
|
+
mockRegister: vi.fn(),
|
|
20
|
+
mockGetSuggestions: vi.fn().mockResolvedValue([]),
|
|
21
|
+
}));
|
|
25
22
|
|
|
26
23
|
mockNuxtImport("useUser", () => () => ({
|
|
27
24
|
register: mockRegister,
|
|
28
|
-
isLoggedIn: ref(mockIsLoggedIn.value),
|
|
29
25
|
}));
|
|
30
26
|
|
|
31
27
|
mockNuxtImport("useAddressAutocomplete", () => () => ({
|
|
32
28
|
getSuggestions: mockGetSuggestions,
|
|
33
29
|
}));
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}));
|
|
55
|
-
|
|
56
|
-
// UCheckbox renders the clickable control as `button[role="checkbox"]` next to
|
|
57
|
-
// an aria-hidden native input that only mirrors the state, so the button is
|
|
58
|
-
// what has to be clicked to toggle the v-model.
|
|
59
|
-
async function toggleCheckbox(wrapper: VueWrapper, name: string) {
|
|
60
|
-
const hiddenInput = wrapper.find(`input[name="${name}"]`);
|
|
61
|
-
const button = hiddenInput.element.parentElement!.querySelector(
|
|
62
|
-
'button[role="checkbox"]',
|
|
63
|
-
)!;
|
|
64
|
-
await new DOMWrapper(button).trigger("click");
|
|
65
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
31
|
+
type FormVm = {
|
|
32
|
+
state: {
|
|
33
|
+
guest: boolean;
|
|
34
|
+
accountType: string;
|
|
35
|
+
isShippingAddressDifferent: boolean;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const vmOf = (wrapper: VueWrapper) => wrapper.vm as unknown as FormVm;
|
|
39
|
+
|
|
40
|
+
// SbCheckbox renders a Reka `button[role="checkbox"]` that its <label> points
|
|
41
|
+
// to; the button is what toggles the v-model.
|
|
42
|
+
async function toggleCheckbox(wrapper: VueWrapper, label: string) {
|
|
43
|
+
const labelElement = wrapper
|
|
44
|
+
.findAll("label")
|
|
45
|
+
.find((element) => element.text().includes(label));
|
|
46
|
+
await wrapper
|
|
47
|
+
.get(`[id="${labelElement!.attributes("for")}"]`)
|
|
48
|
+
.trigger("click");
|
|
49
|
+
await nextTick();
|
|
66
50
|
}
|
|
67
51
|
|
|
68
|
-
|
|
69
|
-
|
|
52
|
+
// Fills everything the schema requires except the password fields.
|
|
53
|
+
async function fillRequiredFields(
|
|
54
|
+
wrapper: VueWrapper,
|
|
55
|
+
email = "john@example.com",
|
|
56
|
+
) {
|
|
57
|
+
await wrapper.get("#firstName").setValue("John");
|
|
58
|
+
await wrapper.get("#lastName").setValue("Doe");
|
|
59
|
+
await wrapper.get("#email").setValue(email);
|
|
60
|
+
await wrapper.get("#billingAddress-street").setValue("Musterstr 1");
|
|
61
|
+
await wrapper.get("#billingAddress-zipcode").setValue("12345");
|
|
62
|
+
await wrapper.get("#billingAddress-city").setValue("Musterstadt");
|
|
63
|
+
await wrapper.get("#billingAddress-phoneNumber").setValue("12345678");
|
|
64
|
+
await wrapper.get("#acceptedDataProtection").trigger("click");
|
|
70
65
|
}
|
|
71
66
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
await
|
|
75
|
-
await wrapper.find('input[name="lastName"]').setValue("Doe");
|
|
76
|
-
await wrapper.find('input[name="email"]').setValue("john@example.com");
|
|
77
|
-
const state = (
|
|
78
|
-
wrapper.vm as unknown as {
|
|
79
|
-
state: {
|
|
80
|
-
billingAddress: { street: string; zipcode: string; city: string };
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
).state;
|
|
84
|
-
state.billingAddress.street = "Musterstr 1";
|
|
85
|
-
state.billingAddress.zipcode = "12345";
|
|
86
|
-
state.billingAddress.city = "Musterstadt";
|
|
87
|
-
await wrapper
|
|
88
|
-
.find('input[name="billingAddress.phoneNumber"]')
|
|
89
|
-
.setValue("12345678");
|
|
90
|
-
await acceptDataProtection(wrapper);
|
|
67
|
+
async function submit(wrapper: VueWrapper) {
|
|
68
|
+
await wrapper.find("form").trigger("submit");
|
|
69
|
+
await flushPromises();
|
|
91
70
|
}
|
|
92
71
|
|
|
93
72
|
describe("RegistrationForm", () => {
|
|
94
73
|
beforeEach(() => {
|
|
95
74
|
vi.clearAllMocks();
|
|
96
|
-
|
|
75
|
+
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
97
76
|
mockGetSuggestions.mockResolvedValue([]);
|
|
77
|
+
useRuntimeConfig().public.site.countryId = "default-country-id";
|
|
98
78
|
});
|
|
99
79
|
|
|
100
80
|
it("renders correctly", async () => {
|
|
101
81
|
const wrapper = await mountSuspended(RegistrationForm);
|
|
102
|
-
expect(wrapper.exists()).toBeTruthy();
|
|
103
82
|
expect(wrapper.find('input[name="email"]').exists()).toBe(true);
|
|
104
83
|
});
|
|
105
84
|
|
|
106
85
|
it("shows company field only for business account", async () => {
|
|
107
86
|
const wrapper = await mountSuspended(RegistrationForm);
|
|
108
87
|
|
|
109
|
-
|
|
110
|
-
expect(wrapper.find('input[name="billingAddress.company"]').exists()).toBe(
|
|
111
|
-
false,
|
|
112
|
-
);
|
|
88
|
+
expect(wrapper.find("#billingAddress-company").exists()).toBe(false);
|
|
113
89
|
|
|
114
|
-
|
|
115
|
-
(
|
|
116
|
-
wrapper.vm as unknown as { state: { accountType: string } }
|
|
117
|
-
).state.accountType = "business";
|
|
90
|
+
vmOf(wrapper).state.accountType = "business";
|
|
118
91
|
await nextTick();
|
|
119
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
120
92
|
|
|
121
|
-
|
|
122
|
-
expect(wrapper.find('input[name="billingAddress.company"]').exists()).toBe(
|
|
123
|
-
true,
|
|
124
|
-
);
|
|
93
|
+
expect(wrapper.find("#billingAddress-company").exists()).toBe(true);
|
|
125
94
|
});
|
|
126
95
|
|
|
127
96
|
it("shows shipping address fields when checkbox is checked", async () => {
|
|
128
97
|
const wrapper = await mountSuspended(RegistrationForm);
|
|
98
|
+
expect(wrapper.find("#shippingAddress-street").exists()).toBe(false);
|
|
129
99
|
|
|
130
|
-
|
|
131
|
-
const initialStreets = wrapper.findAll(
|
|
132
|
-
'input[name="billingAddress.street"]',
|
|
133
|
-
).length;
|
|
100
|
+
await toggleCheckbox(wrapper, "Lieferadresse weicht");
|
|
134
101
|
|
|
135
|
-
(
|
|
136
|
-
|
|
137
|
-
state: { isShippingAddressDifferent: boolean };
|
|
138
|
-
}
|
|
139
|
-
).state.isShippingAddressDifferent = true;
|
|
140
|
-
await nextTick();
|
|
141
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
142
|
-
|
|
143
|
-
// Should have more street inputs now (billing street + shipping street)
|
|
144
|
-
expect(wrapper.findAll('input[name$=".street"]').length).toBeGreaterThan(
|
|
145
|
-
initialStreets,
|
|
146
|
-
);
|
|
102
|
+
expect(vmOf(wrapper).state.isShippingAddressDifferent).toBe(true);
|
|
103
|
+
expect(wrapper.find("#shippingAddress-street").exists()).toBe(true);
|
|
147
104
|
});
|
|
148
105
|
|
|
149
106
|
it("submits the form with correct data", async () => {
|
|
107
|
+
mockRegister.mockResolvedValueOnce({ id: "customer-id", active: true });
|
|
150
108
|
const wrapper = await mountSuspended(RegistrationForm);
|
|
151
109
|
|
|
152
|
-
|
|
153
|
-
(wrapper
|
|
154
|
-
await nextTick();
|
|
155
|
-
|
|
156
|
-
// Fill required fields
|
|
157
|
-
await wrapper.find('input[name="firstName"]').setValue("John");
|
|
158
|
-
await wrapper.find('input[name="lastName"]').setValue("Doe");
|
|
159
|
-
await wrapper.find('input[name="email"]').setValue("john@example.com");
|
|
160
|
-
|
|
161
|
-
// Billing address fields (AddressFields component): set values directly on state
|
|
162
|
-
(
|
|
163
|
-
wrapper.vm as unknown as {
|
|
164
|
-
state: {
|
|
165
|
-
billingAddress: { street: string; zipcode: string; city: string };
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
).state.billingAddress.street = "Musterstr 1";
|
|
169
|
-
(
|
|
170
|
-
wrapper.vm as unknown as {
|
|
171
|
-
state: {
|
|
172
|
-
billingAddress: { street: string; zipcode: string; city: string };
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
).state.billingAddress.zipcode = "12345";
|
|
176
|
-
(
|
|
177
|
-
wrapper.vm as unknown as {
|
|
178
|
-
state: {
|
|
179
|
-
billingAddress: { street: string; zipcode: string; city: string };
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
).state.billingAddress.city = "Musterstadt";
|
|
183
|
-
|
|
184
|
-
await wrapper
|
|
185
|
-
.find('input[name="billingAddress.phoneNumber"]')
|
|
186
|
-
.setValue("12345678");
|
|
187
|
-
|
|
188
|
-
// Accept data protection
|
|
189
|
-
await acceptDataProtection(wrapper);
|
|
190
|
-
|
|
191
|
-
// Submit
|
|
192
|
-
await wrapper.find("form").trigger("submit");
|
|
193
|
-
|
|
194
|
-
// Wait for async validation and submission
|
|
195
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
110
|
+
await fillRequiredFields(wrapper);
|
|
111
|
+
await submit(wrapper);
|
|
196
112
|
|
|
197
113
|
expect(mockRegister).toHaveBeenCalled();
|
|
198
114
|
const calledData = mockRegister.mock.calls[0]![0];
|
|
115
|
+
expect(calledData.guest).toBe(true);
|
|
199
116
|
expect(calledData.email).toBe("john@example.com");
|
|
200
117
|
expect(calledData.billingAddress.street).toBe("Musterstr 1");
|
|
201
|
-
//
|
|
118
|
+
// The names are copied to the billing address
|
|
202
119
|
expect(calledData.billingAddress.firstName).toBe("John");
|
|
203
120
|
expect(calledData.billingAddress.lastName).toBe("Doe");
|
|
121
|
+
expect(calledData.password).toBeUndefined();
|
|
122
|
+
expect(wrapper.emitted("registration-success")).toHaveLength(1);
|
|
204
123
|
});
|
|
205
124
|
|
|
206
|
-
it("shows
|
|
125
|
+
it("shows the API error details in the form on ApiClientError", async () => {
|
|
207
126
|
const apiClientError = new ApiClientError({
|
|
208
127
|
errors: [
|
|
209
128
|
{
|
|
@@ -214,39 +133,15 @@ describe("RegistrationForm", () => {
|
|
|
214
133
|
mockRegister.mockRejectedValueOnce(apiClientError);
|
|
215
134
|
const wrapper = await mountSuspended(RegistrationForm);
|
|
216
135
|
|
|
217
|
-
|
|
218
|
-
(wrapper
|
|
219
|
-
await nextTick();
|
|
136
|
+
await fillRequiredFields(wrapper, "lirim@veliu.net");
|
|
137
|
+
await submit(wrapper);
|
|
220
138
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
(
|
|
226
|
-
wrapper.vm as unknown as {
|
|
227
|
-
state: { billingAddress: { street: string; city: string } };
|
|
228
|
-
}
|
|
229
|
-
).state.billingAddress.street = "Musterstr 1";
|
|
230
|
-
(
|
|
231
|
-
wrapper.vm as unknown as {
|
|
232
|
-
state: { billingAddress: { street: string; city: string } };
|
|
233
|
-
}
|
|
234
|
-
).state.billingAddress.city = "Musterstadt";
|
|
235
|
-
await wrapper
|
|
236
|
-
.find('input[name="billingAddress.phoneNumber"]')
|
|
237
|
-
.setValue("12345678");
|
|
238
|
-
await acceptDataProtection(wrapper);
|
|
239
|
-
|
|
240
|
-
await wrapper.find("form").trigger("submit");
|
|
241
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
242
|
-
|
|
243
|
-
expect(mockToastAdd).toHaveBeenCalledWith(
|
|
244
|
-
expect.objectContaining({
|
|
245
|
-
title: "Registrierung fehlgeschlagen",
|
|
246
|
-
description: 'The email address "lirim@veliu.net" is already in use',
|
|
247
|
-
color: "error",
|
|
248
|
-
}),
|
|
139
|
+
const alert = wrapper.get('[role="alert"]');
|
|
140
|
+
expect(alert.text()).toContain("Das hat nicht geklappt");
|
|
141
|
+
expect(alert.text()).toContain(
|
|
142
|
+
'The email address "lirim@veliu.net" is already in use',
|
|
249
143
|
);
|
|
144
|
+
expect(wrapper.emitted("registration-success")).toBeUndefined();
|
|
250
145
|
});
|
|
251
146
|
|
|
252
147
|
it("handles ApiClientError with missing errors gracefully", async () => {
|
|
@@ -256,38 +151,11 @@ describe("RegistrationForm", () => {
|
|
|
256
151
|
mockRegister.mockRejectedValueOnce(apiClientError);
|
|
257
152
|
const wrapper = await mountSuspended(RegistrationForm);
|
|
258
153
|
|
|
259
|
-
|
|
260
|
-
(wrapper
|
|
261
|
-
await nextTick();
|
|
154
|
+
await fillRequiredFields(wrapper, "lirim@veliu.net");
|
|
155
|
+
await submit(wrapper);
|
|
262
156
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
await wrapper.find('input[name="lastName"]').setValue("Doe");
|
|
266
|
-
await wrapper.find('input[name="email"]').setValue("lirim@veliu.net");
|
|
267
|
-
(
|
|
268
|
-
wrapper.vm as unknown as {
|
|
269
|
-
state: { billingAddress: { street: string; city: string } };
|
|
270
|
-
}
|
|
271
|
-
).state.billingAddress.street = "Musterstr 1";
|
|
272
|
-
(
|
|
273
|
-
wrapper.vm as unknown as {
|
|
274
|
-
state: { billingAddress: { street: string; city: string } };
|
|
275
|
-
}
|
|
276
|
-
).state.billingAddress.city = "Musterstadt";
|
|
277
|
-
await wrapper
|
|
278
|
-
.find('input[name="billingAddress.phoneNumber"]')
|
|
279
|
-
.setValue("12345678");
|
|
280
|
-
await acceptDataProtection(wrapper);
|
|
281
|
-
|
|
282
|
-
await wrapper.find("form").trigger("submit");
|
|
283
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
284
|
-
|
|
285
|
-
expect(mockToastAdd).toHaveBeenCalledWith(
|
|
286
|
-
expect.objectContaining({
|
|
287
|
-
title: "Registrierung fehlgeschlagen",
|
|
288
|
-
description: "Bitte versuchen Sie es erneut.",
|
|
289
|
-
color: "error",
|
|
290
|
-
}),
|
|
157
|
+
expect(wrapper.get('[role="alert"]').text()).toContain(
|
|
158
|
+
"Bitte versuchen Sie es erneut.",
|
|
291
159
|
);
|
|
292
160
|
});
|
|
293
161
|
|
|
@@ -300,43 +168,13 @@ describe("RegistrationForm", () => {
|
|
|
300
168
|
label: "Corrected Street 123, 54321 Corrected City",
|
|
301
169
|
},
|
|
302
170
|
]);
|
|
171
|
+
mockRegister.mockResolvedValueOnce({ id: "customer-id", active: true });
|
|
303
172
|
|
|
304
173
|
const wrapper = await mountSuspended(RegistrationForm);
|
|
305
174
|
|
|
306
|
-
(wrapper
|
|
307
|
-
await
|
|
308
|
-
|
|
309
|
-
await wrapper.find('input[name="firstName"]').setValue("John");
|
|
310
|
-
await wrapper.find('input[name="lastName"]').setValue("Doe");
|
|
311
|
-
await wrapper.find('input[name="email"]').setValue("john@example.com");
|
|
312
|
-
(
|
|
313
|
-
wrapper.vm as unknown as {
|
|
314
|
-
state: {
|
|
315
|
-
billingAddress: { street: string; zipcode: string; city: string };
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
).state.billingAddress.street = "Musterstr 1";
|
|
319
|
-
(
|
|
320
|
-
wrapper.vm as unknown as {
|
|
321
|
-
state: {
|
|
322
|
-
billingAddress: { street: string; zipcode: string; city: string };
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
).state.billingAddress.zipcode = "12345";
|
|
326
|
-
(
|
|
327
|
-
wrapper.vm as unknown as {
|
|
328
|
-
state: {
|
|
329
|
-
billingAddress: { street: string; zipcode: string; city: string };
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
).state.billingAddress.city = "Musterstadt";
|
|
333
|
-
await wrapper
|
|
334
|
-
.find('input[name="billingAddress.phoneNumber"]')
|
|
335
|
-
.setValue("12345678");
|
|
336
|
-
await acceptDataProtection(wrapper);
|
|
337
|
-
|
|
338
|
-
await wrapper.find("form").trigger("submit");
|
|
339
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
175
|
+
await fillRequiredFields(wrapper);
|
|
176
|
+
await submit(wrapper);
|
|
177
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
340
178
|
|
|
341
179
|
// Registration must not be blocked by the correction suggestion
|
|
342
180
|
expect(mockRegister).toHaveBeenCalled();
|
|
@@ -351,17 +189,12 @@ describe("RegistrationForm", () => {
|
|
|
351
189
|
const wrapper = await mountSuspended(RegistrationForm);
|
|
352
190
|
|
|
353
191
|
expect(wrapper.text()).toContain("Kundenkonto anlegen");
|
|
354
|
-
expect(
|
|
355
|
-
(wrapper.vm as unknown as { state: { guest: boolean } }).state.guest,
|
|
356
|
-
).toBe(true);
|
|
192
|
+
expect(vmOf(wrapper).state.guest).toBe(true);
|
|
357
193
|
expect(wrapper.find('input[name="password"]').exists()).toBe(false);
|
|
358
194
|
|
|
359
|
-
await toggleCheckbox(wrapper, "
|
|
360
|
-
await nextTick();
|
|
195
|
+
await toggleCheckbox(wrapper, "Kundenkonto anlegen");
|
|
361
196
|
|
|
362
|
-
expect(
|
|
363
|
-
(wrapper.vm as unknown as { state: { guest: boolean } }).state.guest,
|
|
364
|
-
).toBe(false);
|
|
197
|
+
expect(vmOf(wrapper).state.guest).toBe(false);
|
|
365
198
|
expect(wrapper.find('input[name="password"]').exists()).toBe(true);
|
|
366
199
|
expect(wrapper.find('input[name="passwordConfirm"]').exists()).toBe(true);
|
|
367
200
|
});
|
|
@@ -372,9 +205,7 @@ describe("RegistrationForm", () => {
|
|
|
372
205
|
});
|
|
373
206
|
|
|
374
207
|
expect(wrapper.text()).not.toContain("Kundenkonto anlegen");
|
|
375
|
-
expect(
|
|
376
|
-
(wrapper.vm as unknown as { state: { guest: boolean } }).state.guest,
|
|
377
|
-
).toBe(false);
|
|
208
|
+
expect(vmOf(wrapper).state.guest).toBe(false);
|
|
378
209
|
expect(wrapper.find('input[name="password"]').exists()).toBe(true);
|
|
379
210
|
expect(wrapper.find('input[name="passwordConfirm"]').exists()).toBe(true);
|
|
380
211
|
});
|
|
@@ -385,13 +216,13 @@ describe("RegistrationForm", () => {
|
|
|
385
216
|
});
|
|
386
217
|
|
|
387
218
|
await fillRequiredFields(wrapper);
|
|
388
|
-
await wrapper
|
|
389
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
219
|
+
await submit(wrapper);
|
|
390
220
|
|
|
391
221
|
expect(mockRegister).not.toHaveBeenCalled();
|
|
392
222
|
expect(wrapper.text()).toContain(
|
|
393
223
|
"Das Passwort muss mindestens 8 Zeichen lang sein.",
|
|
394
224
|
);
|
|
225
|
+
expect(wrapper.get("#password").attributes("aria-invalid")).toBe("true");
|
|
395
226
|
});
|
|
396
227
|
|
|
397
228
|
it("registers a real customer account when allowGuest is false", async () => {
|
|
@@ -405,22 +236,17 @@ describe("RegistrationForm", () => {
|
|
|
405
236
|
});
|
|
406
237
|
|
|
407
238
|
await fillRequiredFields(wrapper);
|
|
408
|
-
await wrapper.
|
|
409
|
-
await wrapper.
|
|
410
|
-
|
|
411
|
-
await wrapper.find("form").trigger("submit");
|
|
412
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
239
|
+
await wrapper.get("#password").setValue("supersecret");
|
|
240
|
+
await wrapper.get("#passwordConfirm").setValue("supersecret");
|
|
241
|
+
await submit(wrapper);
|
|
413
242
|
|
|
414
243
|
expect(mockRegister).toHaveBeenCalled();
|
|
415
244
|
const calledData = mockRegister.mock.calls[0]![0];
|
|
416
245
|
expect(calledData.guest).toBe(false);
|
|
417
246
|
expect(calledData.password).toBe("supersecret");
|
|
418
|
-
expect(
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
color: "success",
|
|
422
|
-
}),
|
|
423
|
-
);
|
|
247
|
+
expect(wrapper.find('[role="alert"]').exists()).toBe(false);
|
|
248
|
+
expect(wrapper.find('[role="status"]').exists()).toBe(false);
|
|
249
|
+
expect(wrapper.emitted("registration-success")).toHaveLength(1);
|
|
424
250
|
});
|
|
425
251
|
|
|
426
252
|
it("asks for the e-mail confirmation on double opt-in registrations", async () => {
|
|
@@ -435,18 +261,11 @@ describe("RegistrationForm", () => {
|
|
|
435
261
|
});
|
|
436
262
|
|
|
437
263
|
await fillRequiredFields(wrapper);
|
|
438
|
-
await wrapper.
|
|
439
|
-
await wrapper.
|
|
264
|
+
await wrapper.get("#password").setValue("supersecret");
|
|
265
|
+
await wrapper.get("#passwordConfirm").setValue("supersecret");
|
|
266
|
+
await submit(wrapper);
|
|
440
267
|
|
|
441
|
-
|
|
442
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
443
|
-
|
|
444
|
-
expect(mockToastAdd).toHaveBeenCalledWith(
|
|
445
|
-
expect.objectContaining({
|
|
446
|
-
title: "Fast geschafft!",
|
|
447
|
-
color: "info",
|
|
448
|
-
}),
|
|
449
|
-
);
|
|
268
|
+
expect(wrapper.get('[role="status"]').text()).toContain("Fast geschafft");
|
|
450
269
|
const emitted = wrapper.emitted("registration-success");
|
|
451
270
|
expect(emitted).toBeTruthy();
|
|
452
271
|
expect(emitted![0]![1]).toEqual(customer);
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { mountSuspended } from "@nuxt/test-utils/runtime";
|
|
3
|
+
import { nextTick, ref } from "vue";
|
|
4
|
+
import SbButton from "~/components/Sb/Button.vue";
|
|
5
|
+
import SbIconButton from "~/components/Sb/IconButton.vue";
|
|
6
|
+
import SbChip from "~/components/Sb/Chip.vue";
|
|
7
|
+
import SbStepper from "~/components/Sb/Stepper.vue";
|
|
8
|
+
import SbField from "~/components/Sb/Field.vue";
|
|
9
|
+
import SbInput from "~/components/Sb/Input.vue";
|
|
10
|
+
import SbSegmentedControl from "~/components/Sb/SegmentedControl.vue";
|
|
11
|
+
import SbChoiceGroup from "~/components/Sb/ChoiceGroup.vue";
|
|
12
|
+
import SbCheckbox from "~/components/Sb/Checkbox.vue";
|
|
13
|
+
|
|
14
|
+
describe("Sb base components (#440)", () => {
|
|
15
|
+
it("SbButton renders a button, or a link with `to`", async () => {
|
|
16
|
+
const button = await mountSuspended(SbButton, {
|
|
17
|
+
props: { type: "submit" },
|
|
18
|
+
slots: { default: () => "Bestellen" },
|
|
19
|
+
});
|
|
20
|
+
expect(button.find("button").attributes("type")).toBe("submit");
|
|
21
|
+
expect(button.text()).toBe("Bestellen");
|
|
22
|
+
|
|
23
|
+
const link = await mountSuspended(SbButton, {
|
|
24
|
+
props: { to: "/speisekarte" },
|
|
25
|
+
slots: { default: () => "Speisekarte" },
|
|
26
|
+
});
|
|
27
|
+
expect(link.find("a").attributes("href")).toBe("/speisekarte");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("SbButton disables itself while loading", async () => {
|
|
31
|
+
const wrapper = await mountSuspended(SbButton, {
|
|
32
|
+
props: { loading: true },
|
|
33
|
+
slots: { default: () => "Bestellen" },
|
|
34
|
+
});
|
|
35
|
+
const button = wrapper.find("button");
|
|
36
|
+
expect(button.attributes("disabled")).toBeDefined();
|
|
37
|
+
expect(button.attributes("aria-busy")).toBe("true");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("SbIconButton has its label as accessible name", async () => {
|
|
41
|
+
const wrapper = await mountSuspended(SbIconButton, {
|
|
42
|
+
props: { label: "Schließen" },
|
|
43
|
+
});
|
|
44
|
+
expect(wrapper.find("button").attributes("aria-label")).toBe("Schließen");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("SbChip ingredient reads 'ohne' when off and keeps its name", async () => {
|
|
48
|
+
const wrapper = await mountSuspended(SbChip, {
|
|
49
|
+
props: { label: "Pilze", variant: "ingredient", modelValue: true },
|
|
50
|
+
});
|
|
51
|
+
const button = wrapper.find("button");
|
|
52
|
+
expect(button.attributes("aria-pressed")).toBe("true");
|
|
53
|
+
expect(button.text()).toBe("Pilze");
|
|
54
|
+
|
|
55
|
+
await button.trigger("click");
|
|
56
|
+
expect(wrapper.emitted("update:modelValue")?.[0]).toEqual([false]);
|
|
57
|
+
await wrapper.setProps({ modelValue: false });
|
|
58
|
+
expect(button.text()).toBe("ohne Pilze");
|
|
59
|
+
expect(button.attributes("aria-label")).toBe("Pilze");
|
|
60
|
+
expect(button.attributes("aria-pressed")).toBe("false");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("SbStepper counts and offers removal at the minimum", async () => {
|
|
64
|
+
const wrapper = await mountSuspended(SbStepper, {
|
|
65
|
+
props: { itemName: "Pizza Mix", modelValue: 2, removable: true },
|
|
66
|
+
});
|
|
67
|
+
const [minus, plus] = wrapper.findAll("button");
|
|
68
|
+
expect(wrapper.attributes("aria-label")).toBe("Menge Pizza Mix");
|
|
69
|
+
expect(plus!.attributes("aria-label")).toBe("Pizza Mix, eine mehr");
|
|
70
|
+
|
|
71
|
+
await plus!.trigger("click");
|
|
72
|
+
expect(wrapper.emitted("update:modelValue")?.[0]).toEqual([3]);
|
|
73
|
+
|
|
74
|
+
await wrapper.setProps({ modelValue: 1 });
|
|
75
|
+
expect(minus!.attributes("aria-label")).toBe("Pizza Mix entfernen");
|
|
76
|
+
await minus!.trigger("click");
|
|
77
|
+
expect(wrapper.emitted("remove")).toHaveLength(1);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("SbField wires label, hint and error to the control", async () => {
|
|
81
|
+
const wrapper = await mountSuspended(
|
|
82
|
+
{
|
|
83
|
+
components: { SbField, SbInput },
|
|
84
|
+
setup: () => ({ value: ref("") }),
|
|
85
|
+
template: `
|
|
86
|
+
<SbField label="Telefon" hint="Nur für Rückfragen" error="Bitte geben Sie eine Telefonnummer an." v-slot="{ id, describedBy, invalid }">
|
|
87
|
+
<SbInput :id="id" v-model="value" :aria-describedby="describedBy" :invalid="invalid" />
|
|
88
|
+
</SbField>`,
|
|
89
|
+
},
|
|
90
|
+
{},
|
|
91
|
+
);
|
|
92
|
+
const input = wrapper.find("input");
|
|
93
|
+
const label = wrapper.find("label");
|
|
94
|
+
expect(label.attributes("for")).toBe(input.attributes("id"));
|
|
95
|
+
expect(input.attributes("aria-invalid")).toBe("true");
|
|
96
|
+
|
|
97
|
+
const describedBy = input.attributes("aria-describedby")!.split(" ");
|
|
98
|
+
const texts = describedBy.map((id) => wrapper.find(`[id="${id}"]`).text());
|
|
99
|
+
expect(texts).toEqual([
|
|
100
|
+
"Bitte geben Sie eine Telefonnummer an.",
|
|
101
|
+
"Nur für Rückfragen",
|
|
102
|
+
]);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("SbField marks optional fields only", async () => {
|
|
106
|
+
const wrapper = await mountSuspended(SbField, {
|
|
107
|
+
props: { label: "Hinweis für den Fahrer", optional: true },
|
|
108
|
+
});
|
|
109
|
+
expect(wrapper.find("label").text()).toContain("(optional)");
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("SbSegmentedControl is a labelled radio group", async () => {
|
|
113
|
+
const wrapper = await mountSuspended(SbSegmentedControl, {
|
|
114
|
+
props: {
|
|
115
|
+
label: "Bestellart",
|
|
116
|
+
modelValue: "delivery",
|
|
117
|
+
options: [
|
|
118
|
+
{ value: "delivery", label: "Lieferung" },
|
|
119
|
+
{ value: "pickup", label: "Abholung" },
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
expect(wrapper.find('[role="radiogroup"]').attributes("aria-label")).toBe(
|
|
124
|
+
"Bestellart",
|
|
125
|
+
);
|
|
126
|
+
const radios = wrapper.findAll('[role="radio"]');
|
|
127
|
+
expect(radios.map((radio) => radio.attributes("aria-checked"))).toEqual([
|
|
128
|
+
"true",
|
|
129
|
+
"false",
|
|
130
|
+
]);
|
|
131
|
+
|
|
132
|
+
await radios[1]!.trigger("click");
|
|
133
|
+
await nextTick();
|
|
134
|
+
expect(wrapper.emitted("update:modelValue")?.at(-1)).toEqual(["pickup"]);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("SbChoiceGroup names the group by its legend and marks required", async () => {
|
|
138
|
+
const wrapper = await mountSuspended(SbChoiceGroup, {
|
|
139
|
+
props: {
|
|
140
|
+
legend: "Fleisch",
|
|
141
|
+
required: true,
|
|
142
|
+
options: [
|
|
143
|
+
{ value: "kalb", label: "Kalb" },
|
|
144
|
+
{ value: "haehnchen", label: "Hähnchen" },
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
const group = wrapper.find('[role="radiogroup"]');
|
|
149
|
+
const legend = wrapper.find(
|
|
150
|
+
`[id="${group.attributes("aria-labelledby")}"]`,
|
|
151
|
+
);
|
|
152
|
+
expect(legend.text()).toContain("Fleisch");
|
|
153
|
+
expect(legend.text()).toContain("Pflicht");
|
|
154
|
+
expect(wrapper.findAll('[role="radio"]')).toHaveLength(2);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("SbCheckbox is labelled by its row", async () => {
|
|
158
|
+
const wrapper = await mountSuspended(SbCheckbox, {
|
|
159
|
+
props: { label: "Artischocken", trailing: "+1,00 €" },
|
|
160
|
+
});
|
|
161
|
+
const checkbox = wrapper.find('[role="checkbox"]');
|
|
162
|
+
const label = wrapper.find("label");
|
|
163
|
+
expect(label.attributes("for")).toBe(checkbox.attributes("id"));
|
|
164
|
+
expect(label.text()).toContain("Artischocken");
|
|
165
|
+
expect(label.text()).toContain("+1,00 €");
|
|
166
|
+
|
|
167
|
+
await checkbox.trigger("click");
|
|
168
|
+
expect(wrapper.emitted("update:modelValue")?.[0]).toEqual([true]);
|
|
169
|
+
});
|
|
170
|
+
});
|