Skip to content

Commit 1b1746a

Browse files
author
SqlRush
committed
Accept wrapped single expectation fields
1 parent 1555f78 commit 1b1746a

5 files changed

Lines changed: 94 additions & 0 deletions

File tree

docs/cc-100-roadmap.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,8 @@ M7 补充:prompt history `LogEntry` 读取现在接受 `sessionID`/`session`/`
610610

611611
本轮补充:interaction script 的 direct expectation collection alias 字段现在也递归解包 wrapper;`expectEvents``expectDialogResults` 可从 wrapped `events`/`results`/`items`/`nodes` 中恢复结构化断言列表,避免 wrapper collection fixture 被当成空对象断言。
612612

613+
本轮补充:interaction script 的 direct single expectation alias 字段现在也递归解包 wrapper;`expectEvent``expectDialogResult` 可从 wrapped `event`/`result`/`expected` 中恢复结构化单项断言,避免 wrapper fixture 被当成空 expectation。
614+
613615
本轮补充:interaction script action/type/kind/name/operation 动作判别字段现在也接受 compact/camel event/media aliases,包括 `focusIn``focusOut``mouseEvent``pasteImage``imagePaste`
614616

615617
本轮补充:interaction script 的 mouseEvent/pasteImage action payload 现在递归解包 JSON:API/GraphQL-style `resource`/`attributes`/`properties`/`attrs`/`edge.node` wrapper,wrapped mouse 坐标/按钮和 image filename/media/content 可直接驱动 dialog click 与 image paste。

docs/claude-code-go-rewrite-plan.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ test/parity/ # golden tests against TS/official behavior
316316
- 本轮补充:interaction script 的 direct expectation count alias 字段现在也递归解包 wrapper;`expectEventCount``expectTotalEventCount``expectDialogResultCount``expectTotalDialogResultCount` 可从 wrapped `value`/`count`/`total` 恢复计数断言。
317317
- 本轮补充:interaction script 的 direct expectation string-list alias 字段现在也递归解包 wrapper;`expectStatusContains`/`NotContains``expectSnapshotContains`/`NotContains` 可从 wrapped `value`/`values`/`contains`/`items` 恢复断言列表。
318318
- 本轮补充:interaction script 的 direct expectation collection alias 字段现在也递归解包 wrapper;`expectEvents``expectDialogResults` 可从 wrapped `events`/`results`/`items`/`nodes` 中恢复结构化断言列表。
319+
- 本轮补充:interaction script 的 direct single expectation alias 字段现在也递归解包 wrapper;`expectEvent``expectDialogResult` 可从 wrapped `event`/`result`/`expected` 中恢复结构化单项断言。
319320
- 本轮补充:interaction script action/type/kind/name/operation 动作判别字段继续接受 compact/camel event/media aliases,包括 `focusIn``focusOut``mouseEvent``pasteImage``imagePaste`
320321
- 本轮补充:interaction script mouseEvent/pasteImage action payload 现在递归解包 JSON:API/GraphQL-style `resource`/`attributes`/`properties`/`attrs`/`edge.node` wrapper,wrapped mouse 坐标/按钮和 image filename/media/content 可直接驱动 dialog click 与 image paste。
321322
- 本轮补充:interaction script action/type/kind/name/operation 动作判别字段也可驱动 runtime/dialog mutation,支持 `requestPermission``taskStatus``showTasks``cancelTasks``removeTask``showDialog` 等动作,并从 `value`/`payload`/`data`/`body` 载荷解析对象、ID 或取消原因。

docs/first-second-parity-audit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ M7 progress now includes:
296296
- `internal/tui`: direct scripted expectation count aliases such as `expectEventCount`, `expectTotalEventCount`, `expectDialogResultCount`, and `expectTotalDialogResultCount` now recursively unwrap numeric JSON:API/GraphQL-style wrapper objects.
297297
- `internal/tui`: direct scripted expectation string-list aliases such as `expectStatusContains`, `expectStatusNotContains`, `expectSnapshotContains`, and `expectSnapshotNotContains` now recursively unwrap JSON:API/GraphQL-style wrapper objects.
298298
- `internal/tui`: direct scripted expectation collection aliases such as `expectEvents` and `expectDialogResults` now recursively unwrap JSON:API/GraphQL-style wrapper objects.
299+
- `internal/tui`: direct scripted single expectation aliases such as `expectEvent` and `expectDialogResult` now recursively unwrap JSON:API/GraphQL-style wrapper objects.
299300
- `internal/tui`: terminal key parsing now accepts CSI-u/kitty keyboard protocol sequences for existing ctrl/alt editing keys, shift-enter, shift-tab, and printable shift-only runes.
300301
- `internal/tui`: terminal CSI-u/kitty keyboard parsing now also accepts colon-suffixed alternate codepoint and modifier event-type fields such as `CSI 97:65;5:1u`.
301302
- `internal/tui`: terminal CSI-u/kitty keyboard parsing now also accepts base/unmodified sequences such as `CSI 97u` and `CSI 13;1u`, mapping printable runes plus Enter, Tab, Esc, and Backspace instead of treating ordinary extended-key reports as unknown.

internal/tui/script_aliases.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,21 @@ func (step *ScriptStep) UnmarshalJSON(data []byte) error {
835835
if fields.ExpectEventCamel != nil {
836836
step.ExpectEvent = fields.ExpectEventCamel
837837
}
838+
if events := scriptNamedEventListField(fieldMap,
839+
[]string{"expect_event", "expectEvent"},
840+
"event",
841+
"expected_event",
842+
"expectedEvent",
843+
"expected",
844+
"items",
845+
"entries",
846+
"nodes",
847+
"results",
848+
"value",
849+
); len(events) > 0 {
850+
event := events[0]
851+
step.ExpectEvent = &event
852+
}
838853
if events := scriptNamedEventListField(fieldMap,
839854
[]string{"expect_events", "expectEvents"},
840855
"events",
@@ -880,6 +895,22 @@ func (step *ScriptStep) UnmarshalJSON(data []byte) error {
880895
if fields.ExpectDialogResultCamel != nil {
881896
step.ExpectDialogResult = fields.ExpectDialogResultCamel
882897
}
898+
if results := scriptNamedDialogResultListField(fieldMap,
899+
[]string{"expect_dialog_result", "expectDialogResult"},
900+
"dialog_result",
901+
"dialogResult",
902+
"result",
903+
"expected_result",
904+
"expectedResult",
905+
"expected",
906+
"items",
907+
"entries",
908+
"nodes",
909+
"value",
910+
); len(results) > 0 {
911+
result := results[0]
912+
step.ExpectDialogResult = &result
913+
}
883914
if results := scriptNamedDialogResultListField(fieldMap,
884915
[]string{"expect_dialog_results", "expectDialogResults"},
885916
"dialog_results",

internal/tui/tui_test.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7085,6 +7085,65 @@ func TestRunInteractionScriptAcceptsWrappedExpectationCollectionAliasFields(t *t
70857085
}
70867086
}
70877087

7088+
func TestRunInteractionScriptAcceptsWrappedSingleExpectationAliasFields(t *testing.T) {
7089+
steps, err := ParseInteractionScript([]byte(`[
7090+
{"input": "go", "expectPrompt": {"text": "go"}},
7091+
{
7092+
"key": "enter",
7093+
"expectEvent": {
7094+
"resource": {
7095+
"attributes": {
7096+
"event": {"type": "prompt_submitted", "value": "go"}
7097+
}
7098+
}
7099+
}
7100+
}
7101+
]`))
7102+
if err != nil {
7103+
t.Fatal(err)
7104+
}
7105+
if len(steps) != 2 || steps[1].ExpectEvent == nil ||
7106+
steps[1].ExpectEvent.Type != ScreenEventPromptSubmitted ||
7107+
steps[1].ExpectEvent.Value != "go" {
7108+
t.Fatalf("expect event = %#v", steps[1].ExpectEvent)
7109+
}
7110+
screen := NewREPLScreen(30, 6, nil)
7111+
if _, err := RunInteractionScriptChecked(&screen, steps); err != nil {
7112+
t.Fatal(err)
7113+
}
7114+
7115+
dialogSteps, err := ParseInteractionScript([]byte(`[
7116+
{"request_permission": {"id": "perm_1", "tool_name": "Bash"}},
7117+
{
7118+
"key": "enter",
7119+
"expectDialogResult": {
7120+
"edge": {
7121+
"node": {
7122+
"attrs": {
7123+
"result": {"id": "perm_1", "status": "allowed", "found": true}
7124+
}
7125+
}
7126+
}
7127+
}
7128+
}
7129+
]`))
7130+
if err != nil {
7131+
t.Fatal(err)
7132+
}
7133+
if len(dialogSteps) != 2 || dialogSteps[1].ExpectDialogResult == nil ||
7134+
dialogSteps[1].ExpectDialogResult.ID != "perm_1" ||
7135+
dialogSteps[1].ExpectDialogResult.Status != DialogResultAllowed ||
7136+
dialogSteps[1].ExpectDialogResult.Found == nil ||
7137+
!*dialogSteps[1].ExpectDialogResult.Found {
7138+
t.Fatalf("expect dialog result = %#v", dialogSteps[1].ExpectDialogResult)
7139+
}
7140+
dialogScreen := NewREPLScreen(40, 8, nil)
7141+
runtime := NewDialogRuntime()
7142+
if _, err := RunDialogRuntimeScriptChecked(&dialogScreen, runtime, "ready", dialogSteps); err != nil {
7143+
t.Fatal(err)
7144+
}
7145+
}
7146+
70887147
func TestRunInteractionScriptAcceptsExpectationWrappers(t *testing.T) {
70897148
steps, err := ParseInteractionScript([]byte(`[
70907149
{

0 commit comments

Comments
 (0)