feat(simulation): expose semantic UI snapshots (#37802)
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
import { expect, test } from "bun:test"
|
||||
import { permissionSemanticLabel } from "../../../src/routes/session/permission"
|
||||
|
||||
test("uses the permission action when a surface has no display title", () => {
|
||||
expect(permissionSemanticLabel("shell")).toBe("Permission required: shell")
|
||||
expect(permissionSemanticLabel("edit", "Edit fixture.txt")).toBe("Permission required: Edit fixture.txt")
|
||||
})
|
||||
@@ -0,0 +1,23 @@
|
||||
import { expect, test } from "bun:test"
|
||||
import { BoxRenderable } from "@opentui/core"
|
||||
import { Effect } from "effect"
|
||||
import { SimulationSemantics as Reader } from "@opencode-ai/simulation/frontend/semantics"
|
||||
import { SimulationRenderer } from "@opencode-ai/simulation/frontend/renderer"
|
||||
import { SimulationSemantics } from "../../src/simulation/semantics"
|
||||
|
||||
test("shares lazy semantic annotations with the simulation renderer", async () => {
|
||||
await Effect.runPromise(
|
||||
Effect.scoped(
|
||||
Effect.gen(function* () {
|
||||
const renderer = yield* SimulationRenderer.create({})
|
||||
const renderable = new BoxRenderable(renderer, { id: "permission" })
|
||||
let selected = false
|
||||
SimulationSemantics.bind(() => ({ role: "option", selected }))(renderable)
|
||||
|
||||
expect(Reader.read(renderable)?.()).toEqual({ role: "option", selected: false })
|
||||
selected = true
|
||||
expect(Reader.read(renderable)?.()).toEqual({ role: "option", selected: true })
|
||||
}),
|
||||
),
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user