create-freeholder 0.2.0-beta.5 → 0.2.0-beta.6
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/dist/template/.changeset/blog-playground-content.md +4 -0
- package/dist/template/.changeset/blog-wordpress-structure.md +6 -0
- package/dist/template/.changeset/managed-preview-assistant.md +4 -0
- package/dist/template/.changeset/public-beta-6.md +4 -0
- package/dist/template/.github/ISSUE_TEMPLATE/bug_report.yml +1 -1
- package/dist/template/MASTER.md +81 -8
- package/dist/template/README.md +1 -1
- package/dist/template/app/(admin)/admin/assistant/page.tsx +9 -1
- package/dist/template/app/(admin)/admin/blog/PostSettings.tsx +26 -0
- package/dist/template/app/(admin)/admin/blog/[kind]/page.tsx +53 -0
- package/dist/template/app/(admin)/admin/blog/actions.ts +186 -6
- package/dist/template/app/(admin)/admin/blog/comments/page.tsx +25 -0
- package/dist/template/app/(admin)/admin/blog/page.tsx +21 -5
- package/dist/template/app/(admin)/admin/imports/[id]/page.tsx +2 -0
- package/dist/template/app/(admin)/admin/pages/[id]/page.tsx +3 -0
- package/dist/template/app/(admin)/assistant-actions.ts +13 -6
- package/dist/template/app/(public)/[[...slug]]/ReaderComments.tsx +25 -0
- package/dist/template/app/(public)/[[...slug]]/blog-parts.tsx +153 -0
- package/dist/template/app/(public)/[[...slug]]/comment-actions.ts +16 -0
- package/dist/template/app/(public)/[[...slug]]/page.tsx +182 -18
- package/dist/template/app/api/chat/assistant/call/route.ts +35 -0
- package/dist/template/db/migrations/0061_blog_structure.sql +89 -0
- package/dist/template/db/migrations/0062_blog_reader_comments.sql +24 -0
- package/dist/template/db/migrations/meta/_journal.json +14 -0
- package/dist/template/deploy/blog-wordpress-2026-11-07.md +146 -0
- package/dist/template/deploy/docker-selfhost/.env.example +1 -1
- package/dist/template/deploy/docker-selfhost/README.md +3 -2
- package/dist/template/deploy/docker-selfhost/infra/compose.https.yml +1 -1
- package/dist/template/deploy/docker-selfhost/infra/compose.yml +1 -1
- package/dist/template/deploy/f-criteria-matrix.md +74 -0
- package/dist/template/deploy/linux/README.md +1 -1
- package/dist/template/deploy/linux/install.sh +1 -1
- package/dist/template/deploy/managed-preview-assistant.md +99 -0
- package/dist/template/eslint.config.mjs +3 -1
- package/dist/template/locales/ar.json +85 -6
- package/dist/template/locales/en.json +83 -4
- package/dist/template/locales/es.json +83 -4
- package/dist/template/locales/fr.json +85 -6
- package/dist/template/next.config.ts +2 -0
- package/dist/template/package.json +1 -1
- package/dist/template/packages/cli/package.json +1 -1
- package/dist/template/packages/create-freeholder/package.json +1 -1
- package/dist/template/packages/freeholder-app/package.json +1 -1
- package/dist/template/packages/mobile-app/package.json +1 -1
- package/dist/template/packages/plugin-kit/package.json +1 -1
- package/dist/template/packages/sdk/package.json +1 -1
- package/dist/template/packages/sdk/src/generated.ts +177 -9
- package/dist/template/packages/sdk/src/version.ts +1 -1
- package/dist/template/packages/templates/package.json +1 -1
- package/dist/template/proxy.ts +18 -1
- package/dist/template/public/managed-assistant/0.1.10/duplex-codec/NOTICE.txt +117 -0
- package/dist/template/public/managed-assistant/0.1.10/duplex-codec/audio-output-processor.js +267 -0
- package/dist/template/public/managed-assistant/0.1.10/duplex-codec/decoderWorker.min.js +847 -0
- package/dist/template/public/managed-assistant/0.1.10/duplex-codec/decoderWorker.min.wasm +0 -0
- package/dist/template/public/managed-assistant/0.1.10/duplex-codec/encoderWorker.min.js +1 -0
- package/dist/template/public/managed-assistant/0.1.10/manifest.json +12 -0
- package/dist/template/public/managed-assistant/0.1.10/pm-ai-duplex-client.js +1376 -0
- package/dist/template/scripts/license-headers.mjs +3 -0
- package/dist/template/scripts/verify-wordpress-migration.d.mts +8 -0
- package/dist/template/scripts/verify-wordpress-migration.mjs +105 -0
- package/dist/template/security/adversarial-audit-2026-10-08.md +1 -1
- package/dist/template/src/adapters/ai/types.ts +5 -0
- package/dist/template/src/adapters/paradise/assistant.ts +37 -0
- package/dist/template/src/adapters/paradise/http.ts +4 -3
- package/dist/template/src/core/contract/json-schema.ts +8 -0
- package/dist/template/src/core/demo/playground-inserts.ts +29 -0
- package/dist/template/src/core/demo/playground-policy.ts +9 -0
- package/dist/template/src/core/env.ts +2 -0
- package/dist/template/src/core/http/csp.ts +10 -2
- package/dist/template/src/core/http/csrf-client.ts +10 -0
- package/dist/template/src/core/import/service.ts +217 -12
- package/dist/template/src/core/import/wordpress.ts +80 -15
- package/dist/template/src/core/notifications/service.ts +1 -0
- package/dist/template/src/core/retention/registry.ts +2 -0
- package/dist/template/src/core/search/registry.ts +2 -0
- package/dist/template/src/core/seo/feeds.ts +2 -0
- package/dist/template/src/core/seo/jsonld.ts +46 -2
- package/dist/template/src/core/seo/legacy-proxy.ts +53 -0
- package/dist/template/src/core/seo/meta.ts +10 -7
- package/dist/template/src/core/seo/service.ts +14 -1
- package/dist/template/src/core/update/release-declaration.json +1 -1
- package/dist/template/src/modules/assistant/contract.ts +1 -1
- package/dist/template/src/modules/assistant/limits.ts +3 -0
- package/dist/template/src/modules/assistant/preview.ts +124 -0
- package/dist/template/src/modules/assistant/provider.ts +7 -0
- package/dist/template/src/modules/assistant/service.ts +21 -5
- package/dist/template/src/modules/cms/blocks/PreviewAssistantCall.tsx +176 -0
- package/dist/template/src/modules/cms/blocks/SiteChatClient.tsx +10 -4
- package/dist/template/src/modules/cms/blocks/surfaces.tsx +10 -0
- package/dist/template/src/modules/cms/blog-comments-schema.ts +27 -0
- package/dist/template/src/modules/cms/blog-comments.ts +111 -0
- package/dist/template/src/modules/cms/blog-schema.ts +146 -0
- package/dist/template/src/modules/cms/blog-service.ts +999 -0
- package/dist/template/src/modules/cms/blog.tsx +245 -25
- package/dist/template/src/modules/cms/manifest.ts +7 -1
- package/dist/template/src/modules/cms/read.ts +18 -0
- package/dist/template/src/modules/cms/service.ts +22 -4
- package/dist/template/src/modules/cms/tables.ts +2 -0
- package/dist/template/src/modules/seed/launch.ts +31 -3
- package/dist/template/tests/browser/blog-structure.spec.ts +69 -0
- package/dist/template/tests/core/analytics-consent.test.ts +1 -1
- package/dist/template/tests/core/blog-playground.test.ts +106 -0
- package/dist/template/tests/core/blog-structure-comments.test.ts +166 -0
- package/dist/template/tests/core/csp.test.ts +1 -1
- package/dist/template/tests/core/internal-services.test.ts +4 -0
- package/dist/template/tests/core/legacy-redirect-proxy.test.ts +59 -0
- package/dist/template/tests/core/locale-routing.test.ts +1 -1
- package/dist/template/tests/core/playground-cache.test.ts +1 -1
- package/dist/template/tests/core/playground.test.ts +3 -3
- package/dist/template/tests/core/preview-assistant-call.test.ts +88 -0
- package/dist/template/tests/core/private-preview-webhooks.test.ts +1 -1
- package/dist/template/tests/core/private-preview.test.ts +1 -1
- package/dist/template/tests/core/proxy-locale.test.ts +1 -1
- package/dist/template/tests/core/sdk-schema.test.ts +20 -0
- package/dist/template/tests/core/seo.test.ts +1 -1
- package/dist/template/tests/core/site-chat-client.test.ts +50 -0
- package/dist/template/tests/core/wordpress-import-flow.test.ts +81 -18
- package/dist/template/tests/core/wordpress-import.test.ts +25 -12
- package/dist/template/tests/core/wordpress-migration-verification.test.ts +37 -0
- package/dist/template/tests/modules/preview-assistant.test.ts +164 -0
- package/dist/template-manifest.json +349 -139
- package/package.json +1 -1
|
@@ -22,7 +22,13 @@ import {
|
|
|
22
22
|
reconcileImport,
|
|
23
23
|
rollbackImport,
|
|
24
24
|
startImport,
|
|
25
|
+
reviewImportConflicts,
|
|
26
|
+
wordpressVerificationPlan,
|
|
25
27
|
} from "@/core/import/service";
|
|
28
|
+
import { saveAuthor, setPostMeta, postMetaAt, resolveBlogArchive } from "@/modules/cms/blog-service";
|
|
29
|
+
import { listReaderComments } from "@/modules/cms/blog-comments";
|
|
30
|
+
import { blogReaderComments } from "@/modules/cms/blog-comments-schema";
|
|
31
|
+
import { resolveRedirect } from "@/core/seo/service";
|
|
26
32
|
import { closeDb, hasDatabase, OWNER, truncateSpine } from "../helpers/spine";
|
|
27
33
|
|
|
28
34
|
const getPinnedBytes = vi.hoisted(() => vi.fn());
|
|
@@ -77,9 +83,9 @@ describe.runIf(hasDatabase)("WordPress import studio", { timeout: 60_000 }, () =
|
|
|
77
83
|
const started = await startImport.call({ origin: "https://old.example.org", kind: "wordpress-wxr" }, OWNER);
|
|
78
84
|
const previewed = await previewFromSource.call({ id: started.id, payload: FIXTURE }, OWNER);
|
|
79
85
|
expect(previewed.status).toBe("previewed");
|
|
80
|
-
expect(previewed.counts).toMatchObject({ pages: 5, posts: 3, media: 2, redirects:
|
|
86
|
+
expect(previewed.counts).toMatchObject({ pages: 5, posts: 3, media: 2, redirects: 0, menus: 1, commentsSkipped: 2 });
|
|
81
87
|
// Nothing is written by a preview.
|
|
82
|
-
expect(await pageAt("
|
|
88
|
+
expect(await pageAt("2025/03/first-wood-firing")).toBeUndefined();
|
|
83
89
|
|
|
84
90
|
const committed = await commitImport.call({ id: started.id }, OWNER);
|
|
85
91
|
expect(committed.status).toBe("committed");
|
|
@@ -90,12 +96,13 @@ describe.runIf(hasDatabase)("WordPress import studio", { timeout: 60_000 }, () =
|
|
|
90
96
|
posts: 3,
|
|
91
97
|
media: 2,
|
|
92
98
|
mediaFailed: 0,
|
|
93
|
-
redirects:
|
|
99
|
+
redirects: 0,
|
|
94
100
|
menus: 1,
|
|
95
101
|
categories: 2,
|
|
96
102
|
tags: 1,
|
|
97
103
|
authors: 1,
|
|
98
|
-
|
|
104
|
+
commentsImported: 2,
|
|
105
|
+
commentsSkipped: 0,
|
|
99
106
|
skippedPages: 0,
|
|
100
107
|
});
|
|
101
108
|
// The external image is never fetched; only the two attachments are.
|
|
@@ -114,36 +121,45 @@ describe.runIf(hasDatabase)("WordPress import studio", { timeout: 60_000 }, () =
|
|
|
114
121
|
sourceUrl: "https://old.example.org/wp-content/uploads/2025/03/kiln.jpg",
|
|
115
122
|
});
|
|
116
123
|
|
|
117
|
-
const post = (await pageAt("
|
|
124
|
+
const post = (await pageAt("2025/03/first-wood-firing"))!;
|
|
118
125
|
expect(post.status).toBe("draft");
|
|
119
126
|
expect(post.seo).toEqual({
|
|
120
127
|
title: expect.stringMatching(/^Our First Wood Firing – Wood firing diary/) as unknown,
|
|
121
128
|
description: "Three days of loading and two of stoking.",
|
|
129
|
+
preserveTitle: true,
|
|
130
|
+
preserveDescription: true,
|
|
122
131
|
});
|
|
123
132
|
const blocks = post.blocks as Array<{ type: string; props: Record<string, unknown> }>;
|
|
124
133
|
expect(blocks.filter((block) => block.type === "image").map((block) => block.props.assetId)).toEqual([kiln.id]);
|
|
125
|
-
expect(JSON.stringify(blocks)).toContain('"href":"/
|
|
134
|
+
expect(JSON.stringify(blocks)).toContain('"href":"/glaze-notes"');
|
|
126
135
|
expect((await pageAt("about/team"))!.status).toBe("draft");
|
|
127
|
-
expect(JSON.stringify((await pageAt("about"))!.blocks)).toContain('"href":"/
|
|
136
|
+
expect(JSON.stringify((await pageAt("about"))!.blocks)).toContain('"href":"/2025/03/first-wood-firing"');
|
|
128
137
|
expect((await pageAt("blog"))!.blocks).toEqual(expect.arrayContaining([expect.objectContaining({ type: "blogIndex" })]));
|
|
129
138
|
|
|
130
139
|
const moved = await db().select().from(redirects);
|
|
131
|
-
expect(moved.
|
|
132
|
-
["2025/03/first-wood-firing", "blog/first-wood-firing", "import"],
|
|
133
|
-
["glaze-notes", "blog/glaze-notes", "import"],
|
|
134
|
-
]);
|
|
140
|
+
expect(moved).toEqual([]);
|
|
135
141
|
|
|
136
142
|
const reconciled = await reconcileImport.call({ id: started.id }, OWNER);
|
|
137
143
|
expect(reconciled.checkpoint).toMatchObject({
|
|
138
|
-
reconciliation: { found: { pages: 5, media: 2, redirects:
|
|
144
|
+
reconciliation: { found: { pages: 5, media: 2, redirects: 0 }, matches: true },
|
|
139
145
|
});
|
|
140
146
|
|
|
141
147
|
const published = await publishImport.call({ id: started.id }, OWNER);
|
|
142
148
|
expect(published.status).toBe("published");
|
|
143
|
-
expect((await pageAt("
|
|
149
|
+
expect((await pageAt("2025/03/first-wood-firing"))!.publishedAt?.toISOString()).toBe("2025-03-14T18:00:00.000Z");
|
|
144
150
|
expect((await pageAt("blog/upcoming-sale"))!.status).toBe("draft");
|
|
145
151
|
const listing = await listBlogPosts.call({ locale: "en", prefix: "blog", page: 1, limit: 12 }, { kind: "anonymous" });
|
|
146
|
-
expect(listing.posts.map((entry) => entry.slug)).toEqual(["
|
|
152
|
+
expect(listing.posts.map((entry) => entry.slug)).toEqual(["glaze-notes", "2025/03/first-wood-firing"]);
|
|
153
|
+
expect(await resolveRedirect.call({ path: "?p=20" }, { kind: "anonymous" })).toEqual({ toPath: post.slug, status: "301" });
|
|
154
|
+
expect(await resolveRedirect.call({ path: "?attachment_id=10" }, { kind: "anonymous" })).toEqual({ toPath: post.slug, status: "301" });
|
|
155
|
+
expect(await resolveBlogArchive.call({ path: "author/maple" }, { kind: "anonymous" })).toMatchObject({ name: "Maple Rivers", posts: 2 });
|
|
156
|
+
expect(await resolveBlogArchive.call({ path: "2025/03" }, { kind: "anonymous" })).toMatchObject({ kind: "date", posts: 1 });
|
|
157
|
+
expect(await resolveRedirect.call({ path: "author/maple/page/1" }, { kind: "anonymous" })).toEqual({ toPath: "author/maple", status: "301" });
|
|
158
|
+
expect(await resolveRedirect.call({ path: "author/maple/page/9999" }, { kind: "anonymous" })).toBeNull();
|
|
159
|
+
expect(await listReaderComments.call({ pageId: post.id }, { kind: "anonymous" })).toHaveLength(1);
|
|
160
|
+
const verification = await wordpressVerificationPlan.call({ id: started.id }, OWNER);
|
|
161
|
+
expect(verification.checks.some(check => check.requestPath === "/?p=20" && check.redirect)).toBe(true);
|
|
162
|
+
expect(verification.checks.some(check => check.destinationPath.includes("upcoming-sale"))).toBe(false);
|
|
147
163
|
const [nav] = await db()
|
|
148
164
|
.select()
|
|
149
165
|
.from(sections)
|
|
@@ -151,12 +167,12 @@ describe.runIf(hasDatabase)("WordPress import studio", { timeout: 60_000 }, () =
|
|
|
151
167
|
// Top-level items only: the nav block is flat, so "Team" stays on record.
|
|
152
168
|
expect((nav!.blocks as Array<{ props: { links: unknown[] } }>)[0]!.props.links).toEqual([
|
|
153
169
|
{ label: "About", href: "/about" },
|
|
154
|
-
{ label: "Journal", href: "/
|
|
170
|
+
{ label: "Journal", href: "/2025/03/first-wood-firing" },
|
|
155
171
|
]);
|
|
156
172
|
|
|
157
173
|
const rolled = await rollbackImport.call({ id: started.id }, OWNER);
|
|
158
174
|
expect(rolled.status).toBe("rolled_back");
|
|
159
|
-
expect(await pageAt("
|
|
175
|
+
expect(await pageAt("2025/03/first-wood-firing")).toBeUndefined();
|
|
160
176
|
expect((await pageAt("blog"))!.status).toBe("published");
|
|
161
177
|
expect(await db().select().from(redirects)).toHaveLength(0);
|
|
162
178
|
expect((await db().select().from(assets)).every((asset) => asset.status === "trashed")).toBe(true);
|
|
@@ -191,11 +207,11 @@ describe.runIf(hasDatabase)("WordPress import studio", { timeout: 60_000 }, () =
|
|
|
191
207
|
},
|
|
192
208
|
});
|
|
193
209
|
// The page still lands, without the picture it could not fetch.
|
|
194
|
-
const post = (await pageAt("
|
|
210
|
+
const post = (await pageAt("2025/03/first-wood-firing"))!;
|
|
195
211
|
expect(JSON.stringify(post.blocks)).not.toContain('"type":"image"');
|
|
196
212
|
|
|
197
213
|
await rollbackImport.call({ id: started.id }, OWNER);
|
|
198
|
-
expect(await pageAt("
|
|
214
|
+
expect(await pageAt("2025/03/first-wood-firing")).toBeUndefined();
|
|
199
215
|
expect(await pageAt("blog")).toBeUndefined();
|
|
200
216
|
});
|
|
201
217
|
|
|
@@ -213,4 +229,51 @@ describe.runIf(hasDatabase)("WordPress import studio", { timeout: 60_000 }, () =
|
|
|
213
229
|
expect(rolled.status).toBe("rolled_back");
|
|
214
230
|
expect((await db().select().from(assets)).every((asset) => asset.status === "trashed")).toBe(true);
|
|
215
231
|
});
|
|
232
|
+
|
|
233
|
+
it("stages live replacement bylines and approved comments until cutover, then restores the original date and metadata on rollback", async () => {
|
|
234
|
+
const { createPage, publishPage } = await import("@/modules/cms/service");
|
|
235
|
+
const page = await createPage.call({ slug: "2025/03/first-wood-firing", title: "Original live title", blocks: [{ id: "original-h", type: "heading", props: { text: "Original live title", level: 1 } }] }, OWNER);
|
|
236
|
+
const author = await saveAuthor.call({ name: "Original Author" }, OWNER);
|
|
237
|
+
await setPostMeta.call({ pageId: page.id, isPost: true, authorId: author.id, commentsEnabled: false }, OWNER);
|
|
238
|
+
const originalDate = "2024-01-02T12:00:00.000Z";
|
|
239
|
+
await publishPage.call({ id: page.id, published: true, publishedAt: originalDate }, OWNER);
|
|
240
|
+
const started = await startImport.call({ origin: "https://old.example.org", kind: "wordpress-wxr" }, OWNER);
|
|
241
|
+
await previewFromSource.call({ id: started.id, payload: FIXTURE }, OWNER);
|
|
242
|
+
await reviewImportConflicts.call({ id: started.id, conflicts: [{ slug: page.slug, resolution: "replace" }] }, OWNER);
|
|
243
|
+
const committed = await commitImport.call({ id: started.id }, OWNER);
|
|
244
|
+
expect(committed.counts).toMatchObject({ commentsImported: 0, commentsStaged: 2, commentsSkipped: 0 });
|
|
245
|
+
expect((await postMetaAt.call({ slug: page.slug }, { kind: "anonymous" }))?.author?.name).toBe("Original Author");
|
|
246
|
+
expect(await listReaderComments.call({ pageId: page.id }, { kind: "anonymous" })).toEqual([]);
|
|
247
|
+
await reconcileImport.call({ id: started.id }, OWNER);
|
|
248
|
+
await publishImport.call({ id: started.id }, OWNER);
|
|
249
|
+
expect((await postMetaAt.call({ slug: page.slug }, { kind: "anonymous" }))?.author?.name).toBe("Maple Rivers");
|
|
250
|
+
expect(await listReaderComments.call({ pageId: page.id }, { kind: "anonymous" })).toHaveLength(1);
|
|
251
|
+
await rollbackImport.call({ id: started.id }, OWNER);
|
|
252
|
+
const restored = await pageAt(page.slug);
|
|
253
|
+
expect(restored?.title).toBe("Original live title");
|
|
254
|
+
expect(restored?.publishedAt?.toISOString()).toBe(originalDate);
|
|
255
|
+
expect((await postMetaAt.call({ slug: page.slug }, { kind: "anonymous" }))?.author?.name).toBe("Original Author");
|
|
256
|
+
expect(await listReaderComments.call({ pageId: page.id }, { kind: "anonymous" })).toEqual([]);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it("hides an old blog thread when an ordinary page replaces it, and restores the same history on rollback", async () => {
|
|
260
|
+
const { createPage, publishPage } = await import("@/modules/cms/service");
|
|
261
|
+
const page = await createPage.call({ slug: "about", title: "An old blog post", blocks: [{ id: "old-h", type: "heading", props: { text: "An old blog post", level: 1 } }] }, OWNER);
|
|
262
|
+
await setPostMeta.call({ pageId: page.id, isPost: true }, OWNER);
|
|
263
|
+
await publishPage.call({ id: page.id, published: true }, OWNER);
|
|
264
|
+
const [comment] = await db().insert(blogReaderComments).values({ pageId: page.id, authorName: "Original Reader", body: "Original approved history", status: "approved" }).returning();
|
|
265
|
+
const started = await startImport.call({ origin: "https://old.example.org", kind: "wordpress-wxr" }, OWNER);
|
|
266
|
+
await previewFromSource.call({ id: started.id, payload: FIXTURE }, OWNER);
|
|
267
|
+
await reviewImportConflicts.call({ id: started.id, conflicts: [{ slug: "about", resolution: "replace" }] }, OWNER);
|
|
268
|
+
await commitImport.call({ id: started.id }, OWNER);
|
|
269
|
+
expect(await listReaderComments.call({ pageId: page.id }, { kind: "anonymous" })).toHaveLength(1);
|
|
270
|
+
await reconcileImport.call({ id: started.id }, OWNER);
|
|
271
|
+
await publishImport.call({ id: started.id }, OWNER);
|
|
272
|
+
expect(await postMetaAt.call({ slug: page.slug }, { kind: "anonymous" })).toBeNull();
|
|
273
|
+
expect(await listReaderComments.call({ pageId: page.id }, { kind: "anonymous" })).toEqual([]);
|
|
274
|
+
expect((await db().select().from(blogReaderComments).where(eq(blogReaderComments.id, comment!.id)))[0]?.body).toBe("Original approved history");
|
|
275
|
+
await rollbackImport.call({ id: started.id }, OWNER);
|
|
276
|
+
expect((await postMetaAt.call({ slug: page.slug }, { kind: "anonymous" }))?.pageId).toBe(page.id);
|
|
277
|
+
expect((await listReaderComments.call({ pageId: page.id }, { kind: "anonymous" }))[0]?.id).toBe(comment!.id);
|
|
278
|
+
});
|
|
216
279
|
});
|
|
@@ -36,7 +36,7 @@ function context(overrides: Partial<BodyContext> = {}): BodyContext {
|
|
|
36
36
|
: wpId === "11" || src.includes("glaze")
|
|
37
37
|
? { assetId: GLAZE }
|
|
38
38
|
: null,
|
|
39
|
-
rewriteHref: (href) => href.replace("https://old.example.org/glaze-notes/", "/
|
|
39
|
+
rewriteHref: (href) => href.replace("https://old.example.org/glaze-notes/", "/glaze-notes"),
|
|
40
40
|
...overrides,
|
|
41
41
|
};
|
|
42
42
|
}
|
|
@@ -63,6 +63,19 @@ describe("WordPress WXR export (C3.22)", () => {
|
|
|
63
63
|
expect(exported.skipped).toEqual({ "status: trash": 1, "post type: product": 1 });
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
+
it("preserves reader paragraph boundaries while removing executable HTML", () => {
|
|
67
|
+
const changed = FIXTURE.replace("Lovely kiln!", "<p>First paragraph.</p><p>Next<br>line.</p><script>hidden()</script>");
|
|
68
|
+
const parsed = parseWordpressExport(changed);
|
|
69
|
+
const post = parsed.items.find(item => item.comments.entries?.length);
|
|
70
|
+
expect(post?.comments.entries?.find(comment => comment.status === "approved")?.body).toBe("First paragraph.\n\nNext\nline.");
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("preserves a source home page at the empty CMS path", () => {
|
|
74
|
+
const changed = FIXTURE.replace("<link>https://old.example.org/about/</link>", "<link>https://old.example.org/</link>");
|
|
75
|
+
const plan = planWordpressImport(parseWordpressExport(changed), ORIGIN);
|
|
76
|
+
expect(plan.pages.find(page => page.wpId === "30")?.slug).toBe("");
|
|
77
|
+
});
|
|
78
|
+
|
|
66
79
|
it("keeps dates, terms, SEO, featured images and comment counts", () => {
|
|
67
80
|
const post = exported.items.find((item) => item.slug === "first-wood-firing")!;
|
|
68
81
|
expect(post.publishedAt).toBe("2025-03-14T18:00:00.000Z");
|
|
@@ -71,11 +84,11 @@ describe("WordPress WXR export (C3.22)", () => {
|
|
|
71
84
|
expect(post.seo.title).toBe("Our First Wood Firing – Wood firing diary from a very small studio in the hills");
|
|
72
85
|
expect(post.seo.description).toBe("Three days of loading and two of stoking.");
|
|
73
86
|
expect(post.featuredWpId).toBe("10");
|
|
74
|
-
expect(post.comments).
|
|
87
|
+
expect(post.comments).toMatchObject({ total: 2, approved: 1 });
|
|
75
88
|
// A body that says </item> inside CDATA does not end the item.
|
|
76
89
|
expect(post.body).toContain("</item> on purpose");
|
|
77
90
|
const about = exported.items.find((item) => item.slug === "about")!;
|
|
78
|
-
expect(about.seo).
|
|
91
|
+
expect(about.seo).toMatchObject({
|
|
79
92
|
title: "About the Studio – Fernwood Kiln",
|
|
80
93
|
description: "A small studio making wood-fired stoneware by hand.",
|
|
81
94
|
});
|
|
@@ -97,12 +110,12 @@ describe("WordPress WXR export (C3.22)", () => {
|
|
|
97
110
|
describe("WordPress import plan (C3.22)", () => {
|
|
98
111
|
const plan = planWordpressImport(parseWordpressExport(FIXTURE), ORIGIN);
|
|
99
112
|
|
|
100
|
-
it("
|
|
113
|
+
it("keeps original page and post permalinks; query-only posts get a blog address", () => {
|
|
101
114
|
expect(plan.pages.map((page) => [page.slug, page.redirectFrom ?? null])).toEqual([
|
|
102
115
|
["about", null],
|
|
103
116
|
["about/team", null],
|
|
104
|
-
["
|
|
105
|
-
["
|
|
117
|
+
["2025/03/first-wood-firing", null],
|
|
118
|
+
["glaze-notes", null],
|
|
106
119
|
// `/?p=22` has no path of its own, so there is nothing to redirect.
|
|
107
120
|
["blog/upcoming-sale", null],
|
|
108
121
|
]);
|
|
@@ -116,7 +129,7 @@ describe("WordPress import plan (C3.22)", () => {
|
|
|
116
129
|
["glaze-scaled.png", true],
|
|
117
130
|
]);
|
|
118
131
|
expect(plan.media[1]!.aliases).toContain("old.example.org/wp-content/uploads/2025/04/glaze.png");
|
|
119
|
-
expect(plan.pages.find((page) => page.slug === "
|
|
132
|
+
expect(plan.pages.find((page) => page.slug === "2025/03/first-wood-firing")!.featuredMedia).toBe(plan.media[0]!.key);
|
|
120
133
|
expect(plan.report.externalImages).toEqual(["https://cdn.other.example.net/borrowed.jpg"]);
|
|
121
134
|
});
|
|
122
135
|
|
|
@@ -129,8 +142,8 @@ describe("WordPress import plan (C3.22)", () => {
|
|
|
129
142
|
{ login: "maple", displayName: "Maple Rivers", email: "maple@example.org", posts: 3 },
|
|
130
143
|
]);
|
|
131
144
|
expect(plan.report.comments).toEqual({ total: 2, approved: 1 });
|
|
132
|
-
expect(plan.report.seoTrimmed).toBe(
|
|
133
|
-
expect(plan.pages.find((page) => page.slug === "
|
|
145
|
+
expect(plan.report.seoTrimmed).toBe(0);
|
|
146
|
+
expect(plan.pages.find((page) => page.slug === "2025/03/first-wood-firing")!.seo.title).toBe("Our First Wood Firing – Wood firing diary from a very small studio in the hills");
|
|
134
147
|
});
|
|
135
148
|
|
|
136
149
|
it("maps menu items to imported pages, custom links and nesting", () => {
|
|
@@ -172,7 +185,7 @@ describe("WordPress body conversion (C3.22)", () => {
|
|
|
172
185
|
expect(title!.props).toMatchObject({ text: "Our First Wood Firing", level: 1 });
|
|
173
186
|
expect(section!.props).toMatchObject({ text: "Loading the kiln", level: 2 });
|
|
174
187
|
expect(JSON.stringify(prose!.props.body)).toContain('"marks":["strong"]');
|
|
175
|
-
expect(JSON.stringify(prose!.props.body)).toContain('"href":"/
|
|
188
|
+
expect(JSON.stringify(prose!.props.body)).toContain('"href":"/glaze-notes"');
|
|
176
189
|
expect(image!.props).toEqual({ assetId: KILN, alt: "A brick kiln stacked with bowls" });
|
|
177
190
|
expect(JSON.stringify(after!.props.body)).toContain("Packed and ready.");
|
|
178
191
|
expect(JSON.stringify(after!.props.body)).toContain('"type":"bulletList"');
|
|
@@ -253,8 +266,8 @@ describe("WordPress REST payloads (C3.22)", () => {
|
|
|
253
266
|
});
|
|
254
267
|
expect(exported.skipped).toEqual({ "post type: wp_block": 1 });
|
|
255
268
|
expect(planWordpressImport(exported, ORIGIN).pages[0]).toMatchObject({
|
|
256
|
-
slug: "
|
|
257
|
-
redirectFrom:
|
|
269
|
+
slug: "2025/01/hello",
|
|
270
|
+
redirectFrom: undefined,
|
|
258
271
|
});
|
|
259
272
|
});
|
|
260
273
|
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Copyright (C) 2026 Tony Aly
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { afterAll, describe, expect, it } from "vitest";
|
|
4
|
+
import { createServer, type Server } from "node:http";
|
|
5
|
+
import { htmlMetadata, verifyMigration } from "../../scripts/verify-wordpress-migration.mjs";
|
|
6
|
+
const servers: Server[] = [];
|
|
7
|
+
async function fixture(mode: "source" | "destination") {
|
|
8
|
+
const server = createServer((request, response) => {
|
|
9
|
+
if (request.url === "/old" || request.url === "/two") { response.writeHead(301, { location: request.url === "/old" ? "/story" : "/old" }).end(); return; }
|
|
10
|
+
response.writeHead(200, { "content-type": "text/html; charset=utf-8" }).end(`<html><head><title>A complete original title & its brand</title><meta name="description" content="A description."><link rel="canonical" href="/story"><meta property="og:title" content="A social title"><meta property="og:description" content="A social description"><meta property="og:image" content="https://images.example.test/owned.jpg">${request.url === "/mismatch" && mode === "destination" ? '<meta name="robots" content="noindex">' : ''}<link rel="alternate" hreflang="fr" href="/fr/story"></head><body>Story</body></html>`);
|
|
11
|
+
});
|
|
12
|
+
await new Promise<void>(resolve => server.listen(0, "127.0.0.1", resolve)); servers.push(server);
|
|
13
|
+
const address = server.address(); if (!address || typeof address === "string") throw new Error("No fixture port.");
|
|
14
|
+
return `http://127.0.0.1:${address.port}`;
|
|
15
|
+
}
|
|
16
|
+
afterAll(async () => { await Promise.all(servers.map(server => new Promise<void>((resolve, reject) => server.close(error => error ? reject(error) : resolve())))); });
|
|
17
|
+
|
|
18
|
+
describe("WordPress migration HTTP acceptance report", () => {
|
|
19
|
+
it("reads entities and metadata from parsed HTML", () => {
|
|
20
|
+
expect(htmlMetadata('<title>Full & exact</title><meta name="robots" content="noindex"><link rel="alternate" hreflang="ar" href="/ar/story">')).toMatchObject({ title: "Full & exact", robots: "noindex", hreflang: { ar: "/ar/story" } });
|
|
21
|
+
});
|
|
22
|
+
it("accepts preserved pages and one literal301 alias, but fails two-hop redirects and unresolved source decisions", async () => {
|
|
23
|
+
const source = await fixture("source"), destination = await fixture("destination");
|
|
24
|
+
const plan = { sourceOrigin: source, status: "published", warnings: [] as string[], checks: [
|
|
25
|
+
{ sourceUrl: `${source}/story`, requestPath: "/story", destinationPath: "/story", redirect: false, expected: { title: "A complete original title & its brand" } },
|
|
26
|
+
{ sourceUrl: `${source}/old`, requestPath: "/old", destinationPath: "/story", redirect: true, expected: {} },
|
|
27
|
+
] };
|
|
28
|
+
expect(await verifyMigration(plan, destination)).toMatchObject({ accepted: true });
|
|
29
|
+
const failed = await verifyMigration({ ...plan, checks: [{ ...plan.checks[1]!, requestPath: "/two" }] }, destination);
|
|
30
|
+
expect(failed.accepted).toBe(false);
|
|
31
|
+
expect(failed.rows[0]!.errors.join(" ")).toContain("301");
|
|
32
|
+
expect(await verifyMigration({ ...plan, warnings: ["Choose a destination for an orphan attachment."] }, destination)).toMatchObject({ accepted: false });
|
|
33
|
+
const changed = await verifyMigration({ ...plan, checks: [{ ...plan.checks[0]!, sourceUrl: `${source}/mismatch`, requestPath: "/mismatch" }] }, destination);
|
|
34
|
+
expect(changed.accepted).toBe(false);
|
|
35
|
+
expect(changed.rows[0]!.errors).toContain("noindex changed from the source.");
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// Copyright (C) 2026 Tony Aly
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
6
|
+
import { db } from "@/core/db";
|
|
7
|
+
import { ready } from "@/core/runtime";
|
|
8
|
+
import { updateBusiness } from "@/core/settings/service";
|
|
9
|
+
import { getSiteChat, startSiteChat } from "@/core/messaging/chat";
|
|
10
|
+
import { assistantTurns } from "@/modules/assistant/schema";
|
|
11
|
+
import { answer, updateSettings, previewCall, settings, managedDetails, syncManagedSettings } from "@/modules/assistant/service";
|
|
12
|
+
import { setParadiseFetchForTests } from "@/adapters/paradise/http";
|
|
13
|
+
import { contentSecurityPolicy, isPreviewAssistantContactPath } from "@/core/http/csp";
|
|
14
|
+
import { installLaunch, launchPages, launchSpecSchema } from "@/modules/seed/launch";
|
|
15
|
+
import { ANONYMOUS, OWNER, closeDb, failure, hasDatabase, truncateSpine } from "../helpers/spine";
|
|
16
|
+
import { openTransactions } from "../helpers/open-transactions";
|
|
17
|
+
import { resetEnvForTests } from "@/core/env";
|
|
18
|
+
|
|
19
|
+
const requestBody = (value: BodyInit | null | undefined): Record<string, unknown> =>
|
|
20
|
+
typeof value === "string" ? JSON.parse(value) as Record<string, unknown> : {};
|
|
21
|
+
|
|
22
|
+
describe("managed preview consumer contracts", () => {
|
|
23
|
+
it("keeps v1/v2 unchanged and requires explicit v3 assistant/SFW settings", () => {
|
|
24
|
+
const base = JSON.parse(readFileSync("seed/launch/example-v2.json", "utf8")) as Record<string, unknown>;
|
|
25
|
+
expect(launchSpecSchema.parse(base).version).toBe(2);
|
|
26
|
+
expect(launchSpecSchema.safeParse({ ...base, version: 3 }).success).toBe(false);
|
|
27
|
+
const v3 = launchSpecSchema.parse({ ...base, version: 3, assistant: { provider: "paradise", enabled: true, dailyCapUsd: 1, contentMode: "sfw" } });
|
|
28
|
+
expect(JSON.stringify(launchPages(v3))).toContain('"type":"siteChat"');
|
|
29
|
+
expect(JSON.stringify(launchPages(v3))).toContain("not an endorsement");
|
|
30
|
+
expect(launchSpecSchema.safeParse({ ...v3, version: 2 }).success).toBe(false);
|
|
31
|
+
expect(launchSpecSchema.safeParse({ ...v3, assistant: { ...v3.assistant, contentMode: "adult" } }).success).toBe(false);
|
|
32
|
+
expect(JSON.stringify(v3)).not.toContain("age_confirmed");
|
|
33
|
+
});
|
|
34
|
+
it("pins the distributed shared transport and every same-origin codec byte", () => {
|
|
35
|
+
const root = "public/managed-assistant/0.1.10/";
|
|
36
|
+
const manifest = JSON.parse(readFileSync(`${root}manifest.json`, "utf8")) as { codecs: Record<string, string>; moduleSha256: string };
|
|
37
|
+
for (const [name, hash] of Object.entries(manifest.codecs)) {
|
|
38
|
+
expect(createHash("sha256").update(readFileSync(`${root}duplex-codec/${name}`)).digest("hex")).toBe(hash);
|
|
39
|
+
}
|
|
40
|
+
const bundle = readFileSync(`${root}pm-ai-duplex-client.js`, "utf8");
|
|
41
|
+
expect(bundle).toContain('"0.1.10"');
|
|
42
|
+
expect(createHash("sha256").update(bundle.split("\n").slice(3).join("\n")).digest("hex")).toBe(manifest.moduleSha256);
|
|
43
|
+
});
|
|
44
|
+
it("only opens configured call origins and wasm on the assistant surface", () => {
|
|
45
|
+
const options = { nonce: "fixture", production: true, assistantOrigins: ["https://voice.test", "wss://voice.test"] };
|
|
46
|
+
expect(contentSecurityPolicy({ ...options, path: "/contact" })).toContain("https://voice.test wss://voice.test");
|
|
47
|
+
expect(contentSecurityPolicy({ ...options, path: "/contact" })).toContain("'wasm-unsafe-eval'");
|
|
48
|
+
for (const path of ["/fr/contact", "/ar/contact", "/en-CA/contact/"]) {
|
|
49
|
+
expect(isPreviewAssistantContactPath(path)).toBe(true);
|
|
50
|
+
expect(contentSecurityPolicy({ ...options, path })).toContain("https://voice.test wss://voice.test");
|
|
51
|
+
expect(contentSecurityPolicy({ ...options, path })).toContain("'wasm-unsafe-eval'");
|
|
52
|
+
}
|
|
53
|
+
for (const path of ["/", "/fr/services", "/admin", "/contact/other", "/fr/admin/contact"]) {
|
|
54
|
+
expect(isPreviewAssistantContactPath(path)).toBe(false);
|
|
55
|
+
expect(contentSecurityPolicy({ ...options, path })).not.toContain("voice.test");
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe.runIf(hasDatabase)("managed assistants on the existing chat spine", () => {
|
|
61
|
+
beforeAll(async () => ready(), 180000);
|
|
62
|
+
beforeEach(async () => {
|
|
63
|
+
await truncateSpine();
|
|
64
|
+
await updateBusiness.call({ name: "Harbour Studio", country: "CA", baseCurrency: "CAD", timezone: "America/Vancouver" }, OWNER);
|
|
65
|
+
process.env.PARADISEMODERN_API_KEY = "test-only-managed-key";
|
|
66
|
+
process.env.PARADISEMODERN_URL = "https://pm.test";
|
|
67
|
+
process.env.PARADISEMODERN_ASSISTANT_ORIGINS = "https://voice.test";
|
|
68
|
+
resetEnvForTests();
|
|
69
|
+
await updateSettings.call({ enabled: true, provider: "paradise", model: "paradise-managed-assistant", maxOutputTokens: 600, spendCapCents: 100, spendPeriod: "day" }, OWNER);
|
|
70
|
+
});
|
|
71
|
+
afterEach(() => { setParadiseFetchForTests(undefined); });
|
|
72
|
+
afterAll(async () => {
|
|
73
|
+
delete process.env.PARADISEMODERN_API_KEY; delete process.env.PARADISEMODERN_URL; delete process.env.PARADISEMODERN_ASSISTANT_ORIGINS;
|
|
74
|
+
await closeDb();
|
|
75
|
+
});
|
|
76
|
+
const chat = () => startSiteChat.call({ name: "Visitor", email: `${randomUUID()}@example.com`, message: "Hello", locale: "en" }, ANONYMOUS);
|
|
77
|
+
const reply = (body: unknown) => new Response(JSON.stringify(body), { headers: { "content-type": "application/json" } });
|
|
78
|
+
|
|
79
|
+
it("binds text to the cookie, holds the consumer cap and records its actual receipt on the canonical transcript", async () => {
|
|
80
|
+
const session = await chat(); let sent: Record<string, unknown> = {};
|
|
81
|
+
setParadiseFetchForTests(async (_url, init) => {
|
|
82
|
+
expect(await openTransactions()).toBe(0);
|
|
83
|
+
sent = requestBody(init.body);
|
|
84
|
+
return reply({ text: "Hello! How can I help?", model: "managed-model", metered_list_usd: .04, content_mode: "sfw" });
|
|
85
|
+
});
|
|
86
|
+
expect((await answer.call({ token: session.token }, ANONYMOUS)).status).toBe("answered");
|
|
87
|
+
expect(sent.visitor_ref).toBe(createHash("sha256").update(`pm-preview-assistant-visitor-v1\n${session.token}`).digest("hex"));
|
|
88
|
+
expect(sent.max_charge_usd).toBe(1);
|
|
89
|
+
expect((await db().select().from(assistantTurns))[0]?.costCents).toBe(4);
|
|
90
|
+
const transcript = await getSiteChat.call({ token: session.token }, ANONYMOUS);
|
|
91
|
+
expect(transcript.messages.at(-1)?.channel).toBe("assistant");
|
|
92
|
+
expect(transcript.messages.at(-1)?.body).toContain("Hello!");
|
|
93
|
+
expect(JSON.stringify(transcript)).not.toContain("test-only-managed-key");
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("retains the held budget after an unknown model timeout", async () => {
|
|
97
|
+
let calls = 0;
|
|
98
|
+
setParadiseFetchForTests(async () => { calls++; throw Error("lost response"); });
|
|
99
|
+
const one = await chat();
|
|
100
|
+
expect((await answer.call({ token: one.token }, ANONYMOUS)).status).toBe("failed");
|
|
101
|
+
expect((await db().select().from(assistantTurns))[0]?.costCents).toBe(100);
|
|
102
|
+
const two = await chat();
|
|
103
|
+
expect((await answer.call({ token: two.token }, ANONYMOUS)).status).toBe("refused");
|
|
104
|
+
expect(calls).toBe(1);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("serializes claims so two visitors cannot spend the same remaining managed budget", async () => {
|
|
108
|
+
const one = await chat(), two = await chat(); let invoked!: () => void, complete!: () => void;
|
|
109
|
+
const started = new Promise<void>(resolve => { invoked = resolve; });
|
|
110
|
+
const release = new Promise<void>(resolve => { complete = resolve; });
|
|
111
|
+
let calls = 0;
|
|
112
|
+
setParadiseFetchForTests(async () => { calls++; invoked(); await release; return reply({ text: "Hello!", model: "managed-model", metered_list_usd: .04, content_mode: "sfw" }); });
|
|
113
|
+
const first = answer.call({ token: one.token }, ANONYMOUS);
|
|
114
|
+
await started;
|
|
115
|
+
try { expect((await answer.call({ token: two.token }, ANONYMOUS)).status).toBe("refused"); }
|
|
116
|
+
finally { complete(); }
|
|
117
|
+
expect((await first).status).toBe("answered"); expect(calls).toBe(1);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("proxies only visitor-bound controls, fails to text without worker origins, and keeps End available after off", async () => {
|
|
121
|
+
const session = await chat(), id = randomUUID(); const requests: Array<{ url: string; body: Record<string, unknown> }> = [];
|
|
122
|
+
setParadiseFetchForTests(async (url, init) => {
|
|
123
|
+
expect(await openTransactions()).toBe(0);
|
|
124
|
+
requests.push({ url, body: requestBody(init.body) });
|
|
125
|
+
return reply(url.endsWith("/config") ? { enabled: true, modes: ["video", "voice", "text"] } : { session_id: id, status: "ending" });
|
|
126
|
+
});
|
|
127
|
+
delete process.env.PARADISEMODERN_ASSISTANT_ORIGINS;
|
|
128
|
+
resetEnvForTests();
|
|
129
|
+
expect(await previewCall.call({ action: "config", token: session.token }, ANONYMOUS)).toMatchObject({ modes: ["text"] });
|
|
130
|
+
await previewCall.call({ action: "poll", token: session.token, sessionId: id }, ANONYMOUS);
|
|
131
|
+
expect(requests.at(-1)?.url).toMatch(/visitor_ref=[a-f0-9]{64}$/);
|
|
132
|
+
expect((await failure(previewCall.call({ action: "poll", token: "x".repeat(40), sessionId: id }, ANONYMOUS))).code).toBe("not_found");
|
|
133
|
+
await updateSettings.call({ enabled: false, provider: "paradise", model: "paradise-managed-assistant" }, OWNER);
|
|
134
|
+
await previewCall.call({ action: "end", token: session.token, sessionId: id }, ANONYMOUS);
|
|
135
|
+
expect(requests.at(-1)?.url).toContain("/end");
|
|
136
|
+
expect((await failure(previewCall.call({ action: "start", token: session.token, want: "video" }, ANONYMOUS))).code).toBe("not_found");
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("puts bounded browser captions on the same conversation once, after PM verifies its visitor-bound session", async () => {
|
|
140
|
+
const session = await chat(); const id = randomUUID();
|
|
141
|
+
setParadiseFetchForTests(async () => reply({ status: "live", mode: "video" }));
|
|
142
|
+
const input = { action: "caption" as const, token: session.token, sessionId: id, caption: { speaker: "muse" as const, text: "Hello from the call", startedAt: Date.now(), endedAt: Date.now() } };
|
|
143
|
+
await previewCall.call(input, ANONYMOUS); await previewCall.call(input, ANONYMOUS);
|
|
144
|
+
const transcript = await getSiteChat.call({ token: session.token }, ANONYMOUS);
|
|
145
|
+
expect(transcript.messages.filter(message => message.body.includes("Hello from the call"))).toHaveLength(1);
|
|
146
|
+
expect(transcript.messages.at(-1)?.body).toContain("browser-observed");
|
|
147
|
+
});
|
|
148
|
+
it("keeps managed talent and settings on the authorized service path", async () => {
|
|
149
|
+
const remote = { enabled: true, talentSlug: "sienna-rodriguez", dailyCapUsd: 1 };
|
|
150
|
+
setParadiseFetchForTests(async (url, init) => {
|
|
151
|
+
expect(await openTransactions()).toBe(0);
|
|
152
|
+
return reply(url.endsWith("/talent") ? { talent: [] } : { settings: init.method === "PATCH" ? requestBody(init.body) : remote });
|
|
153
|
+
});
|
|
154
|
+
expect((await failure(managedDetails.call({}, ANONYMOUS))).code).toBe("permission");
|
|
155
|
+
expect((await managedDetails.call({}, OWNER)).settings).toEqual(remote);
|
|
156
|
+
expect(await syncManagedSettings.call({ ...remote, enabled: false, dailyCapUsd: 2 }, OWNER)).toMatchObject({ settings: { enabled: false, dailyCapUsd: 2 } });
|
|
157
|
+
expect((await failure(syncManagedSettings.call(remote, ANONYMOUS))).code).toBe("permission");
|
|
158
|
+
});
|
|
159
|
+
it("installs v3 through normal services and leaves v1/v2 behavior available", async () => {
|
|
160
|
+
const base = JSON.parse(readFileSync("seed/launch/example-v2.json", "utf8")) as Record<string, unknown>;
|
|
161
|
+
await installLaunch.call({ ...base, version: 3, assistant: { provider: "paradise", enabled: true, dailyCapUsd: 1, contentMode: "sfw" } }, { kind: "system" });
|
|
162
|
+
expect(await settings.call({}, OWNER)).toMatchObject({ enabled: true, provider: "paradise", spendCapCents: 100, spendPeriod: "day" });
|
|
163
|
+
});
|
|
164
|
+
});
|