test: migrate plugin config fixtures

This commit is contained in:
Kit Langton 2026-05-18 22:14:01 -04:00 committed by GitHub
parent bcc69f0afb
commit d9d43d8519
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 47 additions and 69 deletions

View file

@ -925,49 +925,35 @@ test("installs dependencies in writable OPENCODE_CONFIG_DIR", async () => {
// core Npm.Service (via EffectFlock). Those behaviors are tested in the core
// package's npm tests, not here.
test("resolves scoped npm plugins in config", async () => {
await using tmp = await tmpdir({
init: async (dir) => {
const pluginDir = path.join(dir, "node_modules", "@scope", "plugin")
await fs.mkdir(pluginDir, { recursive: true })
it.instance("resolves scoped npm plugins in config", () =>
Effect.gen(function* () {
const test = yield* TestInstance
const pluginDir = path.join(test.directory, "node_modules", "@scope", "plugin")
yield* mkdirEffect(pluginDir)
yield* writeTextEffect(
path.join(test.directory, "package.json"),
JSON.stringify({ name: "config-fixture", version: "1.0.0", type: "module" }, null, 2),
)
yield* writeTextEffect(
path.join(pluginDir, "package.json"),
JSON.stringify(
{
name: "@scope/plugin",
version: "1.0.0",
type: "module",
main: "./index.js",
},
null,
2,
),
)
yield* writeTextEffect(path.join(pluginDir, "index.js"), "export default {}\n")
yield* writeConfigEffect(test.directory, { plugin: ["@scope/plugin"] })
await Filesystem.write(
path.join(dir, "package.json"),
JSON.stringify({ name: "config-fixture", version: "1.0.0", type: "module" }, null, 2),
)
await Filesystem.write(
path.join(pluginDir, "package.json"),
JSON.stringify(
{
name: "@scope/plugin",
version: "1.0.0",
type: "module",
main: "./index.js",
},
null,
2,
),
)
await Filesystem.write(path.join(pluginDir, "index.js"), "export default {}\n")
await Filesystem.write(
path.join(dir, "opencode.json"),
JSON.stringify({ $schema: "https://opencode.ai/config.json", plugin: ["@scope/plugin"] }, null, 2),
)
},
})
await provideTestInstance({
directory: tmp.path,
fn: async (ctx) => {
const config = await load(ctx)
const pluginEntries = config.plugin ?? []
expect(pluginEntries).toContain("@scope/plugin")
},
})
})
const config = yield* Config.Service.use((svc) => svc.get())
expect(config.plugin ?? []).toContain("@scope/plugin")
}),
)
test("merges plugin arrays from global and local configs", async () => {
await using tmp = await tmpdir({
@ -1015,37 +1001,28 @@ test("merges plugin arrays from global and local configs", async () => {
})
})
test("does not error when only custom agent is a subagent", async () => {
await using tmp = await tmpdir({
init: async (dir) => {
const opencodeDir = path.join(dir, ".opencode")
await fs.mkdir(opencodeDir, { recursive: true })
const agentDir = path.join(opencodeDir, "agent")
await fs.mkdir(agentDir, { recursive: true })
await Filesystem.write(
path.join(agentDir, "helper.md"),
`---
it.instance("does not error when only custom agent is a subagent", () =>
Effect.gen(function* () {
const test = yield* TestInstance
yield* mkdirEffect(path.join(test.directory, ".opencode", "agent"))
yield* writeTextEffect(
path.join(test.directory, ".opencode", "agent", "helper.md"),
`---
model: test/model
mode: subagent
---
Helper subagent prompt`,
)
},
})
await withTestInstance({
directory: tmp.path,
fn: async (ctx) => {
const config = await load(ctx)
expect(config.agent?.["helper"]).toMatchObject({
name: "helper",
model: "test/model",
mode: "subagent",
prompt: "Helper subagent prompt",
})
},
})
})
)
const config = yield* Config.Service.use((svc) => svc.get())
expect(config.agent?.["helper"]).toMatchObject({
name: "helper",
model: "test/model",
mode: "subagent",
prompt: "Helper subagent prompt",
})
}),
)
test("merges instructions arrays from global and local configs", async () => {
await using tmp = await tmpdir({

View file

@ -79,6 +79,7 @@ Repeated setup work, long sleeps/timeouts, serial integration tests, filesystem/
| Legacy tools and permission-order config cases can use Effect-aware instance fixtures | Migrated legacy `tools` migration and permission order cases to `it.instance` | 1.87s | 1.87s | keep | Neutral timing; removes more manual temp-instance plumbing from legacy config migration coverage. |
| Remaining simple config load cases can use Effect-aware instance fixtures | Migrated default config load and legacy TUI-key cases to `it.instance` | 7.78s | 6.39s | keep | Single baseline before edit; after median from three sequential reruns (5.76, 6.39, 6.53). Keep as cleanup with cautious timing. |
| Managed settings config cases can use Effect-aware instance fixtures | Migrated managed override and missing-managed-file cases to `it.instance` | 2.40s | 1.76s | keep | Single baseline before edit; after median from three sequential reruns (1.75, 1.76, 1.80). |
| Local plugin and subagent config fixtures can use Effect-aware instance fixtures | Migrated scoped npm plugin and custom subagent markdown cases to `it.instance` | 2.37s | 1.67s | keep | Single baseline before edit; after median from three sequential reruns (1.66, 1.67, 1.67). |
## Profiling Results