gitflarePublicPartly agent-ready50
cf-workflows-pipeline
Durable content pipeline on Cloudflare Workflows: ingest, extract, summarise with Workers AI via AI Gateway, human approval, publish.
- LicenseApache-2.0
- LanguageTypeScript
- Last landed
629b2faOct 20, 2026
Fix pipeline runs failing at ingest (steps.attempt NOT NULL)
629b2faimport { describe, it, expect, vi } from "vitest";vi.mock("cloudflare:workers", () => ({ WorkflowEntrypoint: class {} }));import { handle } from "../src/index";import type { Env } from "../src/env"; function fakeEnv(first: unknown = null) { const created: unknown[] = []; const db = { prepare: () => ({ bind: () => ({ run: async () => ({}), first: async () => first, all: async () => ({ results: [] }) }) }) }; const env = { DB: db, ASSETS: { fetch: async () => new Response("asset") }, PIPELINE: { create: async (x: unknown) => created.push(x), get: async () => ({ sendEvent: async () => {}, status: async () => ({}) }) } } as unknown as Env; return { env, created };}const post = (b: unknown) => new Request("http://x/api/runs", { method: "POST", body: JSON.stringify(b) }); describe("routes", () => { it("health", async () => { const r = await handle(new Request("http://x/health"), fakeEnv().env); expect(await r.json()).toMatchObject({ ok: true }); }); it("creates run", async () => { const f = fakeEnv(); const r = await handle(post({ url: "https://example.com", failures: { extract: 1 } }), f.env); expect(r.status).toBe(201); expect(f.created).toHaveLength(1); }); it("rejects private url", async () => { expect((await handle(post({ url: "http://127.0.0.1" }), fakeEnv().env)).status).toBe(400); }); it("404 for unknown run, 409 when not awaiting", async () => { expect((await handle(new Request("http://x/api/runs/abc"), fakeEnv().env)).status).toBe(404); const r = await handle(new Request("http://x/api/runs/abc/approve", { method: "POST" }), fakeEnv({ id: "abc", status: "running" }).env); expect(r.status).toBe(409); });});