test(app): wait for the attached presentation instead of racing it
- commit
- 3b7ecba0b7741d54f05085c0532d57818d962100
- author
- brice · · 2026-09-23 21:28 UTC
- parent
- 6a2bad6
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +6 -1
M internal/app/broker_client_test.go +6 -1
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "errors" | |
| 8 | 8 | "io" | |
| 9 | 9 | "os" | |
| 10 | + | "slices" | |
| 10 | 11 | "sync" | |
| 11 | 12 | "testing" | |
| 12 | 13 | "time" | |
| @@ -688,7 +689,11 @@ func TestTerminalCompositionPublishesRealSessionOutput(t *testing.T) { | |||
| 688 | 689 | // The initial publication is committed before the attached marker, so its | |
| 689 | 690 | // recorded boundary status is the pre-attachment Connecting presentation. | |
| 690 | 691 | require.Contains(t, run.terminal.publishes(), ports.UIStatusConnecting) | |
| 691 | - | require.Contains(t, run.terminal.publishes(), ports.UIStatusAttached) | |
| 692 | + | // The attached presentation is published just after the attached state, on | |
| 693 | + | // the attachment goroutine, so wait for it instead of racing it. | |
| 694 | + | require.Eventually(t, func() bool { | |
| 695 | + | return slices.Contains(run.terminal.publishes(), ports.UIStatusAttached) | |
| 696 | + | }, brokerTestWait, 5*time.Millisecond) | |
| 692 | 697 | _, _, restores := run.terminalCounts() | |
| 693 | 698 | require.Zero(t, restores) | |
| 694 | 699 | } | |
| @@ -7,6 +7,7 @@ import ( | |||||
| 7 | "errors" | 7 | "errors" | ||
| 8 | "io" | 8 | "io" | ||
| 9 | "os" | 9 | "os" | ||
| 10 | + | "slices" | |||
| 10 | "sync" | 11 | "sync" | ||
| 11 | "testing" | 12 | "testing" | ||
| 12 | "time" | 13 | "time" | ||
| @@ -688,7 +689,11 @@ func TestTerminalCompositionPublishesRealSessionOutput(t *testing.T) { | |||||
| 688 | // The initial publication is committed before the attached marker, so its | 689 | // The initial publication is committed before the attached marker, so its | ||
| 689 | // recorded boundary status is the pre-attachment Connecting presentation. | 690 | // recorded boundary status is the pre-attachment Connecting presentation. | ||
| 690 | require.Contains(t, run.terminal.publishes(), ports.UIStatusConnecting) | 691 | require.Contains(t, run.terminal.publishes(), ports.UIStatusConnecting) | ||
| 691 | - | require.Contains(t, run.terminal.publishes(), ports.UIStatusAttached) | 692 | + | // The attached presentation is published just after the attached state, on |
| 693 | + | // the attachment goroutine, so wait for it instead of racing it. | |||
| 694 | + | require.Eventually(t, func() bool { | |||
| 695 | + | return slices.Contains(run.terminal.publishes(), ports.UIStatusAttached) | |||
| 696 | + | }, brokerTestWait, 5*time.Millisecond) | |||
| 692 | _, _, restores := run.terminalCounts() | 697 | _, _, restores := run.terminalCounts() | ||
| 693 | require.Zero(t, restores) | 698 | require.Zero(t, restores) | ||
| 694 | } | 699 | } | ||