From 63d5833a84ea3acdb3ece57c865b658e0b5113a0 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 30 Oct 2026 00:38:24 -0700 Subject: [PATCH] feat(nix): the promoting scenario promote puts the focused window on the first tile and keeps its focus, with every window where the layout says. core-e2e passes 241 checks on KDE. --- .../komorebi_vm/core/scenarios/promoting.py | 35 +++++++++++++++++++ nix/tests/vm/lib/tests/fake_platform.py | 3 ++ nix/tests/vm/lib/tests/test_focus_moving.py | 22 ++++++++++++ nix/tests/vm/suites/core-e2e/test.py | 2 ++ 4 files changed, 62 insertions(+) create mode 100644 nix/tests/vm/lib/komorebi_vm/core/scenarios/promoting.py diff --git a/nix/tests/vm/lib/komorebi_vm/core/scenarios/promoting.py b/nix/tests/vm/lib/komorebi_vm/core/scenarios/promoting.py new file mode 100644 index 00000000..5058185e --- /dev/null +++ b/nix/tests/vm/lib/komorebi_vm/core/scenarios/promoting.py @@ -0,0 +1,35 @@ +"""A promoted window takes the first tile, and keeps the focus.""" + +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 focus_agrees + + +def run(platform: Platform, checks: Checks, clients: list[Client]) -> None: + """Promotes the last of `clients`, which are tiled windows of the first workspace in a + container each, with more than one of them.""" + target = clients[-1] + platform.activate(target) + platform.wait_for(lambda: focus_agrees(platform, clients, target.title)) + first = platform.state().workspace().latest_layout[0] + + platform.komorebic("promote") + checks.check( + f"after 'promote' the daemon has {target.title} in the first container", + platform.wait_for(lambda: platform.state().containers()[0] == [target.title], timeout=20), + ) + + def on_the_first_tile() -> bool: + window = platform.os_window(target) + return window is not None and (window.frame.x, window.frame.y) == (first.x, first.y) + + checks.check("... and the window is on the first tile", platform.wait_for(on_the_first_tile)) + checks.check( + "... every window is where the layout says", + platform.wait_for(lambda: tiled(platform, clients), timeout=20), + ) + checks.check( + "... and the window still has the focus", + platform.wait_for(lambda: focus_agrees(platform, clients, target.title), timeout=20), + ) diff --git a/nix/tests/vm/lib/tests/fake_platform.py b/nix/tests/vm/lib/tests/fake_platform.py index 273da51f..7dccbbe4 100644 --- a/nix/tests/vm/lib/tests/fake_platform.py +++ b/nix/tests/vm/lib/tests/fake_platform.py @@ -410,6 +410,9 @@ class FakePlatform: a, b = self.tiles[i], self.tiles[i + 1] self.tiles[i] = Rect(a.x, a.y, a.w + d, a.h) self.tiles[i + 1] = Rect(b.x + d, b.y, b.w - d, b.h) + case ("promote",): + self.containers.insert(0, self.containers.pop(self.focus)) + self.focus = 0 case ("toggle-float",): if self.floats: self.containers.insert(self.focus, [self.floats.pop()]) diff --git a/nix/tests/vm/lib/tests/test_focus_moving.py b/nix/tests/vm/lib/tests/test_focus_moving.py index f5724ceb..a029dc09 100644 --- a/nix/tests/vm/lib/tests/test_focus_moving.py +++ b/nix/tests/vm/lib/tests/test_focus_moving.py @@ -17,6 +17,7 @@ from komorebi_vm.core.scenarios import ( moving, padding, placement, + promoting, resize, resize_commands, rules, @@ -295,6 +296,27 @@ def test_a_daemon_that_does_not_resize_fails_resize_commands() -> None: assert checks.failed > 0 +def test_a_daemon_that_is_right_passes_promoting() -> None: + platform = FakePlatform() + checks = Checks() + clients = opened(platform, checks) + promoting.run(platform, checks, clients) + assert checks.failed == 0, checks.failures + assert checks.passed > 3 + + +def test_a_daemon_that_does_not_promote_fails_promoting() -> None: + class Stubborn(FakePlatform): + def komorebic(self, *args: str) -> str: + return "" if args == ("promote",) else super().komorebic(*args) + + platform = Stubborn() + checks = Checks() + clients = opened(platform, checks) + promoting.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 66ac33e9..267c90a1 100644 --- a/nix/tests/vm/suites/core-e2e/test.py +++ b/nix/tests/vm/suites/core-e2e/test.py @@ -27,6 +27,7 @@ from komorebi_vm.core.scenarios import ( moving, padding, placement, + promoting, resize_commands, rules, stacks, @@ -460,6 +461,7 @@ floating.run(platform, checks, neutral) minimizing.run(platform, checks, neutral) maximizing.run(platform, checks, neutral) resize_commands.run(platform, checks, neutral) +promoting.run(platform, checks, neutral) padding.run(platform, checks, neutral) monocle.run(platform, checks, neutral) workspace_moves.run(platform, checks, neutral)