@shopbite-de/storefront 1.26.0 → 1.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/.github/workflows/build.yaml +1 -1
  2. package/.github/workflows/ci.yaml +3 -3
  3. package/.gitignore +40 -0
  4. package/CLAUDE.md +10 -3
  5. package/app/app.vue +4 -1
  6. package/app/components/Hero.vue +17 -7
  7. package/app/components/Product/CrossSelling.vue +137 -24
  8. package/app/components/Product/DeselectIngredient.vue +9 -2
  9. package/app/components/Product/Detail.vue +16 -18
  10. package/app/components/Product/QuickView.vue +5 -4
  11. package/app/components/User/RegistrationForm.vue +73 -29
  12. package/app/composables/useStoreStatus.ts +12 -7
  13. package/app/composables/useSyncWishlist.ts +119 -0
  14. package/app/pages/[...all].vue +9 -3
  15. package/app/pages/index.vue +1 -5
  16. package/app/pages/kontakt.vue +1 -5
  17. package/app/pages/registrierung/bestaetigen.vue +100 -27
  18. package/app/pages/registrierung/index.vue +20 -1
  19. package/app/utils/notFound.ts +14 -0
  20. package/content/index.yml +9 -9
  21. package/docs/notes/2026-09-17-quick-view-compact-options.md +63 -0
  22. package/docs/notes/2026-09-21-dependency-update.md +89 -0
  23. package/docs/notes/2026-09-21-issue-273-cache-and-demo-video.md +49 -0
  24. package/docs/notes/2026-09-21-issue-363-non-fatal-404.md +43 -0
  25. package/docs/notes/2026-09-21-issue-365-home-hydration-mismatch.md +47 -0
  26. package/docs/notes/2026-09-21-issue-366-wishlist-404.md +41 -0
  27. package/docs/notes/2026-09-21-issue-369-register-confirm.md +35 -0
  28. package/modules/public-cache.ts +44 -0
  29. package/node.dockerfile +3 -3
  30. package/nuxt.config.ts +6 -0
  31. package/package.json +26 -26
  32. package/patches/@shopware__nuxt-module@1.5.2.patch +13 -0
  33. package/pnpm-workspace.yaml +3 -1
  34. package/shopware.d.ts +1 -1
  35. package/test/nuxt/Hero.test.ts +60 -2
  36. package/test/nuxt/ProductCrossSelling.test.ts +99 -0
  37. package/test/nuxt/RegisterConfirmPage.test.ts +117 -0
  38. package/test/nuxt/RegistrationForm.test.ts +132 -2
  39. package/test/nuxt/notFound.test.ts +13 -0
  40. package/test/nuxt/useSearchTracking.test.ts +3 -0
  41. package/test/nuxt/useStoreStatus.test.ts +40 -10
  42. package/test/nuxt/useSyncWishlist.test.ts +85 -0
  43. package/test/unit/publicCache.spec.ts +64 -0
  44. package/patches/@shopware__nuxt-module@1.5.1.patch +0 -32
