@shopbite-de/storefront 1.23.3 → 1.25.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.
- package/.env.example +22 -0
- package/.github/workflows/build.yaml +1 -1
- package/.github/workflows/ci.yaml +6 -3
- package/CLAUDE.md +48 -3
- package/README.md +139 -40
- package/api-gen.config.json +9 -0
- package/api-types/storeApiSchema.shopbite.overrides.json +35 -0
- package/api-types/storeApiTypes.d.ts +95 -81
- package/app/app.config.ts +3 -2
- package/app/app.vue +40 -53
- package/app/assets/css/main.css +36 -4
- package/app/components/AddToWishlist.vue +13 -6
- package/app/components/Address/Fields.vue +2 -21
- package/app/components/AnimatedSection.vue +9 -4
- package/app/components/BottomNavi.vue +9 -2
- package/app/components/Cart/Bar.vue +102 -0
- package/app/components/Cart/Item.vue +21 -10
- package/app/components/Cart/QuickView.vue +4 -0
- package/app/components/Cart/Upsell.vue +106 -0
- package/app/components/Category/Header.vue +9 -3
- package/app/components/Category/Listing.vue +62 -45
- package/app/components/Checkout/PaymentAndDelivery.vue +19 -3
- package/app/components/Checkout/Summary.vue +70 -2
- package/app/components/Cta.vue +4 -2
- package/app/components/DemoBanner.vue +13 -0
- package/app/components/Feature/Card.vue +121 -0
- package/app/components/Features.vue +14 -9
- package/app/components/Food/MarqueeItem.vue +20 -8
- package/app/components/Footer/Contact.vue +82 -0
- package/app/components/Footer/StoreStatus.vue +30 -0
- package/app/components/Footer.vue +2 -1
- package/app/components/Header/Body.vue +1 -1
- package/app/components/Header/Right.vue +60 -17
- package/app/components/Header/Title.vue +1 -0
- package/app/components/Header.vue +5 -15
- package/app/components/Hero.vue +169 -36
- package/app/components/ImageGallery.vue +11 -5
- package/app/components/Product/Card.vue +104 -46
- package/app/components/Product/CardCompact.vue +72 -0
- package/app/components/Product/CardDietBadges.vue +38 -31
- package/app/components/Product/CardIngredients.vue +35 -0
- package/app/components/Product/CardSkeleton.vue +10 -18
- package/app/components/Product/Category.vue +9 -2
- package/app/components/Product/Configurator.vue +11 -7
- package/app/components/Product/CrossSelling.vue +45 -34
- package/app/components/Product/DeselectIngredient.vue +37 -31
- package/app/components/Product/Detail.vue +73 -13
- package/app/components/Product/QuickView.vue +77 -0
- package/app/components/Topseller.vue +44 -34
- package/app/components/User/RegistrationForm.vue +0 -1
- package/app/components/Wishlist.vue +2 -15
- package/app/composables/useAddToCart.ts +13 -40
- package/app/composables/useAddressAutocomplete.ts +12 -19
- package/app/composables/useAddressSuggestionArea.ts +16 -0
- package/app/composables/useAddressValidation.ts +3 -19
- package/app/composables/useCartMutations.ts +168 -0
- package/app/composables/useCartQuickView.ts +19 -0
- package/app/composables/useCartUpsell.ts +100 -0
- package/app/composables/{useCategory.ts → useCategoryById.ts} +1 -1
- package/app/composables/useCategorySeo.ts +27 -29
- package/app/composables/useCheckoutMethodGuard.ts +201 -0
- package/app/composables/useMatomo.ts +25 -0
- package/app/composables/useMatomoConfig.ts +12 -0
- package/app/composables/useMenuSectionSchema.ts +55 -0
- package/app/composables/useNavigation.ts +12 -9
- package/app/composables/usePageSeo.ts +50 -0
- package/app/composables/useProductCartQuantity.ts +15 -0
- package/app/composables/useProductCrossSelling.ts +1 -0
- package/app/composables/useProductDetail.ts +15 -1
- package/app/composables/useProductEvents.ts +30 -0
- package/app/composables/useProductQuickView.ts +65 -0
- package/app/composables/useRestaurantSchema.ts +64 -0
- package/app/composables/useScrollAnimation.ts +39 -8
- package/app/composables/useSearchTracking.ts +33 -0
- package/app/composables/useSeoUrlRoute.ts +58 -0
- package/app/composables/useSortingSelection.ts +28 -0
- package/app/composables/useStoreStatus.ts +48 -0
- package/app/composables/useTopSellers.ts +22 -0
- package/app/composables/useTrackEvent.ts +36 -23
- package/app/pages/[...all].vue +4 -4
- package/app/pages/account/recover/password/index.vue +1 -0
- package/app/pages/anmelden.vue +4 -0
- package/app/pages/bestellung/[id]/erfolg.vue +1 -5
- package/app/pages/bestellung/[id]/fehler.vue +2 -2
- package/app/pages/bestellung/[id]/index.vue +9 -3
- package/app/pages/bestellung/bestaetigen.vue +1 -5
- package/app/pages/bestellung/warenkorb.vue +1 -5
- package/app/pages/bestellung/zahlung-versand.vue +1 -5
- package/app/pages/c/[...all].vue +2 -35
- package/app/pages/index.vue +28 -14
- package/app/pages/kontakt.vue +4 -0
- package/app/pages/konto/adressen.vue +4 -0
- package/app/pages/konto/bestellung/[id].vue +4 -0
- package/app/pages/konto/bestellungen.vue +4 -0
- package/app/pages/konto/index.vue +4 -0
- package/app/pages/konto/profil.vue +4 -0
- package/app/pages/maintenance.vue +6 -0
- package/app/pages/merkliste.vue +1 -7
- package/app/pages/passwort-vergessen.vue +1 -0
- package/app/pages/registrierung/bestaetigen.vue +4 -0
- package/app/pages/registrierung/index.vue +4 -0
- package/app/pages/speisekarte/[...all].vue +2 -36
- package/app/pages/suche.vue +42 -26
- package/app/plugins/matomo.ts +35 -0
- package/app/types/Association.d.ts +1 -0
- package/app/utils/hydrateWhenVisible.ts +20 -0
- package/app/utils/media.ts +33 -0
- package/app/utils/openingHours.ts +90 -0
- package/app/utils/product.ts +31 -0
- package/app/utils/schema.ts +235 -0
- package/app/utils/seo.ts +56 -0
- package/app/utils/seoPath.ts +57 -0
- package/content/index.yml +26 -20
- package/content.config.ts +16 -0
- package/docs/notes/2026-07-05-issue-259-matomo-broken.md +7 -0
- package/docs/notes/2026-09-08-issue-240-shipping-method-blocked.md +83 -0
- package/docs/notes/2026-09-08-issue-241-cart-lock-conflicts.md +63 -0
- package/docs/notes/2026-09-08-issue-244-category-url-trailing-slash.md +65 -0
- package/docs/notes/2026-09-08-issue-276-payment-method-blocked.md +39 -0
- package/docs/notes/2026-09-08-issue-277-typecheck.md +99 -0
- package/docs/notes/2026-09-10-issue-250-animated-section.md +23 -0
- package/docs/notes/2026-09-10-issue-251-shop-data-in-base-layer.md +30 -0
- package/docs/notes/2026-09-10-issue-272-restaurant-schema.md +27 -0
- package/docs/notes/2026-09-10-issue-273-performance-media.md +64 -0
- package/docs/notes/2026-09-10-issue-274-seo-basics.md +49 -0
- package/docs/notes/2026-09-10-issue-275-accessibility.md +46 -0
- package/docs/notes/2026-09-10-issue-290-footer-nap.md +28 -0
- package/docs/notes/2026-09-10-issue-291-seo-url-trailing-slash.md +24 -0
- package/docs/notes/2026-09-10-issue-294-matomo-without-config.md +33 -0
- package/docs/notes/2026-09-10-issue-295-search-hydration-mismatch.md +25 -0
- package/docs/notes/2026-09-10-issue-296-track-direct-search.md +19 -0
- package/docs/notes/2026-09-10-issue-312-store-api-criteria-post.md +64 -0
- package/docs/notes/2026-09-10-issue-313-wishlist-scoped-tailwind.md +29 -0
- package/docs/notes/2026-09-10-issue-314-mobile-js-cost.md +119 -0
- package/docs/notes/2026-09-12-issue-319-stylesheet-cost.md +154 -0
- package/docs/notes/2026-09-12-issue-325-product-card.md +100 -0
- package/docs/notes/2026-09-12-issue-327-home-hero.md +64 -0
- package/docs/notes/2026-09-13-demo-banner.md +32 -0
- package/docs/notes/2026-09-13-issue-332-home-info-cards.md +46 -0
- package/docs/notes/2026-09-13-quick-view-flicker.md +65 -0
- package/docs/notes/2026-09-14-cart-upsell.md +105 -0
- package/docs/notes/2026-09-14-demo-noindex.md +57 -0
- package/node.dockerfile +5 -2
- package/nuxt.config.ts +98 -15
- package/package.json +5 -3
- package/patches/@shopware__nuxt-module@1.5.1.patch +32 -0
- package/pnpm-workspace.yaml +2 -0
- package/public/hero-poster.webp +0 -0
- package/scripts/perf/first-render.mjs +30 -0
- package/scripts/perf/h2-proxy.cjs +49 -0
- package/scripts/perf/lighthouse.sh +22 -0
- package/scripts/perf/quick-view-layout.mjs +126 -0
- package/server/api/__sitemap__/urls.get.ts +49 -0
- package/server/api/category/[categoryId].get.ts +20 -9
- package/server/api/content/home.get.ts +14 -0
- package/server/api/content/page.get.ts +22 -0
- package/server/api/listing/[categoryId].get.ts +14 -18
- package/server/api/product/[productId]/cross-selling.get.ts +3 -9
- package/server/api/product/[productId].get.ts +4 -8
- package/server/api/search.get.ts +2 -0
- package/server/plugins/site-url.ts +13 -0
- package/server/plugins/sitemap-trailing-slash.ts +26 -0
- package/server/utils/sitemap.ts +60 -0
- package/server/utils/storeApi.ts +34 -0
- package/shopware.d.ts +35 -11
- package/test/e2e/simple-checkout-as-recurring-customer.test.ts +13 -17
- package/test/nuxt/AddressFields.test.ts +2 -73
- package/test/nuxt/AnimatedSection.test.ts +67 -0
- package/test/nuxt/CartBar.test.ts +110 -0
- package/test/nuxt/CartItem.test.ts +95 -0
- package/test/nuxt/CartUpsell.test.ts +125 -0
- package/test/nuxt/DemoBanner.test.ts +12 -0
- package/test/nuxt/FooterContact.test.ts +102 -0
- package/test/nuxt/FooterStoreStatus.test.ts +48 -0
- package/test/nuxt/HeaderRight.test.ts +14 -10
- package/test/nuxt/Hero.test.ts +68 -0
- package/test/nuxt/PaymentAndDelivery.test.ts +67 -8
- package/test/nuxt/RegistrationForm.test.ts +3 -0
- package/test/nuxt/useAddToCart.test.ts +37 -17
- package/test/nuxt/useAddressAutocomplete.test.ts +2 -38
- package/test/nuxt/useAddressSuggestionArea.test.ts +27 -0
- package/test/nuxt/useBusinessHours.test.ts +1 -1
- package/test/nuxt/useCartMutations.test.ts +225 -0
- package/test/nuxt/useCartUpsell.test.ts +126 -0
- package/test/nuxt/useCheckoutMethodGuard.test.ts +386 -0
- package/test/nuxt/useScrollAnimation.test.ts +55 -49
- package/test/nuxt/useSearchTracking.test.ts +71 -0
- package/test/nuxt/useSeoUrlRoute.test.ts +93 -0
- package/test/nuxt/useStoreStatus.test.ts +77 -0
- package/test/nuxt/useTrackEvent.test.ts +127 -0
- package/test/unit/media.spec.ts +49 -0
- package/test/unit/openingHours.spec.ts +90 -0
- package/test/unit/product.spec.ts +72 -0
- package/test/unit/schema.spec.ts +243 -0
- package/test/unit/seo.spec.ts +107 -0
- package/test/unit/seoPath.spec.ts +116 -0
- package/test/unit/sitemap.spec.ts +88 -0
- package/test/unit/useCategorySeo.spec.ts +42 -31
- package/test/unit/useSortingSelection.spec.ts +39 -0
- package/test/visual/playwright.config.ts +33 -0
- package/test/visual/visual.spec.ts +87 -0
- package/app/components/Product/CardDescription.vue +0 -27
- package/app/components/Product/CardFooter.vue +0 -51
- package/app/composables/useValidCitiesForDelivery.ts +0 -12
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
3
|
+
import { nextTick, ref } from "vue";
|
|
4
|
+
import CartItem from "~/components/Cart/Item.vue";
|
|
5
|
+
import type { Schemas } from "#shopware";
|
|
6
|
+
|
|
7
|
+
const { mockSetQuantity, mockRemoveLineItem } = vi.hoisted(() => ({
|
|
8
|
+
mockSetQuantity: vi.fn(),
|
|
9
|
+
mockRemoveLineItem: vi.fn(),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
// Read lazily inside the factory, i.e. after module initialisation.
|
|
13
|
+
const isMutating = ref(false);
|
|
14
|
+
|
|
15
|
+
mockNuxtImport("useCartMutations", () => () => ({
|
|
16
|
+
setQuantity: mockSetQuantity,
|
|
17
|
+
removeLineItem: mockRemoveLineItem,
|
|
18
|
+
addLineItems: vi.fn(),
|
|
19
|
+
isMutating,
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
mockNuxtImport("useCommercePrice", () => () => ({
|
|
23
|
+
getFormattedPrice: (value: number) => `${value} €`,
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
const lineItem = {
|
|
27
|
+
id: "li-1",
|
|
28
|
+
label: "Pizza Margherita",
|
|
29
|
+
quantity: 2,
|
|
30
|
+
type: "product",
|
|
31
|
+
price: { totalPrice: 18 },
|
|
32
|
+
} as unknown as Schemas["LineItem"];
|
|
33
|
+
|
|
34
|
+
describe("CartItem", () => {
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
vi.clearAllMocks();
|
|
37
|
+
isMutating.value = false;
|
|
38
|
+
mockSetQuantity.mockResolvedValue(undefined);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("forwards each quantity change with the clicked value, based on the local state", async () => {
|
|
42
|
+
const wrapper = await mountSuspended(CartItem, {
|
|
43
|
+
props: { cartItem: lineItem },
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Two quick changes before the cart prop updates
|
|
47
|
+
// @ts-expect-error - access internal state
|
|
48
|
+
wrapper.vm.quantity = 3;
|
|
49
|
+
// @ts-expect-error - access internal state
|
|
50
|
+
wrapper.vm.quantity = 4;
|
|
51
|
+
await nextTick();
|
|
52
|
+
|
|
53
|
+
expect(mockSetQuantity).toHaveBeenNthCalledWith(1, "li-1", 3);
|
|
54
|
+
expect(mockSetQuantity).toHaveBeenNthCalledWith(2, "li-1", 4);
|
|
55
|
+
// @ts-expect-error - access internal state
|
|
56
|
+
expect(wrapper.vm.quantity).toBe(4);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("keeps the optimistic value while a mutation runs and re-syncs afterwards", async () => {
|
|
60
|
+
isMutating.value = true;
|
|
61
|
+
const wrapper = await mountSuspended(CartItem, {
|
|
62
|
+
props: { cartItem: lineItem },
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// @ts-expect-error - access internal state
|
|
66
|
+
wrapper.vm.quantity = 5;
|
|
67
|
+
// intermediate cart state arrives while still mutating
|
|
68
|
+
await wrapper.setProps({ cartItem: { ...lineItem, quantity: 3 } });
|
|
69
|
+
// @ts-expect-error - access internal state
|
|
70
|
+
expect(wrapper.vm.quantity).toBe(5);
|
|
71
|
+
|
|
72
|
+
isMutating.value = false;
|
|
73
|
+
await nextTick();
|
|
74
|
+
// @ts-expect-error - access internal state
|
|
75
|
+
expect(wrapper.vm.quantity).toBe(3);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("removes the item through the mutation queue and disables the button while mutating", async () => {
|
|
79
|
+
const wrapper = await mountSuspended(CartItem, {
|
|
80
|
+
props: { cartItem: lineItem },
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const button = wrapper.find('button[aria-label="Artikel entfernen"]');
|
|
84
|
+
await button.trigger("click");
|
|
85
|
+
expect(mockRemoveLineItem).toHaveBeenCalledWith(lineItem);
|
|
86
|
+
|
|
87
|
+
isMutating.value = true;
|
|
88
|
+
await nextTick();
|
|
89
|
+
expect(
|
|
90
|
+
wrapper
|
|
91
|
+
.find('button[aria-label="Artikel entfernen"]')
|
|
92
|
+
.attributes("disabled"),
|
|
93
|
+
).toBeDefined();
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
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, reactive } from "vue";
|
|
5
|
+
import { clearNuxtData } from "#imports";
|
|
6
|
+
import CartUpsell from "~/components/Cart/Upsell.vue";
|
|
7
|
+
import type { Schemas } from "#shopware";
|
|
8
|
+
|
|
9
|
+
const { mockLoadUpsellProducts, mockAddUpsellProduct } = vi.hoisted(() => ({
|
|
10
|
+
mockLoadUpsellProducts: vi.fn(),
|
|
11
|
+
mockAddUpsellProduct: vi.fn(),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
// Read lazily inside the factories, i.e. after module initialisation.
|
|
15
|
+
const cart = reactive({ items: [] as unknown[] });
|
|
16
|
+
|
|
17
|
+
mockNuxtImport("useCartUpsell", () => () => ({
|
|
18
|
+
loadUpsellProducts: mockLoadUpsellProducts,
|
|
19
|
+
addUpsellProduct: mockAddUpsellProduct,
|
|
20
|
+
isAdding: () => false,
|
|
21
|
+
}));
|
|
22
|
+
mockNuxtImport("useCart", () => () => ({
|
|
23
|
+
cartItems: computed(() => cart.items as Schemas["LineItem"][]),
|
|
24
|
+
}));
|
|
25
|
+
mockNuxtImport("useCommercePrice", () => () => ({
|
|
26
|
+
getFormattedPrice: (value: number) => `${value} €`,
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
const product = (id: string, name: string, overrides = {}) =>
|
|
30
|
+
({
|
|
31
|
+
id,
|
|
32
|
+
productNumber: id.toUpperCase(),
|
|
33
|
+
name,
|
|
34
|
+
translated: { name },
|
|
35
|
+
calculatedPrice: { totalPrice: 5.5 },
|
|
36
|
+
...overrides,
|
|
37
|
+
}) as unknown as Schemas["Product"];
|
|
38
|
+
|
|
39
|
+
const tiramisu = product("tiramisu", "Tiramisu");
|
|
40
|
+
const cola = product("cola", "Cola");
|
|
41
|
+
|
|
42
|
+
async function mountUpsell() {
|
|
43
|
+
const wrapper = await mountSuspended(CartUpsell);
|
|
44
|
+
await flushPromises();
|
|
45
|
+
return wrapper;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
describe("CartUpsell", () => {
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
vi.clearAllMocks();
|
|
51
|
+
clearNuxtData("cart-upsell");
|
|
52
|
+
cart.items = [];
|
|
53
|
+
mockLoadUpsellProducts.mockResolvedValue([tiramisu, cola]);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("shows the suggestions with name, number and price", async () => {
|
|
57
|
+
const wrapper = await mountUpsell();
|
|
58
|
+
|
|
59
|
+
expect(wrapper.find("h3").text()).toBe("Dazu passt");
|
|
60
|
+
const tiles = wrapper.findAll("li");
|
|
61
|
+
expect(tiles).toHaveLength(2);
|
|
62
|
+
expect(tiles[0]!.text()).toContain("#TIRAMISU");
|
|
63
|
+
expect(tiles[0]!.text()).toContain("Tiramisu");
|
|
64
|
+
expect(tiles[0]!.text()).toContain("5.5 €");
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("hides products that are already in the cart", async () => {
|
|
68
|
+
cart.items = [{ id: "li-1", type: "product", referencedId: "tiramisu" }];
|
|
69
|
+
const wrapper = await mountUpsell();
|
|
70
|
+
|
|
71
|
+
expect(wrapper.text()).not.toContain("Tiramisu");
|
|
72
|
+
expect(wrapper.text()).toContain("Cola");
|
|
73
|
+
|
|
74
|
+
// Also as the product of a container item with extras.
|
|
75
|
+
cart.items = [
|
|
76
|
+
{
|
|
77
|
+
id: "li-2",
|
|
78
|
+
type: "container",
|
|
79
|
+
children: [{ id: "c-1", type: "product", referencedId: "cola" }],
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
await flushPromises();
|
|
83
|
+
expect(wrapper.text()).toContain("Tiramisu");
|
|
84
|
+
expect(wrapper.text()).not.toContain("Cola");
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("renders no row when every suggestion is in the cart", async () => {
|
|
88
|
+
cart.items = [
|
|
89
|
+
{ id: "li-1", type: "product", referencedId: "tiramisu" },
|
|
90
|
+
{ id: "li-2", type: "product", referencedId: "cola" },
|
|
91
|
+
];
|
|
92
|
+
const wrapper = await mountUpsell();
|
|
93
|
+
|
|
94
|
+
expect(wrapper.find("section").exists()).toBe(false);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("adds the product on a plus click", async () => {
|
|
98
|
+
const wrapper = await mountUpsell();
|
|
99
|
+
|
|
100
|
+
await wrapper
|
|
101
|
+
.find('button[aria-label="Tiramisu in den Warenkorb"]')
|
|
102
|
+
.trigger("click");
|
|
103
|
+
|
|
104
|
+
expect(mockAddUpsellProduct).toHaveBeenCalledWith(tiramisu);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("disables the button of an unavailable product", async () => {
|
|
108
|
+
mockLoadUpsellProducts.mockResolvedValue([
|
|
109
|
+
product("panna-cotta", "Panna Cotta", { available: false }),
|
|
110
|
+
cola,
|
|
111
|
+
]);
|
|
112
|
+
const wrapper = await mountUpsell();
|
|
113
|
+
|
|
114
|
+
expect(
|
|
115
|
+
wrapper
|
|
116
|
+
.find('button[aria-label="Panna Cotta in den Warenkorb"]')
|
|
117
|
+
.attributes("disabled"),
|
|
118
|
+
).toBeDefined();
|
|
119
|
+
expect(
|
|
120
|
+
wrapper
|
|
121
|
+
.find('button[aria-label="Cola in den Warenkorb"]')
|
|
122
|
+
.attributes("disabled"),
|
|
123
|
+
).toBeUndefined();
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { mountSuspended } from "@nuxt/test-utils/runtime";
|
|
3
|
+
import DemoBanner from "~/components/DemoBanner.vue";
|
|
4
|
+
|
|
5
|
+
describe("DemoBanner", () => {
|
|
6
|
+
it("renders the demo notice", async () => {
|
|
7
|
+
const wrapper = await mountSuspended(DemoBanner);
|
|
8
|
+
|
|
9
|
+
expect(wrapper.text()).toContain("Demo-Shop");
|
|
10
|
+
expect(wrapper.text()).toContain("nicht ausgeliefert");
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
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 FooterStoreStatus from "~/components/Footer/StoreStatus.vue";
|
|
5
|
+
import type { StoreStatus } from "~/composables/useStoreStatus";
|
|
6
|
+
|
|
7
|
+
const { state } = vi.hoisted(() => ({
|
|
8
|
+
state: { status: null as StoreStatus | null },
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
mockNuxtImport("useStoreStatus", () => () => ({
|
|
12
|
+
status: ref(state.status),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
describe("FooterStoreStatus", () => {
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
state.status = null;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("shows the closing time while open", async () => {
|
|
21
|
+
state.status = { open: true, closesAt: "23:00" };
|
|
22
|
+
|
|
23
|
+
const wrapper = await mountSuspended(FooterStoreStatus);
|
|
24
|
+
const status = wrapper.find('[role="status"]');
|
|
25
|
+
|
|
26
|
+
expect(status.text()).toBe("Geöffnet bis 23:00 Uhr");
|
|
27
|
+
expect(status.find(".bg-success").exists()).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("shows the next opening while closed", async () => {
|
|
31
|
+
state.status = { open: false, nextOpening: "morgen um 11:30 Uhr" };
|
|
32
|
+
|
|
33
|
+
const wrapper = await mountSuspended(FooterStoreStatus);
|
|
34
|
+
const status = wrapper.find('[role="status"]');
|
|
35
|
+
|
|
36
|
+
expect(status.text()).toBe(
|
|
37
|
+
"Geschlossen, wir öffnen wieder morgen um 11:30 Uhr",
|
|
38
|
+
);
|
|
39
|
+
expect(status.find(".bg-success").exists()).toBe(false);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("renders a placeholder while the status is unknown", async () => {
|
|
43
|
+
const wrapper = await mountSuspended(FooterStoreStatus);
|
|
44
|
+
|
|
45
|
+
expect(wrapper.find('[role="status"]').exists()).toBe(false);
|
|
46
|
+
expect(wrapper.text()).toBe("");
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -8,6 +8,7 @@ const mocks = vi.hoisted(() => ({
|
|
|
8
8
|
isLoggedIn: false,
|
|
9
9
|
isGuestSession: false,
|
|
10
10
|
user: null as { firstName: string; lastName: string } | null,
|
|
11
|
+
telephone: "+49 6104 71427",
|
|
11
12
|
},
|
|
12
13
|
toastAddCalled: { value: false },
|
|
13
14
|
}));
|
|
@@ -26,13 +27,7 @@ mockNuxtImport("useUser", () => () => ({
|
|
|
26
27
|
|
|
27
28
|
mockNuxtImport("useToast", () => () => ({
|
|
28
29
|
add: (_payload: unknown) => {
|
|
29
|
-
|
|
30
|
-
typeof global !== "undefined" &&
|
|
31
|
-
(global as Record<string, { value: boolean }>).toastAddCalled
|
|
32
|
-
) {
|
|
33
|
-
(global as Record<string, { value: boolean }>).toastAddCalled!.value =
|
|
34
|
-
true;
|
|
35
|
-
}
|
|
30
|
+
mocks.toastAddCalled.value = true;
|
|
36
31
|
},
|
|
37
32
|
}));
|
|
38
33
|
|
|
@@ -46,7 +41,7 @@ mockNuxtImport("useCart", () => () => ({
|
|
|
46
41
|
|
|
47
42
|
mockNuxtImport("useRuntimeConfig", () => () => ({
|
|
48
43
|
app: { baseURL: "/" },
|
|
49
|
-
public: { shopware: {} },
|
|
44
|
+
public: { shopware: {}, site: { telephone: mocks.state.telephone } },
|
|
50
45
|
}));
|
|
51
46
|
|
|
52
47
|
mockNuxtImport("useWishlist", () => () => ({
|
|
@@ -83,14 +78,23 @@ describe("HeaderRight", () => {
|
|
|
83
78
|
reactiveState.isGuestSession = false;
|
|
84
79
|
reactiveState.user = null;
|
|
85
80
|
mocks.toastAddCalled.value = false;
|
|
86
|
-
(global as Record<string, unknown>).toastAddCalled = mocks.toastAddCalled;
|
|
87
81
|
vi.clearAllMocks();
|
|
88
82
|
});
|
|
89
83
|
|
|
90
|
-
it("renders phone link", async () => {
|
|
84
|
+
it("renders the phone link from the site config", async () => {
|
|
91
85
|
const component = await mountSuspended(HeaderRight);
|
|
92
86
|
const phoneButton = component.find('a[href="tel:+49610471427"]');
|
|
93
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";
|
|
94
98
|
});
|
|
95
99
|
|
|
96
100
|
it("shows logged out dropdown items when not logged in", async () => {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { describe, it, expect, vi, afterEach } from "vitest";
|
|
2
|
+
import { mountSuspended } from "@nuxt/test-utils/runtime";
|
|
3
|
+
import { nextTick } from "vue";
|
|
4
|
+
import Hero from "~/components/Hero.vue";
|
|
5
|
+
|
|
6
|
+
const props = {
|
|
7
|
+
title: "Pizzeria",
|
|
8
|
+
links: [],
|
|
9
|
+
backgroundVideo: "https://cdn.example.com/hero.mp4",
|
|
10
|
+
poster: "/hero-poster.webp",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function stubMatchMedia(matches: boolean) {
|
|
14
|
+
const listeners: Array<(event: { matches: boolean }) => void> = [];
|
|
15
|
+
vi.stubGlobal("matchMedia", (query: string) => ({
|
|
16
|
+
matches,
|
|
17
|
+
media: query,
|
|
18
|
+
addEventListener: (_: string, listener: (typeof listeners)[number]) =>
|
|
19
|
+
listeners.push(listener),
|
|
20
|
+
}));
|
|
21
|
+
return (next: boolean) =>
|
|
22
|
+
listeners.forEach((listener) => listener({ matches: next }));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
describe("Hero", () => {
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
vi.unstubAllGlobals();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("renders the poster as high-priority image and no video on narrow screens", async () => {
|
|
31
|
+
stubMatchMedia(false);
|
|
32
|
+
|
|
33
|
+
const wrapper = await mountSuspended(Hero, { props });
|
|
34
|
+
|
|
35
|
+
const poster = wrapper.find("img");
|
|
36
|
+
expect(poster.attributes("src")).toBe("/hero-poster.webp");
|
|
37
|
+
expect(poster.attributes("fetchpriority")).toBe("high");
|
|
38
|
+
expect(wrapper.find("video").exists()).toBe(false);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("adds the video on wide screens, with the poster and without eager loading", async () => {
|
|
42
|
+
const changeViewport = stubMatchMedia(true);
|
|
43
|
+
|
|
44
|
+
const wrapper = await mountSuspended(Hero, { props });
|
|
45
|
+
|
|
46
|
+
const video = wrapper.find("video");
|
|
47
|
+
expect(video.exists()).toBe(true);
|
|
48
|
+
expect(video.attributes("poster")).toBe("/hero-poster.webp");
|
|
49
|
+
expect(video.attributes("preload")).toBe("metadata");
|
|
50
|
+
expect(video.attributes("fetchpriority")).toBeUndefined();
|
|
51
|
+
expect(video.find("source").attributes("src")).toBe(props.backgroundVideo);
|
|
52
|
+
|
|
53
|
+
changeViewport(false);
|
|
54
|
+
await nextTick();
|
|
55
|
+
expect(wrapper.find("video").exists()).toBe(false);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("renders neither poster nor video without media", async () => {
|
|
59
|
+
stubMatchMedia(true);
|
|
60
|
+
|
|
61
|
+
const wrapper = await mountSuspended(Hero, {
|
|
62
|
+
props: { title: "Pizzeria", links: [] },
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
expect(wrapper.find("img").exists()).toBe(false);
|
|
66
|
+
expect(wrapper.find("video").exists()).toBe(false);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -3,12 +3,25 @@ import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
|
3
3
|
import PaymentAndDelivery from "~/components/Checkout/PaymentAndDelivery.vue";
|
|
4
4
|
import { ref } from "vue";
|
|
5
5
|
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const {
|
|
7
|
+
mockSetPaymentMethod,
|
|
8
|
+
mockSetShippingMethod,
|
|
9
|
+
mockRefreshCart,
|
|
10
|
+
mockEnsureAvailableCheckoutMethods,
|
|
11
|
+
} = vi.hoisted(() => ({
|
|
12
|
+
mockSetPaymentMethod: vi.fn(),
|
|
13
|
+
mockSetShippingMethod: vi.fn(),
|
|
14
|
+
mockRefreshCart: vi.fn(),
|
|
15
|
+
mockEnsureAvailableCheckoutMethods: vi.fn(),
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
// Shared so tests can simulate the session's methods changing.
|
|
19
|
+
// Only read lazily inside the composable factory, after module init.
|
|
20
|
+
const selectedPaymentMethod = ref({
|
|
21
|
+
id: "pm1",
|
|
22
|
+
distinguishableName: "Payment 1",
|
|
23
|
+
});
|
|
24
|
+
const selectedShippingMethod = ref({ id: "sm1", name: "Shipping 1" });
|
|
12
25
|
|
|
13
26
|
mockNuxtImport("useCheckout", () => () => ({
|
|
14
27
|
paymentMethods: ref([
|
|
@@ -19,8 +32,8 @@ mockNuxtImport("useCheckout", () => () => ({
|
|
|
19
32
|
{ id: "sm1", name: "Shipping 1" },
|
|
20
33
|
{ id: "sm2", name: "Shipping 2" },
|
|
21
34
|
]),
|
|
22
|
-
selectedPaymentMethod
|
|
23
|
-
selectedShippingMethod
|
|
35
|
+
selectedPaymentMethod,
|
|
36
|
+
selectedShippingMethod,
|
|
24
37
|
setPaymentMethod: mockSetPaymentMethod,
|
|
25
38
|
setShippingMethod: mockSetShippingMethod,
|
|
26
39
|
getPaymentMethods: vi.fn(),
|
|
@@ -31,6 +44,15 @@ mockNuxtImport("useCart", () => () => ({
|
|
|
31
44
|
refreshCart: mockRefreshCart,
|
|
32
45
|
}));
|
|
33
46
|
|
|
47
|
+
mockNuxtImport("useCheckoutMethodGuard", () => () => ({
|
|
48
|
+
ensureAvailableCheckoutMethods: mockEnsureAvailableCheckoutMethods,
|
|
49
|
+
ensureAvailableShippingMethod: vi.fn(),
|
|
50
|
+
ensureAvailablePaymentMethod: vi.fn(),
|
|
51
|
+
isShippingMethodBlocked: ref(false),
|
|
52
|
+
isPaymentMethodBlocked: ref(false),
|
|
53
|
+
isResolving: ref(false),
|
|
54
|
+
}));
|
|
55
|
+
|
|
34
56
|
mockNuxtImport("useToast", () => () => ({
|
|
35
57
|
add: vi.fn(),
|
|
36
58
|
}));
|
|
@@ -38,6 +60,43 @@ mockNuxtImport("useToast", () => () => ({
|
|
|
38
60
|
describe("PaymentAndDelivery", () => {
|
|
39
61
|
beforeEach(() => {
|
|
40
62
|
vi.clearAllMocks();
|
|
63
|
+
selectedPaymentMethod.value = {
|
|
64
|
+
id: "pm1",
|
|
65
|
+
distinguishableName: "Payment 1",
|
|
66
|
+
};
|
|
67
|
+
selectedShippingMethod.value = { id: "sm1", name: "Shipping 1" };
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("resolves blocked checkout methods after loading the methods", async () => {
|
|
71
|
+
await mountSuspended(PaymentAndDelivery);
|
|
72
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
73
|
+
|
|
74
|
+
expect(mockEnsureAvailableCheckoutMethods).toHaveBeenCalledTimes(1);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("syncs the radio when the session payment method changes without re-setting it", async () => {
|
|
78
|
+
const wrapper = await mountSuspended(PaymentAndDelivery);
|
|
79
|
+
|
|
80
|
+
selectedPaymentMethod.value = {
|
|
81
|
+
id: "pm2",
|
|
82
|
+
distinguishableName: "Payment 2",
|
|
83
|
+
};
|
|
84
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
85
|
+
|
|
86
|
+
// @ts-expect-error - access internal state
|
|
87
|
+
expect(wrapper.vm.selectedPaymentMethodId).toBe("pm2");
|
|
88
|
+
expect(mockSetPaymentMethod).not.toHaveBeenCalled();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("syncs the radio when the session shipping method changes without re-setting it", async () => {
|
|
92
|
+
const wrapper = await mountSuspended(PaymentAndDelivery);
|
|
93
|
+
|
|
94
|
+
selectedShippingMethod.value = { id: "sm2", name: "Shipping 2" };
|
|
95
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
96
|
+
|
|
97
|
+
// @ts-expect-error - access internal state
|
|
98
|
+
expect(wrapper.vm.selectedShippingMethodId).toBe("sm2");
|
|
99
|
+
expect(mockSetShippingMethod).not.toHaveBeenCalled();
|
|
41
100
|
});
|
|
42
101
|
|
|
43
102
|
it("renders correctly", async () => {
|