@shopbite-de/storefront 1.26.1 → 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.
- package/.github/workflows/build.yaml +1 -1
- package/.github/workflows/ci.yaml +3 -3
- package/.gitignore +40 -0
- package/CLAUDE.md +9 -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/modules/public-cache.ts +44 -0
- package/node.dockerfile +3 -3
- package/nuxt.config.ts +6 -0
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopbite-de/storefront",
|
|
3
|
-
"version": "1.
|
|
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.
|
|
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[]) =>
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
3
|
-
import { ref } from "vue";
|
|
4
|
-
import {
|
|
2
|
+
import { mockNuxtImport, mountSuspended } from "@nuxt/test-utils/runtime";
|
|
3
|
+
import { defineComponent, ref } from "vue";
|
|
4
|
+
import type { Ref } from "vue";
|
|
5
|
+
import {
|
|
6
|
+
useStoreStatus,
|
|
7
|
+
type StoreStatus,
|
|
8
|
+
} from "../../app/composables/useStoreStatus";
|
|
5
9
|
|
|
6
10
|
const { state } = vi.hoisted(() => ({
|
|
7
11
|
state: {
|
|
@@ -31,6 +35,22 @@ const at = (hours: number, minutes = 0) => {
|
|
|
31
35
|
return date;
|
|
32
36
|
};
|
|
33
37
|
|
|
38
|
+
// The status needs a mounted component: the clock starts in onMounted.
|
|
39
|
+
async function mountStatus() {
|
|
40
|
+
let status!: Ref<StoreStatus | null>;
|
|
41
|
+
let statusDuringSetup: StoreStatus | null | undefined;
|
|
42
|
+
await mountSuspended(
|
|
43
|
+
defineComponent({
|
|
44
|
+
setup() {
|
|
45
|
+
status = useStoreStatus().status;
|
|
46
|
+
statusDuringSetup = status.value;
|
|
47
|
+
return () => null;
|
|
48
|
+
},
|
|
49
|
+
}),
|
|
50
|
+
);
|
|
51
|
+
return { status, statusDuringSetup };
|
|
52
|
+
}
|
|
53
|
+
|
|
34
54
|
describe("useStoreStatus", () => {
|
|
35
55
|
beforeEach(() => {
|
|
36
56
|
vi.useFakeTimers();
|
|
@@ -43,33 +63,43 @@ describe("useStoreStatus", () => {
|
|
|
43
63
|
vi.useRealTimers();
|
|
44
64
|
});
|
|
45
65
|
|
|
46
|
-
it("is unknown until business hours and holidays are loaded", () => {
|
|
66
|
+
it("is unknown until business hours and holidays are loaded", async () => {
|
|
47
67
|
state.businessHours = null;
|
|
48
|
-
expect(
|
|
68
|
+
expect((await mountStatus()).status.value).toBeNull();
|
|
49
69
|
|
|
50
70
|
state.businessHours = [{}];
|
|
51
71
|
state.holidays = null;
|
|
52
|
-
expect(
|
|
72
|
+
expect((await mountStatus()).status.value).toBeNull();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("is unknown before the component is mounted, like on the server", async () => {
|
|
76
|
+
state.open = true;
|
|
77
|
+
state.intervals = [{ start: at(11, 30), end: at(14, 30) }];
|
|
78
|
+
|
|
79
|
+
const { status, statusDuringSetup } = await mountStatus();
|
|
80
|
+
|
|
81
|
+
expect(statusDuringSetup).toBeNull();
|
|
82
|
+
expect(status.value).toEqual({ open: true, closesAt: "14:30" });
|
|
53
83
|
});
|
|
54
84
|
|
|
55
|
-
it("reports the closing time of the current interval when open", () => {
|
|
85
|
+
it("reports the closing time of the current interval when open", async () => {
|
|
56
86
|
state.open = true;
|
|
57
87
|
state.intervals = [
|
|
58
88
|
{ start: at(11, 30), end: at(14, 30) },
|
|
59
89
|
{ start: at(17, 30), end: at(23, 0) },
|
|
60
90
|
];
|
|
61
91
|
|
|
62
|
-
expect(
|
|
92
|
+
expect((await mountStatus()).status.value).toEqual({
|
|
63
93
|
open: true,
|
|
64
94
|
closesAt: "14:30",
|
|
65
95
|
});
|
|
66
96
|
});
|
|
67
97
|
|
|
68
|
-
it("reports the next opening when closed", () => {
|
|
98
|
+
it("reports the next opening when closed", async () => {
|
|
69
99
|
state.open = false;
|
|
70
100
|
state.nextOpening = "17:30 Uhr";
|
|
71
101
|
|
|
72
|
-
expect(
|
|
102
|
+
expect((await mountStatus()).status.value).toEqual({
|
|
73
103
|
open: false,
|
|
74
104
|
nextOpening: "17:30 Uhr",
|
|
75
105
|
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import { mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
3
|
+
import { useSyncWishlist } from "../../app/composables/useSyncWishlist";
|
|
4
|
+
|
|
5
|
+
const { ApiClientErrorMock } = vi.hoisted(() => ({
|
|
6
|
+
ApiClientErrorMock: class extends Error {
|
|
7
|
+
details: unknown;
|
|
8
|
+
constructor(details: unknown) {
|
|
9
|
+
super("ApiClientError");
|
|
10
|
+
this.details = details;
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
vi.mock("@shopware/api-client", () => ({
|
|
16
|
+
ApiClientError: ApiClientErrorMock,
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
const invokeMock = vi.fn();
|
|
20
|
+
mockNuxtImport("useShopwareContext", () => () => ({
|
|
21
|
+
apiClient: { invoke: invokeMock },
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
function apiError(code: string) {
|
|
25
|
+
return new ApiClientErrorMock({ errors: [{ code }] });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe("useSyncWishlist", () => {
|
|
29
|
+
let consoleErrorSpy: ReturnType<typeof vi.spyOn>;
|
|
30
|
+
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
vi.clearAllMocks();
|
|
33
|
+
consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
afterEach(() => {
|
|
37
|
+
consoleErrorSpy.mockRestore();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("loads the wishlist products", async () => {
|
|
41
|
+
invokeMock.mockResolvedValueOnce({
|
|
42
|
+
data: {
|
|
43
|
+
products: {
|
|
44
|
+
elements: [{ id: "p1" }, { id: "p2" }],
|
|
45
|
+
total: 2,
|
|
46
|
+
page: 1,
|
|
47
|
+
limit: 15,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const { getWishlistProducts, items, count } = useSyncWishlist();
|
|
53
|
+
await getWishlistProducts();
|
|
54
|
+
|
|
55
|
+
expect(items.value).toEqual(["p1", "p2"]);
|
|
56
|
+
expect(count.value).toBe(2);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it.each([
|
|
60
|
+
"CHECKOUT__WISHLIST_NOT_FOUND",
|
|
61
|
+
"CHECKOUT__WISHLIST_IS_NOT_ACTIVATED",
|
|
62
|
+
])("treats %s as an empty wishlist without logging", async (code) => {
|
|
63
|
+
invokeMock.mockRejectedValueOnce(apiError(code));
|
|
64
|
+
|
|
65
|
+
const { getWishlistProducts, items, count } = useSyncWishlist();
|
|
66
|
+
await getWishlistProducts();
|
|
67
|
+
|
|
68
|
+
expect(items.value).toEqual([]);
|
|
69
|
+
expect(count.value).toBe(0);
|
|
70
|
+
expect(consoleErrorSpy).not.toHaveBeenCalled();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("logs unexpected errors", async () => {
|
|
74
|
+
invokeMock.mockRejectedValueOnce(new Error("Network down"));
|
|
75
|
+
|
|
76
|
+
const { getWishlistProducts, items } = useSyncWishlist();
|
|
77
|
+
await getWishlistProducts();
|
|
78
|
+
|
|
79
|
+
expect(items.value).toEqual([]);
|
|
80
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
|
81
|
+
"[useSyncWishlist][getWishlistProducts][error]:",
|
|
82
|
+
expect.any(Error),
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
});
|