aboutsummaryrefslogtreecommitdiff
path: root/tests/e2e.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/e2e.sh')
-rwxr-xr-xtests/e2e.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/e2e.sh b/tests/e2e.sh
index f874c15..13a698f 100755
--- a/tests/e2e.sh
+++ b/tests/e2e.sh
@@ -737,6 +737,26 @@ r switch-client -c "$TTY1" -t '=elsewhere'
renv "$DINGGER" focus --pane "$AG"
expect "a window already on the agent's session wins over a more recent one" "tail -1 $DIR/ghostty-raised" BBBB-2222 50
expect "and the other window is not moved" "client_session $TTY1" elsewhere
+# Across a Space switch Ghostty still names the terminal that had focus
+# for a moment: the other window's.
+focus_out viewer; focus_in viewer2 AAAA-1111
+sleep 0.5; echo BBBB-2222 >"$DIR/ghostty-focused"
+sleep 1
+expect "Ghostty lagging behind tmux's focus: the right terminal" "paired $TTY2" BBBB-2222 50
+expect "and the other window keeps its own" "paired $TTY1" AAAA-1111
+# Pairings crossed (as the lag used to leave them): Ghostty's lagging
+# answer is then the client's own wrong terminal.
+r set -g "@dingger_terminal_$(basename "$TTY1")" "1 BBBB-2222 $FAKE_APP"
+r set -g "@dingger_terminal_$(basename "$TTY2")" "1 AAAA-1111 $FAKE_APP"
+focus_out viewer2; focus_in viewer2 AAAA-1111
+sleep 0.5; echo BBBB-2222 >"$DIR/ghostty-focused"
+expect "crossed pairings heal: the focused client's" "paired $TTY2" BBBB-2222 50
+expect "and the other's wrong one is dropped" "paired $TTY1" ""
+focus_out viewer2; focus_in viewer AAAA-1111
+expect "until its next focus" "paired $TTY1" AAAA-1111 50
+r set -g @dingger_terminal_ttysgone "1 DDDD-4444 $FAKE_APP"
+focus_out viewer; focus_in viewer2 BBBB-2222
+expect "a client no longer attached loses its pairing" "r show -gv @dingger_terminal_ttysgone 2>/dev/null" "" 50
echo viewer >"$DIR/ghostty-race"; : >"$DIR/ghostty-queries"
focus_in viewer CCCC-3333
expect "Ghostty asked" "wc -l <$DIR/ghostty-queries | tr -d ' '" 1 50