@@ -0,0 +1,43 @@
1
+ # Issue #363: 404 pages logged as fatal request errors
2
+
3
+ ## Finding
4
+
5
+ Nitro (`nitropack/dist/runtime/internal/error/prod.mjs`) logs a
6
+ `[request error] [fatal|unhandled] [GET] <url>` block with the full error
7
+ object only for errors that are `fatal` or `unhandled`. The catch-all page, the
8
+ home page and `/kontakt` threw their 404 with `fatal: true`, so every scanner
9
+ request (`/.env`, `/.git/config`, `/api/v1/.env`, …) produced such a block.
10
+
11
+ Container logs in OpenObserve (`docker_logs`, 2026-09-19 to 2026-09-21):
12
+
13
+ | Container | `[fatal]` blocks (3 days) |
14
+ | ----------------------- | ------------------------- |
15
+ | `lafattoria-storefront` | ~2,500 |
16
+ | `shopbite-storefront` | 565 |
17
+ | `shopbite-homepage` | 423 (same pattern, own repo) |
18
+
19
+ `fatal` cannot simply be dropped: Nuxt's root component
20
+ (`nuxt/dist/app/components/nuxt-root.vue`, `onErrorCaptured`) shows the error
21
+ page on the server for every error, but in the browser only for fatal ones. A
22
+ non-fatal 404 during client-side navigation would leave the page blank.
23
+
24
+ ## Fix
25
+
26
+ `createNotFoundError()` (`app/utils/notFound.ts`) throws the 404 with
27
+ `fatal: import.meta.client`. The catch-all page passes 5xx errors of the content
28
+ route on as a fatal 500 (logged, a real failure); 4xx of that route count as
29
+ "not found" (it rejects over-long scanner paths with 400).
30
+
31
+ ## Verification
32
+
33
+ Production build against the demo backend: `/.env`, `/.git/config`,
34
+ `/firebase-key.json`, `/gibtesnicht` and a 300-character path return 404 with
35
+ the error page and add no line to the server log; `/` is 200. Client-side
36
+ navigation to an unknown path still shows the error page.
37
+
38
+ ## Other findings
39
+
40
+ - 117 `[unhandled]` errors on `/api/category|listing|product/*` at La Fattoria,
41
+ all on 2026-09-19 18:00 UTC: the Shopware backend answered with
42
+ `404 page not found` (backend unreachable). Logged correctly; the URL shows a
43
+ double slash (`/store-api//category/…`) because the endpoint env ends in `/`.
@@ -0,0 +1,47 @@
1
+ # Issue #365: hydration mismatch on the home page
2
+
3
+ ## Cause
4
+
5
+ The hero status line ("Geöffnet bis …" / "Geschlossen · öffnet …") was
6
+ rendered on the server. `useRestaurantSchema` (home page JSON-LD, #272)
7
+ prefetches business hours and holidays with `onServerPrefetch`, so
8
+ `useStoreStatus` had data on the server and computed the status with the
9
+ **server's** clock and time zone. The browser computed it again during
10
+ hydration with its own clock. Whenever the two disagreed (a UTC server is two
11
+ hours behind the shop in Europe/Berlin, which often crosses an opening
12
+ boundary), Vue reported `Hydration completed but contains mismatches.`
13
+
14
+ In production Vue does not rectify class mismatches, so affected visitors could
15
+ also see the wrong open/closed dot.
16
+
17
+ ## Reproduction
18
+
19
+ The demo backend is open 00:00–23:59, so the real clock never differs. With
20
+ Playwright's clock set to 23:59:30 Europe/Berlin while the dev server renders
21
+ at the real time:
22
+
23
+ ```
24
+ [Vue warn]: Hydration text mismatch … rendered on server: " Geöffnet bis 23:59"
25
+ - expected on client: " Geschlossen · öffnet morgen um 00:00 Uhr" at <Hero …>
26
+ [Vue warn]: Hydration class mismatch … bg-green-400 … expected bg-neutral-400
27
+ Hydration completed but contains mismatches.
28
+ ```
29
+
30
+ ## Fix
31
+
32
+ - `useStoreStatus`: `now` is `null` until the component is mounted, so the
33
+ status is `null` on the server and during hydration for every consumer
34
+ (hero, feature card, footer).
35
+ - Hero status line: on phones status and delivery time get one fixed row each
36
+ (`grid-rows-[1.5rem_1.5rem]`); a long status is truncated instead of wrapping.
37
+ The delivery time does not depend on the clock and is rendered on the server.
38
+ From `sm` both share one row as before, and the delivery time waits for the
39
+ status. Measured SSR vs hydrated at 360, 390 and 1280 px: status line height
40
+ and the CTA position are identical.
41
+
42
+ ## Open
43
+
44
+ - RUM verification (acceptance: < 1 % of sessions for 48 h) needs OpenObserve;
45
+ on 2026-09-21 its host served only the Traefik default certificate.
46
+ - At 360 px the longest status ("öffnet Mittwoch, 23.09. um 17:30 Uhr") is
47
+ truncated.
@@ -0,0 +1,41 @@
1
+ # Issue #366: wishlist 404 logged as an error
2
+
3
+ ## Finding
4
+
5
+ `useSyncWishlist` of `@shopware/composables` (1.12.1) catches every error of
6
+ `readCustomerWishlist post /customer/wishlist` and logs it with
7
+ `console.error`. Two responses are expected states, not errors:
8
+
9
+ | Response | Code | When |
10
+ | -------- | ------------------------------------- | -------------------------------------------- |
11
+ | 404 | `CHECKOUT__WISHLIST_NOT_FOUND` | logged-in customer who never saved a product |
12
+ | 403 | `CHECKOUT__WISHLIST_IS_NOT_ACTIVATED` | wishlist disabled in Shopware (demo shop) |
13
+
14
+ The log happens inside the layer, so a `try/catch` around
15
+ `getWishlistProducts()` in `app.vue` cannot suppress it. The layer's
16
+ `useWishlist` also calls it after login (`mergeWishlistProducts`).
17
+
18
+ The guard in `app.vue` checked the route name for `wishlist`, but the page is
19
+ `merkliste`, so `/merkliste` fetched the wishlist twice (`app.vue` and
20
+ `components/Wishlist.vue`).
21
+
22
+ ## Fix
23
+
24
+ - `app/composables/useSyncWishlist.ts` overrides the layer composable (a
25
+ project composable with the same name also replaces it inside the layer's
26
+ `useWishlist`). It is a copy of 1.12.1 that skips the log for the two codes
27
+ above. Compare with the layer source when Renovate bumps
28
+ `@shopware/composables`.
29
+ - `app.vue` compares the route name with `merkliste`.
30
+
31
+ ## Verification (2026-09-21)
32
+
33
+ Dev server against `shopware.shopbite.de` with a logged-in test customer: one
34
+ wishlist request on `/` and one on `/merkliste`, no
35
+ `[useSyncWishlist][getWishlistProducts][error]` in the console. The browser
36
+ still prints its own "Failed to load resource" line for the 403/404 response;
37
+ that is not a JavaScript error and cannot be suppressed from the page.
38
+
39
+ `storefront/.env` currently points at the La Fattoria production backend; to test
40
+ against the demo, set `NUXT_PUBLIC_SHOPWARE_ENDPOINT`/`_ACCESS_TOKEN` in the
41
+ environment (they take precedence over `.env`).
@@ -0,0 +1,35 @@
1
+ # Issue #369: registration confirmation reported success on failure
2
+
3
+ ## Finding
4
+
5
+ `app/pages/registrierung/bestaetigen.vue` swallowed every error of
6
+ `registerConfirm post /account/register-confirm` and then always showed the
7
+ success toast and navigated to `/konto`.
8
+
9
+ Even the success path was broken: Shopware's `RegisterConfirmRoute::confirm()`
10
+ logs the customer in (it replaces the context token and returns it in the
11
+ `sw-context-token` header), but the page never reloaded the session context.
12
+ `useUser().isLoggedIn` stayed `false`, so the `account` layout sent the visitor
13
+ on to `/anmelden`.
14
+
15
+ Error codes (checked against `shopware.shopbite.de` and the Shopware 6.7 source, 2026-09-21):
16
+
17
+ | Case | Status | Code |
18
+ | ------------------------ | ------ | ----------------------------------------- |
19
+ | unknown hash | 404 | `CHECKOUT__CUSTOMER_NOT_FOUND_BY_HASH` |
20
+ | no hash | 404 | `CHECKOUT__NO_HASH_PROVIDED` |
21
+ | link already used | 404 | `CHECKOUT__CUSTOMER_IS_ALREADY_CONFIRMED` |
22
+ | `em` does not match mail | 400 | validation error |
23
+
24
+ ## Fix
25
+
26
+ - Missing `em`/`hash` query parameters: no API call, error shown.
27
+ - Success: `refreshSessionContext()` + `refreshCart()` (like `useUser().login`),
28
+ merge the wishlist, toast, `/konto`.
29
+ - Already confirmed: info alert with a link to `/anmelden`.
30
+ - Any other failure: error alert with links to `/anmelden` and `/kontakt`.
31
+ Shopware has no Store API route to resend the double opt-in mail, so the page
32
+ cannot offer that.
33
+
34
+ The route stays client-side rendered (`routeRules`), so the confirmation runs
35
+ once in the browser; `useAsyncData` is no longer needed.
@@ -0,0 +1,44 @@
1
+ import { existsSync, readdirSync } from "node:fs";
2
+ import { relative, resolve, sep } from "node:path";
3
+ import type { Nuxt } from "nuxt/schema";
4
+
5
+ // Files in public/ are not fingerprinted, so they get 30 days instead of the
6
+ // year (immutable) of /_nuxt/: a file replaced under the same name reaches
7
+ // returning visitors within 30 days, so replace files under a new name (#273).
8
+ export const PUBLIC_CACHE_CONTROL =
9
+ "public, max-age=2592000, stale-while-revalidate=86400";
10
+
11
+ function listFiles(dir: string): string[] {
12
+ return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
13
+ const path = resolve(dir, entry.name);
14
+ return entry.isDirectory() ? listFiles(path) : [path];
15
+ });
16
+ }
17
+
18
+ /**
19
+ * Cache-Control for the files in public/ of every layer (the shop's and this
20
+ * storefront's): Nitro serves them without it. A route rule per file keeps
21
+ * the header off the HTML pages. Images resized by IPX (`/_ipx`) get the same
22
+ * lifetime through `image.ipx.maxAge` in nuxt.config.ts.
23
+ */
24
+ export default function publicCache(_options: unknown, nuxt: Nuxt) {
25
+ const rules = (nuxt.options.routeRules ??= {});
26
+ const headers = { "cache-control": PUBLIC_CACHE_CONTROL };
27
+
28
+ for (const layer of nuxt.options._layers) {
29
+ const { config } = layer;
30
+ const publicDir = resolve(
31
+ config.srcDir || layer.cwd,
32
+ config.dir?.public || "public",
33
+ );
34
+ if (!existsSync(publicDir)) continue;
35
+
36
+ for (const file of listFiles(publicDir)) {
37
+ const path = "/" + relative(publicDir, file).split(sep).join("/");
38
+ rules[path] = {
39
+ ...rules[path],
40
+ headers: { ...headers, ...rules[path]?.headers },
41
+ };
42
+ }
43
+ }
44
+ }
package/node.dockerfile CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  FROM node:24-alpine AS build
3
3
 
