返回 DeepSeek-Reasonix
initial_goal_submit_target_test.go
根目录 / desktop / initial_goal_submit_target_test.go
1 package main
2
3 import (
4 "testing"
5
6 "reasonix/internal/control"
7 )
8
9 type initialGoalSubmitRecorder struct {
10 control.SessionAPI
11 display string
12 input string
13 invocations []control.InvocationRequest
14 }
15
16 func (r *initialGoalSubmitRecorder) SubmitDisplay(display, input string) {
17 r.display = display
18 r.input = input
19 }
20
21 func (r *initialGoalSubmitRecorder) SubmitInvocationDisplay(
22 display, input string,
23 invocations []control.InvocationRequest,
24 ) {
25 r.display = display
26 r.input = input
27 r.invocations = append([]control.InvocationRequest(nil), invocations...)
28 }
29
30 func TestSubmitInitialGoalAcceptsCurrentLocalTarget(t *testing.T) {
31 app := testAppWithOrderedTabs(t, "a", "a")
32 ctrl := control.New(control.Options{Label: "test"})
33 defer ctrl.Close()
34 recorder := &initialGoalSubmitRecorder{SessionAPI: ctrl}
35 tab := app.tabs["a"]
36 tab.Ctrl = recorder
37
38 _, err := app.SubmitInitialGoalToTab(
39 tab.ID,
40 "ship the fix",
41 "/ui-ux-pro-max ship the fix",
42 "ship the fix",
43 []InvocationRequest{{Name: "ui-ux-pro-max", Kind: "skill", Offset: 4}},
44 "normal",
45 "ask",
46 )
47 if err != nil {
48 t.Fatal(err)
49 }
50 if tab.goal != "ship the fix" {
51 t.Fatalf("tab goal = %q, want %q", tab.goal, "ship the fix")
52 }
53 if got := ctrl.Goal(); got != "ship the fix" {
54 t.Fatalf("controller goal = %q, want %q", got, "ship the fix")
55 }
56 if recorder.display != "/ui-ux-pro-max ship the fix" || recorder.input != "ship the fix" {
57 t.Fatalf("recorded submit = display %q input %q", recorder.display, recorder.input)
58 }
59 if len(recorder.invocations) != 1 {
60 t.Fatalf("recorded invocations = %+v, want one", recorder.invocations)
61 }
62 if got := recorder.invocations[0]; got.Name != "ui-ux-pro-max" || got.Kind != "skill" || got.Offset != 4 {
63 t.Fatalf("recorded invocation = %+v", got)
64 }
65 }
66
67 func TestSubmitInitialGoalAppliesToolApprovalProfileBeforeSubmit(t *testing.T) {
68 app := testAppWithOrderedTabs(t, "a", "a")
69 ctrl := control.New(control.Options{Label: "test"})
70 defer ctrl.Close()
71 recorder := &initialGoalSubmitRecorder{SessionAPI: ctrl}
72 tab := app.tabs["a"]
73 tab.Ctrl = recorder
74
75 _, err := app.SubmitInitialGoalToTab(
76 tab.ID,
77 "ship with YOLO",
78 "ship with YOLO",
79 "ship with YOLO",
80 nil,
81 "normal",
82 string(control.ToolApprovalYolo),
83 )
84 if err != nil {
85 t.Fatal(err)
86 }
87 if tab.toolApprovalMode != string(control.ToolApprovalYolo) {
88 t.Fatalf("tab approval mode = %q, want %q", tab.toolApprovalMode, control.ToolApprovalYolo)
89 }
90 if got := recorder.ToolApprovalMode(); got != string(control.ToolApprovalYolo) {
91 t.Fatalf("controller approval mode = %q, want %q", got, control.ToolApprovalYolo)
92 }
93 if recorder.input != "ship with YOLO" {
94 t.Fatalf("recorded input = %q, want first Goal input", recorder.input)
95 }
96 }
97
97 lines GO