@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.
Files changed (187) hide show
  1. package/.github/workflows/ci.yaml +87 -0
  2. package/.gitignore +5 -0
  3. package/CLAUDE.md +27 -8
  4. package/app/app.vue +10 -6
  5. package/app/assets/css/main.css +103 -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 +24 -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/modules/theme.ts +123 -0
  114. package/nuxt.config.ts +30 -16
  115. package/package.json +6 -8
  116. package/playwright.config.ts +11 -0
  117. package/server/api/listing/[categoryId].get.ts +3 -0
  118. package/shared/theme/presets.ts +303 -0
  119. package/test/a11y/presets.test.ts +225 -0
  120. package/test/layer/nuxt.config.ts +8 -0
  121. package/test/nuxt/AccountPagesPreset.test.ts +191 -0
  122. package/test/nuxt/AuthPagesPreset.test.ts +87 -0
  123. package/test/nuxt/CartCheckoutPreset.test.ts +154 -0
  124. package/test/nuxt/CartItem.test.ts +18 -3
  125. package/test/nuxt/CartUpsell.test.ts +1 -2
  126. package/test/nuxt/CheckoutFormsPreset.test.ts +120 -0
  127. package/test/nuxt/CheckoutOnePage.test.ts +115 -0
  128. package/test/nuxt/CheckoutSummary.test.ts +6 -6
  129. package/test/nuxt/CheckoutVoucherInput.test.ts +20 -32
  130. package/test/nuxt/ContactFormPreset.test.ts +115 -0
  131. package/test/nuxt/FooterStoreStatus.test.ts +2 -2
  132. package/test/nuxt/HeaderFooterPreset.test.ts +134 -0
  133. package/test/nuxt/HomeFaq.test.ts +3 -2
  134. package/test/nuxt/MenuBonCard.test.ts +122 -0
  135. package/test/nuxt/OrderPagesPreset.test.ts +132 -0
  136. package/test/nuxt/PaymentAndDelivery.test.ts +0 -4
  137. package/test/nuxt/ProductCrossSelling.test.ts +2 -1
  138. package/test/nuxt/ProductDeselectIngredient.test.ts +5 -3
  139. package/test/nuxt/ProductSheetPreset.test.ts +105 -0
  140. package/test/nuxt/RegisterConfirmPage.test.ts +0 -8
  141. package/test/nuxt/RegistrationForm.test.ts +89 -270
  142. package/test/nuxt/SbBaseComponents.test.ts +170 -0
  143. package/test/nuxt/SbStars.test.ts +25 -0
  144. package/test/nuxt/useCartMutations.test.ts +3 -17
  145. package/test/nuxt/useCartUpsell.test.ts +1 -1
  146. package/test/nuxt/useCheckoutMethodGuard.test.ts +0 -27
  147. package/test/nuxt/useShareLink.test.ts +1 -9
  148. package/test/nuxt/useWishlistActions.test.ts +3 -26
  149. package/test/unit/highlight.spec.ts +31 -0
  150. package/test/unit/product.spec.ts +12 -0
  151. package/test/unit/themePresets.spec.ts +61 -0
  152. package/app/app.config.ts +0 -19
  153. package/app/components/AnimatedSection.vue +0 -74
  154. package/app/components/BottomNavi.vue +0 -70
  155. package/app/components/Category/Header.vue +0 -48
  156. package/app/components/Checkout/PaymentMethod.vue +0 -30
  157. package/app/components/Checkout/ShippingMethod.vue +0 -30
  158. package/app/components/Cta.vue +0 -30
  159. package/app/components/Feature/Card.vue +0 -121
  160. package/app/components/Features.vue +0 -42
  161. package/app/components/Footer/Contact.vue +0 -82
  162. package/app/components/Header/Body.vue +0 -82
  163. package/app/components/Header/Right.vue +0 -187
  164. package/app/components/Header/Title.vue +0 -10
  165. package/app/components/Hero.vue +0 -233
  166. package/app/components/Home/MenuCategories.vue +0 -148
  167. package/app/components/ImageGallery.vue +0 -63
  168. package/app/components/Loading.vue +0 -29
  169. package/app/components/Navigation/DesktopLeft.vue +0 -39
  170. package/app/components/Product/Card.vue +0 -177
  171. package/app/components/Product/CardCompact.vue +0 -72
  172. package/app/components/Product/CardDietBadges.vue +0 -43
  173. package/app/components/Product/CardIngredients.vue +0 -35
  174. package/app/components/Product/CardKitchen.vue +0 -34
  175. package/app/components/Product/SearchBar.vue +0 -95
  176. package/app/components/PublicAnnouncement.vue +0 -17
  177. package/app/pages/bestellung/bestaetigen.vue +0 -16
  178. package/app/pages/bestellung/warenkorb.vue +0 -49
  179. package/app/pages/bestellung/zahlung-versand.vue +0 -25
  180. package/test/nuxt/AddressFields.test.ts +0 -222
  181. package/test/nuxt/AnimatedSection.test.ts +0 -67
  182. package/test/nuxt/ContactForm.test.ts +0 -207
  183. package/test/nuxt/FooterContact.test.ts +0 -102
  184. package/test/nuxt/HeaderRight.test.ts +0 -142
  185. package/test/nuxt/Hero.test.ts +0 -126
  186. package/test/nuxt/HomeMenuCategories.test.ts +0 -94
  187. package/test/nuxt/LoginForm.test.ts +0 -159