4
- ARG PNPM_VERSION=10.32.1
4
+ ARG PNPM_VERSION=12.5.1
5
5
  ARG NUXT_PUBLIC_SHOPWARE_ENDPOINT='https://my.shop/store-api'
6
6
  ARG NUXT_PUBLIC_SHOPWARE_ACCESS_TOKEN='TOKEN'
7
7
 
@@ -15,9 +15,9 @@ WORKDIR /app
15
15
  RUN corepack enable && corepack prepare pnpm@${PNPM_VERSION} --activate
16
16
 
17
17
  # Copy manifests first so dependency layer is cached independently from source changes.
18
- # pnpm-workspace.yaml (allowBuilds, patchedDependencies) and patches/ are part of the
18
+ # pnpm-workspace.yaml (settings, allowBuilds, patchedDependencies) and patches/ are part of the
19
19
  # lockfile contract; without them `--frozen-lockfile` fails.
20
- COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
20
+ COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
21
21
  COPY patches ./patches
22
22
  RUN pnpm install --frozen-lockfile --prefer-offline
23
23
 
package/nuxt.config.ts CHANGED
@@ -155,6 +155,12 @@ export default defineNuxtConfig({
155
155
  },
156
156
  },
157
157
 
158
+ image: {
159
+ // Logos resized by IPX: 30 days like the files in public/
160
+ // (modules/public-cache.ts, #273) instead of IPX's 60 seconds.
161
+ ipx: { maxAge: 2592000 },
162
+ },
163
+
158
164
  shopware: {
159
165
  endpoint: "",
160
166
  accessToken: "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopbite-de/storefront",
3
- "version": "1.26.0",
3
+ "version": "1.27.0",
4
4
  "main": "nuxt.config.ts",
5
5
  "description": "Shopware storefront for food delivery shops",
6
6
  "keywords": [
@@ -20,24 +20,24 @@
20
20
  "dependencies": {
21
21
  "@headlessui/vue": "^1.7.23",
22
22
  "@heroicons/vue": "^2.2.0",
23
- "@iconify-json/lucide": "^1.2.130",
24
- "@iconify-json/simple-icons": "^1.2.95",
23
+ "@iconify-json/lucide": "^1.2.135",
24
+ "@iconify-json/simple-icons": "^1.2.97",
25
25
  "@nuxt/content": "3.16.0",
26
26
  "@nuxt/image": "^2.1.0",
27
27
  "@nuxt/scripts": "1.3.9",
28
28
  "@nuxt/ui": "^4.11.1",
29
- "@nuxtjs/robots": "^6.2.0",
30
- "@nuxtjs/sitemap": "^8.5.0",
31
- "@sentry/nuxt": "^10.73.0",
32
- "@shopware/api-client": "^1.5.1",
33
- "@shopware/api-gen": "^1.5.1",
34
- "@shopware/composables": "^1.12.1",
35
- "@shopware/helpers": "^1.7.2",
36
- "@shopware/nuxt-module": "^1.5.1",
37
- "@unhead/vue": "^3.4.0",
29
+ "@nuxtjs/robots": "^6.2.3",
30
+ "@nuxtjs/sitemap": "^8.5.1",
31
+ "@sentry/nuxt": "^10.75.0",
32
+ "@shopware/api-client": "^1.6.0",
33
+ "@shopware/api-gen": "^1.5.2",
34
+ "@shopware/composables": "^1.13.0",
35
+ "@shopware/helpers": "^1.8.0",
36
+ "@shopware/nuxt-module": "^1.5.2",
37
+ "@unhead/vue": "^3.4.1",
38
38
  "@vite-pwa/nuxt": "^1.1.1",
39
- "@vueuse/core": "^14.4.0",
40
- "dotenv": "^17.4.2",
39
+ "@vueuse/core": "^15.0.0",
40
+ "dotenv": "^18.0.1",
41
41
  "fflate": "^0.8.3",
42
42
  "nuxt": "^4.5.2",
43
43
  "nuxt-vitalizer": "3.0.0",
@@ -45,31 +45,31 @@
45
45
  },
46
46
  "devDependencies": {
47
47
  "@iconify-json/heroicons": "^1.2.3",
48
- "@iconify-json/hugeicons": "^1.2.34",
49
- "@nuxt/devtools-kit": "^3.2.4",
48
+ "@iconify-json/hugeicons": "^1.2.35",
49
+ "@nuxt/devtools-kit": "^3.4.2",
50
50
  "@nuxt/eslint": "^1.17.0",
51
51
  "@nuxt/hints": "1.1.4",
52
52
  "@nuxt/test-utils": "^4.3.2",
53
53
  "@playwright/test": "^1.63.0",
54
54
  "@types/js-cookie": "^3.0.6",
55
- "@types/node": "^26.5.0",
55
+ "@types/node": "^26.6.2",
56
56
  "@typescript-eslint/eslint-plugin": "^8.70.0",
57
57
  "@typescript-eslint/parser": "^8.70.0",
58
- "@vitejs/plugin-vue": "^6.0.8",
58
+ "@vitejs/plugin-vue": "^6.0.9",
59
59
  "@vitest/ui": "5.0.1",
60
- "@vue/compiler-dom": "^3.5.42",
61
- "@vue/server-renderer": "^3.5.42",
62
- "@vue/test-utils": "^2.5.0",
60
+ "@vue/compiler-dom": "^3.5.43",
61
+ "@vue/server-renderer": "^3.5.43",
62
+ "@vue/test-utils": "^2.5.1",
63
63
  "@vue/typescript-plugin": "^3.3.11",
64
- "eslint": "^10.10.0",
64
+ "eslint": "^10.11.0",
65
65
  "eslint-config-prettier": "^10.1.8",
66
- "happy-dom": "^20.14.0",
67
- "jsdom": "^30.0.1",
66
+ "happy-dom": "^20.14.5",
67
+ "jsdom": "^30.1.0",
68
68
  "playwright-core": "^1.63.0",
69
- "prettier": "^3.9.6",
69
+ "prettier": "^3.9.8",
70
70
  "tailwindcss": "^4.3.3",
71
71
  "typescript": "^6.0.3",
72
- "vitest": "^5.0.0",
72
+ "vitest": "^5.0.1",
73
73
  "vue-tsc": "3.3.11"
74
74
  },
75
75
  "scripts": {
@@ -0,0 +1,13 @@
1
+ diff --git a/plugin.ts b/plugin.ts
2
+ index 2b843eaa6d89f38ef4bd1bce3a0090aa41034572..3a59bd45ac795e80d668fa195f5f311bb92c8a4b 100644
3
+ --- a/plugin.ts
4
+ +++ b/plugin.ts
5
+ @@ -16,7 +16,7 @@ import {
6
+ } from "#imports";
7
+ import type { ApiClient } from "#shopware";
8
+
9
+ -import type { ShopwareNuxtOptions } from "./src";
10
+ +import type { ShopwareNuxtOptions } from "./dist/index";
11
+
12
+ type ShopwarePluginInjections = {
13
+ shopwareApiClient: ApiClient;
@@ -1,3 +1,5 @@
1
+ # Settings live here since pnpm 11; .npmrc is read for auth/registry only.
2
+ shamefullyHoist: true
1
3
  allowBuilds:
2
4
  '@parcel/watcher': true
3
5
  '@sentry/cli': true
@@ -7,4 +9,4 @@ allowBuilds:
7
9
  unrs-resolver: true
8
10
  vue-demi: true
9
11
  patchedDependencies:
10
- '@shopware/nuxt-module@1.5.1': patches/@shopware__nuxt-module@1.5.1.patch
12
+ '@shopware/nuxt-module@1.5.2': patches/@shopware__nuxt-module@1.5.2.patch
package/shopware.d.ts CHANGED
@@ -19,7 +19,7 @@ declare module "#shopware" {
19
19
 
20
20
  // Fallback operations reference the default schemas, but the composables
21
21
  // compare their responses against ours. Re-map the affected responses.
22
- type CreateOrderFromQuote = "createOrderFromQuote post /quote/order/{id}";
22
+ type CreateOrderFromQuote = "createOrderFromQuote post /quote/{id}/order";
23
23
 
24
24
  export type operations = Omit<FallbackOperations, CreateOrderFromQuote> &
25
25
  CustomOperations & {
@@ -1,7 +1,24 @@
1
1
  import { describe, it, expect, vi, afterEach } from "vitest";
2
- import { mountSuspended } from "@nuxt/test-utils/runtime";
3
- import { nextTick } from "vue";
2
+ import { mockNuxtImport, mountSuspended } from "@nuxt/test-utils/runtime";
3
+ import { computed, nextTick, ref } from "vue";
4
4
  import Hero from "~/components/Hero.vue";
5
+ import type { StoreStatus } from "~/composables/useStoreStatus";
6
+
7
+ const { liveState } = vi.hoisted(() => ({
8
+ liveState: {
9
+ status: null as StoreStatus | null,
10
+ isCheckoutEnabled: true,
11
+ },
12
+ }));
13
+
14
+ mockNuxtImport("useStoreStatus", () => () => ({
15
+ status: ref(liveState.status),
16
+ }));
17
+
18
+ mockNuxtImport("useShopBiteConfig", () => () => ({
19
+ deliveryTime: computed(() => 30),
20
+ isCheckoutEnabled: computed(() => liveState.isCheckoutEnabled),
21
+ }));
5
22
 
6
23
  const props = {
7
24
  title: "Pizzeria",
@@ -25,6 +42,47 @@ function stubMatchMedia(matches: boolean) {
25
42
  describe("Hero", () => {
26
43
  afterEach(() => {
27
44
  vi.unstubAllGlobals();
45
+ liveState.status = null;
46
+ liveState.isCheckoutEnabled = true;
47
+ });
48
+
49
+ it("shows the delivery time before the store status is known", async () => {
50
+ stubMatchMedia(false);
51
+
52
+ const wrapper = await mountSuspended(Hero, { props });
53
+
54
+ expect(wrapper.find('[data-testid="hero-status"]').exists()).toBe(false);
55
+ const delivery = wrapper.find('[data-testid="hero-delivery"]');
56
+ expect(delivery.text()).toBe("Lieferung ca. 30 Min");
57
+ // Phones show it in its own row; from sm it waits for the status.
58
+ expect(delivery.classes()).toContain("sm:hidden");
59
+ });
60
+
61
+ it("shows status and delivery time side by side once the status is known", async () => {
62
+ stubMatchMedia(false);
63
+ liveState.status = { open: false, nextOpening: "17:30 Uhr" };
64
+
65
+ const wrapper = await mountSuspended(Hero, { props });
66
+
67
+ expect(wrapper.find('[data-testid="hero-status"]').text()).toBe(
68
+ "Geschlossen · öffnet 17:30 Uhr",
69
+ );
70
+ expect(
71
+ wrapper.find('[data-testid="hero-delivery"]').classes(),
72
+ ).not.toContain("sm:hidden");
73
+ });
74
+
75
+ it("hides the delivery time when the checkout is disabled", async () => {
76
+ stubMatchMedia(false);
77
+ liveState.status = { open: true, closesAt: "23:00" };
78
+ liveState.isCheckoutEnabled = false;
79
+
80
+ const wrapper = await mountSuspended(Hero, { props });
81
+
82
+ expect(wrapper.find('[data-testid="hero-status"]').text()).toBe(
83
+ "Geöffnet bis 23:00",
84
+ );
85
+ expect(wrapper.find('[data-testid="hero-delivery"]').exists()).toBe(false);
28
86
  });
29
87
 
30
88
  it("renders the poster as high-priority image and no video on narrow screens", async () => {
@@ -0,0 +1,99 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
3
+ import ProductCrossSelling from "~/components/Product/CrossSelling.vue";
4
+ import type { AssociationItem } from "~/types/Association";
5
+
6
+ mockNuxtImport("useCommercePrice", () => () => ({
7
+ getFormattedPrice: (price: number) => `${price.toFixed(2)} €`,
8
+ }));
9
+
10
+ const group = (label: string, count: number): AssociationItem => ({
11
+ label,
12
+ products: Array.from({ length: count }, (_, index) => ({
13
+ label: `${label} ${index + 1}`,
14
+ value: `${label}-${index + 1}`,
15
+ price: "1.00 €",
16
+ unitPrice: 1,
17
+ })),
18
+ });
19
+
20
+ const rows = (wrapper: Awaited<ReturnType<typeof mountSuspended>>) =>
21
+ wrapper.findAll('[role="checkbox"]');
22
+
23
+ describe("ProductCrossSelling", () => {
24
+ it("opens only the first group", async () => {
25
+ const wrapper = await mountSuspended(ProductCrossSelling, {
26
+ props: { associations: [group("Extras", 3), group("Saucen", 2)] },
27
+ });
28
+
29
+ const toggles = wrapper.findAll("button[aria-expanded]");
30
+ expect(toggles.map((toggle) => toggle.attributes("aria-expanded"))).toEqual(
31
+ ["true", "false"],
32
+ );
33
+ expect(rows(wrapper)).toHaveLength(3);
34
+
35
+ await toggles[1]!.trigger("click");
36
+ expect(rows(wrapper)).toHaveLength(5);
37
+ });
38
+
39
+ it("shows every entry of a short list", async () => {
40
+ const wrapper = await mountSuspended(ProductCrossSelling, {
41
+ props: { associations: [group("Extras", 8)] },
42
+ });
43
+
44
+ expect(rows(wrapper)).toHaveLength(8);
45
+ expect(wrapper.text()).not.toContain("anzeigen");
46
+ });
47
+
48
+ it("shows the first entries of a long list and the rest on request", async () => {
49
+ const wrapper = await mountSuspended(ProductCrossSelling, {
50
+ props: { associations: [group("Extras", 12)] },
51
+ });
52
+
53
+ expect(rows(wrapper)).toHaveLength(6);
54
+ const showAll = wrapper
55
+ .findAll("button")
56
+ .find((button) => button.text().includes("Alle 12 anzeigen"));
57
+ await showAll!.trigger("click");
58
+ expect(rows(wrapper)).toHaveLength(12);
59
+ });
60
+
61
+ it("offers a search field for very long lists", async () => {
62
+ const wrapper = await mountSuspended(ProductCrossSelling, {
63
+ props: { associations: [group("Extras", 20)] },
64
+ });
65
+
66
+ const search = wrapper.find('input[aria-label="Extras durchsuchen"]');
67
+ await search.setValue("extras 1");
68
+ // "Extras 1" and "Extras 10" … "Extras 19"
69
+ expect(rows(wrapper)).toHaveLength(11);
70
+
71
+ await search.setValue("nichts");
72
+ expect(rows(wrapper)).toHaveLength(0);
73
+ expect(wrapper.text()).toContain("Keine Treffer");
74
+ });
75
+
76
+ it("emits the selection and summarises it in the group header", async () => {
77
+ const wrapper = await mountSuspended(ProductCrossSelling, {
78
+ props: { associations: [group("Extras", 3), group("Saucen", 2)] },
79
+ });
80
+
81
+ expect(wrapper.text()).toContain("optional");
82
+ await rows(wrapper)[0]!.trigger("click");
83
+ await rows(wrapper)[2]!.trigger("click");
84
+
85
+ const emitted = wrapper.emitted("extras-selected")!;
86
+ expect(emitted.at(-1)![0]).toMatchObject([
87
+ { value: "Extras-1" },
88
+ { value: "Extras-3" },
89
+ ]);
90
+ expect(wrapper.find("button[aria-expanded]").text()).toContain(
91
+ "2 gewählt · +2.00 €",
92
+ );
93
+
94
+ await rows(wrapper)[0]!.trigger("click");
95
+ expect(wrapper.emitted("extras-selected")!.at(-1)![0]).toMatchObject([
96
+ { value: "Extras-3" },
97
+ ]);
98
+ });
99
+ });
@@ -0,0 +1,117 @@
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 RegisterConfirmPage from "@/pages/registrierung/bestaetigen.vue";
5
+
6
+ const { ApiClientErrorMock } = vi.hoisted(() => ({
7
+ ApiClientErrorMock: class extends Error {
8
+ details: unknown;
9
+ constructor(details: unknown) {
10
+ super("ApiClientError");
11
+ this.details = details;
12
+ }
13
+ },
14
+ }));
15
+
16
+ vi.mock("@shopware/api-client", () => ({
17
+ ApiClientError: ApiClientErrorMock,
18
+ }));
19
+
20
+ let query: Record<string, string> = {};
21
+ mockNuxtImport("useRoute", () => () => ({ query }));
22
+
23
+ const invokeMock = vi.fn();
24
+ mockNuxtImport("useShopwareContext", () => () => ({
25
+ apiClient: { invoke: invokeMock },
26
+ }));
27
+
28
+ const refreshSessionContextMock = vi.fn();
29
+ mockNuxtImport("useSessionContext", () => () => ({
30
+ refreshSessionContext: refreshSessionContextMock,
31
+ }));
32
+
33
+ const refreshCartMock = vi.fn();
34
+ mockNuxtImport("useCart", () => () => ({ refreshCart: refreshCartMock }));
35
+
36
+ const mergeWishlistProductsMock = vi.fn();
37
+ mockNuxtImport("useWishlist", () => () => ({
38
+ mergeWishlistProducts: mergeWishlistProductsMock,
39
+ }));
40
+
41
+ const toastAddMock = vi.fn();
42
+ mockNuxtImport("useToast", () => () => ({ add: toastAddMock }));
43
+
44
+ const { navigateToMock } = vi.hoisted(() => ({ navigateToMock: vi.fn() }));
45
+ mockNuxtImport("navigateTo", () => navigateToMock);
46
+
47
+ async function mountPage() {
48
+ const wrapper = await mountSuspended(RegisterConfirmPage);
49
+ await flushPromises();
50
+ return wrapper;
51
+ }
52
+
53
+ describe("registrierung/bestaetigen", () => {
54
+ beforeEach(() => {
55
+ vi.clearAllMocks();
56
+ query = { em: "em-hash", hash: "confirm-hash" };
57
+ });
58
+
59
+ it("loads the new session and opens the account on success", async () => {
60
+ invokeMock.mockResolvedValueOnce({ data: {} });
61
+
62
+ await mountPage();
63
+
64
+ expect(invokeMock).toHaveBeenCalledWith(
65
+ "registerConfirm post /account/register-confirm",
66
+ { body: { em: "em-hash", hash: "confirm-hash" } },
67
+ );
68
+ expect(refreshSessionContextMock).toHaveBeenCalled();
69
+ expect(refreshCartMock).toHaveBeenCalled();
70
+ expect(mergeWishlistProductsMock).toHaveBeenCalled();
71
+ expect(toastAddMock).toHaveBeenCalledWith(
72
+ expect.objectContaining({ color: "success" }),
73
+ );
74
+ expect(navigateToMock).toHaveBeenCalledWith({ path: "/konto" });
75
+ });
76
+
77
+ it("shows an error and stays on the page when the link is invalid", async () => {
78
+ invokeMock.mockRejectedValueOnce(
79
+ new ApiClientErrorMock({
80
+ errors: [{ code: "CHECKOUT__CUSTOMER_NOT_FOUND_BY_HASH" }],
81
+ }),
82
+ );
83
+
84
+ const wrapper = await mountPage();
85
+
86
+ expect(wrapper.text()).toContain("Bestätigung fehlgeschlagen");
87
+ expect(wrapper.text()).toContain("Kontakt");
88
+ expect(refreshSessionContextMock).not.toHaveBeenCalled();
89
+ expect(toastAddMock).not.toHaveBeenCalled();
90
+ expect(navigateToMock).not.toHaveBeenCalled();
91
+ });
92
+
93
+ it("tells the visitor to log in when the account is already confirmed", async () => {
94
+ invokeMock.mockRejectedValueOnce(
95
+ new ApiClientErrorMock({
96
+ errors: [{ code: "CHECKOUT__CUSTOMER_IS_ALREADY_CONFIRMED" }],
97
+ }),
98
+ );
99
+
100
+ const wrapper = await mountPage();
101
+
102
+ expect(wrapper.text()).toContain("Konto bereits bestätigt");
103
+ expect(wrapper.text()).toContain("Zur Anmeldung");
104
+ expect(toastAddMock).not.toHaveBeenCalled();
105
+ expect(navigateToMock).not.toHaveBeenCalled();
106
+ });
107
+
108
+ it("does not call the API when the link parameters are missing", async () => {
109
+ query = { em: "em-hash" };
110
+
111
+ const wrapper = await mountPage();
112
+
113
+ expect(invokeMock).not.toHaveBeenCalled();
114
+ expect(wrapper.text()).toContain("Bestätigung fehlgeschlagen");
115
+ expect(navigateToMock).not.toHaveBeenCalled();
116
+ });
117
+ });