b3a7f98e5a
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
114 lines
3.3 KiB
TypeScript
114 lines
3.3 KiB
TypeScript
/**
|
|
* Smoke test for the aggregator's test infrastructure.
|
|
*
|
|
* Proves the workers-pool wiring is healthy: migrations apply into the test
|
|
* D1 instance, the schema accepts a write, and the worker module loads. No
|
|
* business logic is exercised — the actual ingest and read paths are tested
|
|
* in their own files as later PRs land them.
|
|
*
|
|
* If this test fails after a migration change, fix the migration; the rest
|
|
* of the suite assumes this passes.
|
|
*/
|
|
|
|
import { applyD1Migrations, env } from "cloudflare:test";
|
|
import { beforeAll, describe, expect, it } from "vitest";
|
|
|
|
interface TestEnv {
|
|
DB: D1Database;
|
|
TEST_MIGRATIONS: Parameters<typeof applyD1Migrations>[1];
|
|
}
|
|
|
|
const testEnv = env as unknown as TestEnv;
|
|
|
|
beforeAll(async () => {
|
|
await applyD1Migrations(testEnv.DB, testEnv.TEST_MIGRATIONS);
|
|
});
|
|
|
|
describe("aggregator scaffold smoke test", () => {
|
|
it("applies the initial migration and round-trips a packages row", async () => {
|
|
const now = new Date().toISOString();
|
|
await testEnv.DB.prepare(
|
|
`INSERT INTO packages (
|
|
did, slug, type, license, authors, security, record_blob, verified_at
|
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
)
|
|
.bind(
|
|
"did:plc:test",
|
|
"smoke",
|
|
"emdash-plugin",
|
|
"MIT",
|
|
JSON.stringify([{ name: "Tester" }]),
|
|
JSON.stringify([{ email: "x@y.test" }]),
|
|
new Uint8Array([0x00]),
|
|
now,
|
|
)
|
|
.run();
|
|
|
|
const row = await testEnv.DB.prepare(
|
|
"SELECT did, slug, license FROM packages WHERE did = ? AND slug = ?",
|
|
)
|
|
.bind("did:plc:test", "smoke")
|
|
.first<{ did: string; slug: string; license: string }>();
|
|
|
|
expect(row).not.toBeNull();
|
|
expect(row?.license).toBe("MIT");
|
|
});
|
|
|
|
it("populates packages_fts on insert via trigger", async () => {
|
|
const now = new Date().toISOString();
|
|
await testEnv.DB.prepare(
|
|
`INSERT INTO packages (
|
|
did, slug, type, name, description, license, authors, security, record_blob, verified_at
|
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
)
|
|
.bind(
|
|
"did:plc:fts",
|
|
"searchable",
|
|
"emdash-plugin",
|
|
"A Searchable Plugin",
|
|
"Does something searchable",
|
|
"MIT",
|
|
JSON.stringify([{ name: "Tester" }]),
|
|
JSON.stringify([{ email: "x@y.test" }]),
|
|
new Uint8Array([0x00]),
|
|
now,
|
|
)
|
|
.run();
|
|
|
|
const result = await testEnv.DB.prepare(
|
|
"SELECT p.slug FROM packages_fts JOIN packages p ON p.rowid = packages_fts.rowid WHERE packages_fts MATCH ?",
|
|
)
|
|
.bind("searchable")
|
|
.first<{ slug: string }>();
|
|
|
|
expect(result?.slug).toBe("searchable");
|
|
});
|
|
|
|
it("rejects a release whose did/package does not match an existing profile (FK)", async () => {
|
|
// Releases reference packages via composite FK; SQLite enforces this when
|
|
// FK checks are enabled. workers-pool's miniflare D1 has FK checks on by
|
|
// default per Cloudflare's runtime configuration.
|
|
const now = new Date().toISOString();
|
|
const insertOrphan = testEnv.DB.prepare(
|
|
`INSERT INTO releases (
|
|
did, package, version, rkey, version_sort, artifacts, emdash_extension, cts, record_blob, verified_at
|
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
)
|
|
.bind(
|
|
"did:plc:orphan",
|
|
"nonexistent",
|
|
"1.0.0",
|
|
"nonexistent:1.0.0",
|
|
"00000000001.00000000000.00000000000.zzz",
|
|
"{}",
|
|
"{}",
|
|
now,
|
|
new Uint8Array([0x00]),
|
|
now,
|
|
)
|
|
.run();
|
|
|
|
await expect(insertOrphan).rejects.toThrow();
|
|
});
|
|
});
|