@@ -0,0 +1,122 @@
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 { computed, ref } from "vue";
5
+ import MenuBonCard from "~/components/Menu/BonCard.vue";
6
+ import type { Schemas } from "#shopware";
7
+
8
+ const mocks = vi.hoisted(() => ({
9
+ setSelectedProduct: vi.fn(),
10
+ addToCart: vi.fn(),
11
+ quantity: { value: 0 },
12
+ }));
13
+
14
+ mockNuxtImport("useAddToCart", () => () => ({
15
+ setSelectedProduct: mocks.setSelectedProduct,
16
+ addToCart: mocks.addToCart,
17
+ isLoading: ref(false),
18
+ }));
19
+ mockNuxtImport("useProductCartQuantity", () => () => ({
20
+ quantity: computed(() => mocks.quantity.value),
21
+ }));
22
+ mockNuxtImport("useCommercePrice", () => () => ({
23
+ getFormattedPrice: (value: number) => `${value.toFixed(2)} €`,
24
+ }));
25
+
26
+ const group = (name: string, options: string[]) => ({
27
+ translated: { name },
28
+ options: options.map((option, i) => ({
29
+ id: `${name}-${i}`,
30
+ name: option,
31
+ translated: { name: option },
32
+ })),
33
+ });
34
+
35
+ const product = (overrides: Record<string, unknown> = {}) =>
36
+ ({
37
+ id: "p29",
38
+ productNumber: "29",
39
+ name: "Pizza 4 Stagioni",
40
+ translated: { name: "Pizza 4 Stagioni" },
41
+ calculatedPrice: { totalPrice: 8.5 },
42
+ childCount: 0,
43
+ sortedProperties: [
44
+ group("Hauptzutaten", ["Artischocken", "Salami"]),
45
+ group("Vegetarisch", ["Ja"]),
46
+ ],
47
+ ...overrides,
48
+ }) as unknown as Schemas["Product"];
49
+
50
+ function mountCard(props: Record<string, unknown> = {}) {
51
+ return mountSuspended(MenuBonCard, {
52
+ props: {
53
+ product: product(),
54
+ href: "/speisekarte/pizza/?produkt=29",
55
+ ...props,
56
+ },
57
+ });
58
+ }
59
+
60
+ describe("MenuBonCard (#441)", () => {
61
+ beforeEach(() => {
62
+ vi.clearAllMocks();
63
+ mocks.quantity.value = 0;
64
+ });
65
+
66
+ it("shows number, name, diet, ingredients and price", async () => {
67
+ const wrapper = await mountCard();
68
+ expect(wrapper.find("h3").text()).toBe("Nr. 29 Pizza 4 Stagioni");
69
+ expect(wrapper.text()).toContain("Vegetarisch");
70
+ expect(wrapper.text()).toContain("Artischocken, Salami");
71
+ expect(wrapper.text()).toContain("8.50 €");
72
+ });
73
+
74
+ it("adds a product without variants straight to the cart", async () => {
75
+ const wrapper = await mountCard();
76
+ const button = wrapper.find('[data-testid="menu-add"]');
77
+ expect(button.attributes("aria-label")).toBe("Pizza 4 Stagioni hinzufügen");
78
+ await button.trigger("click");
79
+ await flushPromises();
80
+ expect(mocks.setSelectedProduct).toHaveBeenCalledWith(
81
+ expect.objectContaining({ id: "p29" }),
82
+ );
83
+ expect(mocks.addToCart).toHaveBeenCalledTimes(1);
84
+ expect(wrapper.emitted("select")).toBeUndefined();
85
+ });
86
+
87
+ it("shows the quantity once the product is in the cart", async () => {
88
+ mocks.quantity.value = 2;
89
+ const wrapper = await mountCard();
90
+ const button = wrapper.find('[data-testid="menu-add"]');
91
+ expect(button.text()).toBe("2");
92
+ expect(button.attributes("aria-label")).toBe(
93
+ "Pizza 4 Stagioni, 2 im Warenkorb, noch eine hinzufügen",
94
+ );
95
+ });
96
+
97
+ it("opens the quick view for a product with variants", async () => {
98
+ const wrapper = await mountCard({
99
+ product: product({ childCount: 2 }),
100
+ });
101
+ expect(wrapper.text()).toContain("ab 8.50 €");
102
+ const button = wrapper.find('[data-testid="menu-add"]');
103
+ expect(button.attributes("aria-label")).toBe("Pizza 4 Stagioni auswählen");
104
+ await button.trigger("click");
105
+ expect(mocks.addToCart).not.toHaveBeenCalled();
106
+ expect(wrapper.emitted("select")).toHaveLength(1);
107
+ });
108
+
109
+ it("opens the quick view on a plain click on the name", async () => {
110
+ const wrapper = await mountCard();
111
+ await wrapper.find("h3 a").trigger("click");
112
+ expect(wrapper.emitted("select")).toHaveLength(1);
113
+ });
114
+
115
+ it("offers no button for a sold-out product", async () => {
116
+ const wrapper = await mountCard({
117
+ product: product({ available: false }),
118
+ });
119
+ expect(wrapper.find('[data-testid="menu-add"]').exists()).toBe(false);
120
+ expect(wrapper.text()).toContain("Ausverkauft");
121
+ });
122
+ });
@@ -0,0 +1,132 @@
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 ConfirmationPreset from "~/components/Order/Confirmation.vue";
6
+ import DetailPreset from "~/components/Order/Detail.vue";
7
+ import type { Schemas } from "#shopware";
8
+
9
+ // Order confirmation and order page of the presets (#445).
10
+ const mocks = vi.hoisted(() => ({
11
+ loadOrderDetails: vi.fn(),
12
+ }));
13
+ const order = ref<Schemas["Order"] | undefined>(undefined);
14
+
15
+ vi.mock("@shopware/composables", async (importOriginal) => ({
16
+ ...(await importOriginal<typeof import("@shopware/composables")>()),
17
+ useOrderDetails: () => ({
18
+ order,
19
+ status: ref("Offen"),
20
+ loadOrderDetails: mocks.loadOrderDetails,
21
+ }),
22
+ }));
23
+ mockNuxtImport("useThemePreset", () => () => ({
24
+ preset: "trattoria",
25
+ menuView: "bon",
26
+ }));
27
+ mockNuxtImport("useCommercePrice", () => () => ({
28
+ getFormattedPrice: (value: number) => `${value} €`,
29
+ }));
30
+
31
+ const sampleOrder = {
32
+ id: "order-1",
33
+ orderNumber: "10042",
34
+ createdAt: "2026-10-08T17:30:00.000Z",
35
+ taxStatus: "gross",
36
+ customerComment: "Wunschlieferzeit: 19:15",
37
+ shippingTotal: 1,
38
+ amountTotal: 21.5,
39
+ price: { calculatedTaxes: [{ taxRate: 7, tax: 1.41 }] },
40
+ deliveries: [{ shippingMethod: { name: "Lieferung" } }],
41
+ transactions: [
42
+ {
43
+ paymentMethod: { distinguishableName: "Bar" },
44
+ stateMachineState: { name: "Offen" },
45
+ },
46
+ ],
47
+ lineItems: [
48
+ {
49
+ id: "li-1",
50
+ parentId: null,
51
+ quantity: 2,
52
+ label: "Pizza Margherita",
53
+ totalPrice: 17,
54
+ payload: { productNumber: "LF-4" },
55
+ },
56
+ { id: "li-2", parentId: "li-1", quantity: 1, label: "Extra Käse" },
57
+ ],
58
+ } as unknown as Schemas["Order"];
59
+
60
+ describe("order pages with a preset (#445)", () => {
61
+ beforeEach(() => {
62
+ vi.clearAllMocks();
63
+ order.value = undefined;
64
+ Object.assign(useRuntimeConfig().public.site, {
65
+ telephone: "06104 71427",
66
+ });
67
+ });
68
+
69
+ it("thanks the guest and shows the order after loading", async () => {
70
+ mocks.loadOrderDetails.mockImplementation(async () => {
71
+ order.value = sampleOrder;
72
+ });
73
+ const wrapper = await mountSuspended(ConfirmationPreset, {
74
+ props: { orderId: "order-1", kind: "success" },
75
+ });
76
+ expect(wrapper.find("h1").text()).toBe("Vielen Dank für Ihre Bestellung");
77
+ await flushPromises();
78
+
79
+ expect(wrapper.text()).toContain("Ihre Bestellnummer ist 10042");
80
+ const facts = wrapper
81
+ .findAll("dl")[0]!
82
+ .findAll("div")
83
+ .map((row) => row.text());
84
+ expect(facts).toEqual([
85
+ "StatusOffen",
86
+ "Lieferung oder AbholungLieferung",
87
+ "Wunschzeit19:15",
88
+ "BezahlungBar, Offen",
89
+ ]);
90
+ // only top-level lines, the extra belongs to its container
91
+ const lines = wrapper.findAll("li").map((li) => li.text());
92
+ expect(lines).toHaveLength(1);
93
+ expect(lines[0]).toContain("2× Pizza Margherita");
94
+ expect(wrapper.text()).toContain("enthaltene MwSt. 7 %");
95
+
96
+ const call = wrapper.find('a[href^="tel:"]');
97
+ expect(call.text()).toContain("Anrufen:");
98
+ expect(call.text()).toContain("06104 71427");
99
+ });
100
+
101
+ it("titles the order page with the order number", async () => {
102
+ mocks.loadOrderDetails.mockImplementation(async () => {
103
+ order.value = sampleOrder;
104
+ });
105
+ const wrapper = await mountSuspended(ConfirmationPreset, {
106
+ props: { orderId: "order-1" },
107
+ });
108
+ await flushPromises();
109
+ expect(wrapper.find("h1").text()).toBe("10042");
110
+ });
111
+
112
+ it("says when the order cannot be loaded", async () => {
113
+ mocks.loadOrderDetails.mockRejectedValue(new Error("403"));
114
+ vi.spyOn(console, "error").mockImplementation(() => {});
115
+ const wrapper = await mountSuspended(ConfirmationPreset, {
116
+ props: { orderId: "order-1", kind: "success" },
117
+ });
118
+ await flushPromises();
119
+ const alert = wrapper.find('[role="alert"]');
120
+ expect(alert.text()).toContain(
121
+ "Die Bestellung konnte nicht geladen werden",
122
+ );
123
+ expect(alert.text()).toContain("trotzdem bei uns eingegangen");
124
+ });
125
+
126
+ it("lists the tax on top for net orders", async () => {
127
+ const wrapper = await mountSuspended(DetailPreset, {
128
+ props: { order: { ...sampleOrder, taxStatus: "net" } },
129
+ });
130
+ expect(wrapper.text()).toContain("zzgl. MwSt. 7 %");
131
+ });
132
+ });
@@ -53,10 +53,6 @@ mockNuxtImport("useCheckoutMethodGuard", () => () => ({
53
53
  isResolving: ref(false),
54
54
  }));
