chore: import upstream snapshot with attribution
CI / E2E Cloudflare (4/8) (push) Failing after 0s
CI / E2E Cloudflare (8/8) (push) Failing after 1s
CI / Lint (push) Failing after 1s
Auto Extract / Extract (push) Failing after 4s
CI / Version Check (push) Failing after 9s
CI / Integration Tests (push) Failing after 1s
CI / E2E tests (1/8) (push) Failing after 1s
CI / E2E tests (2/8) (push) Failing after 2s
CI / E2E tests (3/8) (push) Failing after 2s
CI / Browser Tests (push) Failing after 1s
CI / E2E tests (5/8) (push) Failing after 1s
CI / E2E Cloudflare (2/8) (push) Failing after 2s
CI / Typecheck (push) Failing after 1s
CI / Changeset Validation (push) Failing after 2s
CI / E2E Cloudflare (5/8) (push) Failing after 1s
CI / E2E Cloudflare (6/8) (push) Failing after 1s
CI / E2E Cloudflare (7/8) (push) Failing after 1s
CodeQL / Analyze (javascript-typescript) (push) Failing after 1s
Format / Format (push) Failing after 0s
CodeQL / Analyze (actions) (push) Failing after 4s
CI / E2E tests (4/8) (push) Failing after 1s
CI / E2E tests (6/8) (push) Failing after 1s
CI / E2E tests (7/8) (push) Failing after 2s
CI / E2E tests (8/8) (push) Failing after 1s
CI / E2E Cloudflare (1/8) (push) Failing after 1s
CI / E2E Cloudflare (3/8) (push) Failing after 2s
Preview Releases / Publish Preview (push) Failing after 0s
zizmor / Run zizmor (push) Failing after 1s
Release / Release (push) Failing after 2s
CI / Smoke Tests (push) Failing after 5m36s
CI / Tests (push) Failing after 6m36s
Release / Sync Templates (push) Has been skipped
CI / E2E Tests (push) Has been cancelled
CI / E2E Cloudflare (4/8) (push) Failing after 0s
CI / E2E Cloudflare (8/8) (push) Failing after 1s
CI / Lint (push) Failing after 1s
Auto Extract / Extract (push) Failing after 4s
CI / Version Check (push) Failing after 9s
CI / Integration Tests (push) Failing after 1s
CI / E2E tests (1/8) (push) Failing after 1s
CI / E2E tests (2/8) (push) Failing after 2s
CI / E2E tests (3/8) (push) Failing after 2s
CI / Browser Tests (push) Failing after 1s
CI / E2E tests (5/8) (push) Failing after 1s
CI / E2E Cloudflare (2/8) (push) Failing after 2s
CI / Typecheck (push) Failing after 1s
CI / Changeset Validation (push) Failing after 2s
CI / E2E Cloudflare (5/8) (push) Failing after 1s
CI / E2E Cloudflare (6/8) (push) Failing after 1s
CI / E2E Cloudflare (7/8) (push) Failing after 1s
CodeQL / Analyze (javascript-typescript) (push) Failing after 1s
Format / Format (push) Failing after 0s
CodeQL / Analyze (actions) (push) Failing after 4s
CI / E2E tests (4/8) (push) Failing after 1s
CI / E2E tests (6/8) (push) Failing after 1s
CI / E2E tests (7/8) (push) Failing after 2s
CI / E2E tests (8/8) (push) Failing after 1s
CI / E2E Cloudflare (1/8) (push) Failing after 1s
CI / E2E Cloudflare (3/8) (push) Failing after 2s
Preview Releases / Publish Preview (push) Failing after 0s
zizmor / Run zizmor (push) Failing after 1s
Release / Release (push) Failing after 2s
CI / Smoke Tests (push) Failing after 5m36s
CI / Tests (push) Failing after 6m36s
Release / Sync Templates (push) Has been skipped
CI / E2E Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
|
||||
vi.mock("emdash", () => ({
|
||||
definePlugin: (definition: unknown) => definition,
|
||||
}));
|
||||
|
||||
function createCtx() {
|
||||
return {
|
||||
kv: {
|
||||
get: vi.fn(async () => undefined),
|
||||
set: vi.fn(async () => undefined),
|
||||
},
|
||||
storage: {
|
||||
records: {
|
||||
get: vi.fn(async () => null),
|
||||
put: vi.fn(async () => undefined),
|
||||
},
|
||||
},
|
||||
http: {
|
||||
fetch: vi.fn(),
|
||||
},
|
||||
log: {
|
||||
info: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
error: vi.fn(),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
describe("sandbox hooks", () => {
|
||||
it("does not create syndication records from afterSave when published content has not been synced", async () => {
|
||||
const { default: plugin } = await import("../src/plugin.js");
|
||||
const ctx = createCtx();
|
||||
const handler = (plugin as any).hooks["content:afterSave"].handler;
|
||||
|
||||
await handler(
|
||||
{
|
||||
collection: "posts",
|
||||
isNew: false,
|
||||
content: {
|
||||
id: "post-1",
|
||||
status: "published",
|
||||
title: "A published edit",
|
||||
},
|
||||
},
|
||||
ctx,
|
||||
);
|
||||
|
||||
expect(ctx.storage.records.get).toHaveBeenCalledWith("posts:post-1");
|
||||
expect(ctx.storage.records.put).not.toHaveBeenCalled();
|
||||
expect(ctx.http.fetch).not.toHaveBeenCalled();
|
||||
expect(ctx.kv.get).not.toHaveBeenCalledWith("settings:siteUrl");
|
||||
});
|
||||
|
||||
it("does not syndicate pages by default", async () => {
|
||||
const { default: plugin } = await import("../src/plugin.js");
|
||||
const ctx = createCtx();
|
||||
const handler = (plugin as any).hooks["content:afterPublish"].handler;
|
||||
|
||||
await handler(
|
||||
{
|
||||
collection: "pages",
|
||||
content: {
|
||||
id: "page-1",
|
||||
status: "published",
|
||||
title: "About",
|
||||
},
|
||||
},
|
||||
ctx,
|
||||
);
|
||||
|
||||
expect(ctx.kv.get).toHaveBeenCalledWith("settings:collections");
|
||||
expect(ctx.storage.records.get).not.toHaveBeenCalled();
|
||||
expect(ctx.storage.records.put).not.toHaveBeenCalled();
|
||||
expect(ctx.http.fetch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not expose standard.site metadata for pages by default", async () => {
|
||||
const { default: plugin } = await import("../src/plugin.js");
|
||||
const ctx = createCtx();
|
||||
ctx.storage.records.get.mockResolvedValueOnce({
|
||||
atUri: "at://did:example/site.standard.document/abc",
|
||||
status: "synced",
|
||||
});
|
||||
|
||||
const result = await (plugin as any).hooks["page:metadata"](
|
||||
{
|
||||
page: {
|
||||
content: {
|
||||
collection: "pages",
|
||||
id: "page-1",
|
||||
},
|
||||
},
|
||||
},
|
||||
ctx,
|
||||
);
|
||||
|
||||
expect(result).toBeNull();
|
||||
expect(ctx.kv.get).toHaveBeenCalledWith("settings:collections");
|
||||
expect(ctx.storage.records.get).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user