@shopbite-de/storefront 1.31.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/.github/workflows/ci.yaml +54 -0
  2. package/.nuxtrc +1 -1
  3. package/CLAUDE.md +23 -8
  4. package/app/app.vue +10 -6
  5. package/app/assets/css/main.css +100 -61
  6. package/app/components/AddToWishlist.vue +15 -25
  7. package/app/components/Address/Card.vue +6 -11
  8. package/app/components/Address/Detail.vue +23 -23
  9. package/app/components/Address/Fields.vue +175 -73
  10. package/app/components/Address/Form.vue +107 -106
  11. package/app/components/Cart/Bar.vue +6 -9
  12. package/app/components/Cart/Item.vue +48 -63
  13. package/app/components/Cart/QuickView.vue +38 -25
  14. package/app/components/Cart/Upsell.vue +24 -62
  15. package/app/components/Category/Breadcrumb.vue +29 -3
  16. package/app/components/Category/FilterGroup.vue +20 -41
  17. package/app/components/Category/Listing.vue +100 -130
  18. package/app/components/Category/SearchInput.vue +22 -19
  19. package/app/components/Checkout/DeliveryTimeSelect.vue +55 -77
  20. package/app/components/Checkout/LoginOrRegister.vue +28 -29
  21. package/app/components/Checkout/PaymentAndDelivery.vue +114 -86
  22. package/app/components/Checkout/Summary.vue +90 -60
  23. package/app/components/Checkout/VoucherInput.vue +40 -27
  24. package/app/components/Contact/Form.vue +164 -192
  25. package/app/components/DemoBanner.vue +5 -5
  26. package/app/components/Footer/StoreStatus.vue +2 -2
  27. package/app/components/Footer.vue +125 -57
  28. package/app/components/Header.vue +283 -18
  29. package/app/components/Home/Categories.vue +116 -0
  30. package/app/components/Home/Facts.vue +71 -0
  31. package/app/components/Home/Faq.vue +34 -16
  32. package/app/components/Home/Hero.vue +172 -0
  33. package/app/components/Home/Highlights.vue +29 -37
  34. package/app/components/Home/Restaurant.vue +102 -0
  35. package/app/components/Menu/BonCard.vue +180 -0
  36. package/app/components/Menu/CartPanel.vue +24 -0
  37. package/app/components/Menu/CategoryIndex.vue +54 -0
  38. package/app/components/Menu/OrderMode.vue +20 -0
  39. package/app/components/Menu/SectionHeader.vue +38 -0
  40. package/app/components/Navigation/MobileTop.vue +23 -15
  41. package/app/components/Order/Confirmation.vue +119 -0
  42. package/app/components/Order/Detail.vue +80 -88
  43. package/app/components/Product/CardSkeleton.vue +8 -12
  44. package/app/components/Product/Configurator.vue +8 -16
  45. package/app/components/Product/CrossSelling.vue +75 -83
  46. package/app/components/Product/DeselectIngredient.vue +17 -22
  47. package/app/components/Product/Detail.vue +35 -27
  48. package/app/components/Product/QuickView.vue +80 -51
  49. package/app/components/SalesChannelSwitch.vue +14 -28
  50. package/app/components/Sb/Button.vue +70 -0
  51. package/app/components/Sb/Checkbox.vue +73 -0
  52. package/app/components/Sb/Chip.vue +51 -0
  53. package/app/components/Sb/ChoiceGroup.vue +82 -0
  54. package/app/components/Sb/ConfirmDialog.vue +60 -0
  55. package/app/components/Sb/Field.vue +77 -0
  56. package/app/components/Sb/Icon.vue +66 -0
  57. package/app/components/Sb/IconButton.vue +55 -0
  58. package/app/components/Sb/Input.vue +23 -0
  59. package/app/components/Sb/SegmentedControl.vue +34 -0
  60. package/app/components/Sb/Select.vue +49 -0
  61. package/app/components/Sb/Sheet.vue +83 -0
  62. package/app/components/Sb/Stars.vue +60 -0
  63. package/app/components/Sb/StatusPill.vue +38 -0
  64. package/app/components/Sb/Stepper.vue +72 -0
  65. package/app/components/User/AccountHeader.vue +16 -0
  66. package/app/components/User/AuthPanel.vue +41 -0
  67. package/app/components/User/Detail.vue +32 -29
  68. package/app/components/User/LoginForm.vue +92 -98
  69. package/app/components/User/RegistrationForm.vue +285 -249
  70. package/app/components/Wishlist.vue +55 -155
  71. package/app/composables/useCartMutations.ts +9 -27
  72. package/app/composables/useCheckoutMethodGuard.ts +2 -24
  73. package/app/composables/useContactForm.ts +66 -0
  74. package/app/composables/useHomeMenuCategories.ts +41 -0
  75. package/app/composables/useNavigation.ts +10 -2
  76. package/app/composables/useOrderMode.ts +65 -0
  77. package/app/composables/useRegistrationForm.ts +161 -0
  78. package/app/composables/useRestaurantSchema.ts +1 -1
  79. package/app/composables/useShareLink.ts +3 -13
  80. package/app/composables/useSortingSelection.ts +13 -0
  81. package/app/composables/useThemePreset.ts +15 -0
  82. package/app/composables/useVoucherCode.ts +7 -16
  83. package/app/composables/useWishlistActions.ts +0 -51
  84. package/app/error.vue +31 -9
  85. package/app/layouts/account.vue +45 -50
  86. package/app/layouts/default.vue +2 -3
  87. package/app/layouts/listing.vue +3 -5
  88. package/app/pages/[...all].vue +8 -4
  89. package/app/pages/account/recover/password/index.vue +113 -80
  90. package/app/pages/anmelden.vue +11 -10
  91. package/app/pages/bestellung/[id]/erfolg.vue +1 -15
  92. package/app/pages/bestellung/[id]/fehler.vue +63 -51
  93. package/app/pages/bestellung/[id]/index.vue +3 -85
  94. package/app/pages/bestellung/kasse.vue +29 -0
  95. package/app/pages/bestellung.vue +8 -60
  96. package/app/pages/index.vue +12 -52
  97. package/app/pages/kontakt.vue +27 -7
  98. package/app/pages/konto/adressen.vue +106 -102
  99. package/app/pages/konto/bestellung/[id].vue +9 -43
  100. package/app/pages/konto/bestellungen.vue +55 -33
  101. package/app/pages/konto/index.vue +47 -62
  102. package/app/pages/konto/profil.vue +162 -100
  103. package/app/pages/maintenance.vue +8 -6
  104. package/app/pages/merkliste.vue +7 -8
  105. package/app/pages/passwort-vergessen.vue +92 -75
  106. package/app/pages/registrierung/bestaetigen.vue +20 -48
  107. package/app/pages/registrierung/index.vue +16 -7
  108. package/app/pages/suche.vue +94 -95
  109. package/app/plugins/theme-preset.ts +9 -0
  110. package/app/utils/highlight.ts +25 -0
  111. package/app/utils/product.ts +9 -0
  112. package/app/validation/registrationSchema.ts +1 -1
  113. package/docs/notes/2026-10-07-issue-434-property-group-projection.md +27 -0
  114. package/docs/notes/2026-10-07-listing-payload.md +38 -0
  115. package/docs/notes/2026-10-07-nuxt-4.6-inline-error-rendering.md +31 -0
  116. package/modules/theme.ts +115 -0
  117. package/nuxt.config.ts +27 -15
  118. package/package.json +6 -8
  119. package/playwright.config.ts +11 -0
  120. package/server/api/listing/[categoryId].get.ts +10 -11
  121. package/server/api/product/[productId].get.ts +4 -2
  122. package/server/api/product/variant.get.ts +1 -2
  123. package/server/api/search.get.ts +7 -12
  124. package/shared/theme/presets.ts +303 -0
  125. package/test/a11y/presets.test.ts +225 -0
  126. package/test/nuxt/AccountPagesPreset.test.ts +191 -0
  127. package/test/nuxt/AuthPagesPreset.test.ts +87 -0
  128. package/test/nuxt/CartCheckoutPreset.test.ts +154 -0
  129. package/test/nuxt/CartItem.test.ts +18 -3
  130. package/test/nuxt/CartUpsell.test.ts +1 -2
  131. package/test/nuxt/CheckoutFormsPreset.test.ts +120 -0
  132. package/test/nuxt/CheckoutOnePage.test.ts +115 -0
  133. package/test/nuxt/CheckoutSummary.test.ts +6 -6
  134. package/test/nuxt/CheckoutVoucherInput.test.ts +20 -32
  135. package/test/nuxt/ContactFormPreset.test.ts +115 -0
  136. package/test/nuxt/FooterStoreStatus.test.ts +2 -2
  137. package/test/nuxt/HeaderFooterPreset.test.ts +134 -0
  138. package/test/nuxt/HomeFaq.test.ts +3 -2
  139. package/test/nuxt/MenuBonCard.test.ts +122 -0
  140. package/test/nuxt/OrderPagesPreset.test.ts +132 -0
  141. package/test/nuxt/PaymentAndDelivery.test.ts +0 -4
  142. package/test/nuxt/ProductCrossSelling.test.ts +2 -1
  143. package/test/nuxt/ProductDeselectIngredient.test.ts +5 -3
  144. package/test/nuxt/ProductSheetPreset.test.ts +105 -0
  145. package/test/nuxt/RegisterConfirmPage.test.ts +0 -8
  146. package/test/nuxt/RegistrationForm.test.ts +89 -270
  147. package/test/nuxt/SbBaseComponents.test.ts +170 -0
  148. package/test/nuxt/SbStars.test.ts +25 -0
  149. package/test/nuxt/useCartMutations.test.ts +3 -17
  150. package/test/nuxt/useCartUpsell.test.ts +1 -1
  151. package/test/nuxt/useCheckoutMethodGuard.test.ts +0 -27
  152. package/test/nuxt/useShareLink.test.ts +1 -9
  153. package/test/nuxt/useWishlistActions.test.ts +3 -26
  154. package/test/unit/highlight.spec.ts +31 -0
  155. package/test/unit/product.spec.ts +12 -0
  156. package/test/unit/themePresets.spec.ts +61 -0
  157. package/app/app.config.ts +0 -19
  158. package/app/components/AnimatedSection.vue +0 -74
  159. package/app/components/BottomNavi.vue +0 -70
  160. package/app/components/Category/Header.vue +0 -48
  161. package/app/components/Checkout/PaymentMethod.vue +0 -30
  162. package/app/components/Checkout/ShippingMethod.vue +0 -30
  163. package/app/components/Cta.vue +0 -30
  164. package/app/components/Feature/Card.vue +0 -121
  165. package/app/components/Features.vue +0 -42
  166. package/app/components/Footer/Contact.vue +0 -82
  167. package/app/components/Header/Body.vue +0 -82
  168. package/app/components/Header/Right.vue +0 -187
  169. package/app/components/Header/Title.vue +0 -10
  170. package/app/components/Hero.vue +0 -233
  171. package/app/components/Home/MenuCategories.vue +0 -148
  172. package/app/components/ImageGallery.vue +0 -63
  173. package/app/components/Loading.vue +0 -29
  174. package/app/components/Navigation/DesktopLeft.vue +0 -39
  175. package/app/components/Product/Card.vue +0 -177
  176. package/app/components/Product/CardCompact.vue +0 -72
  177. package/app/components/Product/CardDietBadges.vue +0 -43
  178. package/app/components/Product/CardIngredients.vue +0 -35
  179. package/app/components/Product/CardKitchen.vue +0 -34
  180. package/app/components/Product/Category.vue +0 -160
  181. package/app/components/Product/SearchBar.vue +0 -95
  182. package/app/components/PublicAnnouncement.vue +0 -17
  183. package/app/pages/bestellung/bestaetigen.vue +0 -16
  184. package/app/pages/bestellung/warenkorb.vue +0 -49
  185. package/app/pages/bestellung/zahlung-versand.vue +0 -25
  186. package/test/nuxt/AddressFields.test.ts +0 -222
  187. package/test/nuxt/AnimatedSection.test.ts +0 -67
  188. package/test/nuxt/ContactForm.test.ts +0 -207
  189. package/test/nuxt/FooterContact.test.ts +0 -102
  190. package/test/nuxt/HeaderRight.test.ts +0 -142
  191. package/test/nuxt/Hero.test.ts +0 -126
  192. package/test/nuxt/HomeMenuCategories.test.ts +0 -94
  193. package/test/nuxt/LoginForm.test.ts +0 -159
