diff --git a/e2e/lib/komorebi_vm/core/scenarios/handover.py b/e2e/lib/komorebi_vm/core/scenarios/handover.py index 9f1a75bb..439ee301 100644 --- a/e2e/lib/komorebi_vm/core/scenarios/handover.py +++ b/e2e/lib/komorebi_vm/core/scenarios/handover.py @@ -22,7 +22,20 @@ def run(platform: Platform, checks: Checks, clients: list[Client]) -> None: They take a window out of the daemon's hands, so a sweep of commands does not run them. The window is tiled again at the end. + + There have to be two containers or more on the focused workspace. A window that is alone there + stays on the tile it was put on, and an emptied workspace keeps its last layout (the daemon has + nothing to calculate), so "not on a tile of the layout" could never hold: the scenario says so + and stops, rather than fail on a precondition that was never met. """ + tiled = len(platform.state().workspace().containers) + if not checks.check( + "the focused workspace has two tiled containers or more, for a window to be let go of" + f" (it has {tiled})", + tiled >= 2, + ): + print(describe(platform, clients)) + return title = platform.state().focused_title() target = Client(title) before = platform.state().managed() diff --git a/komorebi-for-kde/nix/tests/vm/lib/komorebi_vm/core/scenarios/handover.py b/komorebi-for-kde/nix/tests/vm/lib/komorebi_vm/core/scenarios/handover.py index 9f1a75bb..439ee301 100644 --- a/komorebi-for-kde/nix/tests/vm/lib/komorebi_vm/core/scenarios/handover.py +++ b/komorebi-for-kde/nix/tests/vm/lib/komorebi_vm/core/scenarios/handover.py @@ -22,7 +22,20 @@ def run(platform: Platform, checks: Checks, clients: list[Client]) -> None: They take a window out of the daemon's hands, so a sweep of commands does not run them. The window is tiled again at the end. + + There have to be two containers or more on the focused workspace. A window that is alone there + stays on the tile it was put on, and an emptied workspace keeps its last layout (the daemon has + nothing to calculate), so "not on a tile of the layout" could never hold: the scenario says so + and stops, rather than fail on a precondition that was never met. """ + tiled = len(platform.state().workspace().containers) + if not checks.check( + "the focused workspace has two tiled containers or more, for a window to be let go of" + f" (it has {tiled})", + tiled >= 2, + ): + print(describe(platform, clients)) + return title = platform.state().focused_title() target = Client(title) before = platform.state().managed() diff --git a/komorebi-for-kde/nix/tests/vm/lib/tests/test_moved.py b/komorebi-for-kde/nix/tests/vm/lib/tests/test_moved.py index 675bd9d6..8b484c55 100644 --- a/komorebi-for-kde/nix/tests/vm/lib/tests/test_moved.py +++ b/komorebi-for-kde/nix/tests/vm/lib/tests/test_moved.py @@ -60,7 +60,7 @@ def test_a_daemon_that_lets_go_and_takes_up_again_passes_handover() -> None: base = checks.passed handover.run(platform, checks, clients) assert checks.failed == 0, checks.failures - assert checks.passed - base == 5 + assert checks.passed - base == 6 def test_a_daemon_that_keeps_an_unmanaged_window_fails_handover() -> None: @@ -332,3 +332,14 @@ def test_a_crash_that_leaves_a_window_hidden_fails() -> None: clients = opened(platform, checks) lifecycle_hidden.crash(platform, checks, clients) assert any("none is left out of sight" in f for f in checks.failures), checks.failures + + +def test_a_window_that_is_alone_on_its_workspace_fails_handover_on_the_precondition() -> None: + platform = FakePlatform() + checks = Checks() + clients = opened(platform, checks) + platform.komorebic("send-to-workspace", "1") + platform.komorebic("send-to-workspace", "1") + handover.run(platform, checks, clients) + assert any("two tiled containers" in f for f in checks.failures) + assert not any("unmanage" in f for f in checks.failures)