@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
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { describe, it, expect } from "vitest";
|
|
5
|
+
import type { Nuxt } from "nuxt/schema";
|
|
6
|
+
import publicCache, { PUBLIC_CACHE_CONTROL } from "../../modules/public-cache";
|
|
7
|
+
|
|
8
|
+
function layer(files: string[]) {
|
|
9
|
+
const root = mkdtempSync(join(tmpdir(), "public-cache-"));
|
|
10
|
+
for (const file of files) {
|
|
11
|
+
const path = join(root, "public", file);
|
|
12
|
+
mkdirSync(join(path, ".."), { recursive: true });
|
|
13
|
+
writeFileSync(path, "x");
|
|
14
|
+
}
|
|
15
|
+
return { cwd: root, config: { srcDir: root, rootDir: root } };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function run(layers: ReturnType<typeof layer>[], routeRules = {}) {
|
|
19
|
+
const nuxt = { options: { _layers: layers, routeRules } } as unknown as Nuxt;
|
|
20
|
+
publicCache(undefined, nuxt);
|
|
21
|
+
return nuxt.options.routeRules as Record<
|
|
22
|
+
string,
|
|
23
|
+
{ headers?: Record<string, string> }
|
|
24
|
+
>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe("public-cache module", () => {
|
|
28
|
+
it("adds Cache-Control for the public files of every layer", () => {
|
|
29
|
+
const rules = run([
|
|
30
|
+
layer(["brand/logo.png"]),
|
|
31
|
+
layer(["hero-poster.webp", "light/Logo.png"]),
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
for (const path of [
|
|
35
|
+
"/brand/logo.png",
|
|
36
|
+
"/hero-poster.webp",
|
|
37
|
+
"/light/Logo.png",
|
|
38
|
+
]) {
|
|
39
|
+
expect(rules[path]?.headers?.["cache-control"]).toBe(
|
|
40
|
+
PUBLIC_CACHE_CONTROL,
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
expect(rules["/"]).toBeUndefined();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("keeps headers a shop configured itself", () => {
|
|
47
|
+
const rules = run([layer(["favicon.ico"])], {
|
|
48
|
+
"/favicon.ico": { headers: { "cache-control": "no-cache", "x-a": "1" } },
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
expect(rules["/favicon.ico"]?.headers).toEqual({
|
|
52
|
+
"cache-control": "no-cache",
|
|
53
|
+
"x-a": "1",
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("skips layers without a public directory", () => {
|
|
58
|
+
const root = mkdtempSync(join(tmpdir(), "public-cache-"));
|
|
59
|
+
|
|
60
|
+
expect(
|
|
61
|
+
run([{ cwd: root, config: { srcDir: root, rootDir: root } }]),
|
|
62
|
+
).toEqual({});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
diff --git a/plugin.ts b/plugin.ts
|
|
2
|
-
index 5b9cdef440df1eb477ffea4d66180bc65b33835a..c23d08a8af61875b55e192d108d009bc5ddd7b07 100644
|
|
3
|
-
--- a/plugin.ts
|
|
4
|
-
+++ b/plugin.ts
|
|
5
|
-
@@ -14,7 +14,8 @@ 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
|
-
+import type { Plugin } from "#app";
|
|
12
|
-
|
|
13
|
-
declare module "#app" {
|
|
14
|
-
interface NuxtApp {
|
|
15
|
-
@@ -28,7 +29,10 @@ declare module "vue" {
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
-export default defineNuxtPlugin((NuxtApp) => {
|
|
20
|
-
+// Explicit type keeps Nuxt's generated NuxtApp augmentation from
|
|
21
|
-
+// recursively depending on this plugin's inferred return type.
|
|
22
|
-
+const shopwarePlugin: Plugin<{ shopwareApiClient: ApiClient }> =
|
|
23
|
-
+ defineNuxtPlugin((NuxtApp) => {
|
|
24
|
-
const runtimeConfig = useRuntimeConfig();
|
|
25
|
-
|
|
26
|
-
const shopwareRuntimeConfigPublic = runtimeConfig.public
|
|
27
|
-
@@ -143,3 +147,5 @@ export default defineNuxtPlugin((NuxtApp) => {
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
+
|
|
32
|
-
+export default shopwarePlugin;
|