@shopbite-de/storefront 1.26.1 → 1.28.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/.github/workflows/build.yaml +1 -1
- package/.github/workflows/ci.yaml +3 -3
- package/.gitignore +40 -0
- package/CLAUDE.md +10 -2
- package/app/app.vue +4 -1
- package/app/components/Hero.vue +17 -7
- package/app/components/User/RegistrationForm.vue +73 -29
- package/app/composables/useStoreStatus.ts +12 -7
- package/app/composables/useSyncWishlist.ts +119 -0
- package/app/pages/[...all].vue +9 -3
- package/app/pages/index.vue +1 -5
- package/app/pages/kontakt.vue +1 -5
- package/app/pages/registrierung/bestaetigen.vue +100 -27
- package/app/pages/registrierung/index.vue +20 -1
- package/app/utils/notFound.ts +14 -0
- package/content/index.yml +9 -9
- package/docs/notes/2026-09-21-dependency-update.md +89 -0
- package/docs/notes/2026-09-21-issue-273-cache-and-demo-video.md +49 -0
- package/docs/notes/2026-09-21-issue-363-non-fatal-404.md +43 -0
- package/docs/notes/2026-09-21-issue-365-home-hydration-mismatch.md +47 -0
- package/docs/notes/2026-09-21-issue-366-wishlist-404.md +41 -0
- package/docs/notes/2026-09-21-issue-369-register-confirm.md +35 -0
- package/docs/notes/2026-09-21-issue-378-dev-modules.md +35 -0
- package/modules/dev-tooling.ts +34 -0
- package/modules/public-cache.ts +44 -0
- package/node.dockerfile +3 -3
- package/nuxt.config.ts +7 -15
- package/package.json +26 -26
- package/patches/@shopware__nuxt-module@1.5.2.patch +13 -0
- package/pnpm-workspace.yaml +3 -1
- package/shopware.d.ts +1 -1
- package/test/nuxt/Hero.test.ts +60 -2
- package/test/nuxt/RegisterConfirmPage.test.ts +117 -0
- package/test/nuxt/RegistrationForm.test.ts +132 -2
- package/test/nuxt/notFound.test.ts +13 -0
- package/test/nuxt/useSearchTracking.test.ts +3 -0
- package/test/nuxt/useStoreStatus.test.ts +40 -10
- package/test/nuxt/useSyncWishlist.test.ts +85 -0
- package/test/unit/publicCache.spec.ts +64 -0
- package/patches/@shopware__nuxt-module@1.5.1.patch +0 -32
|
@@ -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=
|
|
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
|
|
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: "",
|
|
@@ -174,7 +180,7 @@ export default defineNuxtConfig({
|
|
|
174
180
|
"@nuxt/ui",
|
|
175
181
|
"@nuxt/scripts",
|
|
176
182
|
"nuxt-vitalizer",
|
|
177
|
-
|
|
183
|
+
// @nuxt/eslint, @nuxt/hints and @nuxt/test-utils: modules/dev-tooling.ts
|
|
178
184
|
],
|
|
179
185
|
|
|
180
186
|
content: {
|
|
@@ -316,18 +322,4 @@ export default defineNuxtConfig({
|
|
|
316
322
|
},
|
|
317
323
|
},
|
|
318
324
|
},
|
|
319
|
-
$development: {
|
|
320
|
-
modules: [
|
|
321
|
-
"@shopware/nuxt-module",
|
|
322
|
-
"@nuxt/image",
|
|
323
|
-
"@nuxtjs/sitemap",
|
|
324
|
-
"@nuxt/content",
|
|
325
|
-
"@nuxtjs/robots",
|
|
326
|
-
"@nuxt/ui",
|
|
327
|
-
"@nuxt/scripts",
|
|
328
|
-
"@nuxt/test-utils/module",
|
|
329
|
-
"@nuxt/eslint",
|
|
330
|
-
"@nuxt/hints",
|
|
331
|
-
],
|
|
332
|
-
},
|
|
333
325
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopbite-de/storefront",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.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.
|
|
24
|
-
"@iconify-json/simple-icons": "^1.2.
|
|
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.
|
|
30
|
-
"@nuxtjs/sitemap": "^8.5.
|
|
31
|
-
"@sentry/nuxt": "^10.
|
|
32
|
-
"@shopware/api-client": "^1.
|
|
33
|
-
"@shopware/api-gen": "^1.5.
|
|
34
|
-
"@shopware/composables": "^1.
|
|
35
|
-
"@shopware/helpers": "^1.
|
|
36
|
-
"@shopware/nuxt-module": "^1.5.
|
|
37
|
-
"@unhead/vue": "^3.4.
|
|
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": "^
|
|
40
|
-
"dotenv": "^
|
|
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.
|
|
49
|
-
"@nuxt/devtools-kit": "^3.2
|
|
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.
|
|
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.
|
|
58
|
+
"@vitejs/plugin-vue": "^6.0.9",
|
|
59
59
|
"@vitest/ui": "5.0.1",
|
|
60
|
-
"@vue/compiler-dom": "^3.5.
|
|
61
|
-
"@vue/server-renderer": "^3.5.
|
|
62
|
-
"@vue/test-utils": "^2.5.
|
|
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.
|
|
64
|
+
"eslint": "^10.11.0",
|
|
65
65
|
"eslint-config-prettier": "^10.1.8",
|
|
66
|
-
"happy-dom": "^20.14.
|
|
67
|
-
"jsdom": "^30.0
|
|
66
|
+
"happy-dom": "^20.14.5",
|
|
67
|
+
"jsdom": "^30.1.0",
|
|
68
68
|
"playwright-core": "^1.63.0",
|
|
69
|
-
"prettier": "^3.9.
|
|
69
|
+
"prettier": "^3.9.8",
|
|
70
70
|
"tailwindcss": "^4.3.3",
|
|
71
71
|
"typescript": "^6.0.3",
|
|
72
|
-
"vitest": "^5.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;
|
package/pnpm-workspace.yaml
CHANGED
|
@@ -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.
|
|
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/
|
|
22
|
+
type CreateOrderFromQuote = "createOrderFromQuote post /quote/{id}/order";
|
|
23
23
|
|
|
24
24
|
export type operations = Omit<FallbackOperations, CreateOrderFromQuote> &
|
|
25
25
|
CustomOperations & {
|
package/test/nuxt/Hero.test.ts
CHANGED
|
@@ -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,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
|
+
});
|
|
@@ -56,8 +56,8 @@ mockNuxtImport("useRuntimeConfig", () => () => ({
|
|
|
56
56
|
// UCheckbox renders the clickable control as `button[role="checkbox"]` next to
|
|
57
57
|
// an aria-hidden native input that only mirrors the state, so the button is
|
|
58
58
|
// what has to be clicked to toggle the v-model.
|
|
59
|
-
async function
|
|
60
|
-
const hiddenInput = wrapper.find(
|
|
59
|
+
async function toggleCheckbox(wrapper: VueWrapper, name: string) {
|
|
60
|
+
const hiddenInput = wrapper.find(`input[name="${name}"]`);
|
|
61
61
|
const button = hiddenInput.element.parentElement!.querySelector(
|
|
62
62
|
'button[role="checkbox"]',
|
|
63
63
|
)!;
|
|
@@ -65,6 +65,31 @@ async function acceptDataProtection(wrapper: VueWrapper) {
|
|
|
65
65
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
async function acceptDataProtection(wrapper: VueWrapper) {
|
|
69
|
+
await toggleCheckbox(wrapper, "acceptedDataProtection");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Fills everything the schema requires except the password fields.
|
|
73
|
+
async function fillRequiredFields(wrapper: VueWrapper) {
|
|
74
|
+
await wrapper.find('input[name="firstName"]').setValue("John");
|
|
75
|
+
await wrapper.find('input[name="lastName"]').setValue("Doe");
|
|
76
|
+
await wrapper.find('input[name="email"]').setValue("john@example.com");
|
|
77
|
+
const state = (
|
|
78
|
+
wrapper.vm as unknown as {
|
|
79
|
+
state: {
|
|
80
|
+
billingAddress: { street: string; zipcode: string; city: string };
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
).state;
|
|
84
|
+
state.billingAddress.street = "Musterstr 1";
|
|
85
|
+
state.billingAddress.zipcode = "12345";
|
|
86
|
+
state.billingAddress.city = "Musterstadt";
|
|
87
|
+
await wrapper
|
|
88
|
+
.find('input[name="billingAddress.phoneNumber"]')
|
|
89
|
+
.setValue("12345678");
|
|
90
|
+
await acceptDataProtection(wrapper);
|
|
91
|
+
}
|
|
92
|
+
|
|
68
93
|
describe("RegistrationForm", () => {
|
|
69
94
|
beforeEach(() => {
|
|
70
95
|
vi.clearAllMocks();
|
|
@@ -321,4 +346,109 @@ describe("RegistrationForm", () => {
|
|
|
321
346
|
"Meinten Sie: Corrected Street 123, 54321 Corrected City?",
|
|
322
347
|
);
|
|
323
348
|
});
|
|
349
|
+
|
|
350
|
+
it("orders as a guest by default and reveals the password fields on opt-in", async () => {
|
|
351
|
+
const wrapper = await mountSuspended(RegistrationForm);
|
|
352
|
+
|
|
353
|
+
expect(wrapper.text()).toContain("Kundenkonto anlegen");
|
|
354
|
+
expect(
|
|
355
|
+
(wrapper.vm as unknown as { state: { guest: boolean } }).state.guest,
|
|
356
|
+
).toBe(true);
|
|
357
|
+
expect(wrapper.find('input[name="password"]').exists()).toBe(false);
|
|
358
|
+
|
|
359
|
+
await toggleCheckbox(wrapper, "guest");
|
|
360
|
+
await nextTick();
|
|
361
|
+
|
|
362
|
+
expect(
|
|
363
|
+
(wrapper.vm as unknown as { state: { guest: boolean } }).state.guest,
|
|
364
|
+
).toBe(false);
|
|
365
|
+
expect(wrapper.find('input[name="password"]').exists()).toBe(true);
|
|
366
|
+
expect(wrapper.find('input[name="passwordConfirm"]').exists()).toBe(true);
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it("never offers a guest account when allowGuest is false", async () => {
|
|
370
|
+
const wrapper = await mountSuspended(RegistrationForm, {
|
|
371
|
+
props: { allowGuest: false },
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
expect(wrapper.text()).not.toContain("Kundenkonto anlegen");
|
|
375
|
+
expect(
|
|
376
|
+
(wrapper.vm as unknown as { state: { guest: boolean } }).state.guest,
|
|
377
|
+
).toBe(false);
|
|
378
|
+
expect(wrapper.find('input[name="password"]').exists()).toBe(true);
|
|
379
|
+
expect(wrapper.find('input[name="passwordConfirm"]').exists()).toBe(true);
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it("does not register without a password when allowGuest is false", async () => {
|
|
383
|
+
const wrapper = await mountSuspended(RegistrationForm, {
|
|
384
|
+
props: { allowGuest: false },
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
await fillRequiredFields(wrapper);
|
|
388
|
+
await wrapper.find("form").trigger("submit");
|
|
389
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
390
|
+
|
|
391
|
+
expect(mockRegister).not.toHaveBeenCalled();
|
|
392
|
+
expect(wrapper.text()).toContain(
|
|
393
|
+
"Das Passwort muss mindestens 8 Zeichen lang sein.",
|
|
394
|
+
);
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
it("registers a real customer account when allowGuest is false", async () => {
|
|
398
|
+
mockRegister.mockResolvedValueOnce({
|
|
399
|
+
id: "customer-id",
|
|
400
|
+
active: true,
|
|
401
|
+
doubleOptInRegistration: false,
|
|
402
|
+
});
|
|
403
|
+
const wrapper = await mountSuspended(RegistrationForm, {
|
|
404
|
+
props: { allowGuest: false },
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
await fillRequiredFields(wrapper);
|
|
408
|
+
await wrapper.find('input[name="password"]').setValue("supersecret");
|
|
409
|
+
await wrapper.find('input[name="passwordConfirm"]').setValue("supersecret");
|
|
410
|
+
|
|
411
|
+
await wrapper.find("form").trigger("submit");
|
|
412
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
413
|
+
|
|
414
|
+
expect(mockRegister).toHaveBeenCalled();
|
|
415
|
+
const calledData = mockRegister.mock.calls[0]![0];
|
|
416
|
+
expect(calledData.guest).toBe(false);
|
|
417
|
+
expect(calledData.password).toBe("supersecret");
|
|
418
|
+
expect(mockToastAdd).toHaveBeenCalledWith(
|
|
419
|
+
expect.objectContaining({
|
|
420
|
+
title: "Konto erfolgreich erstellt",
|
|
421
|
+
color: "success",
|
|
422
|
+
}),
|
|
423
|
+
);
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
it("asks for the e-mail confirmation on double opt-in registrations", async () => {
|
|
427
|
+
const customer = {
|
|
428
|
+
id: "customer-id",
|
|
429
|
+
active: false,
|
|
430
|
+
doubleOptInRegistration: true,
|
|
431
|
+
};
|
|
432
|
+
mockRegister.mockResolvedValueOnce(customer);
|
|
433
|
+
const wrapper = await mountSuspended(RegistrationForm, {
|
|
434
|
+
props: { allowGuest: false },
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
await fillRequiredFields(wrapper);
|
|
438
|
+
await wrapper.find('input[name="password"]').setValue("supersecret");
|
|
439
|
+
await wrapper.find('input[name="passwordConfirm"]').setValue("supersecret");
|
|
440
|
+
|
|
441
|
+
await wrapper.find("form").trigger("submit");
|
|
442
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
443
|
+
|
|
444
|
+
expect(mockToastAdd).toHaveBeenCalledWith(
|
|
445
|
+
expect.objectContaining({
|
|
446
|
+
title: "Fast geschafft!",
|
|
447
|
+
color: "info",
|
|
448
|
+
}),
|
|
449
|
+
);
|
|
450
|
+
const emitted = wrapper.emitted("registration-success");
|
|
451
|
+
expect(emitted).toBeTruthy();
|
|
452
|
+
expect(emitted![0]![1]).toEqual(customer);
|
|
453
|
+
});
|
|
324
454
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { createNotFoundError } from "../../app/utils/notFound";
|
|
3
|
+
|
|
4
|
+
describe("createNotFoundError", () => {
|
|
5
|
+
it("is a 404 that stays fatal in the browser, so navigation shows the error page", () => {
|
|
6
|
+
const error = createNotFoundError("Page /x not found!");
|
|
7
|
+
|
|
8
|
+
expect(error.statusCode).toBe(404);
|
|
9
|
+
expect(error.statusMessage).toBe("Page /x not found!");
|
|
10
|
+
// The test environment runs as client; on the server `fatal` is false.
|
|
11
|
+
expect(error.fatal).toBe(import.meta.client);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -6,8 +6,11 @@ import { useSearchTracking } from "../../app/composables/useSearchTracking";
|
|
|
6
6
|
|
|
7
7
|
const { mockTrackSearch } = vi.hoisted(() => ({ mockTrackSearch: vi.fn() }));
|
|
8
8
|
|
|
9
|
+
// plugins/matomo.ts calls trackPageView when Matomo is configured in the
|
|
10
|
+
// test environment; without it the plugin rejects outside the test (#323).
|
|
9
11
|
mockNuxtImport("useTrackEvent", () => () => ({
|
|
10
12
|
trackSearch: mockTrackSearch,
|
|
13
|
+
trackPageView: vi.fn(),
|
|
11
14
|
}));
|
|
12
15
|
|
|
13
16
|
const products = (...numbers: string[]) =>
|