test(palette): synchronize displaced target feedback
- commit
- 26241db9f268d2d82cfb489a14c48945327e1d9f
- author
- brice · · 2026-07-27 17:14 UTC
- committer
- brice · · 2026-07-27 17:17 UTC
- parent
- 47d7f8d
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +11 -3
M internal/usecase/daemon/palette_test.go +11 -3
| @@ -409,14 +409,22 @@ func TestPaletteJRSDisplacedTargetKeepsInteractionOpen(t *testing.T) { | |||
| 409 | 409 | } | |
| 410 | 410 | d.handleInput(sess, ac, []byte("\x1b ")) | |
| 411 | 411 | awaitFrame(t, sends, ports.MsgOutput) | |
| 412 | - | go d.handleInput(sess, ac, []byte("JRS 1\r")) | |
| 413 | - | <-validated | |
| 412 | + | inputHandled := make(chan struct{}) | |
| 413 | + | go func() { | |
| 414 | + | d.handleInput(sess, ac, []byte("JRS 1\r")) | |
| 415 | + | close(inputHandled) | |
| 416 | + | }() | |
| 417 | + | awaitTestCompletion(t, validated, "JRS did not validate its captured target") | |
| 414 | 418 | d.mu.Lock() | |
| 415 | 419 | delete(d.sessions, target.id) | |
| 416 | 420 | d.mu.Unlock() | |
| 417 | 421 | close(releaseHandoff) | |
| 418 | 422 | ||
| 419 | - | awaitFrame(t, sends, ports.MsgOutput) | |
| 423 | + | // switchToTarget repaints its failed hand-off before handlePaletteInput | |
| 424 | + | // records the generation-safe feedback and schedules the feedback repaint. | |
| 425 | + | // Wait for the input transaction, rather than mistaking that intermediate | |
| 426 | + | // repaint for publication of the final palette state. | |
| 427 | + | awaitTestCompletion(t, inputHandled, "JRS displaced-target input did not complete") | |
| 420 | 428 | require.True(t, ac.overlays.paletteActive()) | |
| 421 | 429 | ac.overlays.paletteMu.Lock() | |
| 422 | 430 | require.Equal(t, "JRS 1", ac.overlays.palette.Query()) | |
| @@ -409,14 +409,22 @@ func TestPaletteJRSDisplacedTargetKeepsInteractionOpen(t *testing.T) { | |||||
| 409 | } | 409 | } | ||
| 410 | d.handleInput(sess, ac, []byte("\x1b ")) | 410 | d.handleInput(sess, ac, []byte("\x1b ")) | ||
| 411 | awaitFrame(t, sends, ports.MsgOutput) | 411 | awaitFrame(t, sends, ports.MsgOutput) | ||
| 412 | - | go d.handleInput(sess, ac, []byte("JRS 1\r")) | 412 | + | inputHandled := make(chan struct{}) |
| 413 | - | <-validated | 413 | + | go func() { |
| 414 | + | d.handleInput(sess, ac, []byte("JRS 1\r")) | |||
| 415 | + | close(inputHandled) | |||
| 416 | + | }() | |||
| 417 | + | awaitTestCompletion(t, validated, "JRS did not validate its captured target") | |||
| 414 | d.mu.Lock() | 418 | d.mu.Lock() | ||
| 415 | delete(d.sessions, target.id) | 419 | delete(d.sessions, target.id) | ||
| 416 | d.mu.Unlock() | 420 | d.mu.Unlock() | ||
| 417 | close(releaseHandoff) | 421 | close(releaseHandoff) | ||
| 418 | 422 | ||||
| 419 | - | awaitFrame(t, sends, ports.MsgOutput) | 423 | + | // switchToTarget repaints its failed hand-off before handlePaletteInput |
| 424 | + | // records the generation-safe feedback and schedules the feedback repaint. | |||
| 425 | + | // Wait for the input transaction, rather than mistaking that intermediate | |||
| 426 | + | // repaint for publication of the final palette state. | |||
| 427 | + | awaitTestCompletion(t, inputHandled, "JRS displaced-target input did not complete") | |||
| 420 | require.True(t, ac.overlays.paletteActive()) | 428 | require.True(t, ac.overlays.paletteActive()) | ||
| 421 | ac.overlays.paletteMu.Lock() | 429 | ac.overlays.paletteMu.Lock() | ||
| 422 | require.Equal(t, "JRS 1", ac.overlays.palette.Query()) | 430 | require.Equal(t, "JRS 1", ac.overlays.palette.Query()) | ||