55
55
 
56
- mockNuxtImport("useToast", () => () => ({
57
- add: vi.fn(),
58
- }));
59
-
60
56
  describe("PaymentAndDelivery", () => {
61
57
  beforeEach(() => {
62
58
  vi.clearAllMocks();
@@ -64,7 +64,8 @@ describe("ProductCrossSelling", () => {
64
64
  props: { associations: [group("Extras", 20)] },
65
65
  });
66
66
 
67
- const search = wrapper.find('input[aria-label="Extras durchsuchen"]');
67
+ const search = wrapper.find('input[type="search"]');
68
+ expect(search.attributes("placeholder")).toBe("20 Extras durchsuchen");
68
69
  await search.setValue("extras 1");
69
70
  // "Extras 1" and "Extras 10" … "Extras 19"
70
71
  expect(rows(wrapper)).toHaveLength(11);
@@ -17,7 +17,9 @@ describe("ProductDeselectIngredient", () => {
17
17
  });
18
18
 
19
19
  expect(wrapper.emitted("ingredients-deselected")).toBeUndefined();
20
- expect(wrapper.findAll('[aria-pressed="true"]')).toHaveLength(0);
20
+ // A pressed chip is an included ingredient.
21
+ expect(wrapper.findAll('[aria-pressed="true"]')).toHaveLength(3);
22
+ expect(wrapper.findAll('[aria-pressed="false"]')).toHaveLength(0);
21
23
  });
22
24
 
23
25
  it("deselects ingredients from the URL and ignores unknown names (#411)", async () => {
@@ -28,7 +30,7 @@ describe("ProductDeselectIngredient", () => {
28
30
  expect(wrapper.emitted("ingredients-deselected")?.[0]).toEqual([
29
31
  ["Zwiebeln"],
30
32
  ]);
31
- const pressed = wrapper.findAll('[aria-pressed="true"]');
32
- expect(pressed.map((button) => button.text())).toEqual(["Zwiebeln"]);
33
+ const removed = wrapper.findAll('[aria-pressed="false"]');
34
+ expect(removed.map((button) => button.text())).toEqual(["ohne Zwiebeln"]);
33
35
  });
34
36
  });
@@ -0,0 +1,105 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
3
+ import type { Schemas } from "#shopware";
4
+ import ProductDeselectIngredient from "~/components/Product/DeselectIngredient.vue";
5
+ import ProductCrossSelling from "~/components/Product/CrossSelling.vue";
6
+ import type { AssociationItem } from "~/types/Association";
7
+
8
+ // The product sheet of a shop with a style preset (#442).
9
+ mockNuxtImport("useThemePreset", () => () => ({
10
+ preset: "trattoria",
11
+ menuView: "bon",
12
+ }));
13
+ mockNuxtImport("useCommercePrice", () => () => ({
14
+ getFormattedPrice: (price: number) => `${price.toFixed(2)} €`,
15
+ }));
16
+
17
+ const product = {
18
+ properties: ["Pilze", "Salami", "Schinken"].map((name) => ({
19
+ group: { name: "Hauptzutaten" },
20
+ translated: { name },
21
+ })),
22
+ } as unknown as Schemas["Product"];
23
+
24
+ const extras = (count: number): AssociationItem => ({
25
+ label: "Extras",
26
+ products: Array.from({ length: count }, (_, index) => ({
27
+ label: `Extra ${index + 1}`,
28
+ value: `extra-${index + 1}`,
29
+ productNumber: `E${index + 1}`,
30
+ price: "1.00 €",
31
+ unitPrice: 1,
32
+ })),
33
+ });
34
+
35
+ describe("product sheet with a preset (#442)", () => {
36
+ it("shows the ingredients as chips, pressed while included", async () => {
37
+ const wrapper = await mountSuspended(ProductDeselectIngredient, {
38
+ props: { product, initialDeselected: ["Pilze"] },
39
+ });
40
+
41
+ const group = wrapper.find('[role="group"]');
42
+ const label = wrapper.find(`[id="${group.attributes("aria-labelledby")}"]`);
43
+ expect(label.text()).toBe("Zutaten");
44
+
45
+ const chips = group.findAll("button");
46
+ expect(chips.map((chip) => chip.text())).toEqual([
47
+ "ohne Pilze",
48
+ "Salami",
49
+ "Schinken",
50
+ ]);
51
+ expect(chips.map((chip) => chip.attributes("aria-pressed"))).toEqual([
52
+ "false",
53
+ "true",
54
+ "true",
55
+ ]);
56
+
57
+ await chips[1]!.trigger("click");
58
+ expect(wrapper.emitted("ingredients-deselected")?.at(-1)).toEqual([
59
+ ["Pilze", "Salami"],
60
+ ]);
61
+
62
+ await chips[0]!.trigger("click");
63
+ expect(wrapper.emitted("ingredients-deselected")?.at(-1)).toEqual([
64
+ ["Salami"],
65
+ ]);
66
+ });
67
+
68
+ it("lists the extras as labelled checkboxes with their price", async () => {
69
+ const wrapper = await mountSuspended(ProductCrossSelling, {
70
+ props: { associations: [extras(3)], initialExtras: ["E2"] },
71
+ });
72
+
73
+ const checkboxes = wrapper.findAll('[role="checkbox"]');
74
+ expect(checkboxes).toHaveLength(3);
75
+ expect(checkboxes.map((box) => box.attributes("aria-checked"))).toEqual([
76
+ "false",
77
+ "true",
78
+ "false",
79
+ ]);
80
+ const label = wrapper.find(
81
+ `label[for="${checkboxes[0]!.attributes("id")}"]`,
82
+ );
83
+ expect(label.text()).toContain("Extra 1");
84
+ expect(label.text()).toContain("+1.00 €");
85
+
86
+ await checkboxes[0]!.trigger("click");
87
+ const emitted = wrapper.emitted("extras-selected")?.at(-1)?.[0] as {
88
+ value: string;
89
+ }[];
90
+ expect(emitted.map((extra) => extra.value)).toEqual(["extra-2", "extra-1"]);
91
+ });
92
+
93
+ it("adds a labelled search field above a long list", async () => {
94
+ const wrapper = await mountSuspended(ProductCrossSelling, {
95
+ props: { associations: [extras(20)] },
96
+ });
97
+
98
+ const input = wrapper.find('input[type="search"]');
99
+ expect(wrapper.find(`label[for="${input.attributes("id")}"]`).text()).toBe(
100
+ "Extras durchsuchen",
101
+ );
102
+ await input.setValue("Extra 1");
103
+ expect(wrapper.findAll('[role="checkbox"]').length).toBe(11);
104
+ });
105
+ });
@@ -38,9 +38,6 @@ mockNuxtImport("useWishlist", () => () => ({
38
38
  mergeWishlistProducts: mergeWishlistProductsMock,
39
39
  }));
40
40
 
41
- const toastAddMock = vi.fn();
42
- mockNuxtImport("useToast", () => () => ({ add: toastAddMock }));
43
-
44
41
  const { navigateToMock } = vi.hoisted(() => ({ navigateToMock: vi.fn() }));
45
42
  mockNuxtImport("navigateTo", () => navigateToMock);
46
43
 
@@ -68,9 +65,6 @@ describe("registrierung/bestaetigen", () => {
68
65
  expect(refreshSessionContextMock).toHaveBeenCalled();
69
66
  expect(refreshCartMock).toHaveBeenCalled();
70
67
  expect(mergeWishlistProductsMock).toHaveBeenCalled();
71
- expect(toastAddMock).toHaveBeenCalledWith(
72
- expect.objectContaining({ color: "success" }),
73
- );
74
68
  expect(navigateToMock).toHaveBeenCalledWith({ path: "/konto" });
75
69
  });
76
70
 
@@ -86,7 +80,6 @@ describe("registrierung/bestaetigen", () => {
86
80
  expect(wrapper.text()).toContain("Bestätigung fehlgeschlagen");
87
81
  expect(wrapper.text()).toContain("Kontakt");
88
82
  expect(refreshSessionContextMock).not.toHaveBeenCalled();
89
- expect(toastAddMock).not.toHaveBeenCalled();
90
83
  expect(navigateToMock).not.toHaveBeenCalled();
91
84
  });
92
85
 
@@ -101,7 +94,6 @@ describe("registrierung/bestaetigen", () => {
101
94
 
102
95
  expect(wrapper.text()).toContain("Konto bereits bestätigt");
103
96
  expect(wrapper.text()).toContain("Zur Anmeldung");
104
- expect(toastAddMock).not.toHaveBeenCalled();
105
97
  expect(navigateToMock).not.toHaveBeenCalled();
106
98
  });
107
99