MCPcopy Create free account
hub / github.com/Facets-cloud/flow / TestFocusSessionAcrossOSWindows

Function TestFocusSessionAcrossOSWindows

internal/kitty/kitty_test.go:278–306  ·  view source on GitHub ↗

TestFocusSessionAcrossOSWindows — the match scan walks every OS window, not just the first.

(t *testing.T)

Source from the content-addressed store, hash-verified

276// TestFocusSessionAcrossOSWindows — the match scan walks every OS
277// window, not just the first.
278func TestFocusSessionAcrossOSWindows(t *testing.T) {
279 const uuid = "11111111-2222-4333-8444-555555555555"
280 listJSON := `[
281 {"tabs": [
282 {"windows": [{"id": 1, "foreground_processes": [{"cmdline": ["/bin/zsh"]}]}]}
283 ]},
284 {"tabs": [
285 {"windows": [
286 {"id": 22, "foreground_processes": [
287 {"cmdline": ["claude", "--session-id", "11111111-2222-4333-8444-555555555555"]}
288 ]}
289 ]}
290 ]}
291 ]`
292 stubRunnerOutput(t, func(args []string) ([]byte, error) { return []byte(listJSON), nil })
293 var focusArgs []string
294 old := Runner
295 Runner = func(args []string) error { focusArgs = args; return nil }
296 t.Cleanup(func() { Runner = old })
297
298 focused, err := FocusSession(uuid, "claude")
299 if err != nil || !focused {
300 t.Fatalf("got (%v, %v); want (true, nil)", focused, err)
301 }
302 want := []string{"@", "focus-window", "--match=id:22"}
303 if !slices.Equal(focusArgs, want) {
304 t.Errorf("focus argv = %v; want %v", focusArgs, want)
305 }
306}
307
308// TestFocusSessionNoMatch — no foreground process under any window
309// runs claude with the target UUID; Runner must not be called.

Callers

nothing calls this directly

Calls 2

stubRunnerOutputFunction · 0.70
FocusSessionFunction · 0.70

Tested by

no test coverage detected