@@ -1,142 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
3
- import HeaderRight from "~/components/Header/Right.vue";
4
- import { ref, reactive, computed } from "vue";
5
-
6
- const mocks = vi.hoisted(() => ({
7
- state: {
8
- isLoggedIn: false,
9
- isGuestSession: false,
10
- user: null as { firstName: string; lastName: string } | null,
11
- telephone: "+49 6104 71427",
12
- },
13
- toastAddCalled: { value: false },
14
- }));
15
-
16
- const reactiveState = reactive(mocks.state);
17
-
18
- mockNuxtImport("useUser", () => () => ({
19
- isLoggedIn: computed(() => reactiveState.isLoggedIn),
20
- isGuestSession: computed(() => reactiveState.isGuestSession),
21
- user: computed(() => reactiveState.user),
22
- logout: () => {
23
- reactiveState.isLoggedIn = false;
24
- reactiveState.user = null;
25
- },
26
- }));
27
-
28
- mockNuxtImport("useToast", () => () => ({
29
- add: (_payload: unknown) => {
30
- mocks.toastAddCalled.value = true;
31
- },
32
- }));
33
-
34
- mockNuxtImport("useShopBiteConfig", () => () => ({
35
- isCheckoutEnabled: ref(true),
36
- }));
37
-
38
- mockNuxtImport("useCart", () => () => ({
39
- count: ref(5),
40
- }));
41
-
42
- mockNuxtImport("useRuntimeConfig", () => () => ({
43
- app: { baseURL: "/" },
44
- public: { shopware: {}, site: { telephone: mocks.state.telephone } },
45
- }));
46
-
47
- mockNuxtImport("useWishlist", () => () => ({
48
- count: ref(0),
49
- }));
50
-
51
- // Mock Nuxt Content queryCollection
52
- mockNuxtImport("queryCollection", () => (_collection: string) => ({
53
- first: () =>
54
- Promise.resolve({
55
- account: {
56
- loggedIn: [
57
- [{ label: "Mein Konto", type: "label" }],
58
- [
59
- {
60
- label: "Bestellungen",
61
- icon: "i-lucide-pizza",
62
- to: "/konto/bestellungen",
63
- },
64
- ],
65
- [{ label: "Abmelden", icon: "i-lucide-log-out", action: "logout" }],
66
- ],
67
- loggedOut: [
68
- [{ label: "Jetzt anmelden", type: "label" }],
69
- [{ label: "Zur Anmeldung", icon: "i-lucide-user", to: "/anmelden" }],
70
- ],
71
- },
72
- }),
73
- }));
74
-
75
- describe("HeaderRight", () => {
76
- beforeEach(() => {
77
- reactiveState.isLoggedIn = false;
78
- reactiveState.isGuestSession = false;
79
- reactiveState.user = null;
80
- mocks.toastAddCalled.value = false;
81
- vi.clearAllMocks();
82
- });
83
-
84
- it("renders the phone link from the site config", async () => {
85
- const component = await mountSuspended(HeaderRight);
86
- const phoneButton = component.find('a[href="tel:+49610471427"]');
87
- expect(phoneButton.exists()).toBe(true);
88
- expect(phoneButton.attributes("aria-label")).toBe(
89
- "Anrufen: +49 6104 71427",
90
- );
91
- });
92
-
93
- it("hides the phone link without a configured number", async () => {
94
- mocks.state.telephone = "";
95
- const component = await mountSuspended(HeaderRight);
96
- expect(component.find('a[href^="tel:"]').exists()).toBe(false);
97
- mocks.state.telephone = "+49 6104 71427";
98
- });
99
-
100
- it("shows logged out dropdown items when not logged in", async () => {
101
- const component = await mountSuspended(HeaderRight);
102
- const dropdown = component.findComponent({ name: "UDropdownMenu" });
103
- const items = dropdown.props("items");
104
-
105
- expect(items[0][0].label).toBe("Mein Konto");
106
- });
107
-
108
- it("shows logged in dropdown items when logged in", async () => {
109
- reactiveState.isLoggedIn = true;
110
- reactiveState.user = { firstName: "Jane", lastName: "Doe" };
111
-
112
- const component = await mountSuspended(HeaderRight);
113
- const dropdown = component.findComponent({ name: "UDropdownMenu" });
114
- const items = dropdown.props("items");
115
-
116
- expect(items[0][0].label).toBe("Mein Konto");
117
- });
118
-
119
- it("calls logout and updates state when logout is selected", async () => {
120
- reactiveState.isLoggedIn = true;
121
- const component = await mountSuspended(HeaderRight);
122
- const dropdown = component.findComponent({ name: "UDropdownMenu" });
123
- const items = dropdown.props("items");
124
-
125
- // Find the item with logout handler
126
- let logoutItem;
127
- for (const group of items) {
128
- for (const item of group) {
129
- if (item.label === "Abmelden") {
130
- logoutItem = item;
131
- break;
132
- }
133
- }
134
- }
135
-
136
- expect(logoutItem).toBeDefined();
137
- logoutItem.onSelect();
138
-
139
- expect(reactiveState.isLoggedIn).toBe(false);
140
- expect(mocks.toastAddCalled.value).toBe(true);
141
- });
142
- });
@@ -1,126 +0,0 @@
1
- import { describe, it, expect, vi, afterEach } from "vitest";
2
- import { mockNuxtImport, mountSuspended } from "@nuxt/test-utils/runtime";
3
- import { computed, nextTick, ref } from "vue";
4
- import Hero from "~/components/Hero.vue";
5
- import type { StoreStatus } from "~/composables/useStoreStatus";
6
-
7
- const { liveState } = vi.hoisted(() => ({
8
- liveState: {
9
- status: null as StoreStatus | null,
10
- isCheckoutEnabled: true,
11
- },
12
- }));
13
-
14
- mockNuxtImport("useStoreStatus", () => () => ({
15
- status: ref(liveState.status),
16
- }));
17
-
18
- mockNuxtImport("useShopBiteConfig", () => () => ({
19
- deliveryTime: computed(() => 30),
20
- isCheckoutEnabled: computed(() => liveState.isCheckoutEnabled),
21
- }));
22
-
23
- const props = {
24
- title: "Pizzeria",
25
- links: [],
26
- backgroundVideo: "https://cdn.example.com/hero.mp4",
27
- poster: "/hero-poster.webp",
28
- };
29
-
30
- function stubMatchMedia(matches: boolean) {
31
- const listeners: Array<(event: { matches: boolean }) => void> = [];
32
- vi.stubGlobal("matchMedia", (query: string) => ({
33
- matches,
34
- media: query,
35
- addEventListener: (_: string, listener: (typeof listeners)[number]) =>
36
- listeners.push(listener),
37
- }));
38
- return (next: boolean) =>
39
- listeners.forEach((listener) => listener({ matches: next }));
40
- }
41
-
42
- describe("Hero", () => {
43
- afterEach(() => {
44
- vi.unstubAllGlobals();
45
- liveState.status = null;
46
- liveState.isCheckoutEnabled = true;
47
- });
48
-
49
- it("shows the delivery time before the store status is known", async () => {
50
- stubMatchMedia(false);
51
-
52
- const wrapper = await mountSuspended(Hero, { props });
53
-
54
- expect(wrapper.find('[data-testid="hero-status"]').exists()).toBe(false);
55
- const delivery = wrapper.find('[data-testid="hero-delivery"]');
56
- expect(delivery.text()).toBe("Lieferung ca. 30 Min");
57
- // Phones show it in its own row; from sm it waits for the status.
58
- expect(delivery.classes()).toContain("sm:hidden");
59
- });
60
-
61
- it("shows status and delivery time side by side once the status is known", async () => {
62
- stubMatchMedia(false);
63
- liveState.status = { open: false, nextOpening: "17:30 Uhr" };
64
-
65
- const wrapper = await mountSuspended(Hero, { props });
66
-
67
- expect(wrapper.find('[data-testid="hero-status"]').text()).toBe(
68
- "Geschlossen · öffnet 17:30 Uhr",
69
- );
70
- expect(
71
- wrapper.find('[data-testid="hero-delivery"]').classes(),
72
- ).not.toContain("sm:hidden");
73
- });
74
-
75
- it("hides the delivery time when the checkout is disabled", async () => {
76
- stubMatchMedia(false);
77
- liveState.status = { open: true, closesAt: "23:00" };
78
- liveState.isCheckoutEnabled = false;
79
-
80
- const wrapper = await mountSuspended(Hero, { props });
81
-
82
- expect(wrapper.find('[data-testid="hero-status"]').text()).toBe(
83
- "Geöffnet bis 23:00",
84
- );
85
- expect(wrapper.find('[data-testid="hero-delivery"]').exists()).toBe(false);
86
- });
87
-
88
- it("renders the poster as high-priority image and no video on narrow screens", async () => {
89
- stubMatchMedia(false);
90
-
91
- const wrapper = await mountSuspended(Hero, { props });
92
-
93
- const poster = wrapper.find("img");
94
- expect(poster.attributes("src")).toBe("/hero-poster.webp");
95
- expect(poster.attributes("fetchpriority")).toBe("high");
96
- expect(wrapper.find("video").exists()).toBe(false);
97
- });
98
-
99
- it("adds the video on wide screens, with the poster and without eager loading", async () => {
100
- const changeViewport = stubMatchMedia(true);
101
-
102
- const wrapper = await mountSuspended(Hero, { props });
103
-
104
- const video = wrapper.find("video");
105
- expect(video.exists()).toBe(true);
106
- expect(video.attributes("poster")).toBe("/hero-poster.webp");
107
- expect(video.attributes("preload")).toBe("metadata");
108
- expect(video.attributes("fetchpriority")).toBeUndefined();
109
- expect(video.find("source").attributes("src")).toBe(props.backgroundVideo);
110
-
111
- changeViewport(false);
112
- await nextTick();
113
- expect(wrapper.find("video").exists()).toBe(false);
114
- });
115
-
116
- it("renders neither poster nor video without media", async () => {
117
- stubMatchMedia(true);
118
-
119
- const wrapper = await mountSuspended(Hero, {
120
- props: { title: "Pizzeria", links: [] },
121
- });
122
-
123
- expect(wrapper.find("img").exists()).toBe(false);
124
- expect(wrapper.find("video").exists()).toBe(false);
125
- });
126
- });
@@ -1,94 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- import { mockNuxtImport, mountSuspended } from "@nuxt/test-utils/runtime";
3
- import HomeMenuCategories from "~/components/Home/MenuCategories.vue";
4
-
5
- const { mockInvoke } = vi.hoisted(() => ({
6
- mockInvoke: vi.fn(),
7
- }));
8
-
9
- mockNuxtImport("useShopwareContext", () => () => ({
10
- apiClient: { invoke: mockInvoke },
11
- }));
12
-
13
- function category(
14
- id: string,
15
- name: string,
16
- extra: Record<string, unknown> = {},
17
- ) {
18
- return {
19
- id,
20
- name,
21
- translated: { name },
22
- seoUrl: `/Speisekarte/${name}/`,
23
- customFields: { shopbite_category_icon: "i-lucide-pizza" },
24
- media: null,
25
- ...extra,
26
- };
27
- }
28
-
29
- describe("HomeMenuCategories", () => {
30
- beforeEach(() => {
31
- mockInvoke.mockReset();
32
- // useAsyncData keeps the last answer under its key across the cases
33
- clearNuxtData("home-menu-categories");
34
- });
35
-
36
- it("renders one tile per menu section with its photo or icon", async () => {
37
- mockInvoke.mockResolvedValue({
38
- data: [
39
- category("1", "Pizza", {
40
- media: {
41
- url: "https://cdn.example.com/pizza.jpg",
42
- thumbnails: [
43
- { url: "https://cdn.example.com/pizza-400.jpg", width: 400 },
44
- ],
45
- metaData: { width: 800, height: 600 },
46
- },
47
- }),
48
- category("2", "Pasta"),
49
- ],
50
- });
51
-
52
- const wrapper = await mountSuspended(HomeMenuCategories, {
53
- props: { title: "Unsere Speisekarte" },
54
- });
55
-
56
- const tiles = wrapper.findAll("[data-testid=menu-categories] li");
57
- expect(tiles).toHaveLength(2);
58
- expect(tiles[0]?.find("a").attributes("href")).toBe("/Speisekarte/Pizza/");
59
- expect(tiles[0]?.find("img").attributes("srcset")).toContain("400w");
60
- expect(tiles[1]?.find("img").exists()).toBe(false);
61
- expect(wrapper.text()).toContain("Pasta");
62
-
63
- const [operation, options] = mockInvoke.mock.calls[0] ?? [];
64
- expect(operation).toBe(
65
- "readNavigation post /navigation/{activeId}/{rootId}",
66
- );
67
- expect(options.body.includes.category).toContain("media");
68
- });
69
-
70
- it("caps the tiles and links to the whole menu", async () => {
71
- mockInvoke.mockResolvedValue({
72
- data: Array.from({ length: 4 }, (_, i) =>
73
- category(String(i), `Bereich ${i}`),
74
- ),
75
- });
76
-
77
- const wrapper = await mountSuspended(HomeMenuCategories, {
78
- props: { limit: 3 },
79
- });
80
-
81
- const tiles = wrapper.findAll("[data-testid=menu-categories] li");
82
- expect(tiles).toHaveLength(4);
83
- expect(tiles[3]?.find("a").attributes("href")).toBe("/speisekarte/");
84
- expect(tiles[3]?.text()).toContain("4 Bereiche");
85
- });
86
-
87
- it("renders nothing without menu sections", async () => {
88
- mockInvoke.mockResolvedValue({ data: [] });
89
-
90
- const wrapper = await mountSuspended(HomeMenuCategories);
91
-
92
- expect(wrapper.find("[data-testid=menu-categories]").exists()).toBe(false);
93
- });
94
- });
@@ -1,159 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
3
- import { ref } from "vue";
4
- import LoginForm from "@/components/User/LoginForm.vue";
5
- import { ApiClientError } from "@shopware/api-client";
6
-
7
- type LoginFormVm = {
8
- onSubmit: (arg: {
9
- data: { email: string; password: string };
10
- }) => Promise<void>;
11
- };
12
-
13
- vi.mock("@shopware/api-client", () => ({
14
- ApiClientError: class extends Error {
15
- details: unknown;
16
- constructor(details: unknown) {
17
- super("ApiClientError");
18
- this.details = details;
19
- }
20
- },
21
- }));
22
-
23
- vi.mock("@shopware/composables", () => ({
24
- useUser: vi.fn(),
25
- useWishlist: vi.fn(),
26
- }));
27
-
28
- const mockToastAdd = vi.fn();
29
- mockNuxtImport("useToast", () => {
30
- return () => ({
31
- add: mockToastAdd,
32
- });
33
- });
34
-
35
- const loginMock = vi.fn();
36
- const userMock = ref({ firstName: "John", lastName: "Doe" });
37
- const isLoggedInMock = ref(false);
38
-
39
- mockNuxtImport("useUser", () => {
40
- return () => ({
41
- isLoggedIn: isLoggedInMock,
42
- login: loginMock,
43
- user: userMock,
44
- });
45
- });
46
-
47
- mockNuxtImport("useWishlist", () => {
48
- return () => ({
49
- mergeWishlistProducts: vi.fn(),
50
- });
51
- });
52
-
53
- describe("LoginForm", () => {
54
- beforeEach(() => {
55
- vi.clearAllMocks();
56
- loginMock.mockReset();
57
- isLoggedInMock.value = false;
58
- userMock.value = { firstName: "John", lastName: "Doe" };
59
- });
60
-
61
- it("should show success toast on successful login", async () => {
62
- loginMock.mockResolvedValueOnce({});
63
- const wrapper = await mountSuspended(LoginForm);
64
-
65
- // Call onSubmit directly if form trigger is not working in test
66
- await (wrapper.vm as unknown as LoginFormVm).onSubmit({
67
- data: {
68
- email: "test@example.com",
69
- password: "password123",
70
- },
71
- });
72
-
73
- expect(loginMock).toHaveBeenCalledWith({
74
- username: "test@example.com",
75
- password: "password123",
76
- });
77
-
78
- expect(mockToastAdd).toHaveBeenCalledWith(
79
- expect.objectContaining({
80
- title: "Hallo John Doe!",
81
- description: "Erfolgreich angemeldet.",
82
- color: "success",
83
- }),
84
- );
85
- });
86
-
87
- it("should show error toast on failed login", async () => {
88
- loginMock.mockRejectedValueOnce(new Error("Invalid credentials"));
89
- const wrapper = await mountSuspended(LoginForm);
90
-
91
- // Call onSubmit directly if form trigger is not working in test
92
- await (wrapper.vm as unknown as LoginFormVm).onSubmit({
93
- data: {
94
- email: "test@example.com",
95
- password: "wrongpassword",
96
- },
97
- });
98
-
99
- expect(loginMock).toHaveBeenCalled();
100
-
101
- expect(mockToastAdd).toHaveBeenCalledWith(
102
- expect.objectContaining({
103
- title: "Login fehlgeschlagen",
104
- description: "Bitte überprüfen Sie Ihre Zugangsdaten.",
105
- color: "error",
106
- }),
107
- );
108
- });
109
-
110
- it("should show detailed error toast on ApiClientError", async () => {
111
- const apiClientError = new ApiClientError({
112
- errors: [
113
- {
114
- detail: 'The email address "test@example.com" is already in use',
115
- },
116
- ],
117
- } as unknown as ConstructorParameters<typeof ApiClientError>[0]);
118
- loginMock.mockRejectedValueOnce(apiClientError);
119
- const wrapper = await mountSuspended(LoginForm);
120
-
121
- await (wrapper.vm as unknown as LoginFormVm).onSubmit({
122
- data: {
123
- email: "test@example.com",
124
- password: "password123",
125
- },
126
- });
127
-
128
- expect(mockToastAdd).toHaveBeenCalledWith(
129
- expect.objectContaining({
130
- title: "Login fehlgeschlagen",
131
- description: 'The email address "test@example.com" is already in use',
132
- color: "error",
133
- }),
134
- );
135
- });
136
-
137
- it("should handle ApiClientError with missing errors gracefully", async () => {
138
- const apiClientError = new ApiClientError(
139
- {} as unknown as ConstructorParameters<typeof ApiClientError>[0],
140
- );
141
- loginMock.mockRejectedValueOnce(apiClientError);
142
- const wrapper = await mountSuspended(LoginForm);
143
-
144
- await (wrapper.vm as unknown as LoginFormVm).onSubmit({
145
- data: {
146
- email: "test@example.com",
147
- password: "password123",
148
- },
149
- });
150
-
151
- expect(mockToastAdd).toHaveBeenCalledWith(
152
- expect.objectContaining({
153
- title: "Login fehlgeschlagen",
154
- description: "Bitte überprüfen Sie Ihre Zugangsdaten.",
155
- color: "error",
156
- }),
157
- );
158
- });
159
- });