minutework 0.1.27 → 0.1.29
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/assets/templates/next-tenant-app/README.md +1 -1
- package/assets/templates/next-tenant-app/src/app/page.test.ts +32 -2
- package/assets/templates/next-tenant-app/src/app/page.tsx +2 -2
- package/assets/templates/next-tenant-app/src/lib/platform/env.server.test.ts +8 -2
- package/assets/templates/next-tenant-app/src/lib/platform/env.server.ts +1 -1
- package/package.json +1 -1
|
@@ -95,7 +95,7 @@ can boot without MinuteWork CMS credentials; set `MW_PUBLIC_CONTENT_SOURCE` to
|
|
|
95
95
|
`minutework_cms` and fill the CMS values below when enabling the public site.
|
|
96
96
|
|
|
97
97
|
- `MW_PLATFORM_BASE_URL` is required
|
|
98
|
-
- `MW_PUBLIC_CONTENT_SOURCE` defaults to `
|
|
98
|
+
- `MW_PUBLIC_CONTENT_SOURCE` defaults to `none` when omitted; supported values are `minutework_cms`, `custom`, `static_json`, and `none`
|
|
99
99
|
- `MW_CONTENT_API_TOKEN` is required only for `minutework_cms` and must stay server-only
|
|
100
100
|
- `MW_TEMPLATE_APP_NAME` defaults to `MinuteWork Combined Starter`
|
|
101
101
|
- `MW_PUBLIC_BASE_URL` is required for public content sources and should match the deployed public origin; it may be omitted when `MW_PUBLIC_CONTENT_SOURCE=none`
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
2
|
|
|
3
3
|
const getMarketingPage = vi.fn();
|
|
4
4
|
const getSiteConfig = vi.fn();
|
|
5
|
+
const redirect = vi.fn();
|
|
6
|
+
const originalPublicContentSource = process.env.MW_PUBLIC_CONTENT_SOURCE;
|
|
5
7
|
|
|
6
8
|
vi.mock("@/features/public-shell/components/marketing-page-canvas", () => ({
|
|
7
9
|
MarketingPageCanvas: () => null,
|
|
@@ -17,15 +19,28 @@ vi.mock("@/lib/content/adapter.server", () => ({
|
|
|
17
19
|
}));
|
|
18
20
|
|
|
19
21
|
vi.mock("next/navigation", () => ({
|
|
20
|
-
|
|
22
|
+
redirect,
|
|
21
23
|
}));
|
|
22
24
|
|
|
23
25
|
describe("home page", () => {
|
|
24
26
|
beforeEach(() => {
|
|
27
|
+
if (originalPublicContentSource === undefined) {
|
|
28
|
+
delete process.env.MW_PUBLIC_CONTENT_SOURCE;
|
|
29
|
+
} else {
|
|
30
|
+
process.env.MW_PUBLIC_CONTENT_SOURCE = originalPublicContentSource;
|
|
31
|
+
}
|
|
25
32
|
vi.clearAllMocks();
|
|
26
33
|
vi.resetModules();
|
|
27
34
|
});
|
|
28
35
|
|
|
36
|
+
afterEach(() => {
|
|
37
|
+
if (originalPublicContentSource === undefined) {
|
|
38
|
+
delete process.env.MW_PUBLIC_CONTENT_SOURCE;
|
|
39
|
+
} else {
|
|
40
|
+
process.env.MW_PUBLIC_CONTENT_SOURCE = originalPublicContentSource;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
29
44
|
it("renders public home content without auth redirects", async () => {
|
|
30
45
|
getSiteConfig.mockResolvedValue({
|
|
31
46
|
siteName: "MinuteWork Combined Starter",
|
|
@@ -57,4 +72,19 @@ describe("home page", () => {
|
|
|
57
72
|
|
|
58
73
|
await expect(page.default()).resolves.toBeDefined();
|
|
59
74
|
});
|
|
75
|
+
|
|
76
|
+
it("redirects the private-only root route to /app", async () => {
|
|
77
|
+
vi.resetModules();
|
|
78
|
+
process.env.MW_PUBLIC_CONTENT_SOURCE = "none";
|
|
79
|
+
redirect.mockImplementation(() => {
|
|
80
|
+
throw new Error("NEXT_REDIRECT");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const page = await import("./page");
|
|
84
|
+
|
|
85
|
+
await expect(page.default()).rejects.toThrow("NEXT_REDIRECT");
|
|
86
|
+
expect(redirect).toHaveBeenCalledWith("/app");
|
|
87
|
+
expect(getSiteConfig).not.toHaveBeenCalled();
|
|
88
|
+
expect(getMarketingPage).not.toHaveBeenCalled();
|
|
89
|
+
});
|
|
60
90
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { redirect } from "next/navigation";
|
|
2
2
|
|
|
3
3
|
import { MarketingPageCanvas } from "@/features/public-shell/components/marketing-page-canvas";
|
|
4
4
|
import { PublicSiteShell } from "@/features/public-shell/components/public-site-shell";
|
|
@@ -32,7 +32,7 @@ export async function generateMetadata() {
|
|
|
32
32
|
|
|
33
33
|
export default async function HomePage() {
|
|
34
34
|
if (isPublicContentDisabled()) {
|
|
35
|
-
|
|
35
|
+
redirect(appRoutes.appHome);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
const [siteConfig, page] = await Promise.all([
|
|
@@ -65,14 +65,20 @@ describe("server env", () => {
|
|
|
65
65
|
expect(env.MW_PUBLIC_SITE_ENV).toBe("preview");
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
it("defaults MW_PUBLIC_CONTENT_SOURCE to
|
|
68
|
+
it("defaults MW_PUBLIC_CONTENT_SOURCE to private-only mode", async () => {
|
|
69
69
|
applyServerEnv({
|
|
70
70
|
MW_PUBLIC_CONTENT_SOURCE: undefined,
|
|
71
|
+
MW_CONTENT_API_TOKEN: undefined,
|
|
72
|
+
MW_PUBLIC_BASE_URL: undefined,
|
|
73
|
+
MW_PUBLIC_SITE_PROPERTY_KEY: undefined,
|
|
71
74
|
});
|
|
72
75
|
|
|
73
76
|
const { env } = await import("./env.server");
|
|
74
77
|
|
|
75
|
-
expect(env.MW_PUBLIC_CONTENT_SOURCE).toBe("
|
|
78
|
+
expect(env.MW_PUBLIC_CONTENT_SOURCE).toBe("none");
|
|
79
|
+
expect(env.MW_CONTENT_API_TOKEN).toBeUndefined();
|
|
80
|
+
expect(env.MW_PUBLIC_BASE_URL).toBeUndefined();
|
|
81
|
+
expect(env.MW_PUBLIC_SITE_PROPERTY_KEY).toBeUndefined();
|
|
76
82
|
});
|
|
77
83
|
|
|
78
84
|
it("defaults MW_STATIC_PUBLIC_CONTENT_PATH to content/public-site.json", async () => {
|
|
@@ -49,7 +49,7 @@ const envSchema = z
|
|
|
49
49
|
.object({
|
|
50
50
|
MW_PLATFORM_BASE_URL: z.string().url(),
|
|
51
51
|
MW_PUBLIC_CONTENT_SOURCE: z.preprocess(
|
|
52
|
-
(value) => value ?? "
|
|
52
|
+
(value) => value ?? "none",
|
|
53
53
|
publicContentSourceSchema,
|
|
54
54
|
),
|
|
55
55
|
MW_CONTENT_API_TOKEN: optionalStringEnvSchema,
|