@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,191 @@
|
|
|
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 { ref } from "vue";
|
|
5
|
+
import AddressForm from "~/components/Address/Form.vue";
|
|
6
|
+
import AddressesPage from "~/pages/konto/adressen.vue";
|
|
7
|
+
import ProfilePage from "~/pages/konto/profil.vue";
|
|
8
|
+
import type { Schemas } from "#shopware";
|
|
9
|
+
|
|
10
|
+
// Account pages and the address form of the presets (#445).
|
|
11
|
+
const mocks = vi.hoisted(() => ({
|
|
12
|
+
createCustomerAddress: vi.fn(),
|
|
13
|
+
updateCustomerAddress: vi.fn(),
|
|
14
|
+
setDefaultCustomerShippingAddress: vi.fn(),
|
|
15
|
+
setDefaultCustomerBillingAddress: vi.fn(),
|
|
16
|
+
loadCustomerAddresses: vi.fn(),
|
|
17
|
+
refreshUser: vi.fn(),
|
|
18
|
+
updatePersonalInfo: vi.fn(),
|
|
19
|
+
updateEmail: vi.fn(),
|
|
20
|
+
logout: vi.fn(),
|
|
21
|
+
invoke: vi.fn(),
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
const home = {
|
|
25
|
+
id: "addr-home",
|
|
26
|
+
firstName: "Gina",
|
|
27
|
+
lastName: "Rossi",
|
|
28
|
+
street: "Kantstr. 6",
|
|
29
|
+
zipcode: "63179",
|
|
30
|
+
city: "Obertshausen",
|
|
31
|
+
phoneNumber: "06104 71427",
|
|
32
|
+
countryId: "de",
|
|
33
|
+
} as Schemas["CustomerAddress"];
|
|
34
|
+
const office = {
|
|
35
|
+
...home,
|
|
36
|
+
id: "addr-office",
|
|
37
|
+
street: "Waldstr. 1",
|
|
38
|
+
company: "Rossi GmbH",
|
|
39
|
+
} as Schemas["CustomerAddress"];
|
|
40
|
+
|
|
41
|
+
const user = ref({
|
|
42
|
+
firstName: "Gina",
|
|
43
|
+
lastName: "Rossi",
|
|
44
|
+
email: "gina@example.de",
|
|
45
|
+
});
|
|
46
|
+
const userApi = () => ({
|
|
47
|
+
user,
|
|
48
|
+
isLoggedIn: ref(true),
|
|
49
|
+
userDefaultShippingAddress: ref(home),
|
|
50
|
+
userDefaultBillingAddress: ref(home),
|
|
51
|
+
refreshUser: mocks.refreshUser,
|
|
52
|
+
updatePersonalInfo: mocks.updatePersonalInfo,
|
|
53
|
+
updateEmail: mocks.updateEmail,
|
|
54
|
+
logout: mocks.logout,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
vi.mock("@shopware/composables", async (importOriginal) => ({
|
|
58
|
+
...(await importOriginal<typeof import("@shopware/composables")>()),
|
|
59
|
+
useAddress: () => ({
|
|
60
|
+
customerAddresses: ref([home, office]),
|
|
61
|
+
loadCustomerAddresses: mocks.loadCustomerAddresses,
|
|
62
|
+
createCustomerAddress: mocks.createCustomerAddress,
|
|
63
|
+
updateCustomerAddress: mocks.updateCustomerAddress,
|
|
64
|
+
setDefaultCustomerShippingAddress: mocks.setDefaultCustomerShippingAddress,
|
|
65
|
+
setDefaultCustomerBillingAddress: mocks.setDefaultCustomerBillingAddress,
|
|
66
|
+
}),
|
|
67
|
+
useUser: () => userApi(),
|
|
68
|
+
}));
|
|
69
|
+
mockNuxtImport("useUser", () => () => userApi());
|
|
70
|
+
mockNuxtImport("useThemePreset", () => () => ({
|
|
71
|
+
preset: "trattoria",
|
|
72
|
+
menuView: "bon",
|
|
73
|
+
}));
|
|
74
|
+
mockNuxtImport("useShopwareContext", () => () => ({
|
|
75
|
+
apiClient: { invoke: mocks.invoke },
|
|
76
|
+
}));
|
|
77
|
+
mockNuxtImport("useAddressAutocomplete", () => () => ({
|
|
78
|
+
getSuggestions: vi.fn().mockResolvedValue([]),
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
describe("account pages with a preset (#445)", () => {
|
|
82
|
+
beforeEach(() => {
|
|
83
|
+
vi.clearAllMocks();
|
|
84
|
+
for (const mock of Object.values(mocks)) mock.mockReset();
|
|
85
|
+
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("checks a new address before creating it", async () => {
|
|
89
|
+
mocks.createCustomerAddress.mockResolvedValue({ id: "new" });
|
|
90
|
+
const wrapper = await mountSuspended(AddressForm);
|
|
91
|
+
await wrapper.find("form").trigger("submit");
|
|
92
|
+
await flushPromises();
|
|
93
|
+
expect(wrapper.text()).toContain("Bitte geben Sie den Vornamen an.");
|
|
94
|
+
expect(wrapper.text()).toContain("Bitte geben Sie die Postleitzahl an.");
|
|
95
|
+
expect(mocks.createCustomerAddress).not.toHaveBeenCalled();
|
|
96
|
+
|
|
97
|
+
const fill = (name: string, value: string) =>
|
|
98
|
+
wrapper.find(`input[name="shippingAddress.${name}"]`).setValue(value);
|
|
99
|
+
await fill("firstName", "Gina");
|
|
100
|
+
await fill("lastName", "Rossi");
|
|
101
|
+
await fill("street", "Kantstr. 6");
|
|
102
|
+
await fill("zipcode", "63179");
|
|
103
|
+
await fill("city", "Obertshausen");
|
|
104
|
+
await fill("phoneNumber", "06104 71427");
|
|
105
|
+
await wrapper.find("form").trigger("submit");
|
|
106
|
+
await flushPromises();
|
|
107
|
+
expect(mocks.createCustomerAddress).toHaveBeenCalledWith(
|
|
108
|
+
expect.objectContaining({ firstName: "Gina", zipcode: "63179" }),
|
|
109
|
+
);
|
|
110
|
+
expect(wrapper.emitted("submit-success")?.[0]).toEqual([{ id: "new" }]);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("updates an existing address and keeps its company", async () => {
|
|
114
|
+
mocks.updateCustomerAddress.mockResolvedValue(office);
|
|
115
|
+
const wrapper = await mountSuspended(AddressForm, {
|
|
116
|
+
props: { address: office },
|
|
117
|
+
});
|
|
118
|
+
expect(
|
|
119
|
+
(
|
|
120
|
+
wrapper.find('input[name="shippingAddress.company"]')
|
|
121
|
+
.element as HTMLInputElement
|
|
122
|
+
).value,
|
|
123
|
+
).toBe("Rossi GmbH");
|
|
124
|
+
await wrapper.find("form").trigger("submit");
|
|
125
|
+
await flushPromises();
|
|
126
|
+
expect(mocks.updateCustomerAddress).toHaveBeenCalledWith(
|
|
127
|
+
expect.objectContaining({ id: "addr-office", company: "Rossi GmbH" }),
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("shows a failed save in the form", async () => {
|
|
132
|
+
mocks.updateCustomerAddress.mockRejectedValue(new Error("400"));
|
|
133
|
+
const wrapper = await mountSuspended(AddressForm, {
|
|
134
|
+
props: { address: home },
|
|
135
|
+
});
|
|
136
|
+
await wrapper.find("form").trigger("submit");
|
|
137
|
+
await flushPromises();
|
|
138
|
+
expect(wrapper.find('[role="alert"]').text()).toContain(
|
|
139
|
+
"Die Adresse konnte nicht gespeichert werden.",
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it("lists the addresses with their use and named actions", async () => {
|
|
144
|
+
const wrapper = await mountSuspended(AddressesPage);
|
|
145
|
+
await flushPromises();
|
|
146
|
+
const cards = wrapper
|
|
147
|
+
.findAll("main li, ul > li")
|
|
148
|
+
.filter((li) => li.find("address").exists());
|
|
149
|
+
expect(cards).toHaveLength(2);
|
|
150
|
+
expect(cards[0]!.text()).toContain("Lieferadresse");
|
|
151
|
+
expect(cards[0]!.text()).toContain("Rechnungsadresse");
|
|
152
|
+
|
|
153
|
+
const makeShipping = cards[1]!
|
|
154
|
+
.findAll("button")
|
|
155
|
+
.find((b) => b.text().startsWith("Als Lieferadresse"))!;
|
|
156
|
+
expect(makeShipping.text()).toContain("Waldstr. 1, Obertshausen");
|
|
157
|
+
await makeShipping.trigger("click");
|
|
158
|
+
await flushPromises();
|
|
159
|
+
expect(mocks.setDefaultCustomerShippingAddress).toHaveBeenCalledWith(
|
|
160
|
+
"addr-office",
|
|
161
|
+
);
|
|
162
|
+
expect(wrapper.find('[role="status"]').text()).toBe(
|
|
163
|
+
"Die Lieferadresse ist geändert.",
|
|
164
|
+
);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("validates the profile and saves it", async () => {
|
|
168
|
+
const wrapper = await mountSuspended(ProfilePage);
|
|
169
|
+
await flushPromises();
|
|
170
|
+
await wrapper.find('input[name="email"]').setValue("keine-mail");
|
|
171
|
+
await wrapper.find("form").trigger("submit");
|
|
172
|
+
await flushPromises();
|
|
173
|
+
expect(wrapper.text()).toContain(
|
|
174
|
+
"Bitte geben Sie eine gültige E-Mail-Adresse ein.",
|
|
175
|
+
);
|
|
176
|
+
expect(mocks.updatePersonalInfo).not.toHaveBeenCalled();
|
|
177
|
+
|
|
178
|
+
await wrapper.find('input[name="email"]').setValue("gina@example.de");
|
|
179
|
+
await wrapper.find('input[name="firstName"]').setValue("Regina");
|
|
180
|
+
await wrapper.find("form").trigger("submit");
|
|
181
|
+
await flushPromises();
|
|
182
|
+
expect(mocks.updateEmail).not.toHaveBeenCalled();
|
|
183
|
+
expect(mocks.updatePersonalInfo).toHaveBeenCalledWith({
|
|
184
|
+
firstName: "Regina",
|
|
185
|
+
lastName: "Rossi",
|
|
186
|
+
});
|
|
187
|
+
expect(wrapper.find('[role="status"]').text()).toBe(
|
|
188
|
+
"Ihre Änderungen sind gespeichert.",
|
|
189
|
+
);
|
|
190
|
+
});
|
|
191
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
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 PasswordForgotten from "~/pages/passwort-vergessen.vue";
|
|
5
|
+
import PasswordReset from "~/pages/account/recover/password/index.vue";
|
|
6
|
+
|
|
7
|
+
// Password pages of the presets (#445): results in the form, no toasts.
|
|
8
|
+
const mocks = vi.hoisted(() => ({ invoke: vi.fn() }));
|
|
9
|
+
|
|
10
|
+
mockNuxtImport("useThemePreset", () => () => ({
|
|
11
|
+
preset: "trattoria",
|
|
12
|
+
menuView: "bon",
|
|
13
|
+
}));
|
|
14
|
+
mockNuxtImport("useShopwareContext", () => () => ({
|
|
15
|
+
apiClient: { invoke: mocks.invoke },
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
describe("password pages with a preset (#445)", () => {
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
vi.clearAllMocks();
|
|
21
|
+
mocks.invoke.mockReset();
|
|
22
|
+
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("checks the e-mail before sending the recovery mail", async () => {
|
|
26
|
+
const wrapper = await mountSuspended(PasswordForgotten);
|
|
27
|
+
await wrapper.find("form").trigger("submit");
|
|
28
|
+
expect(wrapper.text()).toContain("Bitte geben Sie eine gültige E-Mail");
|
|
29
|
+
expect(mocks.invoke).not.toHaveBeenCalled();
|
|
30
|
+
|
|
31
|
+
await wrapper.find('input[name="email"]').setValue("gast@example.de");
|
|
32
|
+
await wrapper.find("form").trigger("submit");
|
|
33
|
+
await flushPromises();
|
|
34
|
+
expect(mocks.invoke).toHaveBeenCalledWith(
|
|
35
|
+
"sendRecoveryMail post /account/recovery-password",
|
|
36
|
+
expect.objectContaining({
|
|
37
|
+
body: expect.objectContaining({ email: "gast@example.de" }),
|
|
38
|
+
}),
|
|
39
|
+
);
|
|
40
|
+
expect(wrapper.find('[role="status"]').text()).toContain(
|
|
41
|
+
"E-Mail ist unterwegs",
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("reports a failed recovery mail in the form", async () => {
|
|
46
|
+
mocks.invoke.mockRejectedValue(new Error("500"));
|
|
47
|
+
const wrapper = await mountSuspended(PasswordForgotten);
|
|
48
|
+
await wrapper.find('input[name="email"]').setValue("gast@example.de");
|
|
49
|
+
await wrapper.find("form").trigger("submit");
|
|
50
|
+
await flushPromises();
|
|
51
|
+
expect(wrapper.find('[role="alert"]').text()).toContain(
|
|
52
|
+
"konnte nicht gesendet werden",
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("sets a new password with the hash from the link", async () => {
|
|
57
|
+
const wrapper = await mountSuspended(PasswordReset, {
|
|
58
|
+
route: "/account/recover/password?hash=abc",
|
|
59
|
+
});
|
|
60
|
+
await wrapper.find('input[name="newPassword"]').setValue("geheim123");
|
|
61
|
+
await wrapper
|
|
62
|
+
.find('input[name="newPasswordConfirm"]')
|
|
63
|
+
.setValue("anders123");
|
|
64
|
+
await wrapper.find("form").trigger("submit");
|
|
65
|
+
expect(wrapper.text()).toContain("Passwörter stimmen nicht überein");
|
|
66
|
+
expect(mocks.invoke).not.toHaveBeenCalled();
|
|
67
|
+
|
|
68
|
+
await wrapper
|
|
69
|
+
.find('input[name="newPasswordConfirm"]')
|
|
70
|
+
.setValue("geheim123");
|
|
71
|
+
await wrapper.find("form").trigger("submit");
|
|
72
|
+
await flushPromises();
|
|
73
|
+
expect(mocks.invoke).toHaveBeenCalledWith(
|
|
74
|
+
"recoveryPassword post /account/recovery-password-confirm",
|
|
75
|
+
{
|
|
76
|
+
body: {
|
|
77
|
+
newPassword: "geheim123",
|
|
78
|
+
newPasswordConfirm: "geheim123",
|
|
79
|
+
hash: "abc",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
expect(wrapper.find('[role="status"]').text()).toContain(
|
|
84
|
+
"Ihr Passwort ist geändert",
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -0,0 +1,154 @@
|
|
|
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 { ref } from "vue";
|
|
5
|
+
import CartItem from "~/components/Cart/Item.vue";
|
|
6
|
+
import PaymentAndDelivery from "~/components/Checkout/PaymentAndDelivery.vue";
|
|
7
|
+
import type { Schemas } from "#shopware";
|
|
8
|
+
|
|
9
|
+
// Cart and checkout of a shop with a style preset (#443).
|
|
10
|
+
const mocks = vi.hoisted(() => ({
|
|
11
|
+
setQuantity: vi.fn(),
|
|
12
|
+
removeLineItem: vi.fn(),
|
|
13
|
+
setShippingMethod: vi.fn(),
|
|
14
|
+
setPaymentMethod: vi.fn(),
|
|
15
|
+
refreshCart: vi.fn(),
|
|
16
|
+
ensureAvailableCheckoutMethods: vi.fn(),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
const selectedShippingMethod = ref<{ id: string; name: string } | null>({
|
|
20
|
+
id: "delivery",
|
|
21
|
+
name: "Lieferung",
|
|
22
|
+
});
|
|
23
|
+
const selectedPaymentMethod = ref({ id: "cash", distinguishableName: "Bar" });
|
|
24
|
+
|
|
25
|
+
mockNuxtImport("useThemePreset", () => () => ({
|
|
26
|
+
preset: "trattoria",
|
|
27
|
+
menuView: "bon",
|
|
28
|
+
}));
|
|
29
|
+
mockNuxtImport("useCartMutations", () => () => ({
|
|
30
|
+
setQuantity: mocks.setQuantity,
|
|
31
|
+
removeLineItem: mocks.removeLineItem,
|
|
32
|
+
addLineItems: vi.fn(),
|
|
33
|
+
isMutating: ref(false),
|
|
34
|
+
}));
|
|
35
|
+
mockNuxtImport("useCommercePrice", () => () => ({
|
|
36
|
+
getFormattedPrice: (value: number) => `${value} €`,
|
|
37
|
+
}));
|
|
38
|
+
mockNuxtImport("useCheckout", () => () => ({
|
|
39
|
+
paymentMethods: ref([
|
|
40
|
+
{ id: "cash", distinguishableName: "Bar" },
|
|
41
|
+
{ id: "ec", distinguishableName: "EC-Karte" },
|
|
42
|
+
]),
|
|
43
|
+
shippingMethods: ref([
|
|
44
|
+
{ id: "delivery", name: "Lieferung" },
|
|
45
|
+
{ id: "pickup", name: "Abholung" },
|
|
46
|
+
]),
|
|
47
|
+
selectedPaymentMethod,
|
|
48
|
+
selectedShippingMethod,
|
|
49
|
+
setPaymentMethod: mocks.setPaymentMethod,
|
|
50
|
+
setShippingMethod: mocks.setShippingMethod,
|
|
51
|
+
getPaymentMethods: vi.fn(),
|
|
52
|
+
getShippingMethods: vi.fn(),
|
|
53
|
+
}));
|
|
54
|
+
mockNuxtImport("useCart", () => () => ({
|
|
55
|
+
refreshCart: mocks.refreshCart,
|
|
56
|
+
}));
|
|
57
|
+
mockNuxtImport("useCheckoutMethodGuard", () => () => ({
|
|
58
|
+
ensureAvailableCheckoutMethods: mocks.ensureAvailableCheckoutMethods,
|
|
59
|
+
ensureAvailableShippingMethod: vi.fn(),
|
|
60
|
+
ensureAvailablePaymentMethod: vi.fn(),
|
|
61
|
+
isShippingMethodBlocked: ref(false),
|
|
62
|
+
isPaymentMethodBlocked: ref(false),
|
|
63
|
+
isResolving: ref(false),
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
const lineItem = {
|
|
67
|
+
id: "li-1",
|
|
68
|
+
label: "Pizza Mix +Artischocken -Pilze",
|
|
69
|
+
quantity: 1,
|
|
70
|
+
type: "container",
|
|
71
|
+
price: { totalPrice: 9.5 },
|
|
72
|
+
children: [{ payload: { options: [{ group: "Größe", option: "30 cm" }] } }],
|
|
73
|
+
} as unknown as Schemas["LineItem"];
|
|
74
|
+
|
|
75
|
+
describe("cart and checkout with a preset (#443)", () => {
|
|
76
|
+
beforeEach(() => {
|
|
77
|
+
vi.clearAllMocks();
|
|
78
|
+
selectedShippingMethod.value = { id: "delivery", name: "Lieferung" };
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("shows a cart line with options and a stepper that removes at 1", async () => {
|
|
82
|
+
const wrapper = await mountSuspended(CartItem, {
|
|
83
|
+
props: { cartItem: lineItem },
|
|
84
|
+
});
|
|
85
|
+
expect(wrapper.find("h3").text()).toBe("Pizza Mix +Artischocken -Pilze");
|
|
86
|
+
expect(wrapper.text()).toContain("Größe: 30 cm");
|
|
87
|
+
expect(wrapper.text()).toContain("9.5 €");
|
|
88
|
+
|
|
89
|
+
const [remove, more] = wrapper.findAll('[role="group"] button');
|
|
90
|
+
expect(remove!.attributes("aria-label")).toBe(
|
|
91
|
+
"Pizza Mix +Artischocken -Pilze entfernen",
|
|
92
|
+
);
|
|
93
|
+
await more!.trigger("click");
|
|
94
|
+
expect(mocks.setQuantity).toHaveBeenCalledWith("li-1", 2);
|
|
95
|
+
|
|
96
|
+
await wrapper.setProps({ cartItem: { ...lineItem, quantity: 1 } });
|
|
97
|
+
await flushPromises();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("removes the line from the stepper at the minimum", async () => {
|
|
101
|
+
const wrapper = await mountSuspended(CartItem, {
|
|
102
|
+
props: { cartItem: lineItem },
|
|
103
|
+
});
|
|
104
|
+
await wrapper.findAll('[role="group"] button')[0]!.trigger("click");
|
|
105
|
+
expect(mocks.removeLineItem).toHaveBeenCalledWith(lineItem);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("offers shipping and payment as radio cards, shipping first", async () => {
|
|
109
|
+
const wrapper = await mountSuspended(PaymentAndDelivery);
|
|
110
|
+
await flushPromises();
|
|
111
|
+
|
|
112
|
+
const headings = wrapper.findAll("h2").map((h) => h.text());
|
|
113
|
+
expect(headings).toEqual(["Lieferung oder Abholung", "Bezahlung"]);
|
|
114
|
+
const groups = wrapper.findAll('[role="radiogroup"]');
|
|
115
|
+
expect(groups).toHaveLength(2);
|
|
116
|
+
expect(
|
|
117
|
+
groups[0]!.findAll('[role="radio"]').map((radio) => radio.text()),
|
|
118
|
+
).toEqual(["Lieferung", "Abholung"]);
|
|
119
|
+
|
|
120
|
+
await groups[0]!.findAll('[role="radio"]')[1]!.trigger("click");
|
|
121
|
+
await flushPromises();
|
|
122
|
+
expect(mocks.setShippingMethod).toHaveBeenCalledWith({ id: "pickup" });
|
|
123
|
+
expect(mocks.refreshCart).toHaveBeenCalled();
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
describe("useOrderMode (#443)", () => {
|
|
128
|
+
beforeEach(() => {
|
|
129
|
+
vi.clearAllMocks();
|
|
130
|
+
selectedShippingMethod.value = { id: "delivery", name: "Lieferung" };
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("switches the shipping method, then checks payment and the cart", async () => {
|
|
134
|
+
const { options, selectable, selectedId } = useOrderMode();
|
|
135
|
+
expect(selectable.value).toBe(true);
|
|
136
|
+
expect(options.value.map((option) => option.label)).toEqual([
|
|
137
|
+
"Lieferung",
|
|
138
|
+
"Abholung",
|
|
139
|
+
]);
|
|
140
|
+
|
|
141
|
+
selectedId.value = "pickup";
|
|
142
|
+
await flushPromises();
|
|
143
|
+
expect(mocks.setShippingMethod).toHaveBeenCalledWith({ id: "pickup" });
|
|
144
|
+
expect(mocks.ensureAvailableCheckoutMethods).toHaveBeenCalled();
|
|
145
|
+
expect(mocks.refreshCart).toHaveBeenCalled();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("ignores the method that is already selected", async () => {
|
|
149
|
+
const { selectedId } = useOrderMode();
|
|
150
|
+
selectedId.value = "delivery";
|
|
151
|
+
await flushPromises();
|
|
152
|
+
expect(mocks.setShippingMethod).not.toHaveBeenCalled();
|
|
153
|
+
});
|
|
154
|
+
});
|
|
@@ -75,12 +75,27 @@ describe("CartItem", () => {
|
|
|
75
75
|
expect(wrapper.vm.quantity).toBe(3);
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
+
it("removes the item from the stepper at quantity 1", async () => {
|
|
79
|
+
const wrapper = await mountSuspended(CartItem, {
|
|
80
|
+
props: { cartItem: { ...lineItem, quantity: 1 } },
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
await wrapper
|
|
84
|
+
.find('button[aria-label="Pizza Margherita entfernen"]')
|
|
85
|
+
.trigger("click");
|
|
86
|
+
expect(mockRemoveLineItem).toHaveBeenCalledWith(
|
|
87
|
+
expect.objectContaining({ id: "li-1" }),
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
|
|
78
91
|
it("removes the item through the mutation queue and disables the button while mutating", async () => {
|
|
79
92
|
const wrapper = await mountSuspended(CartItem, {
|
|
80
|
-
props: { cartItem: lineItem },
|
|
93
|
+
props: { cartItem: lineItem, withQuantityInput: false },
|
|
81
94
|
});
|
|
82
95
|
|
|
83
|
-
const button = wrapper.find(
|
|
96
|
+
const button = wrapper.find(
|
|
97
|
+
'button[aria-label="Pizza Margherita entfernen"]',
|
|
98
|
+
);
|
|
84
99
|
await button.trigger("click");
|
|
85
100
|
expect(mockRemoveLineItem).toHaveBeenCalledWith(lineItem);
|
|
86
101
|
|
|
@@ -88,7 +103,7 @@ describe("CartItem", () => {
|
|
|
88
103
|
await nextTick();
|
|
89
104
|
expect(
|
|
90
105
|
wrapper
|
|
91
|
-
.find('button[aria-label="
|
|
106
|
+
.find('button[aria-label="Pizza Margherita entfernen"]')
|
|
92
107
|
.attributes("disabled"),
|
|
93
108
|
).toBeDefined();
|
|
94
109
|
});
|
|
@@ -53,13 +53,12 @@ describe("CartUpsell", () => {
|
|
|
53
53
|
mockLoadUpsellProducts.mockResolvedValue([tiramisu, cola]);
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
it("shows the suggestions with name
|
|
56
|
+
it("shows the suggestions with name and price", async () => {
|
|
57
57
|
const wrapper = await mountUpsell();
|
|
58
58
|
|
|
59
59
|
expect(wrapper.find("h3").text()).toBe("Dazu passt");
|
|
60
60
|
const tiles = wrapper.findAll("li");
|
|
61
61
|
expect(tiles).toHaveLength(2);
|
|
62
|
-
expect(tiles[0]!.text()).toContain("#TIRAMISU");
|
|
63
62
|
expect(tiles[0]!.text()).toContain("Tiramisu");
|
|
64
63
|
expect(tiles[0]!.text()).toContain("5.5 €");
|
|
65
64
|
});
|
|
@@ -0,0 +1,120 @@
|
|
|
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 RegistrationFormPreset from "~/components/User/RegistrationForm.vue";
|
|
5
|
+
import LoginFormPreset from "~/components/User/LoginForm.vue";
|
|
6
|
+
|
|
7
|
+
// Forms of the one-page checkout with a style preset (#443).
|
|
8
|
+
const mocks = vi.hoisted(() => ({
|
|
9
|
+
register: vi.fn(),
|
|
10
|
+
login: vi.fn(),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
mockNuxtImport("useUser", () => () => ({
|
|
14
|
+
register: mocks.register,
|
|
15
|
+
login: mocks.login,
|
|
16
|
+
}));
|
|
17
|
+
mockNuxtImport("useAddressAutocomplete", () => () => ({
|
|
18
|
+
getSuggestions: vi.fn().mockResolvedValue([]),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
describe("registration form with a preset (#443)", () => {
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
vi.clearAllMocks();
|
|
24
|
+
useRuntimeConfig().public.site.countryId = "de";
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("lists the missing fields in a focused summary that links to them", async () => {
|
|
28
|
+
const wrapper = await mountSuspended(RegistrationFormPreset, {
|
|
29
|
+
attachTo: document.body,
|
|
30
|
+
});
|
|
31
|
+
await wrapper.find("form").trigger("submit");
|
|
32
|
+
await flushPromises();
|
|
33
|
+
|
|
34
|
+
const summary = wrapper.get('[role="alert"]');
|
|
35
|
+
expect(document.activeElement).toBe(summary.element);
|
|
36
|
+
const links = summary.findAll("a");
|
|
37
|
+
expect(links.length).toBeGreaterThanOrEqual(5);
|
|
38
|
+
// in the order of the form
|
|
39
|
+
expect(links.slice(0, 3).map((link) => link.attributes("href"))).toEqual([
|
|
40
|
+
"#firstName",
|
|
41
|
+
"#lastName",
|
|
42
|
+
"#email",
|
|
43
|
+
]);
|
|
44
|
+
for (const link of links) {
|
|
45
|
+
const id = link.attributes("href")!.slice(1);
|
|
46
|
+
expect(wrapper.find(`[id="${id}"]`).exists()).toBe(true);
|
|
47
|
+
}
|
|
48
|
+
expect(
|
|
49
|
+
wrapper.get("#billingAddress-street").attributes("aria-invalid"),
|
|
50
|
+
).toBe("true");
|
|
51
|
+
expect(mocks.register).not.toHaveBeenCalled();
|
|
52
|
+
wrapper.unmount();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("marks the address inputs for autofill", async () => {
|
|
56
|
+
const wrapper = await mountSuspended(RegistrationFormPreset);
|
|
57
|
+
expect(
|
|
58
|
+
wrapper.get("#billingAddress-street").attributes("autocomplete"),
|
|
59
|
+
).toBe("billing address-line1");
|
|
60
|
+
expect(
|
|
61
|
+
wrapper.get("#billingAddress-zipcode").attributes("autocomplete"),
|
|
62
|
+
).toBe("billing postal-code");
|
|
63
|
+
expect(wrapper.get("#email").attributes("autocomplete")).toBe("email");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("registers a guest once the form is complete", async () => {
|
|
67
|
+
mocks.register.mockResolvedValue({ active: true });
|
|
68
|
+
const wrapper = await mountSuspended(RegistrationFormPreset);
|
|
69
|
+
await wrapper.get("#firstName").setValue("Giulia");
|
|
70
|
+
await wrapper.get("#lastName").setValue("Rossi");
|
|
71
|
+
await wrapper.get("#email").setValue("giulia@example.com");
|
|
72
|
+
await wrapper.get("#billingAddress-street").setValue("Kantstraße 12");
|
|
73
|
+
await wrapper.get("#billingAddress-zipcode").setValue("63179");
|
|
74
|
+
await wrapper.get("#billingAddress-city").setValue("Obertshausen");
|
|
75
|
+
await wrapper.get("#billingAddress-phoneNumber").setValue("06104 12345");
|
|
76
|
+
await wrapper.get("#acceptedDataProtection").trigger("click");
|
|
77
|
+
await wrapper.find("form").trigger("submit");
|
|
78
|
+
await flushPromises();
|
|
79
|
+
|
|
80
|
+
expect(wrapper.find('[role="alert"]').exists()).toBe(false);
|
|
81
|
+
expect(mocks.register).toHaveBeenCalledWith(
|
|
82
|
+
expect.objectContaining({
|
|
83
|
+
guest: true,
|
|
84
|
+
email: "giulia@example.com",
|
|
85
|
+
billingAddress: expect.objectContaining({
|
|
86
|
+
firstName: "Giulia",
|
|
87
|
+
street: "Kantstraße 12",
|
|
88
|
+
}),
|
|
89
|
+
}),
|
|
90
|
+
);
|
|
91
|
+
expect(wrapper.emitted("registration-success")).toHaveLength(1);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe("login form with a preset (#443)", () => {
|
|
96
|
+
beforeEach(() => vi.clearAllMocks());
|
|
97
|
+
|
|
98
|
+
it("shows field errors and does not call the API", async () => {
|
|
99
|
+
const wrapper = await mountSuspended(LoginFormPreset);
|
|
100
|
+
await wrapper.get('input[name="email"]').setValue("keine-mail");
|
|
101
|
+
await wrapper.find("form").trigger("submit");
|
|
102
|
+
await flushPromises();
|
|
103
|
+
expect(wrapper.text()).toContain(
|
|
104
|
+
"Bitte geben Sie eine gültige E-Mail-Adresse ein.",
|
|
105
|
+
);
|
|
106
|
+
expect(mocks.login).not.toHaveBeenCalled();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("shows a failed login above the form", async () => {
|
|
110
|
+
mocks.login.mockRejectedValue(new Error("401"));
|
|
111
|
+
const wrapper = await mountSuspended(LoginFormPreset);
|
|
112
|
+
await wrapper.get('input[name="email"]').setValue("giulia@example.com");
|
|
113
|
+
await wrapper.get('input[name="password"]').setValue("geheim1234");
|
|
114
|
+
await wrapper.find("form").trigger("submit");
|
|
115
|
+
await flushPromises();
|
|
116
|
+
expect(wrapper.get('[role="alert"]').text()).toContain(
|
|
117
|
+
"Anmeldung fehlgeschlagen",
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
});
|