@shopbite-de/storefront 1.25.0 → 1.26.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/CLAUDE.md CHANGED
@@ -126,7 +126,7 @@ The storefront reads plain Shopware entities with fixed names; seed data must ma
126
126
  - `app.vue` sets the title template (`site.titleTemplate`), canonical from the route, `og:url`, fallback `og:image` (`site.ogImage`) and `twitter:card`. Page titles are plain (`"Warenkorb"`), never suffixed with the shop name. Indexable pages use `usePageSeo` (`standalone: true` skips the template, home page); categories use `useCategorySeo`, which overrides the canonical with the SEO URL.
127
127
  - Shopware category SEO URLs end in `/` and 404 without it, but the sitemap module strips trailing slashes from every URL. Sitemap entries that need the slash carry `_trailingSlash: true`; `server/plugins/sitemap-trailing-slash.ts` restores it in the XML. Never normalise trailing slashes of backend SEO URLs.
128
128
  - `@nuxtjs/sitemap` must stay before `@nuxt/content` in `modules`; content collections need the `sitemap` schema field to appear in the sitemap.
129
- - Shop contact data (NAP) lives in `runtimeConfig.public.site` (`address.*`, `telephone`, `googleBusinessProfileUrl`) and is rendered by `components/Footer/Contact.vue`. `useBusinessHours`/`useHolidays` use `immediate: false` (app.vue loads them on mount); a component that needs them in the SSR HTML calls `onServerPrefetch(() => refresh())`.
129
+ - Shop contact data (NAP) lives in `runtimeConfig.public.site` (`address.*`, `telephone`, `googleBusinessProfileUrl`) and is rendered by `components/Footer/Contact.vue`. `useBusinessHours`/`useHolidays` use `immediate: false` (app.vue loads them on mount); a component that needs them in the SSR HTML calls `onServerPrefetch(() => refresh())`. In the browser both requests are retried twice (`withRetries`); `useOpeningHoursData` gives components the combined loading/failed state and `retry()`, and reports a failure only after mounting (a failed server prefetch would otherwise break hydration, #355).
130
130
 
131
131
  ### Testing setup
132
132
 
package/README.md CHANGED
@@ -128,7 +128,6 @@ app/
128
128
  ├── components/ Cart, Checkout, Product, Food, Navigation, Header, …
129
129
  ├── composables/ Business logic — useBusinessHours, useDeliveryTime, useAddToCart, …
130
130
  ├── pages/ German routes: /speisekarte, /warenkorb, /konto, /bestellung
131
- ├── stores/ Pinia (checkout state)
132
131
  ├── validation/ Zod schemas for forms
133
132
  └── assets/css/ Tailwind v4 theme tokens
134
133
  server/api/ Cached Store API proxies + the Geoapify key guard
@@ -45,6 +45,11 @@ const {
45
45
  } = useDeliveryTime(now);
46
46
 
47
47
  const { isClosedHoliday } = useHolidays();
48
+ const {
49
+ isLoaded: isOpeningHoursLoaded,
50
+ hasFailed: hasOpeningHoursFailed,
51
+ retry: retryOpeningHours,
52
+ } = useOpeningHoursData();
48
53
 
49
54
  const validationError = computed<string | null>(() =>
50
55
  selected.value ? validate(selected.value) : null,
@@ -134,7 +139,28 @@ function handleTimeInput(event: Event): void {
134
139
  </script>
135
140
 
136
141
  <template>
137
- <div v-if="isClosedHoliday(now) === false" class="flex flex-col gap-2 mt-4">
142
+ <div v-if="hasOpeningHoursFailed" class="mt-4">
143
+ <UAlert
144
+ color="error"
145
+ variant="subtle"
146
+ icon="i-lucide-circle-alert"
147
+ title="Öffnungszeiten konnten nicht geladen werden"
148
+ description="Ohne Öffnungszeiten können wir keine Lieferzeit anbieten."
149
+ :actions="[
150
+ {
151
+ label: 'Erneut versuchen',
152
+ icon: 'i-lucide-refresh-cw',
153
+ color: 'error',
154
+ variant: 'outline',
155
+ onClick: retryOpeningHours,
156
+ },
157
+ ]"
158
+ />
159
+ </div>
160
+ <div
161
+ v-else-if="isOpeningHoursLoaded && isClosedHoliday(now) === false"
162
+ class="flex flex-col gap-2 mt-4"
163
+ >
138
164
  <div class="flex flex-row items-center justify-between gap-4">
139
165
  <label for="delivery-time" class="flex-1">
140
166
  Wunschlieferung- oder Abholzeit ab:
@@ -171,7 +197,7 @@ function handleTimeInput(event: Event): void {
171
197
  variant="subtle"
172
198
  />
173
199
  </div>
174
- <div v-else-if="isClosedHoliday(now) === true">
200
+ <div v-else-if="isOpeningHoursLoaded && isClosedHoliday(now) === true">
175
201
  <UBadge
176
202
  variant="subtle"
177
203
  class="w-full"
@@ -9,6 +9,8 @@ const { refreshCart } = useCart();
9
9
  const { isLoggedIn, isGuestSession, refreshUser } = useUser();
10
10
  const { isCheckoutEnabled, refresh } = useShopBiteConfig();
11
11
  const { trackOrder } = useTrackEvent();
12
+ const { isLoading: isLoadingOpeningHours, hasFailed: hasOpeningHoursFailed } =
13
+ useOpeningHoursData();
12
14
  const {
13
15
  isShippingMethodBlocked,
14
16
  isPaymentMethodBlocked,
@@ -146,13 +148,27 @@ const blockedMethodIcon = computed(() =>
146
148
 
147
149
  const isPlacingOrder = ref(false);
148
150
  const selectedDeliveryTime = ref("");
149
- const isValidTime = ref(true);
151
+ // DeliveryTimeSelect reports `false` during its setup (no time selected before
152
+ // the business hours load in the browser). Starting with `true` rendered the
153
+ // order button differently on the server and at hydration (#339).
154
+ const isValidTime = ref(false);
150
155
 
151
156
  const checkoutButtonLabel = computed<string>(() => {
152
157
  if (!customerDataAvailable.value) {
153
158
  return "Bitte einloggen oder Kundendaten erfassen";
154
159
  }
155
160
 
161
+ // app.vue loads business hours and holidays after mounting. Until then (or
162
+ // when that fails) an invalid time says nothing about the shop being closed
163
+ // (#349, #355).
164
+ if (isLoadingOpeningHours.value) {
165
+ return "Lade Öffnungszeiten …";
166
+ }
167
+
168
+ if (hasOpeningHoursFailed.value) {
169
+ return "Öffnungszeiten konnten nicht geladen werden";
170
+ }
171
+
156
172
  if (!isValidTime.value) {
157
173
  return "Wir haben aktuell leider geschlossen";
158
174
  }
@@ -202,7 +218,9 @@ const checkoutButtonLabel = computed<string>(() => {
202
218
  <UButton
203
219
  :icon="isValidToProceed ? 'i-lucide-shopping-cart' : 'i-lucide-lock'"
204
220
  :disabled="!isValidToProceed || isPlacingOrder"
205
- :loading="isPlacingOrder"
221
+ :loading="
222
+ isPlacingOrder || (customerDataAvailable && isLoadingOpeningHours)
223
+ "
206
224
  :label="checkoutButtonLabel"
207
225
  size="xl"
208
226
  block
@@ -7,11 +7,17 @@ export type ServiceInterval = { start: Date; end: Date };
7
7
  export function useBusinessHours() {
8
8
  const { apiClient } = useShopwareContext();
9
9
 
10
- const { data, pending, refresh } = useAsyncData(
10
+ const { data, pending, status, refresh } = useAsyncData(
11
11
  "business-hours",
12
12
  async () => {
13
- const response = await apiClient.invoke(
14
- "shopbite.business-hour.get get /shopbite/business-hour",
13
+ // Retried in the browser only: on the server a retry would delay the
14
+ // page, and app.vue loads the data again after mounting (#355).
15
+ const response = await withRetries(
16
+ () =>
17
+ apiClient.invoke(
18
+ "shopbite.business-hour.get get /shopbite/business-hour",
19
+ ),
20
+ import.meta.client ? OPENING_HOURS_RETRY_DELAYS : [],
15
21
  );
16
22
 
17
23
  return response.data.businessHours;
@@ -154,6 +160,7 @@ export function useBusinessHours() {
154
160
  return {
155
161
  businessHours: data,
156
162
  isLoading: pending,
163
+ status,
157
164
  refresh,
158
165
  isStoreOpen,
159
166
  getServiceIntervals,
@@ -3,11 +3,14 @@ import { useShopwareContext } from "#imports";
3
3
  export function useHolidays() {
4
4
  const { apiClient } = useShopwareContext();
5
5
 
6
- const { data, pending, refresh } = useAsyncData(
6
+ const { data, pending, status, refresh } = useAsyncData(
7
7
  "holidays",
8
8
  async () => {
9
- const response = await apiClient.invoke(
10
- "shopbite.holiday.get get /shopbite/holiday",
9
+ // Retried in the browser only: on the server a retry would delay the
10
+ // page, and app.vue loads the data again after mounting (#355).
11
+ const response = await withRetries(
12
+ () => apiClient.invoke("shopbite.holiday.get get /shopbite/holiday"),
13
+ import.meta.client ? OPENING_HOURS_RETRY_DELAYS : [],
11
14
  );
12
15
 
13
16
  return response.data.holidays;
@@ -36,6 +39,7 @@ export function useHolidays() {
36
39
  holidays: data,
37
40
  isClosedHoliday,
38
41
  isLoading: pending,
42
+ status,
39
43
  refresh,
40
44
  };
41
45
  }
@@ -0,0 +1,53 @@
1
+ /** Delays before the browser requests business hours or holidays again. */
2
+ export const OPENING_HOURS_RETRY_DELAYS = [1000, 3000] as const;
3
+
4
+ /**
5
+ * Load state of business hours and holidays, which app.vue fetches after
6
+ * mounting (#349, #355). `hasFailed` once a request failed after its retries
7
+ * and no attempt is running; `retry()` requests the missing data again.
8
+ *
9
+ * `hasFailed` stays `false` until the calling component is mounted: an error
10
+ * from a server prefetch (footer) would otherwise render differently on the
11
+ * server, where the checkout was rendered before it, and at hydration.
12
+ */
13
+ export function useOpeningHoursData() {
14
+ const {
15
+ businessHours,
16
+ status: businessHoursStatus,
17
+ refresh: refreshBusinessHours,
18
+ } = useBusinessHours();
19
+ const {
20
+ holidays,
21
+ status: holidaysStatus,
22
+ refresh: refreshHolidays,
23
+ } = useHolidays();
24
+
25
+ const isMounted = ref(false);
26
+ onMounted(() => {
27
+ isMounted.value = true;
28
+ });
29
+
30
+ const isLoaded = computed(() =>
31
+ Boolean(businessHours.value && holidays.value),
32
+ );
33
+
34
+ const hasFailed = computed(() => {
35
+ if (!isMounted.value || isLoaded.value) return false;
36
+ const missing = [
37
+ businessHours.value ? null : businessHoursStatus.value,
38
+ holidays.value ? null : holidaysStatus.value,
39
+ ].filter((status) => status !== null);
40
+ return missing.includes("error") && !missing.includes("pending");
41
+ });
42
+
43
+ const isLoading = computed(() => !isLoaded.value && !hasFailed.value);
44
+
45
+ async function retry(): Promise<void> {
46
+ await Promise.all([
47
+ businessHours.value ? undefined : refreshBusinessHours(),
48
+ holidays.value ? undefined : refreshHolidays(),
49
+ ]);
50
+ }
51
+
52
+ return { isLoaded, isLoading, hasFailed, retry };
53
+ }
@@ -5,13 +5,10 @@ useSeoMeta({
5
5
  });
6
6
 
7
7
  const { isLoggedIn, isGuestSession } = useUser();
8
- const { setStep } = useCheckoutStore();
9
8
 
10
9
  if (!isLoggedIn.value && !isGuestSession.value) {
11
10
  await navigateTo("/bestellung/warenkorb");
12
11
  }
13
-
14
- setStep(2);
15
12
  </script>
16
13
 
17
14
  <template>
@@ -6,9 +6,6 @@ useSeoMeta({
6
6
 
7
7
  const { isLoggedIn, isGuestSession } = useUser();
8
8
  const { isEmpty } = useCart();
9
- const { setStep } = useCheckoutStore();
10
-
11
- setStep(0);
12
9
 
13
10
  const isCustomerAvailable = computed<boolean>(() => {
14
11
  return isLoggedIn.value || isGuestSession.value;
@@ -5,13 +5,10 @@ useSeoMeta({
5
5
  });
6
6
 
7
7
  const { isLoggedIn, isGuestSession } = useUser();
8
- const { setStep } = useCheckoutStore();
9
8
 
10
9
  if (!isLoggedIn.value && !isGuestSession.value) {
11
10
  await navigateTo("/bestellung/warenkorb");
12
11
  }
13
-
14
- setStep(1);
15
12
  </script>
16
13
 
17
14
  <template>
@@ -1,15 +1,34 @@
1
1
  <script setup lang="ts">
2
2
  import type { StepperItem } from "@nuxt/ui";
3
3
 
4
- const checkoutStore = useCheckoutStore();
5
- const { step } = storeToRefs(checkoutStore);
6
-
7
4
  const stepRoutes = [
8
5
  "/bestellung/warenkorb",
9
6
  "/bestellung/zahlung-versand",
10
7
  "/bestellung/bestaetigen",
11
8
  ] as const;
12
9
 
10
+ const route = useRoute();
11
+ const isPaymentReturnRoute = computed(() =>
12
+ /^\/bestellung\/[0-9a-f]{32}(\/erfolg|\/fehler)?$/.test(route.path),
13
+ );
14
+
15
+ // The active step follows the route, so the server renders the same step the
16
+ // browser hydrates. Setting it from the child pages ran after the stepper had
17
+ // been rendered on the server (#339).
18
+ const step = computed<number>({
19
+ get: () =>
20
+ Math.max(
21
+ 0,
22
+ stepRoutes.findIndex((path) => path === route.path),
23
+ ),
24
+ set: (index) => {
25
+ const path = stepRoutes[index];
26
+ if (path && path !== route.path) {
27
+ navigateTo(path);
28
+ }
29
+ },
30
+ });
31
+
13
32
  const items = computed(
14
33
  () =>
15
34
  [
@@ -30,17 +49,6 @@ const items = computed(
30
49
  },
31
50
  ] satisfies StepperItem[],
32
51
  );
33
-
34
- const route = useRoute();
35
- const isPaymentReturnRoute = computed(() =>
36
- /^\/bestellung\/[0-9a-f]{32}(\/erfolg|\/fehler)?$/.test(route.path),
37
- );
38
- watch(step, (newStep) => {
39
- if (isPaymentReturnRoute.value) {
40
- return;
41
- }
42
- navigateTo(stepRoutes[newStep]);
43
- });
44
52
  </script>
45
53
 
46
54
  <template>
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Runs `request` and, when it throws, runs it again after each of `delays`
3
+ * (milliseconds). The error of the last attempt is thrown.
4
+ */
5
+ export async function withRetries<T>(
6
+ request: () => Promise<T>,
7
+ delays: readonly number[],
8
+ ): Promise<T> {
9
+ for (const delay of delays) {
10
+ try {
11
+ return await request();
12
+ } catch {
13
+ await new Promise((resolve) => setTimeout(resolve, delay));
14
+ }
15
+ }
16
+ return request();
17
+ }
@@ -0,0 +1,49 @@
1
+ # Checkout steps: hydration mismatches on direct load
2
+
3
+ Date: 2026-09-16. Branch `fix/339-checkout-stepper-step`, issue #339.
4
+
5
+ ## Reproduced
6
+
7
+ Production build against the demo backend, guest session with one cart item
8
+ created through the Store API, `sw-context-token` cookie set in Playwright,
9
+ each step loaded directly:
10
+
11
+ | Step | Before | After |
12
+ | ----------------------------- | -------------------------------- | ---------------------- |
13
+ | `/bestellung/warenkorb` | no warning, "Warenkorb" active | unchanged |
14
+ | `/bestellung/zahlung-versand` | mismatch, "Warenkorb" active | no warning, step 2 |
15
+ | `/bestellung/bestaetigen` | mismatch, "Warenkorb" active | no warning, step 3 |
16
+
17
+ ## Two causes, one pattern
18
+
19
+ Both mismatches came from a child component changing state of its parent
20
+ during its setup. With SSR the parent's markup rendered before that change
21
+ reached it (or, in the second case, after it), while the browser hydrated with
22
+ the other value. Vue does not patch attributes and classes in production.
23
+
24
+ 1. **Stepper** (the cause suspected in the issue): the step pages called
25
+ `setStep(n)` of the Pinia checkout store in their setup, after
26
+ `bestellung.vue` had rendered `<UStepper>` with step 0. The serialized store
27
+ state carried the new step, so the browser hydrated with step n.
28
+ Fix: `bestellung.vue` derives the step from `route.path` (index in
29
+ `stepRoutes`); its setter navigates. The store and `useCheckoutStore` had no
30
+ other users (also none in `demos/` and `masala-mio/`) and are removed.
31
+ Pinia is still registered as a module but has no store now.
32
+ 2. **Order button on `/bestellung/bestaetigen`**, found only after fixing the
33
+ stepper (the dev server prints the mismatching node):
34
+ `Checkout/DeliveryTimeSelect.vue` emits `update:valid` from an immediate
35
+ watch. No time is selected before the business hours load in the browser
36
+ (`app.vue` on mount), so it always emits `false` first. On the server the
37
+ button renders after that emit ("Wir haben aktuell leider geschlossen",
38
+ lock icon, disabled); `Summary.vue` started with `isValidTime = ref(true)`,
39
+ so the browser hydrated "Jetzt bestellen!". Fix: start with `false`.
40
+
41
+ ## Verified
42
+
43
+ - Production build: no hydration warning on any step, correct active step.
44
+ - Client-side navigation: stepper click back to "Zahlung & Versand" and
45
+ "Warenkorb", "Weiter zu Prüfen & Bestellen" button forward.
46
+ - After the business hours load the order button reads "Jetzt bestellen!" and
47
+ is enabled (demo shop open).
48
+ - `pnpm typecheck` (0 errors), `pnpm prettier`, `pnpm eslint`,
49
+ `pnpm test:unit` without the Matomo variables (264 tests).
@@ -0,0 +1,39 @@
1
+ # Order button: loading state for the opening hours
2
+
3
+ Date: 2026-09-16. Branch `fix/349-order-button-loading`, issue #349.
4
+
5
+ ## Problem
6
+
7
+ `app.vue` loads business hours and holidays after mounting. Until then
8
+ `Checkout/DeliveryTimeSelect.vue` has no time to select and reports
9
+ `valid = false`, and `Checkout/Summary.vue` labelled the order button
10
+ "Wir haben aktuell leider geschlossen". The server HTML carried that label as
11
+ well, so the confirmation step always said "closed" first.
12
+
13
+ ## Change
14
+
15
+ `Summary.vue` reads `businessHours` and `holidays` from `useBusinessHours` and
16
+ `useHolidays` (the same "loaded" check as `useStoreStatus`). While either is
17
+ missing and customer data is available, the button is disabled, shows the
18
+ spinner and the label "Lade Öffnungszeiten …". "Einloggen oder Kundendaten
19
+ erfassen" keeps priority, it does not depend on the hours.
20
+
21
+ `DeliveryTimeSelect` was left unchanged: emitting a second state from it would
22
+ repeat the pattern of #339 (a child changing parent state during setup).
23
+ Reading the shared `useAsyncData` state directly renders the same on the
24
+ server and at hydration (both without data).
25
+
26
+ A failed request leaves the data empty, so the button keeps the loading state,
27
+ as the "Lade Öffnungszeiten..." badge of `DeliveryTimeSelect` already does.
28
+ Neither retries the request.
29
+
30
+ ## Verified
31
+
32
+ - `test/nuxt/CheckoutSummary.test.ts`: loading, closed after loading, order
33
+ possible with a valid time. The loading test fails without the change.
34
+ - Production build against the demo backend with a guest session: the server
35
+ HTML has the loading label, the button then goes from
36
+ "Lade Öffnungszeiten …" (disabled, spinner) straight to "Jetzt bestellen!"; no "closed" in
37
+ between, no hydration warning.
38
+ - `pnpm typecheck` (0 errors), `pnpm prettier`, `pnpm eslint`,
39
+ `pnpm test:unit` without the Matomo variables (267 tests).
@@ -0,0 +1,41 @@
1
+ # Remove Pinia
2
+
3
+ Date: 2026-09-16. Branch `feature/350-remove-pinia`, issue #350.
4
+
5
+ ## Why
6
+
7
+ #348 (#339) removed the only store, `useCheckoutStore`: the checkout stepper
8
+ derives its step from the route. Shared state is `useState`/`useAsyncData` in
9
+ composables everywhere else. `@shopware/composables`, `@shopware/nuxt-module`
10
+ and the demo shops (`demos/`, `masala-mio/`) do not use Pinia.
11
+
12
+ ## Changes
13
+
14
+ - `@pinia/nuxt` removed from `package.json` and `modules`, `pinia` removed from
15
+ the `framework` code splitting group in `nuxt.config.ts`.
16
+ - `README.md` project structure: no `stores/` directory.
17
+ - Monorepo `CLAUDE.md` (not versioned): "Pinia for state" replaced.
18
+
19
+ `pinia` stays in `pnpm-lock.yaml` as an optional peer dependency of
20
+ `vue-router` and `@sentry/vue`; neither installs nor bundles it for us.
21
+
22
+ Shops extending the layer no longer get Pinia through it. A shop with its own
23
+ stores adds `@pinia/nuxt` to its own dependencies and `modules`.
24
+
25
+ ## Measured
26
+
27
+ Production build, JS files the home page references (37 files):
28
+
29
+ | | Before | After |
30
+ | -------- | ---------- | ---------- |
31
+ | raw | 1,175.1 KB | 1,171.5 KB |
32
+ | gzip | 341.3 KB | 339.7 KB |
33
+ | `pinia` | 1 chunk | 0 chunks |
34
+
35
+ ## Verified
36
+
37
+ - `pnpm build`, home page, category page and `/bestellung/warenkorb` in the
38
+ browser without console errors (apart from the demo data icon
39
+ `lucide:french-fries`, unrelated).
40
+ - `pnpm typecheck` (0 errors), `pnpm prettier`, `pnpm eslint`,
41
+ `pnpm test:unit` without the Matomo variables (264 tests).
@@ -0,0 +1,57 @@
1
+ # Opening hours: error state and retry in the checkout
2
+
3
+ Date: 2026-09-16. Branch `fix/355-opening-hours-error`, issue #355.
4
+
5
+ ## Problem
6
+
7
+ When the business hours or holidays request failed in the browser, the
8
+ confirmation step kept its loading state (#349): order button disabled with
9
+ spinner, delivery time section "Lade Öffnungszeiten...". Nothing retried.
10
+
11
+ ## Decision (Lirim)
12
+
13
+ Retry automatically first, then show an error with a button: two more attempts
14
+ after 1 s and 3 s; if they fail too, the delivery time section shows an alert
15
+ "Öffnungszeiten konnten nicht geladen werden" with "Erneut versuchen", and the
16
+ order button carries the same text (disabled, no spinner).
17
+
18
+ ## Implementation
19
+
20
+ - `utils/retry.ts`: `withRetries(request, delays)`.
21
+ - `useBusinessHours`/`useHolidays`: the request is wrapped in `withRetries` with
22
+ `OPENING_HOURS_RETRY_DELAYS` in the browser only; on the server a retry would
23
+ delay every page (the footer prefetches the hours). Both now return `status`.
24
+ - `useOpeningHoursData`: `isLoaded` (both there), `hasFailed` (a missing one has
25
+ status `error` and no missing one is `pending`), `isLoading`, `retry()`
26
+ (refreshes only what is missing).
27
+ - `Checkout/Summary.vue` and `Checkout/DeliveryTimeSelect.vue` use it. The time
28
+ input and the holiday badge now need both data sets; before, the input showed
29
+ without bounds when only the holidays were loaded.
30
+
31
+ ## Findings
32
+
33
+ - Nuxt's `useAsyncData` keeps `error` set while a refresh runs and resets `data`
34
+ to the default on failure; `status` is the reliable signal (`pending` during
35
+ a retry).
36
+ - On checkout pages the business hours are in the SSR payload
37
+ (`Footer/Contact.vue` prefetches them), and `app.vue`'s refresh on mount is
38
+ served from that payload while hydrating. The browser then requests only the
39
+ holidays, so a browser-side failure of the business hours request does not
40
+ happen on a first load.
41
+ - The footer renders after the checkout on the server. If its prefetch fails,
42
+ the payload carries the error and the browser would hydrate `status: error`
43
+ while the server rendered the checkout without it. `hasFailed` is therefore
44
+ `false` until the component is mounted.
45
+
46
+ ## Verified
47
+
48
+ - Tests: `test/unit/retry.spec.ts`, `test/nuxt/useOpeningHoursData.test.ts`
49
+ (including "no failure before mounting"), `test/nuxt/CheckoutSummary.test.ts`
50
+ (error label).
51
+ - Production build against the demo backend, guest session, holidays request
52
+ answered with 500 in Playwright: three attempts, 4–6 s after loading the alert and
53
+ the button text, no hydration warning; "Erneut versuchen" with the request
54
+ unblocked loads the holidays and the button reads "Jetzt bestellen!". Without
55
+ blocking: unchanged flow, time input present.
56
+ - `pnpm typecheck` (0 errors), `pnpm prettier`, `pnpm eslint`,
57
+ `pnpm test:unit` without the Matomo variables (276 tests).
package/nuxt.config.ts CHANGED
@@ -175,7 +175,6 @@ export default defineNuxtConfig({
175
175
  "@nuxt/scripts",
176
176
  "nuxt-vitalizer",
177
177
  "@nuxt/eslint",
178
- "@pinia/nuxt",
179
178
  ],
180
179
 
181
180
  content: {
@@ -275,7 +274,7 @@ export default defineNuxtConfig({
275
274
  groups: [
276
275
  {
277
276
  name: "framework",
278
- test: /node_modules\/(\.pnpm\/)?(vue|@vue\+|@vue\/|vue-router|unhead|@unhead|nuxt@|hookable|ofetch|ufo|defu|h3|devalue|klona|destr|cookie-es|radix3|rou3|unctx|pinia)[@/]/,
277
+ test: /node_modules\/(\.pnpm\/)?(vue|@vue\+|@vue\/|vue-router|unhead|@unhead|nuxt@|hookable|ofetch|ufo|defu|h3|devalue|klona|destr|cookie-es|radix3|rou3|unctx)[@/]/,
279
278
  minShareCount: 2,
280
279
  priority: 20,
281
280
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopbite-de/storefront",
3
- "version": "1.25.0",
3
+ "version": "1.26.0",
4
4
  "main": "nuxt.config.ts",
5
5
  "description": "Shopware storefront for food delivery shops",
6
6
  "keywords": [
@@ -28,7 +28,6 @@
28
28
  "@nuxt/ui": "^4.11.1",
29
29
  "@nuxtjs/robots": "^6.2.0",
30
30
  "@nuxtjs/sitemap": "^8.5.0",
31
- "@pinia/nuxt": "1.0.2",
32
31
  "@sentry/nuxt": "^10.73.0",
33
32
  "@shopware/api-client": "^1.5.1",
34
33
  "@shopware/api-gen": "^1.5.1",
@@ -57,7 +56,7 @@
57
56
  "@typescript-eslint/eslint-plugin": "^8.70.0",
58
57
  "@typescript-eslint/parser": "^8.70.0",
59
58
  "@vitejs/plugin-vue": "^6.0.8",
60
- "@vitest/ui": "5.0.0",
59
+ "@vitest/ui": "5.0.1",
61
60
  "@vue/compiler-dom": "^3.5.42",
62
61
  "@vue/server-renderer": "^3.5.42",
63
62
  "@vue/test-utils": "^2.5.0",
@@ -0,0 +1,127 @@
1
+ import { describe, it, expect, vi, beforeEach } from "vitest";
2
+ import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
3
+ import { defineComponent, h, onMounted, ref } from "vue";
4
+ import Summary from "~/components/Checkout/Summary.vue";
5
+
6
+ const { state } = vi.hoisted(() => ({
7
+ state: {
8
+ isLoading: true,
9
+ hasFailed: false,
10
+ validTime: false,
11
+ },
12
+ }));
13
+
14
+ mockNuxtImport("useOpeningHoursData", () => () => ({
15
+ isLoading: ref(state.isLoading),
16
+ hasFailed: ref(state.hasFailed),
17
+ }));
18
+
19
+ mockNuxtImport("useCheckout", () => () => ({
20
+ createOrder: vi.fn(),
21
+ selectedPaymentMethod: ref({ id: "pm1" }),
22
+ selectedShippingMethod: ref({ id: "sm1" }),
23
+ }));
24
+
25
+ mockNuxtImport("useCart", () => () => ({
26
+ refreshCart: vi.fn(),
27
+ }));
28
+
29
+ mockNuxtImport("useUser", () => () => ({
30
+ isLoggedIn: ref(false),
31
+ isGuestSession: ref(true),
32
+ refreshUser: vi.fn(),
33
+ }));
34
+
35
+ mockNuxtImport("useShopBiteConfig", () => () => ({
36
+ isCheckoutEnabled: ref(true),
37
+ refresh: vi.fn(),
38
+ }));
39
+
40
+ mockNuxtImport("useTrackEvent", () => () => ({
41
+ trackOrder: vi.fn(),
42
+ }));
43
+
44
+ mockNuxtImport("useCheckoutMethodGuard", () => () => ({
45
+ isShippingMethodBlocked: ref(false),
46
+ isPaymentMethodBlocked: ref(false),
47
+ ensureAvailableCheckoutMethods: vi.fn().mockResolvedValue(true),
48
+ }));
49
+
50
+ vi.mock("@shopware/composables", async (importOriginal) => ({
51
+ ...(await importOriginal<typeof import("@shopware/composables")>()),
52
+ useOrderPayment: () => ({ handlePayment: vi.fn(), paymentUrl: ref(null) }),
53
+ }));
54
+
55
+ // Reports the time as DeliveryTimeSelect does once a time is selected.
56
+ const DeliveryTimeSelectStub = defineComponent({
57
+ emits: ["update:valid"],
58
+ setup(_, { emit }) {
59
+ onMounted(() => emit("update:valid", state.validTime));
60
+ return () => h("div");
61
+ },
62
+ });
63
+
64
+ async function mountSummary() {
65
+ const wrapper = await mountSuspended(Summary, {
66
+ global: {
67
+ stubs: {
68
+ UserDetail: true,
69
+ CheckoutPaymentMethod: true,
70
+ CheckoutShippingMethod: true,
71
+ CheckoutDeliveryTimeSelect: DeliveryTimeSelectStub,
72
+ CheckoutVoucherInput: true,
73
+ QuickView: true,
74
+ },
75
+ },
76
+ });
77
+ await new Promise((resolve) => setTimeout(resolve, 0));
78
+ // The order button is the only button besides the stubbed children.
79
+ return wrapper.get("button");
80
+ }
81
+
82
+ describe("Checkout Summary order button", () => {
83
+ beforeEach(() => {
84
+ state.isLoading = true;
85
+ state.hasFailed = false;
86
+ state.validTime = false;
87
+ });
88
+
89
+ it("shows a loading state while the opening hours are not loaded", async () => {
90
+ const button = await mountSummary();
91
+
92
+ expect(button.text()).toBe("Lade Öffnungszeiten …");
93
+ expect(button.attributes("disabled")).toBeDefined();
94
+ expect(button.find(".animate-spin").exists()).toBe(true);
95
+ });
96
+
97
+ it("says the opening hours could not be loaded when loading failed", async () => {
98
+ state.isLoading = false;
99
+ state.hasFailed = true;
100
+
101
+ const button = await mountSummary();
102
+
103
+ expect(button.text()).toBe("Öffnungszeiten konnten nicht geladen werden");
104
+ expect(button.attributes("disabled")).toBeDefined();
105
+ expect(button.find(".animate-spin").exists()).toBe(false);
106
+ });
107
+
108
+ it("says the shop is closed once loaded without a valid time", async () => {
109
+ state.isLoading = false;
110
+
111
+ const button = await mountSummary();
112
+
113
+ expect(button.text()).toBe("Wir haben aktuell leider geschlossen");
114
+ expect(button.attributes("disabled")).toBeDefined();
115
+ expect(button.find(".animate-spin").exists()).toBe(false);
116
+ });
117
+
118
+ it("allows ordering once loaded with a valid time", async () => {
119
+ state.isLoading = false;
120
+ state.validTime = true;
121
+
122
+ const button = await mountSummary();
123
+
124
+ expect(button.text()).toBe("Jetzt bestellen!");
125
+ expect(button.attributes("disabled")).toBeUndefined();
126
+ });
127
+ });
@@ -0,0 +1,120 @@
1
+ import { describe, it, expect, vi, beforeEach } from "vitest";
2
+ import { mountSuspended, mockNuxtImport } from "@nuxt/test-utils/runtime";
3
+ import { defineComponent, h, nextTick, ref, type Ref } from "vue";
4
+
5
+ // Refs are created per test in beforeEach; the mocks read them lazily.
6
+ const { state } = vi.hoisted(() => ({
7
+ state: {
8
+ refreshBusinessHours: vi.fn(),
9
+ refreshHolidays: vi.fn(),
10
+ } as {
11
+ businessHours: Ref<unknown>;
12
+ businessHoursStatus: Ref<string>;
13
+ holidays: Ref<unknown>;
14
+ holidaysStatus: Ref<string>;
15
+ refreshBusinessHours: ReturnType<typeof vi.fn>;
16
+ refreshHolidays: ReturnType<typeof vi.fn>;
17
+ },
18
+ }));
19
+
20
+ mockNuxtImport("useBusinessHours", () => () => ({
21
+ businessHours: state.businessHours,
22
+ status: state.businessHoursStatus,
23
+ refresh: state.refreshBusinessHours,
24
+ }));
25
+
26
+ mockNuxtImport("useHolidays", () => () => ({
27
+ holidays: state.holidays,
28
+ status: state.holidaysStatus,
29
+ refresh: state.refreshHolidays,
30
+ }));
31
+
32
+ /** Also returns `hasFailed` as the first render (server, hydration) saw it. */
33
+ async function mountComposable() {
34
+ let result!: ReturnType<typeof useOpeningHoursData>;
35
+ let hasFailedOnRender!: boolean;
36
+ await mountSuspended(
37
+ defineComponent({
38
+ setup() {
39
+ result = useOpeningHoursData();
40
+ hasFailedOnRender = result.hasFailed.value;
41
+ return () => h("div");
42
+ },
43
+ }),
44
+ );
45
+ return { ...result, hasFailedOnRender };
46
+ }
47
+
48
+ describe("useOpeningHoursData", () => {
49
+ beforeEach(() => {
50
+ vi.clearAllMocks();
51
+ state.businessHours = ref(null);
52
+ state.businessHoursStatus = ref("idle");
53
+ state.holidays = ref(null);
54
+ state.holidaysStatus = ref("idle");
55
+ });
56
+
57
+ it("is loading until business hours and holidays are there", async () => {
58
+ state.businessHours.value = [];
59
+ state.businessHoursStatus.value = "success";
60
+ state.holidaysStatus.value = "pending";
61
+
62
+ const { isLoaded, isLoading, hasFailed } = await mountComposable();
63
+
64
+ expect(isLoaded.value).toBe(false);
65
+ expect(isLoading.value).toBe(true);
66
+ expect(hasFailed.value).toBe(false);
67
+
68
+ state.holidays.value = [];
69
+ state.holidaysStatus.value = "success";
70
+ await nextTick();
71
+
72
+ expect(isLoaded.value).toBe(true);
73
+ expect(isLoading.value).toBe(false);
74
+ });
75
+
76
+ it("has failed when a request failed and none is running", async () => {
77
+ state.businessHoursStatus.value = "error";
78
+ state.holidaysStatus.value = "pending";
79
+
80
+ const { isLoading, hasFailed } = await mountComposable();
81
+
82
+ expect(hasFailed.value).toBe(false);
83
+
84
+ state.holidays.value = [];
85
+ state.holidaysStatus.value = "success";
86
+ await nextTick();
87
+
88
+ expect(hasFailed.value).toBe(true);
89
+ expect(isLoading.value).toBe(false);
90
+ });
91
+
92
+ it("does not report a failure before mounting (hydration)", async () => {
93
+ state.businessHoursStatus.value = "error";
94
+ state.holidaysStatus.value = "error";
95
+
96
+ const { hasFailed, hasFailedOnRender } = await mountComposable();
97
+
98
+ expect(hasFailedOnRender).toBe(false);
99
+ expect(hasFailed.value).toBe(true);
100
+ });
101
+
102
+ it("loads again when retrying", async () => {
103
+ state.businessHours.value = [];
104
+ state.businessHoursStatus.value = "success";
105
+ state.holidaysStatus.value = "error";
106
+
107
+ const { hasFailed, isLoading, retry } = await mountComposable();
108
+ expect(hasFailed.value).toBe(true);
109
+
110
+ state.refreshHolidays.mockImplementation(async () => {
111
+ state.holidaysStatus.value = "pending";
112
+ });
113
+ await retry();
114
+
115
+ expect(state.refreshHolidays).toHaveBeenCalledTimes(1);
116
+ expect(state.refreshBusinessHours).not.toHaveBeenCalled();
117
+ expect(hasFailed.value).toBe(false);
118
+ expect(isLoading.value).toBe(true);
119
+ });
120
+ });
@@ -0,0 +1,58 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
+ import { withRetries } from "../../app/utils/retry";
3
+
4
+ describe("withRetries", () => {
5
+ beforeEach(() => {
6
+ vi.useFakeTimers();
7
+ });
8
+
9
+ afterEach(() => {
10
+ vi.useRealTimers();
11
+ });
12
+
13
+ it("returns the first successful result without waiting", async () => {
14
+ const request = vi.fn().mockResolvedValue("ok");
15
+
16
+ await expect(withRetries(request, [1000, 3000])).resolves.toBe("ok");
17
+ expect(request).toHaveBeenCalledTimes(1);
18
+ });
19
+
20
+ it("tries again after each delay until a request succeeds", async () => {
21
+ const request = vi
22
+ .fn()
23
+ .mockRejectedValueOnce(new Error("first"))
24
+ .mockRejectedValueOnce(new Error("second"))
25
+ .mockResolvedValue("ok");
26
+
27
+ const result = withRetries(request, [1000, 3000]);
28
+
29
+ await vi.advanceTimersByTimeAsync(999);
30
+ expect(request).toHaveBeenCalledTimes(1);
31
+ await vi.advanceTimersByTimeAsync(1);
32
+ expect(request).toHaveBeenCalledTimes(2);
33
+ await vi.advanceTimersByTimeAsync(3000);
34
+ await expect(result).resolves.toBe("ok");
35
+ expect(request).toHaveBeenCalledTimes(3);
36
+ });
37
+
38
+ it("throws the error of the last attempt", async () => {
39
+ const request = vi
40
+ .fn()
41
+ .mockRejectedValueOnce(new Error("first"))
42
+ .mockRejectedValueOnce(new Error("last"));
43
+
44
+ const result = withRetries(request, [1000]);
45
+ const assertion = expect(result).rejects.toThrow("last");
46
+
47
+ await vi.advanceTimersByTimeAsync(1000);
48
+ await assertion;
49
+ expect(request).toHaveBeenCalledTimes(2);
50
+ });
51
+
52
+ it("does not retry without delays", async () => {
53
+ const request = vi.fn().mockRejectedValue(new Error("down"));
54
+
55
+ await expect(withRetries(request, [])).rejects.toThrow("down");
56
+ expect(request).toHaveBeenCalledTimes(1);
57
+ });
58
+ });
@@ -1 +0,0 @@
1
- export { useCheckoutStore } from "../stores/checkout";
@@ -1,22 +0,0 @@
1
- const stepRoutes = [
2
- "/bestellung/warenkorb",
3
- "/bestellung/zahlung-versand",
4
- "/bestellung/bestaetigen",
5
- ] as const;
6
-
7
- export const useCheckoutStore = defineStore("checkout", () => {
8
- const step = ref(0);
9
-
10
- function setStep(index: number) {
11
- step.value = index;
12
- }
13
-
14
- async function navigateToStep(index: number) {
15
- if (index < 0 || index >= stepRoutes.length) return;
16
- if (index <= step.value) {
17
- await navigateTo(stepRoutes[index]);
18
- }
19
- }
20
-
21
- return { step, setStep, navigateToStep };
22
- });