Skip to content

Commit 2528c59

Browse files
committed
test(progress[coverage]): add comprehensive tests for spinner and build progress
why: The progress spinner and its CLI wiring need thorough test coverage for BuildTree state, template rendering, bar generation, panel behavior, and CLI flag handling. what: - Add tests/cli/test_progress.py covering Spinner lifecycle, BuildTree state transitions, template presets, bar rendering, panel lines, ANSI truncation, non-TTY fallback, and success output - Add tests/workspace/test_progress.py for builder callback integration - Update tests/cli/test_load.py for progress output assertions
1 parent 12e5f12 commit 2528c59

3 files changed

Lines changed: 1763 additions & 0 deletions

File tree

tests/cli/test_load.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,86 @@ def test_load_no_ansi_in_nontty_stderr(
807807
assert "\x1b[" not in captured.err, "ANSI codes leaked into non-TTY stderr"
808808

809809

810+
class ProgressDisableFixture(t.NamedTuple):
811+
"""Test fixture for progress disable logic."""
812+
813+
test_id: str
814+
env_value: str | None
815+
no_progress_flag: bool
816+
expected_disabled: bool
817+
818+
819+
PROGRESS_DISABLE_FIXTURES: list[ProgressDisableFixture] = [
820+
ProgressDisableFixture("default_enabled", None, False, False),
821+
ProgressDisableFixture("env_disabled", "0", False, True),
822+
ProgressDisableFixture("flag_disabled", None, True, True),
823+
ProgressDisableFixture("env_enabled_explicit", "1", False, False),
824+
ProgressDisableFixture("flag_overrides_env", "1", True, True),
825+
]
826+
827+
828+
@pytest.mark.parametrize(
829+
list(ProgressDisableFixture._fields),
830+
PROGRESS_DISABLE_FIXTURES,
831+
ids=[f.test_id for f in PROGRESS_DISABLE_FIXTURES],
832+
)
833+
def test_progress_disable_logic(
834+
test_id: str,
835+
env_value: str | None,
836+
no_progress_flag: bool,
837+
expected_disabled: bool,
838+
monkeypatch: pytest.MonkeyPatch,
839+
) -> None:
840+
"""Progress disable expression matches expected behavior."""
841+
if env_value is not None:
842+
monkeypatch.setenv("TMUXP_PROGRESS", env_value)
843+
else:
844+
monkeypatch.delenv("TMUXP_PROGRESS", raising=False)
845+
846+
import os
847+
848+
result = no_progress_flag or os.getenv("TMUXP_PROGRESS", "1") == "0"
849+
assert result is expected_disabled
850+
851+
852+
def test_load_workspace_no_progress(
853+
server: Server,
854+
monkeypatch: pytest.MonkeyPatch,
855+
) -> None:
856+
"""load_workspace with no_progress=True creates session without spinner."""
857+
monkeypatch.delenv("TMUX", raising=False)
858+
session_file = FIXTURE_PATH / "workspace/builder" / "two_pane.yaml"
859+
860+
session = load_workspace(
861+
session_file,
862+
socket_name=server.socket_name,
863+
detached=True,
864+
no_progress=True,
865+
)
866+
867+
assert isinstance(session, Session)
868+
assert session.name == "sample workspace"
869+
870+
871+
def test_load_workspace_env_progress_disabled(
872+
server: Server,
873+
monkeypatch: pytest.MonkeyPatch,
874+
) -> None:
875+
"""load_workspace with TMUXP_PROGRESS=0 creates session without spinner."""
876+
monkeypatch.delenv("TMUX", raising=False)
877+
monkeypatch.setenv("TMUXP_PROGRESS", "0")
878+
session_file = FIXTURE_PATH / "workspace/builder" / "two_pane.yaml"
879+
880+
session = load_workspace(
881+
session_file,
882+
socket_name=server.socket_name,
883+
detached=True,
884+
)
885+
886+
assert isinstance(session, Session)
887+
assert session.name == "sample workspace"
888+
889+
810890
def test_load_masks_home_in_spinner_message(monkeypatch: pytest.MonkeyPatch) -> None:
811891
"""Spinner message should mask home directory via PrivatePath."""
812892
monkeypatch.setattr(pathlib.Path, "home", lambda: pathlib.Path("/home/testuser"))

0 commit comments

Comments
 (0)