Skip to content

Commit b581ff8

Browse files
authored
feat: add realistic sandbox plugin tests (emdash-cms#3084)
1 parent da171b3 commit b581ff8

47 files changed

Lines changed: 822 additions & 172 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/fresh-tools-test.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@emdash-cms/plugin-test": minor
3+
"@emdash-cms/plugin-cli": minor
4+
---
5+
6+
Adds a workerd-backed Vitest host for sandboxed plugin tests and includes it in projects created by `emdash-plugin init`. `emdashPluginTest()` builds the plugin and configures D1, Worker Loader, and the production `PluginBridge`; `createPluginTestHost()` invokes hooks and routes through the production sandbox boundary and provides helpers for content fixtures, plugin storage, and KV assertions.

apps/aggregator/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
},
3737
"devDependencies": {
3838
"@cloudflare/vite-plugin": "catalog:",
39-
"@cloudflare/vitest-pool-workers": "catalog:",
39+
"@cloudflare/vitest-plugin": "catalog:",
4040
"@emdash-cms/atproto-test-utils": "workspace:*",
4141
"@types/node": "catalog:",
4242
"typescript": "catalog:",

apps/aggregator/test/pds-verify.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* would re-implement what `@atcute/repo` already tests internally, and the
88
* consumer-level test path stubs verification via `ConsumerDeps.verify`
99
* (the FakePublisher / MockPds fixture from `@emdash-cms/atproto-test-utils`
10-
* can't load inside `@cloudflare/vitest-pool-workers` due to a transitive
10+
* can't load inside `@cloudflare/vitest-plugin` due to a transitive
1111
* `@atproto/lex-data` incompatibility; see records-consumer test header).
1212
*
1313
* What we DO test here is the surface every reason code can be reached

apps/aggregator/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// `wrangler types`) — referenced via `include` below. The vitest-pool
66
// types subpath provides the `cloudflare:test` ambient declarations
77
// for the smoke test rig.
8-
"types": ["@cloudflare/vitest-pool-workers/types"],
8+
"types": ["@cloudflare/vitest-plugin/types"],
99
"verbatimModuleSyntax": true,
1010
"noEmit": true
1111
},

apps/aggregator/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* us HMR + proper module resolution, `vite build` produces the deployable
77
* bundle that `wrangler deploy` ships.
88
*
9-
* Test config is separate: `vitest.config.ts` uses `@cloudflare/vitest-pool-workers`,
9+
* Test config is separate: `vitest.config.ts` uses `@cloudflare/vitest-plugin`,
1010
* which manages its own miniflare instance. The two pipelines don't share
1111
* configuration but read the same `wrangler.jsonc` for binding shape, so the
1212
* test environment matches dev/prod by construction.

apps/aggregator/vitest.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Aggregator test config.
33
*
4-
* Uses `@cloudflare/vitest-pool-workers` (v0.16+) so tests run inside a real
4+
* Uses `@cloudflare/vitest-plugin` so tests run inside a real
55
* workerd isolate with real D1, real DOs, and real Queues. The
66
* `cloudflareTest` plugin reads `wrangler.jsonc` for binding shape, so the
77
* test environment matches dev/prod by construction.
@@ -22,7 +22,7 @@
2222

2323
import { fileURLToPath } from "node:url";
2424

25-
import { cloudflareTest, readD1Migrations } from "@cloudflare/vitest-pool-workers";
25+
import { cloudflareTest, readD1Migrations } from "@cloudflare/vitest-plugin";
2626
import { defineConfig } from "vitest/config";
2727

2828
const migrationsPath = fileURLToPath(new URL("./migrations", import.meta.url));

apps/release-service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
"devDependencies": {
4343
"@cloudflare/vite-plugin": "catalog:",
44-
"@cloudflare/vitest-pool-workers": "catalog:",
44+
"@cloudflare/vitest-plugin": "catalog:",
4545
"@playwright/test": "^1.61.1",
4646
"@tailwindcss/vite": "^4.3.3",
4747
"@testing-library/react": "^16.3.0",

apps/release-service/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
4-
"types": ["@cloudflare/vitest-pool-workers/types", "node"],
4+
"types": ["@cloudflare/vitest-plugin/types", "node"],
55
"verbatimModuleSyntax": true,
66
"noEmit": true
77
},

apps/release-service/vitest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { cloudflareTest } from "@cloudflare/vitest-pool-workers";
1+
import { cloudflareTest } from "@cloudflare/vitest-plugin";
22
import { configDefaults, defineConfig } from "vitest/config";
33

44
import { TEST_ACCESS_AUDIENCES, TEST_ASSERTION_KEYSET } from "./test/fixtures/oauth.js";

apps/release-service/vitest.encryption-v2.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { cloudflareTest } from "@cloudflare/vitest-pool-workers";
1+
import { cloudflareTest } from "@cloudflare/vitest-plugin";
22
import { defineConfig } from "vitest/config";
33

44
import { TEST_ACCESS_AUDIENCES, TEST_ASSERTION_KEYSET } from "./test/fixtures/oauth.js";

0 commit comments

Comments
 (0)