@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
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { encodeForQuery } from "@shopware/api-client/helpers";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Fixed projections applied to every listing request. Defined server-side so
|
|
5
3
|
* clients cannot override includes/associations/limit via query params.
|
|
@@ -17,6 +15,8 @@ const BASE_CRITERIA = {
|
|
|
17
15
|
"propertyIds",
|
|
18
16
|
"sortedProperties",
|
|
19
17
|
"cover",
|
|
18
|
+
// "Ausverkauft" on the card (#325).
|
|
19
|
+
"available",
|
|
20
20
|
],
|
|
21
21
|
property: ["id", "name", "translated", "displayType", "options"],
|
|
22
22
|
property_group_option: [
|
|
@@ -28,6 +28,7 @@ const BASE_CRITERIA = {
|
|
|
28
28
|
"mediaId",
|
|
29
29
|
],
|
|
30
30
|
product_option: ["id", "groupId", "name", "translated", "group"],
|
|
31
|
+
...MEDIA_INCLUDES,
|
|
31
32
|
},
|
|
32
33
|
associations: {
|
|
33
34
|
cover: {
|
|
@@ -71,28 +72,23 @@ function resolveAllowedParams(query: Record<string, unknown>) {
|
|
|
71
72
|
export default defineCachedEventHandler(
|
|
72
73
|
async (event) => {
|
|
73
74
|
const categoryId = getRouterParam(event, "categoryId")!;
|
|
74
|
-
const { endpoint, accessToken } = useRuntimeConfig().public.shopware;
|
|
75
75
|
|
|
76
76
|
const { order, properties, manufacturer, query, p } = resolveAllowedParams(
|
|
77
77
|
getQuery(event) as Record<string, unknown>,
|
|
78
78
|
);
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return await $fetch(`${endpoint}/product-listing/${categoryId}`, {
|
|
90
|
-
headers: {
|
|
91
|
-
"sw-access-key": accessToken,
|
|
92
|
-
"sw-include-seo-urls": "true",
|
|
80
|
+
return await storeApiPost(
|
|
81
|
+
`/product-listing/${categoryId}`,
|
|
82
|
+
{
|
|
83
|
+
...BASE_CRITERIA,
|
|
84
|
+
...(order !== undefined && { order }),
|
|
85
|
+
...(properties !== undefined && { properties }),
|
|
86
|
+
...(manufacturer !== undefined && { manufacturer }),
|
|
87
|
+
...(query !== undefined && { query }),
|
|
88
|
+
...(p !== undefined && { p }),
|
|
93
89
|
},
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
{ headers: { "sw-include-seo-urls": "true" } },
|
|
91
|
+
);
|
|
96
92
|
},
|
|
97
93
|
{
|
|
98
94
|
maxAge: useRuntimeConfig().public.shopBite.cacheTtl.listing,
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
import { encodeForQuery } from "@shopware/api-client/helpers";
|
|
2
1
|
import type { components } from "~~/api-types/storeApiTypes";
|
|
3
2
|
|
|
4
3
|
type Schemas = components["schemas"];
|
|
5
4
|
|
|
6
|
-
const criteria =
|
|
5
|
+
const criteria = {
|
|
7
6
|
includes: {
|
|
8
7
|
cross_selling_element: ["crossSelling", "products"],
|
|
9
8
|
cross_selling: ["name"],
|
|
10
9
|
product: ["id", "name", "calculatedPrice", "translated"],
|
|
11
10
|
calculated_price: ["unitPrice"],
|
|
12
11
|
},
|
|
13
|
-
}
|
|
12
|
+
};
|
|
14
13
|
|
|
15
14
|
export default defineCachedEventHandler(
|
|
16
15
|
async (event): Promise<Schemas["CrossSellingElement"][]> => {
|
|
17
16
|
const productId = getRouterParam(event, "productId")!;
|
|
18
|
-
const { endpoint, accessToken } = useRuntimeConfig().public.shopware;
|
|
19
17
|
|
|
20
|
-
return await
|
|
21
|
-
method: "POST",
|
|
22
|
-
headers: { "sw-access-key": accessToken },
|
|
23
|
-
query: { _criteria: criteria },
|
|
24
|
-
});
|
|
18
|
+
return await storeApiPost(`/product/${productId}/cross-selling`, criteria);
|
|
25
19
|
},
|
|
26
20
|
{
|
|
27
21
|
maxAge: useRuntimeConfig().public.shopBite.cacheTtl.crossSelling,
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { encodeForQuery } from "@shopware/api-client/helpers";
|
|
2
1
|
import type { components } from "~~/api-types/storeApiTypes";
|
|
3
2
|
|
|
4
3
|
type Schemas = components["schemas"];
|
|
5
4
|
|
|
6
|
-
const criteria =
|
|
5
|
+
const criteria = {
|
|
7
6
|
includes: {
|
|
8
7
|
product: [
|
|
9
8
|
"id",
|
|
@@ -28,6 +27,7 @@ const criteria = encodeForQuery({
|
|
|
28
27
|
product_configurator_setting: ["id", "optionId", "option", "productId"],
|
|
29
28
|
product_option: ["id", "groupId", "name", "translated", "group"],
|
|
30
29
|
category: ["id", "name", "translated"],
|
|
30
|
+
...MEDIA_INCLUDES,
|
|
31
31
|
},
|
|
32
32
|
associations: {
|
|
33
33
|
cover: { associations: { media: {} } },
|
|
@@ -44,7 +44,7 @@ const criteria = encodeForQuery({
|
|
|
44
44
|
},
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
|
-
}
|
|
47
|
+
};
|
|
48
48
|
|
|
49
49
|
export default defineCachedEventHandler(
|
|
50
50
|
async (
|
|
@@ -54,12 +54,8 @@ export default defineCachedEventHandler(
|
|
|
54
54
|
configurator?: Schemas["PropertyGroup"][];
|
|
55
55
|
}> => {
|
|
56
56
|
const productId = getRouterParam(event, "productId")!;
|
|
57
|
-
const { endpoint, accessToken } = useRuntimeConfig().public.shopware;
|
|
58
57
|
|
|
59
|
-
return await
|
|
60
|
-
headers: { "sw-access-key": accessToken },
|
|
61
|
-
query: { _criteria: criteria },
|
|
62
|
-
});
|
|
58
|
+
return await storeApiPost(`/product/${productId}`, criteria);
|
|
63
59
|
},
|
|
64
60
|
{
|
|
65
61
|
maxAge: useRuntimeConfig().public.shopBite.cacheTtl.product,
|
package/server/api/search.get.ts
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Uses `storeUrl` (NUXT_PUBLIC_STORE_URL) as the site URL of nuxt-site-config,
|
|
3
|
+
* so canonical URLs, the sitemap and robots.txt share one base URL instead of
|
|
4
|
+
* the request origin (which is internal behind a reverse proxy).
|
|
5
|
+
*/
|
|
6
|
+
export default defineNitroPlugin((nitroApp) => {
|
|
7
|
+
nitroApp.hooks.hook("site-config:init", ({ event, siteConfig }) => {
|
|
8
|
+
const { storeUrl } = useRuntimeConfig(event).public;
|
|
9
|
+
if (storeUrl) {
|
|
10
|
+
siteConfig.push({ _context: "storeUrl", url: storeUrl });
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { StorefrontSitemapUrl } from "../utils/sitemap";
|
|
2
|
+
|
|
3
|
+
const CONTEXT_KEY = "sitemapTrailingSlashPaths";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The sitemap module normalises every URL to "no trailing slash", which turns
|
|
7
|
+
* Shopware category URLs like `/c/Pizza/` into 404s. Sources mark such URLs
|
|
8
|
+
* with `_trailingSlash`; the paths are collected per request and restored in
|
|
9
|
+
* the rendered XML, so sitemap and canonical URLs match.
|
|
10
|
+
*/
|
|
11
|
+
export default defineNitroPlugin((nitroApp) => {
|
|
12
|
+
nitroApp.hooks.hook("sitemap:resolved", ({ urls, event }) => {
|
|
13
|
+
event.context[CONTEXT_KEY] = new Set(
|
|
14
|
+
urls
|
|
15
|
+
.filter((url) => (url as StorefrontSitemapUrl)._trailingSlash)
|
|
16
|
+
.map((url) => url._relativeLoc),
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
nitroApp.hooks.hook("sitemap:output", (ctx) => {
|
|
21
|
+
const paths = ctx.event.context[CONTEXT_KEY] as Set<string> | undefined;
|
|
22
|
+
if (paths?.size) {
|
|
23
|
+
ctx.sitemap = restoreTrailingSlashes(ctx.sitemap, paths);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { parseURL, withTrailingSlash } from "ufo";
|
|
2
|
+
import type { SitemapUrl } from "#sitemap/types";
|
|
3
|
+
import type { components } from "~~/api-types/storeApiTypes";
|
|
4
|
+
|
|
5
|
+
type Category = components["schemas"]["Category"];
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `_trailingSlash` marks URLs whose path must keep its trailing slash. The
|
|
9
|
+
* sitemap module strips trailing slashes from every URL, but Shopware
|
|
10
|
+
* category SEO URLs (`/c/Pizza/`) 404 without it; the
|
|
11
|
+
* `sitemap-trailing-slash` server plugin restores them.
|
|
12
|
+
*/
|
|
13
|
+
export type StorefrontSitemapUrl = SitemapUrl & { _trailingSlash?: boolean };
|
|
14
|
+
|
|
15
|
+
/** Maps navigation categories to sitemap entries (pages with an SEO URL only). */
|
|
16
|
+
export function categoriesToSitemapUrls(
|
|
17
|
+
categories: Category[],
|
|
18
|
+
): StorefrontSitemapUrl[] {
|
|
19
|
+
const urls = new Map<string, StorefrontSitemapUrl>();
|
|
20
|
+
|
|
21
|
+
for (const category of categories) {
|
|
22
|
+
const path = category.seoUrl;
|
|
23
|
+
// Technical /navigation/<id> URLs have no storefront route.
|
|
24
|
+
if (
|
|
25
|
+
category.type !== "page" ||
|
|
26
|
+
!path?.startsWith("/") ||
|
|
27
|
+
path.startsWith("//") ||
|
|
28
|
+
path.startsWith("/navigation/") ||
|
|
29
|
+
urls.has(path)
|
|
30
|
+
) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const lastmod = category.updatedAt ?? category.createdAt;
|
|
35
|
+
const image = category.media?.url;
|
|
36
|
+
|
|
37
|
+
urls.set(path, {
|
|
38
|
+
loc: path,
|
|
39
|
+
...(lastmod && { lastmod }),
|
|
40
|
+
...(image && { images: [{ loc: image }] }),
|
|
41
|
+
...(path.endsWith("/") && { _trailingSlash: true }),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return [...urls.values()];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Re-appends the trailing slash to `<loc>` entries whose path is listed. */
|
|
49
|
+
export function restoreTrailingSlashes(
|
|
50
|
+
xml: string,
|
|
51
|
+
paths: ReadonlySet<string>,
|
|
52
|
+
): string {
|
|
53
|
+
if (paths.size === 0) return xml;
|
|
54
|
+
|
|
55
|
+
return xml.replace(/<loc>([^<]+)<\/loc>/g, (match, loc: string) =>
|
|
56
|
+
paths.has(parseURL(loc).pathname)
|
|
57
|
+
? `<loc>${withTrailingSlash(loc)}</loc>`
|
|
58
|
+
: match,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { NitroFetchOptions } from "nitropack";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Field projection for media entities, shared by the routes that return
|
|
5
|
+
* category or product images: the URL plus the thumbnails and intrinsic size
|
|
6
|
+
* the storefront needs for `srcset` and `width`/`height` (#273).
|
|
7
|
+
*/
|
|
8
|
+
export const MEDIA_INCLUDES = {
|
|
9
|
+
media: ["url", "alt", "thumbnails", "metaData"],
|
|
10
|
+
media_thumbnail: ["url", "width", "height"],
|
|
11
|
+
product_media: ["media"],
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Calls the Shopware Store API with a criteria in the request body.
|
|
16
|
+
*
|
|
17
|
+
* Criteria must travel as a POST body: sent as `_criteria` query parameters
|
|
18
|
+
* on a GET, Shopware applies `associations` and `limit` but ignores the
|
|
19
|
+
* `includes` projection, so every entity comes back with all of its fields
|
|
20
|
+
* (a product listing was twice the size, #312).
|
|
21
|
+
*/
|
|
22
|
+
export function storeApiPost<T>(
|
|
23
|
+
path: string,
|
|
24
|
+
body: Record<string, unknown>,
|
|
25
|
+
options: Pick<NitroFetchOptions<string>, "headers"> = {},
|
|
26
|
+
): Promise<T> {
|
|
27
|
+
const { endpoint, accessToken } = useRuntimeConfig().public.shopware;
|
|
28
|
+
|
|
29
|
+
return $fetch<T>(`${endpoint}${path}`, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers: { "sw-access-key": accessToken, ...options.headers },
|
|
32
|
+
body,
|
|
33
|
+
});
|
|
34
|
+
}
|
package/shopware.d.ts
CHANGED
|
@@ -1,19 +1,43 @@
|
|
|
1
1
|
declare module "#shopware" {
|
|
2
2
|
import type { createAPIClient } from "@shopware/api-client";
|
|
3
3
|
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// or for locally generated types
|
|
8
|
-
export type operations = import("./api-types/storeApiTypes").operations;
|
|
9
|
-
|
|
10
|
-
// for default types
|
|
11
|
-
// export type Schemas =
|
|
12
|
-
// import("@shopware/api-client/store-api-types").components["schemas"];
|
|
13
|
-
// or for locally generated types
|
|
14
|
-
export type Schemas =
|
|
4
|
+
// Types generated from our own Shopware instance (`pnpm generate-types`).
|
|
5
|
+
type CustomOperations = import("./api-types/storeApiTypes").operations;
|
|
6
|
+
type CustomSchemas =
|
|
15
7
|
import("./api-types/storeApiTypes").components["schemas"];
|
|
16
8
|
|
|
9
|
+
// The `@shopware/composables` layer references endpoints and schemas our
|
|
10
|
+
// instance does not expose (e.g. B2B quotes). Fall back to the default
|
|
11
|
+
// types shipped with the api-client for those so the layer typechecks;
|
|
12
|
+
// our own types always win where both exist.
|
|
13
|
+
type DefaultOperations =
|
|
14
|
+
import("@shopware/api-client/store-api-types").operations;
|
|
15
|
+
type DefaultSchemas =
|
|
16
|
+
import("@shopware/api-client/store-api-types").components["schemas"];
|
|
17
|
+
|
|
18
|
+
type FallbackOperations = Omit<DefaultOperations, keyof CustomOperations>;
|
|
19
|
+
|
|
20
|
+
// Fallback operations reference the default schemas, but the composables
|
|
21
|
+
// compare their responses against ours. Re-map the affected responses.
|
|
22
|
+
type CreateOrderFromQuote = "createOrderFromQuote post /quote/order/{id}";
|
|
23
|
+
|
|
24
|
+
export type operations = Omit<FallbackOperations, CreateOrderFromQuote> &
|
|
25
|
+
CustomOperations & {
|
|
26
|
+
[K in CreateOrderFromQuote]: Omit<DefaultOperations[K], "response"> & {
|
|
27
|
+
response: CustomSchemas["Order"];
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Shopware 6.7 declares `LineItem.payload` as required, but container,
|
|
32
|
+
// promotion and custom line items carry no product payload. Keep it
|
|
33
|
+
// optional (as in the default types the composables are written against).
|
|
34
|
+
type LineItem = Omit<CustomSchemas["LineItem"], "payload"> & {
|
|
35
|
+
payload?: CustomSchemas["LineItem"]["payload"];
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type Schemas = Omit<DefaultSchemas, keyof CustomSchemas> &
|
|
39
|
+
Omit<CustomSchemas, "LineItem"> & { LineItem: LineItem };
|
|
40
|
+
|
|
17
41
|
// we're exporting our own Api Client definition as it depends on our own instance
|
|
18
42
|
export type ApiClient = ReturnType<typeof createAPIClient<operations>>;
|
|
19
43
|
}
|
|
@@ -64,31 +64,27 @@ async function selectProductAndAddToCart(
|
|
|
64
64
|
) {
|
|
65
65
|
const productCard = page.locator(`#product-card-${productId}`);
|
|
66
66
|
await expect(productCard).toBeVisible();
|
|
67
|
-
|
|
68
|
-
// Verify product card structure
|
|
69
|
-
const buttons = productCard.locator("button");
|
|
70
|
-
await expect(buttons).toHaveCount(2);
|
|
71
67
|
await expect(productCard.locator("button .i-lucide\\:heart")).toBeVisible();
|
|
72
68
|
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
);
|
|
77
|
-
await expect(
|
|
78
|
-
await
|
|
69
|
+
// The card opens the quick view drawer; its state is the `produkt`
|
|
70
|
+
// query parameter (#325).
|
|
71
|
+
await productCard.getByRole("button", { name: /auswählen$/i }).click();
|
|
72
|
+
const drawer = page.locator('[data-vaul-drawer][data-state="open"]');
|
|
73
|
+
await expect(drawer).toBeVisible({ timeout: 10000 });
|
|
74
|
+
await expect(page).toHaveURL(/[?&]produkt=/);
|
|
79
75
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
await expect(quantityInput).toBeVisible();
|
|
76
|
+
const quantityInput = drawer.getByRole("spinbutton", { name: /anzahl/i });
|
|
77
|
+
await expect(quantityInput).toBeVisible({ timeout: 10000 });
|
|
83
78
|
await quantityInput.fill(quantity.toString());
|
|
84
79
|
await expect(quantityInput).toHaveValue(quantity.toString());
|
|
85
80
|
|
|
86
|
-
const addToCartButton =
|
|
87
|
-
name:
|
|
81
|
+
const addToCartButton = drawer.getByRole("button", {
|
|
82
|
+
name: /In den Warenkorb/,
|
|
88
83
|
});
|
|
89
|
-
await expect(addToCartButton).
|
|
84
|
+
await expect(addToCartButton).toBeEnabled({ timeout: 10000 });
|
|
90
85
|
await addToCartButton.click();
|
|
91
|
-
await expect(
|
|
86
|
+
await expect(drawer).not.toBeVisible({ timeout: 10000 });
|
|
87
|
+
await expect(page).not.toHaveURL(/[?&]produkt=/);
|
|
92
88
|
}
|
|
93
89
|
|
|
94
90
|
async function proceedToCheckoutAndLogin(page: Page) {
|
|
@@ -2,6 +2,7 @@ import { describe, it, expect, vi } from "vitest";
|
|
|
2
2
|
import { reactive } from "vue";
|
|
3
3
|
import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
4
4
|
import Fields from "~/components/Address/Fields.vue";
|
|
5
|
+
import type { AddressSchema } from "~/validation/registrationSchema";
|
|
5
6
|
|
|
6
7
|
const { mockGetSuggestions } = vi.hoisted(() => ({
|
|
7
8
|
mockGetSuggestions: vi.fn().mockResolvedValue([]),
|
|
@@ -106,7 +107,7 @@ describe("AddressFields", () => {
|
|
|
106
107
|
props: {
|
|
107
108
|
...defaultProps,
|
|
108
109
|
modelValue,
|
|
109
|
-
"onUpdate:modelValue": (val:
|
|
110
|
+
"onUpdate:modelValue": (val: AddressSchema) =>
|
|
110
111
|
Object.assign(modelValue, val),
|
|
111
112
|
},
|
|
112
113
|
});
|
|
@@ -117,78 +118,6 @@ describe("AddressFields", () => {
|
|
|
117
118
|
expect(modelValue.street).toBe("New Street");
|
|
118
119
|
});
|
|
119
120
|
|
|
120
|
-
it("shows warning when an invalid city is selected for shipping address", async () => {
|
|
121
|
-
const modelValue = reactive({
|
|
122
|
-
firstName: "John",
|
|
123
|
-
lastName: "Doe",
|
|
124
|
-
street: "Main St 1",
|
|
125
|
-
zipcode: "12345",
|
|
126
|
-
city: "InvalidCity",
|
|
127
|
-
phoneNumber: "12345678",
|
|
128
|
-
countryId: "",
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
const wrapper = await mountSuspended(Fields, {
|
|
132
|
-
props: {
|
|
133
|
-
...defaultProps,
|
|
134
|
-
modelValue,
|
|
135
|
-
isShipping: true,
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
expect(wrapper.text()).toContain(
|
|
140
|
-
"An diese Adresse können wir leider nicht liefern.",
|
|
141
|
-
);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it("does not show warning for valid city in shipping address", async () => {
|
|
145
|
-
const modelValue = reactive({
|
|
146
|
-
firstName: "John",
|
|
147
|
-
lastName: "Doe",
|
|
148
|
-
street: "Main St 1",
|
|
149
|
-
zipcode: "63179",
|
|
150
|
-
city: "Obertshausen",
|
|
151
|
-
phoneNumber: "12345678",
|
|
152
|
-
countryId: "",
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
const wrapper = await mountSuspended(Fields, {
|
|
156
|
-
props: {
|
|
157
|
-
...defaultProps,
|
|
158
|
-
modelValue,
|
|
159
|
-
isShipping: true,
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
expect(wrapper.text()).not.toContain(
|
|
164
|
-
"An diese Adresse können wir leider nicht liefern.",
|
|
165
|
-
);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("does not show warning for billing address even if city is 'invalid'", async () => {
|
|
169
|
-
const modelValue = reactive({
|
|
170
|
-
firstName: "John",
|
|
171
|
-
lastName: "Doe",
|
|
172
|
-
street: "Main St 1",
|
|
173
|
-
zipcode: "12345",
|
|
174
|
-
city: "InvalidCity",
|
|
175
|
-
phoneNumber: "12345678",
|
|
176
|
-
countryId: "",
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
const wrapper = await mountSuspended(Fields, {
|
|
180
|
-
props: {
|
|
181
|
-
...defaultProps,
|
|
182
|
-
modelValue,
|
|
183
|
-
isShipping: false,
|
|
184
|
-
},
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
expect(wrapper.text()).not.toContain(
|
|
188
|
-
"An diese Adresse können wir leider nicht liefern.",
|
|
189
|
-
);
|
|
190
|
-
});
|
|
191
|
-
|
|
192
121
|
it("shows correction automatically on input after debounce", async () => {
|
|
193
122
|
mockGetSuggestions.mockResolvedValue([
|
|
194
123
|
{
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
3
|
+
import { ref, reactive, computed } from "vue";
|
|
4
|
+
import CartBar from "~/components/Cart/Bar.vue";
|
|
5
|
+
|
|
6
|
+
const state = reactive({ count: 0, subtotal: 0, path: "/c/Pizza/" });
|
|
7
|
+
const showCalls = vi.hoisted(() => ({ value: 0 }));
|
|
8
|
+
type Addition = {
|
|
9
|
+
product: { name: string; translated: { name: string } };
|
|
10
|
+
quantity: number;
|
|
11
|
+
};
|
|
12
|
+
const listeners: Array<(addition: Addition) => void> = [];
|
|
13
|
+
|
|
14
|
+
mockNuxtImport("useCart", () => () => ({
|
|
15
|
+
count: computed(() => state.count),
|
|
16
|
+
subtotal: computed(() => state.subtotal),
|
|
17
|
+
}));
|
|
18
|
+
mockNuxtImport("useShopBiteConfig", () => () => ({
|
|
19
|
+
isCheckoutEnabled: ref(true),
|
|
20
|
+
}));
|
|
21
|
+
mockNuxtImport("useCommercePrice", () => () => ({
|
|
22
|
+
getFormattedPrice: (price: number) => `${price.toFixed(2)} €`,
|
|
23
|
+
}));
|
|
24
|
+
mockNuxtImport("useRoute", () => () => ({
|
|
25
|
+
get path() {
|
|
26
|
+
return state.path;
|
|
27
|
+
},
|
|
28
|
+
query: {},
|
|
29
|
+
}));
|
|
30
|
+
mockNuxtImport("useProductEvents", () => () => ({
|
|
31
|
+
onCartItemAdded: (callback: (addition: Addition) => void) => {
|
|
32
|
+
listeners.push(callback);
|
|
33
|
+
},
|
|
34
|
+
}));
|
|
35
|
+
mockNuxtImport("useCartQuickView", () => () => ({
|
|
36
|
+
open: ref(false),
|
|
37
|
+
mounted: ref(false),
|
|
38
|
+
show: () => {
|
|
39
|
+
showCalls.value++;
|
|
40
|
+
},
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
describe("CartBar", () => {
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
state.count = 0;
|
|
46
|
+
state.subtotal = 0;
|
|
47
|
+
state.path = "/c/Pizza/";
|
|
48
|
+
showCalls.value = 0;
|
|
49
|
+
listeners.length = 0;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("stays hidden with an empty cart", async () => {
|
|
53
|
+
const wrapper = await mountSuspended(CartBar);
|
|
54
|
+
expect(wrapper.find('[data-testid="cart-bar"]').exists()).toBe(false);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("shows the item count and the subtotal", async () => {
|
|
58
|
+
state.count = 2;
|
|
59
|
+
state.subtotal = 15.5;
|
|
60
|
+
const wrapper = await mountSuspended(CartBar);
|
|
61
|
+
const bar = wrapper.find('[data-testid="cart-bar"]');
|
|
62
|
+
expect(bar.text()).toContain("2 Artikel · 15.50 €");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("uses the singular for one item", async () => {
|
|
66
|
+
state.count = 1;
|
|
67
|
+
state.subtotal = 7;
|
|
68
|
+
const wrapper = await mountSuspended(CartBar);
|
|
69
|
+
expect(wrapper.find('[data-testid="cart-bar"]').text()).toContain(
|
|
70
|
+
"1 Artikel",
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("opens the cart drawer on click", async () => {
|
|
75
|
+
state.count = 2;
|
|
76
|
+
const wrapper = await mountSuspended(CartBar);
|
|
77
|
+
await wrapper.find('[data-testid="cart-bar"]').trigger("click");
|
|
78
|
+
expect(showCalls.value).toBe(1);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("names the added product for a moment instead of a toast", async () => {
|
|
82
|
+
vi.useFakeTimers();
|
|
83
|
+
state.count = 2;
|
|
84
|
+
state.subtotal = 15.5;
|
|
85
|
+
const wrapper = await mountSuspended(CartBar);
|
|
86
|
+
for (const listener of listeners) {
|
|
87
|
+
listener({
|
|
88
|
+
product: { name: "Pizza Salami", translated: { name: "Pizza Salami" } },
|
|
89
|
+
quantity: 2,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
await wrapper.vm.$nextTick();
|
|
93
|
+
expect(wrapper.find('[data-testid="cart-bar"]').text()).toContain(
|
|
94
|
+
"2× Pizza Salami",
|
|
95
|
+
);
|
|
96
|
+
vi.advanceTimersByTime(2000);
|
|
97
|
+
await wrapper.vm.$nextTick();
|
|
98
|
+
expect(wrapper.find('[data-testid="cart-bar"]').text()).toContain(
|
|
99
|
+
"2 Artikel",
|
|
100
|
+
);
|
|
101
|
+
vi.useRealTimers();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("is hidden on the checkout pages", async () => {
|
|
105
|
+
state.count = 2;
|
|
106
|
+
state.path = "/bestellung/warenkorb";
|
|
107
|
+
const wrapper = await mountSuspended(CartBar);
|
|
108
|
+
expect(wrapper.find('[data-testid="cart-bar"]').exists()).toBe(false);
|
|
109
|
+
});
|
|
110
|
+
});
|