From 75cd3f560b622b8390b22ddb27fff1d447388875 Mon Sep 17 00:00:00 2001 From: JeremyDev87 Date: Sun, 12 Apr 2026 13:42:45 +0900 Subject: [PATCH] fix(tests): isolate HUD state file in TestIntegration subprocess tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set CODINGBUDDY_HUD_STATE_FILE to a nonexistent path so integration tests don't read the live session's hud_state.json. Previously, the subprocess picked up the real session mode (e.g. PLAN → ◔‿◔ thinking face) instead of the expected idle face (◕‿◕). --- packages/claude-code-plugin/tests/test_hud.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/claude-code-plugin/tests/test_hud.py b/packages/claude-code-plugin/tests/test_hud.py index 64f63f55..a776db30 100644 --- a/packages/claude-code-plugin/tests/test_hud.py +++ b/packages/claude-code-plugin/tests/test_hud.py @@ -743,6 +743,14 @@ def test_no_content_with_blockers_returns_empty(self): class TestIntegration: + # Isolate HUD state so tests don't read the real session file. + # Without this, select_face_from_state picks up the live session's + # mode (e.g. PLAN → ◔‿◔) instead of returning the idle face (◕‿◕). + _ISOLATED_ENV = { + **os.environ, + "CODINGBUDDY_HUD_STATE_FILE": "/tmp/_test_hud_nonexistent_state.json", + } + def test_pipe_stdin(self): """Run the script as a subprocess with piped stdin.""" script = os.path.join(_hooks_dir, "codingbuddy-hud.py") @@ -766,6 +774,7 @@ def test_pipe_stdin(self): input=stdin_data, capture_output=True, text=True, + env=self._ISOLATED_ENV, ) assert result.returncode == 0 assert "\u25d5\u203f\u25d5" in result.stdout # ◕‿◕ @@ -793,6 +802,7 @@ def test_pipe_stdin_estimated_cost(self): input=stdin_data, capture_output=True, text=True, + env=self._ISOLATED_ENV, ) assert result.returncode == 0 assert "~$" in result.stdout @@ -805,6 +815,7 @@ def test_empty_stdin_fallback(self): input="", capture_output=True, text=True, + env=self._ISOLATED_ENV, ) assert result.returncode == 0 assert "\u25d5\u203f\u25d5" in result.stdout