feat(nix): the workspace_moves scenario

move-to-workspace takes a window to another workspace and the focus
with it, focus-last-workspace goes back and forth, and moving the window
home tiles everything again. core-e2e passes 233 checks on KDE.
This commit is contained in:
LGUG2Z committed 2026-10-30 12:03:00 -07:00
1 parent 4a3b0c4b14
commit a8b30e1c1b
4 files changed
+93 -2

No files matched your search

@@ -0,0 +1,61 @@
"""A window moved to a workspace takes the focus there, and the last workspace is one command
away."""
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 _in_view(platform: Platform, clients: list[Client]) -> list[str]:
return sorted(c.title for c in clients if not platform.hidden(c))
def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
"""Moves the last of `clients`, which are tiled windows of workspace 0 in a container each,
to workspace 1 with `move-to-workspace`, goes back and forth with `focus-last-workspace`, and
moves it home. Workspace 1 is empty."""
target = clients[-1]
rest = sorted(c.title for c in clients if c != target)
everyone = sorted(c.title for c in clients)
platform.activate(target)
platform.wait_for(lambda: focus_agrees(platform, clients, target.title))
platform.komorebic("move-to-workspace", "1")
checks.check(
"after 'move-to-workspace 1' the window is there, in view, and the others are put away",
platform.wait_for(lambda: _in_view(platform, clients) == [target.title], timeout=20),
)
checks.check(
"... the daemon has it on workspace 1",
platform.wait_for(lambda: platform.state().containers(1) == [[target.title]]),
)
checks.check(
"... and it has the focus",
platform.wait_for(lambda: focus_agrees(platform, clients, target.title)),
)
platform.komorebic("focus-last-workspace")
checks.check(
"'focus-last-workspace' brings the others back and puts the window away",
platform.wait_for(lambda: _in_view(platform, clients) == rest, timeout=20),
)
platform.komorebic("focus-last-workspace")
checks.check(
"... and again, it goes back to the window",
platform.wait_for(lambda: _in_view(platform, clients) == [target.title], timeout=20),
)
platform.komorebic("move-to-workspace", "0")
checks.check(
"'move-to-workspace 0' has every window in view again",
platform.wait_for(lambda: _in_view(platform, clients) == everyone, timeout=20),
)
checks.check(
"... tiled where the layout says",
platform.wait_for(lambda: tiled(platform, clients), timeout=20),
)
checks.check(
"... and workspace 1 is empty",
platform.wait_for(lambda: platform.state().containers(1) == []),
)
+6 -2
View File
@@ -80,6 +80,7 @@ class FakePlatform:
self.display_of: dict[str, int] = {}
self.forgets_displays = False
self.floats: list[str] = []
self.last = 0
self.maximized: str | None = None
self.workspace_padding = 0
self.container_padding = 0
@@ -378,7 +379,8 @@ class FakePlatform:
self.ignored.add(title)
case ("move-to-workspace", number):
self.komorebic("send-to-workspace", number)
self.current = int(number)
self.last, self.current = self.current, int(number)
self.focus = len(self.containers) - 1
case ("enforce-workspace-rules",):
for title, number in self.rules.items():
for s, containers in enumerate(self.spaces):
@@ -390,7 +392,9 @@ class FakePlatform:
self.spaces[number].append([title])
break
case ("focus-workspace", number):
self.current = int(number)
self.last, self.current = self.current, int(number)
case ("focus-last-workspace",):
self.last, self.current = self.current, self.last
case ("focused-workspace-padding", size):
self.workspace_padding = int(size)
self._relayout()
@@ -22,6 +22,7 @@ from komorebi_vm.core.scenarios import (
stacks,
startup_rules,
tiling,
workspace_moves,
workspaces,
)
from tests.fake_platform import FakePlatform
@@ -249,6 +250,29 @@ def test_a_daemon_that_does_not_maximize_fails_maximizing() -> None:
assert checks.failed > 0
def test_a_daemon_that_is_right_passes_workspace_moves() -> None:
platform = FakePlatform()
checks = Checks()
clients = opened(platform, checks)
workspace_moves.run(platform, checks, clients)
assert checks.failed == 0, checks.failures
assert checks.passed > 6
def test_a_daemon_that_does_not_follow_the_window_fails_workspace_moves() -> None:
class Staying(FakePlatform):
def komorebic(self, *args: str) -> str:
if args[0] == "move-to-workspace":
return super().komorebic("send-to-workspace", args[1])
return super().komorebic(*args)
platform = Staying()
checks = Checks()
clients = opened(platform, checks)
workspace_moves.run(platform, checks, clients)
assert checks.failed > 0
def test_a_command_the_port_lacks_is_skipped_by_name() -> None:
platform = FakePlatform()
checks = Checks()
+2
View File
@@ -31,6 +31,7 @@ from komorebi_vm.core.scenarios import (
stacks,
startup_rules,
tiling,
workspace_moves,
workspaces,
)
from komorebi_vm.kde_platform import KdePlatform
@@ -459,6 +460,7 @@ minimizing.run(platform, checks, neutral)
maximizing.run(platform, checks, neutral)
padding.run(platform, checks, neutral)
monocle.run(platform, checks, neutral)
workspace_moves.run(platform, checks, neutral)
workspaces.run(platform, checks, neutral)
# the third window is on workspace 1 now: the first is closed, and the second takes its room
closing.run(platform, checks, neutral, Client("neutral1"))