test(display): encode provenance contract in tilde assertions
Two tests still encoded the pre-PR behaviour that the PR removes:
- tests/test_tui_gateway_server.py: the mirrored fixture carries no
`context_estimated` flag, so under the PR's rule it is provider-reported
usage and must render without `~`. The old expectation asserted the
unconditional tilde main used to emit. Assert the flag-less case is
unmarked and, in the same test, flip `context_estimated` both ways to
pin that only the estimate carries `~` in the count and the percent.
- ui-tui appChromeStatusRule.test.tsx: `text.includes('~')` matched the
`~/repo` cwd label, so the "not estimated" arm was always true. Extract
the rendered context token and assert the tilde on that token only.
This commit is contained in:
@@ -10868,7 +10868,7 @@ def test_slash_exec_r7_read_commands_use_metadata_mirror_flag_on(monkeypatch):
|
||||
"history": "live question from state db",
|
||||
"prompt": "host system prompt",
|
||||
"status": "Tokens: 140",
|
||||
"context": "Context usage: ~80 / 1,000 tokens",
|
||||
"context": "Context usage: 80 / 1,000 tokens",
|
||||
"tools": "terminal",
|
||||
"help": "/status",
|
||||
}
|
||||
@@ -10886,6 +10886,16 @@ def test_slash_exec_r7_read_commands_use_metadata_mirror_flag_on(monkeypatch):
|
||||
assert expected in resp["result"]["output"]
|
||||
assert "stale parent mirror" not in resp["result"]["output"]
|
||||
assert "(._.)" not in resp["result"]["output"]
|
||||
mirrored_usage = server._sessions["sid"]["_metadata_mirror"]["usage"]
|
||||
for estimated in (True, False):
|
||||
mirrored_usage["context_estimated"] = estimated
|
||||
mirrored_usage["context_source"] = "local_estimate" if estimated else "provider_usage"
|
||||
response = server.handle_request({
|
||||
"id": "context-provenance", "method": "slash.exec",
|
||||
"params": {"command": "context", "session_id": "sid"},
|
||||
})
|
||||
mark = "~" if estimated else ""
|
||||
assert f"Context usage: {mark}80 / 1,000 tokens ({mark}8.0%)" in response["result"]["output"]
|
||||
finally:
|
||||
server._sessions.pop("sid", None)
|
||||
|
||||
|
||||
@@ -114,7 +114,10 @@ describe('StatusRule session title', () => {
|
||||
usage: { ...baseProps.usage, context_estimated: estimated }
|
||||
}))
|
||||
|
||||
expect(text.includes('~')).toBe(estimated)
|
||||
const context = text.match(/(~?\d+(?:\.\d+)?k(?:\/\d+k| tok))/)?.[1]
|
||||
|
||||
expect(context, `context must render at ${cols} columns`).toBeTruthy()
|
||||
expect(context?.startsWith('~')).toBe(estimated)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user