feat: upgrade investigation and presentation runtime
This commit is contained in:
@@ -1,11 +1,21 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
|
||||
import { tool } from "../../.opencode/tool.js";
|
||||
import presentView from "../../.opencode/tools/present_view.js";
|
||||
import { unwrapFrontendActionResult } from "../../.opencode/tools/frontend_action.js";
|
||||
|
||||
describe("frontend action tool bridge", () => {
|
||||
it("accepts a presentation without a reason and trims optional explanations", () => {
|
||||
const schema = tool.schema.object(presentView.args);
|
||||
const command = { action: "clear_highlights" };
|
||||
expect(schema.parse({ command })).toEqual({ command });
|
||||
expect(schema.parse({ command, reason: " 清理上轮定位 " }).reason).toBe("清理上轮定位");
|
||||
expect(schema.safeParse({ command, reason: " " }).success).toBeFalse();
|
||||
});
|
||||
|
||||
it("returns only validated browser output for successful actions", () => {
|
||||
expect(unwrapFrontendActionResult(JSON.stringify({
|
||||
version: "frontend-action-result@1",
|
||||
version: "frontend-action-result@2",
|
||||
actionId: "action-1",
|
||||
status: "succeeded",
|
||||
output: { cleared: true },
|
||||
@@ -15,14 +25,14 @@ describe("frontend action tool bridge", () => {
|
||||
|
||||
it("throws the browser error for failed and expired actions", () => {
|
||||
expect(() => unwrapFrontendActionResult(JSON.stringify({
|
||||
version: "frontend-action-result@1",
|
||||
version: "frontend-action-result@2",
|
||||
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",
|
||||
version: "frontend-action-result@2",
|
||||
actionId: "action-2",
|
||||
status: "expired",
|
||||
error: { code: "ACTION_TIMEOUT", message: "browser action timed out" },
|
||||
|
||||
Reference in New Issue
Block a user