Compare commits

...
Author SHA1 Message Date
Hermes Agent bf3334878a fix(cms): honor explicit null author without defaulting to publisher 2026-10-24 23:04:40 +00:00
Hermes Agent e96a13b255 fix(editorial): synchronize corrected PMO skill bundle digest
Deploy Canina / deploy (push) Failing after 1m28s
2026-10-24 17:40:26 +00:00
4 changed files with 52 additions and 7 deletions

No files matched your search

+36
View File
@@ -274,6 +274,42 @@ describe("Admin BlogsService", () => {
});
});
describe("explicit author contract", () => {
beforeEach(() => {
mockPrisma.blog.create.mockResolvedValue({ id: "b1", slug: "post" });
mockPrisma.blog.findUnique.mockResolvedValue({ id: "b1", slug: "post" });
mockPrisma.blog.update.mockResolvedValue({ id: "b1", slug: "post" });
});
it.each([
["omitted", {}, { connect: { id: "current-user" } }],
["legacy empty", { authorId: "" }, { connect: { id: "current-user" } }],
["selected", { authorId: "selected-user" }, { connect: { id: "selected-user" } }],
["authorless", { authorId: null }, undefined],
])("creates with %s author without inventing an identity", async (_label, input, expected) => {
await service.createBlog({ title: "Post", slug: "post", content: "Content", ...input }, "current-user");
const payload = mockPrisma.blog.create.mock.calls[0][0].data;
expect(payload.author).toEqual(expected);
if (expected === undefined) expect(payload).not.toHaveProperty("author");
expect(payload).not.toHaveProperty("authorId");
expect(mockRevalidationService.revalidateBlog).toHaveBeenCalledWith("post");
});
it.each([
["omitted", {}, undefined],
["legacy empty", { authorId: "" }, undefined],
["selected", { authorId: "selected-user" }, { connect: { id: "selected-user" } }],
["authorless", { authorId: null }, { disconnect: true }],
])("updates with %s author while preserving omitted values", async (_label, input, expected) => {
await service.updateBlog("b1", input);
const payload = mockPrisma.blog.update.mock.calls[0][0].data;
expect(payload.author).toEqual(expected);
if (expected === undefined) expect(payload).not.toHaveProperty("author");
expect(payload).not.toHaveProperty("authorId");
expect(mockRevalidationService.revalidateBlog).toHaveBeenCalledWith("post");
});
});
describe("updateBlog", () => {
it("should throw NotFoundException if blog does not exist", async () => {
mockPrisma.blog.findUnique.mockResolvedValue(null);
+12 -3
View File
@@ -185,7 +185,9 @@ export class BlogsService implements OnModuleInit, OnModuleDestroy {
}
}
const targetAuthorId = authorId || currentUserId;
// Explicit null requests Organization attribution; omission/legacy empty
// retains the authenticated-author default. No synthetic User is created.
const targetAuthorId = authorId === null ? null : authorId || currentUserId;
const now = new Date();
const isFutureSchedule = parsedScheduledAt && parsedScheduledAt > now;
@@ -239,7 +241,9 @@ export class BlogsService implements OnModuleInit, OnModuleDestroy {
publishedAt: finalPublishedAt,
scheduledAt: parsedScheduledAt,
contentUpdatedAt: parsedContentUpdatedAt,
author: { connect: { id: targetAuthorId } },
...(targetAuthorId !== null
? { author: { connect: { id: targetAuthorId } } }
: {}),
...(categoryId ? { category: { connect: { id: categoryId } } } : {}),
...(tagConnectOrCreate.length > 0
? { tags: { connectOrCreate: tagConnectOrCreate } }
@@ -344,7 +348,12 @@ export class BlogsService implements OnModuleInit, OnModuleDestroy {
...(readingTime !== undefined
? { readingTime: Number(readingTime) }
: {}),
...(authorId ? { author: { connect: { id: authorId } } } : {}),
// null clears attribution; omitted/legacy empty leaves it unchanged.
...(authorId === null
? { author: { disconnect: true } }
: authorId
? { author: { connect: { id: authorId } } }
: {}),
...(categoryId !== undefined
? categoryId
? { category: { connect: { id: categoryId } } }
@@ -87,9 +87,9 @@ describe('BlogPostPage FAQPage Schema injection (SEO-P1-07)', () => {
const jsx=await BlogPostPage({params:Promise.resolve({slug:'technical'})}); const script:any=React.Children.toArray(jsx.props.children)[0]; const json=JSON.parse(script.props.dangerouslySetInnerHTML.__html); expect(json.dateModified).toBeUndefined();
});
it('uses the stable Organization fallback visibly and in metadata', async () => {
it.each([null, { firstName: '', lastName: '' }])('uses the stable Organization fallback for author %j visibly and in metadata', async (author) => {
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ ok: true, json: async () => ({
slug: 'authorless', title: 'Authorless', content: '<p>x</p>', publishedAt: '2026-01-01T00:00:00Z', author: { firstName: '', lastName: '' },
slug: 'authorless', title: 'Authorless', content: '<p>x</p>', publishedAt: '2026-01-01T00:00:00Z', author, authorTeam: null,
}) }));
const metadata = await generateMetadata({ params: Promise.resolve({ slug: 'authorless' }) });
@@ -106,7 +106,7 @@ describe('BlogPostPage FAQPage Schema injection (SEO-P1-07)', () => {
});
});
it('uses a custom authorTeam as the authorless Organization identity in metadata and rendering', async () => {
it('keeps custom team attribution separate from the Organization author identity', async () => {
const organizationName = 'تیم دامپزشکی کنینا';
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ ok: true, json: async () => ({
slug: 'custom-team',
+1 -1
View File
@@ -17,7 +17,7 @@
"profiles/canina-vet-review-worker/skills/canina-editorial-v4/SKILL.md": "1f57072cf34101fa20f47c06be3d27f455e0460c5638acdaa36caf827d605243",
"profiles/canina-vet-review-worker/skills/canina-editorial-v4/references/policy.md": "61cf7c686440d542ae249320a2834cba5f06a5b985248b3ace7ca6233507a8a3",
"profiles/canina-vet-review-worker/skills/canina-editorial-v4/references/role.json": "9c29f4182228221740ec46ab76fd0a47af7885a2fe45e0c3aed0b0e4980f2560",
"profiles/pmo/skills/canina-editorial-v4/SKILL.md": "bfff4d548ed920306b35680149bde2f08a9d1264d8ce5e6907482cec61a5e13c",
"profiles/pmo/skills/canina-editorial-v4/SKILL.md": "7dbf15d46058cec13c409ca0ccf488ccd475ff7f5a8b0260df9d1656c511b9c5",
"profiles/pmo/skills/canina-editorial-v4/references/policy.md": "61cf7c686440d542ae249320a2834cba5f06a5b985248b3ace7ca6233507a8a3",
"profiles/pmo/skills/canina-editorial-v4/references/role.json": "34627d072c8d9328411db814335165ffceaafb354fc5a5d2f1f15f531f739444"
}