Skip to content

Commit dc9d6a0

Browse files
authored
test: migrate agent color config tests (anomalyco#27139)
1 parent af4ab01 commit dc9d6a0

1 file changed

Lines changed: 30 additions & 38 deletions

File tree

packages/opencode/test/config/agent-color.test.ts

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,50 @@
11
import { test, expect } from "bun:test"
22
import { Effect, Layer } from "effect"
33
import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
4-
import path from "path"
5-
import { provideInstance, tmpdirScoped } from "../fixture/fixture"
64
import { Config } from "@/config/config"
75
import { Agent as AgentSvc } from "../../src/agent/agent"
86
import { Color } from "@/util/color"
9-
import { AppRuntime } from "../../src/effect/app-runtime"
107
import { testEffect } from "../lib/effect"
118

12-
const it = testEffect(Layer.mergeAll(AgentSvc.defaultLayer, CrossSpawnSpawner.defaultLayer))
9+
const it = testEffect(Layer.mergeAll(Config.defaultLayer, AgentSvc.defaultLayer, CrossSpawnSpawner.defaultLayer))
1310

14-
const writeConfig = (dir: string, agent: Config.Info["agent"]) =>
15-
Effect.promise(() =>
16-
Bun.write(
17-
path.join(dir, "opencode.json"),
18-
JSON.stringify({
19-
$schema: "https://opencode.ai/config.json",
20-
agent,
21-
}),
22-
),
23-
)
24-
25-
it.live("agent color parsed from project config", () =>
26-
Effect.gen(function* () {
27-
const dir = yield* tmpdirScoped()
28-
yield* writeConfig(dir, {
29-
build: { color: "#FFA500" },
30-
plan: { color: "primary" },
31-
})
32-
33-
yield* Effect.gen(function* () {
34-
const cfg = yield* Effect.promise(() => AppRuntime.runPromise(Config.Service.use((svc) => svc.get())))
11+
it.instance(
12+
"agent color parsed from project config",
13+
() =>
14+
Effect.gen(function* () {
15+
const cfg = yield* Config.Service.use((svc) => svc.get())
3516
expect(cfg.agent?.["build"]?.color).toBe("#FFA500")
3617
expect(cfg.agent?.["plan"]?.color).toBe("primary")
37-
}).pipe(provideInstance(dir))
38-
}),
18+
}),
19+
{
20+
git: true,
21+
config: {
22+
agent: {
23+
build: { color: "#FFA500" },
24+
plan: { color: "primary" },
25+
},
26+
},
27+
},
3928
)
4029

41-
it.live("Agent.get includes color from config", () =>
42-
Effect.gen(function* () {
43-
const dir = yield* tmpdirScoped()
44-
yield* writeConfig(dir, {
45-
plan: { color: "#A855F7" },
46-
build: { color: "accent" },
47-
})
48-
49-
yield* Effect.gen(function* () {
30+
it.instance(
31+
"Agent.get includes color from config",
32+
() =>
33+
Effect.gen(function* () {
5034
const plan = yield* AgentSvc.Service.use((svc) => svc.get("plan"))
5135
expect(plan?.color).toBe("#A855F7")
5236
const build = yield* AgentSvc.Service.use((svc) => svc.get("build"))
5337
expect(build?.color).toBe("accent")
54-
}).pipe(provideInstance(dir))
55-
}),
38+
}),
39+
{
40+
git: true,
41+
config: {
42+
agent: {
43+
plan: { color: "#A855F7" },
44+
build: { color: "accent" },
45+
},
46+
},
47+
},
5648
)
5749

5850
test("Color.hexToAnsiBold converts valid hex to ANSI", () => {

0 commit comments

Comments
 (0)