feat(housekeeping): complete article workflow
This commit is contained in:
1 parent
fc050bd3f8
commit
fa33b4498e
9 files changed
+595
-3
No files matched your search
@@ -118,6 +118,41 @@ describe("Content query", () => {
|
||||
expect(emailTemplates.statement).not.toMatch(/\bbody\b|private_payload/iu);
|
||||
});
|
||||
|
||||
it("loads the editable payload only for an individual article", async () => {
|
||||
queryMocks.execute
|
||||
.mockResolvedValueOnce([[{ total: 1 }]])
|
||||
.mockResolvedValueOnce([
|
||||
[
|
||||
{
|
||||
id: 7,
|
||||
title: "Launch day",
|
||||
description: "launch-day",
|
||||
status: "published",
|
||||
updated_at: null,
|
||||
slug: "launch-day",
|
||||
image: "/media/launch.webp",
|
||||
short_story: "Short launch summary",
|
||||
full_story: "<p>Complete launch story</p>",
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
||||
const result = await loadProductionContentQuery({
|
||||
routeId: "content.editorial.article-detail",
|
||||
params: { id: "7" },
|
||||
list: { search: "", pageSize: 25, offset: 0 },
|
||||
});
|
||||
|
||||
expect(result.items[0]?.privatePayload).toEqual({
|
||||
slug: "launch-day",
|
||||
image: "/media/launch.webp",
|
||||
shortStory: "Short launch summary",
|
||||
fullStory: "<p>Complete launch story</p>",
|
||||
});
|
||||
expect(
|
||||
CONTENT_QUERY_DEFINITIONS["content.editorial.articles"].statement,
|
||||
).not.toMatch(/short_story|full_story/iu);
|
||||
});
|
||||
it("fails closed before production adapters are invoked", async () => {
|
||||
const load = vi.fn(async () => ready);
|
||||
const query = createContentQuery({ load });
|
||||
@@ -162,6 +197,32 @@ describe("Content query", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("fails closed when an article detail payload is incomplete", async () => {
|
||||
const query = createContentQuery({
|
||||
load: async () => ({
|
||||
kind: "editorial",
|
||||
items: [
|
||||
{
|
||||
id: "7",
|
||||
title: "Launch day",
|
||||
privatePayload: { slug: "launch-day" },
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
partialDependencies: [],
|
||||
}),
|
||||
});
|
||||
|
||||
const result = await query.run(context([PERMS.NEWS_VIEW]), {
|
||||
routeId: "content.editorial.article-detail",
|
||||
params: { id: "7" },
|
||||
});
|
||||
|
||||
expect(result).toMatchObject({
|
||||
ok: false,
|
||||
error: { code: "DEPENDENCY_UNAVAILABLE" },
|
||||
});
|
||||
});
|
||||
it("rejects a fake partial result and maps complete adapter failure", async () => {
|
||||
const malformed = createContentQuery({
|
||||
load: async () =>
|
||||
|
||||
Reference in new issue
Block a user