Skip to content

Commit 97243ab

Browse files
committed
test(automatic rename): Fix renaming
1 parent 59d6457 commit 97243ab

File tree

2 files changed

+21
-31
lines changed

2 files changed

+21
-31
lines changed

tests/fixtures/workspace/builder/window_automatic_rename.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
session_name: test window options
22
start_directory: '~'
33
windows:
4-
- layout: main-horizontal
4+
- window_name: renamed_window
5+
layout: main-horizontal
56
options:
67
automatic-rename: on
78
panes:
89
- shell_command:
910
- cmd: man ls
1011
start_directory: '~'
12+
focus: true
1113
- shell_command:
1214
- cmd: echo "hey"
1315
- shell_command:

tests/workspace/test_builder.py

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -415,15 +415,16 @@ def test_environment_variables_logs(session: Session, caplog: pytest.LogCaptureF
415415
sum(
416416
1
417417
for record in caplog.records
418-
if 'Cannot set environment for new panes and windows.' in record.msg
418+
if "Cannot set environment for new panes and windows." in record.msg
419419
)
420420
# From both_overrides_in_first_pane.
421421
== 1
422422
)
423423

424424

425-
def test_automatic_rename_option(session):
426-
"""With option automatic-rename: on."""
425+
def test_automatic_rename_option(
426+
server: "Server", monkeypatch: pytest.MonkeyPatch
427+
) -> None:
427428
workspace = ConfigReader._from_file(
428429
test_utils.get_workspace_file("workspace/builder/window_automatic_rename.yaml")
429430
)
@@ -434,42 +435,29 @@ def test_automatic_rename_option(session):
434435
if " " in portable_command:
435436
portable_command = portable_command.split(" ")[0]
436437

437-
builder = WorkspaceBuilder(sconf=workspace)
438-
439-
window_count = len(session._windows) # current window count
440-
assert len(session._windows) == window_count
441-
for w, wconf in builder.iter_create_windows(session):
442-
443-
for p in builder.iter_create_panes(w, wconf):
444-
w.select_layout("tiled") # fix glitch with pane size
445-
p = p
446-
assert len(session._windows), window_count
447-
assert isinstance(w, Window)
448-
assert w.show_window_option("automatic-rename") == "on"
449-
450-
assert len(session._windows) == window_count
451-
452-
window_count += 1
453-
w.select_layout(wconf["layout"])
438+
builder = WorkspaceBuilder(sconf=workspace, server=server)
439+
builder.build()
440+
session: Session = builder.session
441+
w: Window = session.windows[0]
442+
assert len(session.windows) == 1
454443

455-
assert session.name != "tmuxp"
456-
w = session.windows[0]
444+
assert w.name != "renamed_window"
457445

458446
def check_window_name_mismatch() -> bool:
459-
session.server._update_windows()
447+
w.server._update_windows()
460448
return w.name != portable_command
461449

462-
assert retry_until(check_window_name_mismatch, 2, interval=0.25)
463-
464-
pane_base_index = w.show_window_option("pane-base-index", g=True)
465-
w.select_pane(pane_base_index)
450+
assert retry_until(check_window_name_mismatch, 5, interval=0.25)
466451

467452
def check_window_name_match() -> bool:
468-
session.server._update_windows()
469-
return w.name == portable_command
453+
w.server._update_windows()
454+
assert w.show_window_option("automatic-rename") == "on"
455+
456+
print(f"w.name: {w.name} and portable_command: {portable_command}")
457+
return w.name == "zsh"
470458

471459
assert retry_until(
472-
check_window_name_match, 2, interval=0.25
460+
check_window_name_match, 4, interval=0.05
473461
), f"Window name {w.name} should be {portable_command}"
474462

475463
w.select_pane("-D")

0 commit comments

Comments
 (0)