From 74ddcce4d9bc55222dd8ce05057f56b29498ea0a Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 30 Oct 2026 00:58:04 -0700 Subject: [PATCH] feat(nix): the tiling_off scenario toggle-tiling leaves the windows where they are, a layout change moves none of them, and toggled again every window is tiled where the layout says. core-e2e passes 254 checks on KDE. --- .../komorebi_vm/core/scenarios/tiling_off.py | 39 +++++++++++++++++++ nix/tests/vm/lib/tests/fake_platform.py | 5 ++- nix/tests/vm/lib/tests/test_focus_moving.py | 22 +++++++++++ nix/tests/vm/suites/core-e2e/test.py | 2 + 4 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 nix/tests/vm/lib/komorebi_vm/core/scenarios/tiling_off.py diff --git a/nix/tests/vm/lib/komorebi_vm/core/scenarios/tiling_off.py b/nix/tests/vm/lib/komorebi_vm/core/scenarios/tiling_off.py new file mode 100644 index 00000000..7517fc73 --- /dev/null +++ b/nix/tests/vm/lib/komorebi_vm/core/scenarios/tiling_off.py @@ -0,0 +1,39 @@ +"""A workspace with tiling off leaves its windows where they are, and tiling it again tiles them.""" + +from komorebi_vm.core.checks import Checks +from komorebi_vm.core.platform import Client, Platform +from komorebi_vm.core.scenarios.layouts import tiled +from komorebi_vm.core.scenarios.support import positions + + +def run(platform: Platform, checks: Checks, clients: list[Client]) -> None: + """Toggles tiling off on the first workspace, which has `clients` tiled in a container each, + and on again, with a layout change in between that must not move anything.""" + before = positions(platform, clients) + + platform.komorebic("toggle-tiling") + checks.check( + "after 'toggle-tiling' the daemon has the workspace untiled", + platform.wait_for(lambda: not platform.state().workspace().tile, timeout=20), + ) + checks.check("... and no window moved", positions(platform, clients) == before) + platform.komorebic("change-layout", "columns") + checks.check( + "... a layout change does not move them either", + not platform.wait_for(lambda: positions(platform, clients) != before, timeout=3), + ) + + platform.komorebic("toggle-tiling") + checks.check( + "'toggle-tiling' again has the workspace tiled", + platform.wait_for(lambda: platform.state().workspace().tile, timeout=20), + ) + checks.check( + "... and every window is where the layout says", + platform.wait_for(lambda: tiled(platform, clients), timeout=20), + ) + platform.komorebic("change-layout", "bsp") + checks.check( + "... and in bsp again", + platform.wait_for(lambda: tiled(platform, clients), timeout=20), + ) diff --git a/nix/tests/vm/lib/tests/fake_platform.py b/nix/tests/vm/lib/tests/fake_platform.py index 13060b91..89ea544c 100644 --- a/nix/tests/vm/lib/tests/fake_platform.py +++ b/nix/tests/vm/lib/tests/fake_platform.py @@ -80,6 +80,7 @@ class FakePlatform: self.display_of: dict[str, int] = {} self.forgets_displays = False self.floats: list[str] = [] + self.tiling = True self.paused = False self.flipped = False self.last = 0 @@ -427,6 +428,8 @@ class FakePlatform: self._relayout() case ("toggle-pause",): self.paused = not self.paused + case ("toggle-tiling",): + self.tiling = not self.tiling case ("toggle-float",): if self.floats: self.containers.insert(self.focus, [self.floats.pop()]) @@ -498,7 +501,7 @@ class FakePlatform: "focused": 0, }, "layout": {"Default": "Columns"}, - "tile": True, + "tile": self.tiling, "workspace_padding": self.workspace_padding, "container_padding": self.container_padding, "latest_layout": [rect(r) for r in self.tiles[: len(containers)]], diff --git a/nix/tests/vm/lib/tests/test_focus_moving.py b/nix/tests/vm/lib/tests/test_focus_moving.py index cc60225b..4d8f9d79 100644 --- a/nix/tests/vm/lib/tests/test_focus_moving.py +++ b/nix/tests/vm/lib/tests/test_focus_moving.py @@ -26,6 +26,7 @@ from komorebi_vm.core.scenarios import ( stacks, startup_rules, tiling, + tiling_off, workspace_moves, workspaces, ) @@ -361,6 +362,27 @@ def test_a_daemon_that_manages_while_paused_fails_pausing() -> None: assert checks.failed > 0 +def test_a_daemon_that_is_right_passes_tiling_off() -> None: + platform = FakePlatform() + checks = Checks() + clients = opened(platform, checks) + tiling_off.run(platform, checks, clients) + assert checks.failed == 0, checks.failures + assert checks.passed > 4 + + +def test_a_daemon_that_ignores_toggle_tiling_fails_tiling_off() -> None: + class Stubborn(FakePlatform): + def komorebic(self, *args: str) -> str: + return "" if args == ("toggle-tiling",) else super().komorebic(*args) + + platform = Stubborn() + checks = Checks() + clients = opened(platform, checks) + tiling_off.run(platform, checks, clients) + assert checks.failed > 0 + + def test_a_command_the_port_lacks_is_skipped_by_name() -> None: platform = FakePlatform() checks = Checks() diff --git a/nix/tests/vm/suites/core-e2e/test.py b/nix/tests/vm/suites/core-e2e/test.py index 64ad7aa8..53cc2e87 100644 --- a/nix/tests/vm/suites/core-e2e/test.py +++ b/nix/tests/vm/suites/core-e2e/test.py @@ -35,6 +35,7 @@ from komorebi_vm.core.scenarios import ( stacks, startup_rules, tiling, + tiling_off, workspace_moves, workspaces, ) @@ -466,6 +467,7 @@ resize_commands.run(platform, checks, neutral) promoting.run(platform, checks, neutral) flipping.run(platform, checks, neutral) pausing.run(platform, checks, neutral) +tiling_off.run(platform, checks, neutral) padding.run(platform, checks, neutral) monocle.run(platform, checks, neutral) workspace_moves.run(platform, checks, neutral)