33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "bun:test";
|
|
|
|
import { unwrapFrontendActionResult } from "../../.opencode/tools/frontend_action.js";
|
|
|
|
describe("frontend action tool bridge", () => {
|
|
it("returns only validated browser output for successful actions", () => {
|
|
expect(unwrapFrontendActionResult(JSON.stringify({
|
|
version: "frontend-action-result@1",
|
|
actionId: "action-1",
|
|
status: "succeeded",
|
|
output: { cleared: true },
|
|
completedAt: Date.now(),
|
|
}))).toBe('{"cleared":true}');
|
|
});
|
|
|
|
it("throws the browser error for failed and expired actions", () => {
|
|
expect(() => unwrapFrontendActionResult(JSON.stringify({
|
|
version: "frontend-action-result@1",
|
|
actionId: "action-1",
|
|
status: "failed",
|
|
error: { code: "WFS_UNAVAILABLE", message: "SCADA geometry query failed" },
|
|
completedAt: Date.now(),
|
|
}))).toThrow("WFS_UNAVAILABLE: SCADA geometry query failed");
|
|
expect(() => unwrapFrontendActionResult(JSON.stringify({
|
|
version: "frontend-action-result@1",
|
|
actionId: "action-2",
|
|
status: "expired",
|
|
error: { code: "ACTION_TIMEOUT", message: "browser action timed out" },
|
|
completedAt: Date.now(),
|
|
}))).toThrow("ACTION_TIMEOUT: browser action timed out");
|
|
});
|
|
});
|