@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,222 +0,0 @@
1
- import { describe, it, expect, vi } from "vitest";
2
- import { reactive } from "vue";
3
- import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
4
- import Fields from "~/components/Address/Fields.vue";
5
- import type { AddressSchema } from "~/validation/registrationSchema";
6
-
7
- const { mockGetSuggestions } = vi.hoisted(() => ({
8
- mockGetSuggestions: vi.fn().mockResolvedValue([]),
9
- }));
10
-
11
- mockNuxtImport("useAddressAutocomplete", () => () => ({
12
- getSuggestions: mockGetSuggestions,
13
- }));
14
-
15
- describe("AddressFields", () => {
16
- const defaultProps = {
17
- modelValue: {
18
- firstName: "",
19
- lastName: "",
20
- street: "",
21
- zipcode: "",
22
- city: "",
23
- phoneNumber: "",
24
- countryId: "",
25
- },
26
- prefix: "billingAddress",
27
- };
28
-
29
- it("renders basic address fields", async () => {
30
- const wrapper = await mountSuspended(Fields, {
31
- props: defaultProps,
32
- });
33
-
34
- expect(wrapper.find('input[name="billingAddress.street"]').exists()).toBe(
35
- true,
36
- );
37
- expect(wrapper.find('input[name="billingAddress.zipcode"]').exists()).toBe(
38
- true,
39
- );
40
- expect(wrapper.find('input[name="billingAddress.city"]').exists()).toBe(
41
- true,
42
- );
43
- expect(
44
- wrapper.find('input[name="billingAddress.phoneNumber"]').exists(),
45
- ).toBe(true);
46
- });
47
-
48
- it("renders name fields when showNames is true", async () => {
49
- const wrapper = await mountSuspended(Fields, {
50
- props: {
51
- ...defaultProps,
52
- showNames: true,
53
- },
54
- });
55
-
56
- expect(
57
- wrapper.find('input[name="billingAddress.firstName"]').exists(),
58
- ).toBe(true);
59
- expect(wrapper.find('input[name="billingAddress.lastName"]').exists()).toBe(
60
- true,
61
- );
62
- });
63
-
64
- it("does not render name fields when showNames is false", async () => {
65
- const wrapper = await mountSuspended(Fields, {
66
- props: {
67
- ...defaultProps,
68
- showNames: false,
69
- },
70
- });
71
-
72
- expect(
73
- wrapper.find('input[name="billingAddress.firstName"]').exists(),
74
- ).toBe(false);
75
- expect(wrapper.find('input[name="billingAddress.lastName"]').exists()).toBe(
76
- false,
77
- );
78
- });
79
-
80
- it("renders business fields when accountType is business", async () => {
81
- const wrapper = await mountSuspended(Fields, {
82
- props: {
83
- ...defaultProps,
84
- accountType: "business",
85
- },
86
- });
87
-
88
- expect(wrapper.find('input[name="billingAddress.company"]').exists()).toBe(
89
- true,
90
- );
91
- expect(
92
- wrapper.find('input[name="billingAddress.department"]').exists(),
93
- ).toBe(true);
94
- });
95
-
96
- it("updates modelValue when input changes", async () => {
97
- const modelValue = reactive({
98
- firstName: "",
99
- lastName: "",
100
- street: "",
101
- zipcode: "",
102
- city: "",
103
- phoneNumber: "",
104
- countryId: "",
105
- });
106
- const wrapper = await mountSuspended(Fields, {
107
- props: {
108
- ...defaultProps,
109
- modelValue,
110
- "onUpdate:modelValue": (val: AddressSchema) =>
111
- Object.assign(modelValue, val),
112
- },
113
- });
114
-
115
- await wrapper
116
- .find('input[name="billingAddress.street"]')
117
- .setValue("New Street");
118
- expect(modelValue.street).toBe("New Street");
119
- });
120
-
121
- it("shows correction automatically on input after debounce", async () => {
122
- mockGetSuggestions.mockResolvedValue([
123
- {
124
- street: "Corrected Street 123",
125
- city: "Corrected City",
126
- zipcode: "54321",
127
- label: "Corrected Street 123, 54321 Corrected City",
128
- },
129
- ]);
130
-
131
- const modelValue = reactive({
132
- firstName: "John",
133
- lastName: "Doe",
134
- street: "Musterstr 1",
135
- zipcode: "12345",
136
- city: "Musterstadt",
137
- phoneNumber: "12345678",
138
- countryId: "",
139
- });
140
-
141
- const wrapper = await mountSuspended(Fields, {
142
- props: {
143
- ...defaultProps,
144
- modelValue,
145
- },
146
- });
147
-
148
- // Change input to trigger watch
149
- await wrapper
150
- .find('input[name="billingAddress.street"]')
151
- .setValue("Musterstr 2");
152
-
153
- // Wait for debounce and async check
154
- await new Promise((resolve) => setTimeout(resolve, 600));
155
-
156
- expect(wrapper.text()).toContain(
157
- "Meinten Sie: Corrected Street 123, 54321 Corrected City?",
158
- );
159
- });
160
-
161
- it("shows correction when checkAddress is called", async () => {
162
- const modelValue = reactive({
163
- firstName: "John",
164
- lastName: "Doe",
165
- street: "Musterstr 1",
166
- zipcode: "12345",
167
- city: "Musterstadt",
168
- phoneNumber: "12345678",
169
- countryId: "",
170
- });
171
-
172
- const _wrapper = await mountSuspended(Fields, {
173
- props: {
174
- ...defaultProps,
175
- modelValue,
176
- },
177
- });
178
-
179
- // Mock getSuggestions to return a correction
180
- // Note: In a real test we might need to mock useAddressAutocomplete
181
- // But let's see if we can just call the exposed method
182
-
183
- // For this to work reliably in test, we might need to mock useAddressAutocomplete
184
- // since it's used inside checkAddress
185
- });
186
-
187
- it("shows correction automatically on input after debounce even for short street names", async () => {
188
- mockGetSuggestions.mockResolvedValueOnce([
189
- {
190
- street: "B 1",
191
- city: "Berlin",
192
- zipcode: "10115",
193
- label: "B 1, 10115 Berlin",
194
- },
195
- ]);
196
-
197
- const modelValue = reactive({
198
- firstName: "John",
199
- lastName: "Doe",
200
- street: "",
201
- zipcode: "10115",
202
- city: "Berlin",
203
- phoneNumber: "12345678",
204
- countryId: "",
205
- });
206
-
207
- const wrapper = await mountSuspended(Fields, {
208
- props: {
209
- ...defaultProps,
210
- modelValue,
211
- },
212
- });
213
-
214
- // Change input to trigger watch
215
- await wrapper.find('input[name="billingAddress.street"]').setValue("B1");
216
-
217
- // Wait for debounce and async check
218
- await new Promise((resolve) => setTimeout(resolve, 600));
219
-
220
- expect(wrapper.text()).toContain("Meinten Sie: B 1, 10115 Berlin?");
221
- });
222
- });
@@ -1,67 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2
- import { mountSuspended } from "@nuxt/test-utils/runtime";
3
- import { renderToString } from "@vue/server-renderer";
4
- import { createSSRApp, h, nextTick } from "vue";
5
- import AnimatedSection from "~/components/AnimatedSection.vue";
6
-
7
- describe("AnimatedSection", () => {
8
- let intersectionCallback: IntersectionObserverCallback;
9
-
10
- beforeEach(() => {
11
- global.IntersectionObserver = vi.fn().mockImplementation(function (
12
- this: IntersectionObserver,
13
- callback: IntersectionObserverCallback,
14
- ) {
15
- intersectionCallback = callback;
16
- this.observe = vi.fn();
17
- this.unobserve = vi.fn();
18
- this.disconnect = vi.fn();
19
- }) as unknown as typeof IntersectionObserver;
20
- vi.stubGlobal("matchMedia", () => ({ matches: false }));
21
- });
22
-
23
- afterEach(() => {
24
- vi.unstubAllGlobals();
25
- });
26
-
27
- it("renders the content visible in the server HTML", async () => {
28
- const app = createSSRApp({
29
- render: () =>
30
- h(AnimatedSection, null, { default: () => h("p", "Pizza Salami") }),
31
- });
32
-
33
- const html = await renderToString(app);
34
-
35
- expect(html).toContain("Pizza Salami");
36
- expect(html).toContain("opacity-100");
37
- expect(html).not.toContain("opacity-0");
38
- });
39
-
40
- it("only hides a section that is out of view after mount, then reveals it", async () => {
41
- const wrapper = await mountSuspended(AnimatedSection, {
42
- slots: { default: () => "Pizza Salami" },
43
- });
44
- const section = wrapper.find("div");
45
-
46
- expect(section.classes()).toContain("opacity-100");
47
-
48
- intersectionCallback(
49
- [
50
- { isIntersecting: false, target: section.element },
51
- ] as unknown as IntersectionObserverEntry[],
52
- {} as IntersectionObserver,
53
- );
54
- await nextTick();
55
- expect(section.classes()).toContain("opacity-0");
56
- expect(section.classes()).toContain("translate-y-20");
57
-
58
- intersectionCallback(
59
- [
60
- { isIntersecting: true, target: section.element },
61
- ] as unknown as IntersectionObserverEntry[],
62
- {} as IntersectionObserver,
63
- );
64
- await nextTick();
65
- expect(section.classes()).toContain("opacity-100");
66
- });
67
- });
@@ -1,207 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
3
- import ContactForm from "~/components/Contact/Form.vue";
4
-
5
- type ContactFormVm = {
6
- submitted: boolean;
7
- successMessage: string;
8
- onSubmit: (arg: {
9
- data: Record<string, string | undefined>;
10
- }) => Promise<void>;
11
- };
12
-
13
- const { mockInvoke } = vi.hoisted(() => {
14
- return {
15
- mockInvoke: vi.fn(),
16
- };
17
- });
18
-
19
- mockNuxtImport("useShopwareContext", () => () => ({
20
- apiClient: {
21
- invoke: mockInvoke,
22
- },
23
- }));
24
-
25
- mockNuxtImport("useSalutations", () => () => ({
26
- getSalutations: ref([
27
- { id: "1", displayName: "Herr" },
28
- { id: "2", displayName: "Frau" },
29
- ]),
30
- }));
31
-
32
- const mockToastAdd = vi.fn();
33
- mockNuxtImport("useToast", () => () => ({
34
- add: mockToastAdd,
35
- }));
36
-
37
- describe("ContactForm", () => {
38
- beforeEach(() => {
39
- vi.clearAllMocks();
40
- });
41
-
42
- it("submits the form and shows success message component with custom individualSuccessMessage", async () => {
43
- const customMessage = "Vielen Dank für deine Nachricht!";
44
- mockInvoke.mockResolvedValueOnce({
45
- data: {
46
- individualSuccessMessage: customMessage,
47
- apiAlias: "contact_form_result",
48
- },
49
- });
50
-
51
- const wrapper = await mountSuspended(ContactForm);
52
-
53
- const validData = {
54
- salutationId: "1",
55
- firstName: "Max",
56
- lastName: "Mustermann",
57
- email: "max@example.com",
58
- phone: "01234 567890",
59
- subject: "Frage zum Produkt",
60
- comment: "Ich habe eine Frage zu Ihrem Produkt.",
61
- };
62
-
63
- await (wrapper.vm as unknown as ContactFormVm).onSubmit({
64
- data: validData,
65
- });
66
-
67
- expect(mockInvoke).toHaveBeenCalled();
68
- expect(mockToastAdd).toHaveBeenCalledWith(
69
- expect.objectContaining({
70
- description: customMessage,
71
- color: "success",
72
- }),
73
- );
74
-
75
- // Verify submitted state
76
- expect((wrapper.vm as unknown as ContactFormVm).submitted).toBe(true);
77
- expect((wrapper.vm as unknown as ContactFormVm).successMessage).toBe(
78
- customMessage,
79
- );
80
-
81
- // Wait for DOM update
82
- await nextTick();
83
-
84
- // Check if success message is displayed in the template
85
- expect(wrapper.text()).toContain(customMessage);
86
- expect(wrapper.text()).toContain("Weiteres Formular senden");
87
- expect(wrapper.find("form").exists()).toBe(false);
88
-
89
- // Click on "Weiteres Formular senden"
90
- await wrapper.find("button").trigger("click");
91
- expect((wrapper.vm as unknown as ContactFormVm).submitted).toBe(false);
92
-
93
- await nextTick();
94
- expect(wrapper.find("form").exists()).toBe(true);
95
- });
96
-
97
- it("submits the form and shows default success message if individualSuccessMessage is empty", async () => {
98
- mockInvoke.mockResolvedValueOnce({
99
- data: {
100
- individualSuccessMessage: "",
101
- apiAlias: "contact_form_result",
102
- },
103
- });
104
-
105
- const wrapper = await mountSuspended(ContactForm);
106
-
107
- const validData = {
108
- salutationId: "1",
109
- firstName: "Max",
110
- lastName: "Mustermann",
111
- email: "max@example.com",
112
- phone: "01234 567890",
113
- subject: "Frage zum Produkt",
114
- comment: "Ich habe eine Frage zu Ihrem Produkt.",
115
- };
116
-
117
- await (wrapper.vm as unknown as ContactFormVm).onSubmit({
118
- data: validData,
119
- });
120
-
121
- const defaultMessage = "Deine Nachricht wurde erfolgreich versendet.";
122
- expect((wrapper.vm as unknown as ContactFormVm).successMessage).toBe(
123
- defaultMessage,
124
- );
125
-
126
- await nextTick();
127
- expect(wrapper.text()).toContain(defaultMessage);
128
- });
129
-
130
- it("submits the form with only mandatory fields", async () => {
131
- mockInvoke.mockResolvedValueOnce({
132
- data: {
133
- individualSuccessMessage: "",
134
- apiAlias: "contact_form_result",
135
- },
136
- });
137
-
138
- const wrapper = await mountSuspended(ContactForm);
139
-
140
- const mandatoryDataOnly = {
141
- email: "test@example.com",
142
- subject: "Nur Betreff",
143
- comment: "Dies ist ein Test mit nur Pflichtfeldern.",
144
- };
145
-
146
- await (wrapper.vm as unknown as ContactFormVm).onSubmit({
147
- data: mandatoryDataOnly,
148
- });
149
-
150
- expect(mockInvoke).toHaveBeenCalledWith(
151
- "sendContactMail post /contact-form",
152
- {
153
- body: expect.objectContaining({
154
- email: "test@example.com",
155
- subject: "Nur Betreff",
156
- comment: "Dies ist ein Test mit nur Pflichtfeldern.",
157
- }),
158
- },
159
- );
160
-
161
- expect((wrapper.vm as unknown as ContactFormVm).submitted).toBe(true);
162
- });
163
-
164
- it("shows error toast when submission fails", async () => {
165
- mockInvoke.mockRejectedValueOnce(new Error("Network error"));
166
-
167
- const wrapper = await mountSuspended(ContactForm);
168
-
169
- const validData = {
170
- salutationId: "2",
171
- firstName: "Erika",
172
- lastName: "Musterfrau",
173
- email: "erika@example.com",
174
- phone: "09876 54321",
175
- subject: "Supportanfrage",
176
- comment: "Bitte um Unterstützung.",
177
- };
178
-
179
- await (wrapper.vm as unknown as ContactFormVm).onSubmit({
180
- data: validData,
181
- });
182
-
183
- expect(mockInvoke).toHaveBeenCalled();
184
-
185
- expect(mockToastAdd).toHaveBeenCalledWith(
186
- expect.objectContaining({
187
- title: "Fehler!",
188
- color: "error",
189
- }),
190
- );
191
- });
192
-
193
- it("does not call API but marks form as submitted when honeypot is filled", async () => {
194
- mockInvoke.mockClear();
195
- mockToastAdd.mockClear();
196
- const wrapper = await mountSuspended(ContactForm);
197
- const botData = {
198
- email: "bot@example.com",
199
- subject: "Bot request",
200
- comment: "This is spam.",
201
- hp: "I am a bot",
202
- };
203
- await (wrapper.vm as unknown as ContactFormVm).onSubmit({ data: botData });
204
- expect(mockInvoke).not.toHaveBeenCalled();
205
- expect((wrapper.vm as unknown as ContactFormVm).submitted).toBe(true);
206
- });
207
- });
@@ -1,102 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
3
- import { ref } from "vue";
4
- import FooterContact from "~/components/Footer/Contact.vue";
5
-
6
- const { businessHours } = vi.hoisted(() => ({
7
- businessHours: {
8
- value: [] as Array<{
9
- dayOfWeek: number;
10
- openingTime: string;
11
- closingTime: string;
12
- }>,
13
- },
14
- }));
15
-
16
- mockNuxtImport("useBusinessHours", () => () => ({
17
- businessHours: ref(businessHours.value),
18
- refresh: vi.fn(),
19
- }));
20
-
21
- mockNuxtImport("useStoreStatus", () => () => ({
22
- status: ref(null),
23
- }));
24
-
25
- // A useRuntimeConfig mock would also have to provide `app.baseURL` for the
26
- // router setup of the test environment; setting the real config is simpler.
27
- function setSite(site: {
28
- street?: string;
29
- postalCode?: string;
30
- city?: string;
31
- telephone?: string;
32
- googleBusinessProfileUrl?: string;
33
- }) {
34
- const config = useRuntimeConfig().public.site;
35
- Object.assign(config, {
36
- name: "Pizzeria Test",
37
- telephone: site.telephone ?? "",
38
- googleBusinessProfileUrl: site.googleBusinessProfileUrl ?? "",
39
- });
40
- Object.assign(config.address, {
41
- street: site.street ?? "",
42
- postalCode: site.postalCode ?? "",
43
- city: site.city ?? "",
44
- });
45
- }
46
-
47
- describe("FooterContact", () => {
48
- beforeEach(() => {
49
- businessHours.value = [];
50
- setSite({});
51
- });
52
-
53
- it("renders address, phone link, Google link and grouped opening hours", async () => {
54
- setSite({
55
- street: "Kantstr. 6",
56
- postalCode: "63179",
57
- city: "Obertshausen",
58
- telephone: "+49 6104 71427",
59
- googleBusinessProfileUrl: "https://maps.google.com/?cid=123",
60
- });
61
- businessHours.value = [
62
- { dayOfWeek: 1, openingTime: "11:30:00", closingTime: "14:30:00" },
63
- { dayOfWeek: 3, openingTime: "11:30:00", closingTime: "14:30:00" },
64
- ];
65
-
66
- const wrapper = await mountSuspended(FooterContact);
67
- const text = wrapper.text();
68
-
69
- expect(wrapper.find("address").exists()).toBe(true);
70
- expect(text).toContain("Pizzeria Test");
71
- expect(text).toContain("Kantstr. 6");
72
- expect(text).toContain("63179 Obertshausen");
73
- expect(wrapper.find('a[href="tel:+49610471427"]').text()).toContain(
74
- "+49 6104 71427",
75
- );
76
- expect(
77
- wrapper.find('a[href="https://maps.google.com/?cid=123"]').exists(),
78
- ).toBe(true);
79
- expect(text).toContain("Öffnungszeiten");
80
- expect(text).toContain("Di");
81
- expect(text).toContain("Ruhetag");
82
- expect(text).toContain("11:30–14:30");
83
- });
84
-
85
- it("hides empty contact values", async () => {
86
- setSite({ city: "Obertshausen" });
87
-
88
- const wrapper = await mountSuspended(FooterContact);
89
-
90
- expect(wrapper.text()).toContain("Obertshausen");
91
- expect(wrapper.find('a[href^="tel:"]').exists()).toBe(false);
92
- expect(wrapper.text()).not.toContain("Auf Google ansehen");
93
- expect(wrapper.text()).not.toContain("Öffnungszeiten");
94
- });
95
-
96
- it("renders nothing without contact data and opening hours", async () => {
97
- const wrapper = await mountSuspended(FooterContact);
98
-
99
- expect(wrapper.find("address").exists()).toBe(false);
100
- expect(wrapper.text()).toBe("");
101
- });
102
- });