Repository navigation
test(ui): keep tests off the developer's real config and state files - #1365
Open
yongjincho wants to merge 1 commit into
Open
yongjincho wants to merge 1 commit into
yongjincho wants to merge 1 commit into
Conversation
Running `bun run test` rewrote the developer's global config.toml and
added extension trust entries for deleted temp repos to their state.json.
- HunkSessionHost "blocks reopening until dirty-quit cancellation
settles" called pressKey("escape"). OpenTUI's KeyCodes only has
ESCAPE, so the mock typed e, s, c, a, p, e. `s` is the prompt's save
key, so the test saved view preferences to the real config.toml
instead of cancelling. Send a real Escape, let the lone ESC byte
flush, and assert the prompt closed before pressing Enter.
- AppHost.extensions and AppHost.status-line isolated XDG_CONFIG_HOME
only. Trust decisions moved to $XDG_STATE_HOME/hunk/state.json in
modem-dev#920, so they landed in ~/.local/state/hunk/state.json. Isolate
XDG_STATE_HOME as well and drop a comment that credited the config
override with that isolation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
This PR does not match any of the 1 configured review trigger rule. |
Member
|
Oof good find |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
bun run testshould not touch the developer's own Hunk files. Today one run rewrites~/.config/hunk/config.tomlwiththeme = "github-dark-dimmed"and the other view-preference defaults. It also addsextensionTrustentries for deleted temp repos to~/.local/state/hunk/state.json.What changed
HunkSessionHost.test.tsx, "blocks reopening until dirty-quit cancellation settles", meant to cancel the save-view-preferences prompt withpressKey("escape"). OpenTUI'sKeyCodesonly hasESCAPE, so the mock typede,s,c,a,p,e.sis the prompt's save key, so the test saved to the global config instead of cancelling. The test now callspressEscape()and waits past the stdin parser's 20 ms lone-ESC timeout. Without that wait, ESC and the next Enter parse as meta+return, which also saves. It then asserts that the prompt closed before it presses Enter. This was the onlypressKey("escape")in the repo.AppHost.extensions.test.tsxandAppHost.status-line.test.tsxisolated onlyXDG_CONFIG_HOME. fix: store persistent state under XDG state directory #920 moved trust decisions to$XDG_STATE_HOME/hunk/state.json. Both files now also pointXDG_STATE_HOMEat a temp directory and restore it after each test. I removed one comment that credited the config override with that isolation.Scope
app/documents/documentSaveClaim.test.tsstill creates an empty~/.config/hunk/document-save-claims/<host>/. It resolves the account home from OS records on purpose, so redirecting it needs its own discussion.Verification
I ran each file with
HOMEandXDG_CONFIG_HOMEset to a fresh temp directory and listed theconfig.tomlandstate.jsonfiles left there.ui/session/HunkSessionHost.test.tsxxdg/hunk/config.tomlui/AppHost.extensions.test.tsx.local/state/hunk/state.jsonui/AppHost.status-line.test.tsx.local/state/hunk/state.jsonpressEscape()and no wait, the dirty-quit test failed 5 of 5 runs and wroteconfig.toml. With a 20 ms or 60 ms wait, it passed 5 of 5.bun run testwith the same isolation. It left neither file and finished with 5969 pass and 10 fail. The same 10 tests fail onmainon this machine (macOS, Bun 1.4.5). They hit/varvs/private/varpath mismatches inAppHost.reload,filesystemSource.observe,brokerLauncher,installedPackageResolution, andhostRuntimeModules.bun run typecheck,bun run lint, andbun run format:checkpass. I tested on macOS only.🤖 Generated with Claude Code