Skip to content

Commit 8dfd403

Browse files
committed
test(orchestrator): stabilize decrypt TUI end-to-end tests
Reduces flakiness in the decrypt TUI end-to-end tests when run with coverage enabled or under package-level load. - increases simulated input delays - extends end-to-end test timeouts and contexts - avoids false negatives without changing production code
1 parent 9550745 commit 8dfd403

2 files changed

Lines changed: 19 additions & 16 deletions

File tree

internal/orchestrator/decrypt_tui_e2e_helpers_test.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -187,35 +187,35 @@ func createDecryptTUIEncryptedFixture(t *testing.T) *decryptTUIFixture {
187187

188188
func successDecryptTUISequence(secret string) []timedSimKey {
189189
keys := []timedSimKey{
190-
{Key: tcell.KeyEnter, Wait: 150 * time.Millisecond},
191-
{Key: tcell.KeyEnter, Wait: 300 * time.Millisecond},
190+
{Key: tcell.KeyEnter, Wait: 250 * time.Millisecond},
191+
{Key: tcell.KeyEnter, Wait: 500 * time.Millisecond},
192192
}
193193

194194
for _, r := range secret {
195195
keys = append(keys, timedSimKey{
196196
Key: tcell.KeyRune,
197197
R: r,
198-
Wait: 20 * time.Millisecond,
198+
Wait: 35 * time.Millisecond,
199199
})
200200
}
201201

202202
keys = append(keys,
203-
timedSimKey{Key: tcell.KeyTab, Wait: 80 * time.Millisecond},
204-
timedSimKey{Key: tcell.KeyEnter, Wait: 50 * time.Millisecond},
205-
timedSimKey{Key: tcell.KeyTab, Wait: 300 * time.Millisecond},
206-
timedSimKey{Key: tcell.KeyEnter, Wait: 50 * time.Millisecond},
203+
timedSimKey{Key: tcell.KeyTab, Wait: 150 * time.Millisecond},
204+
timedSimKey{Key: tcell.KeyEnter, Wait: 100 * time.Millisecond},
205+
timedSimKey{Key: tcell.KeyTab, Wait: 500 * time.Millisecond},
206+
timedSimKey{Key: tcell.KeyEnter, Wait: 100 * time.Millisecond},
207207
)
208208

209209
return keys
210210
}
211211

212212
func abortDecryptTUISequence() []timedSimKey {
213213
return []timedSimKey{
214-
{Key: tcell.KeyEnter, Wait: 150 * time.Millisecond},
215-
{Key: tcell.KeyEnter, Wait: 300 * time.Millisecond},
216-
{Key: tcell.KeyRune, R: '0', Wait: 300 * time.Millisecond},
217-
{Key: tcell.KeyTab, Wait: 80 * time.Millisecond},
218-
{Key: tcell.KeyEnter, Wait: 50 * time.Millisecond},
214+
{Key: tcell.KeyEnter, Wait: 250 * time.Millisecond},
215+
{Key: tcell.KeyEnter, Wait: 500 * time.Millisecond},
216+
{Key: tcell.KeyRune, R: '0', Wait: 500 * time.Millisecond},
217+
{Key: tcell.KeyTab, Wait: 150 * time.Millisecond},
218+
{Key: tcell.KeyEnter, Wait: 100 * time.Millisecond},
219219
}
220220
}
221221

@@ -233,8 +233,11 @@ func runDecryptWorkflowTUIForTest(t *testing.T, ctx context.Context, cfg *config
233233
select {
234234
case err := <-errCh:
235235
return err
236-
case <-time.After(12 * time.Second):
237-
t.Fatalf("RunDecryptWorkflowTUI did not complete within 12s")
236+
case <-ctx.Done():
237+
t.Fatalf("RunDecryptWorkflowTUI context expired: %v", ctx.Err())
238+
return nil
239+
case <-time.After(20 * time.Second):
240+
t.Fatalf("RunDecryptWorkflowTUI did not complete within 20s")
238241
return nil
239242
}
240243
}

internal/orchestrator/decrypt_tui_e2e_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestRunDecryptWorkflowTUI_SuccessLocalEncrypted(t *testing.T) {
2222
fixture := createDecryptTUIEncryptedFixture(t)
2323
withTimedSimAppSequence(t, successDecryptTUISequence(fixture.Secret))
2424

25-
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
25+
ctx, cancel := context.WithTimeout(context.Background(), 18*time.Second)
2626
defer cancel()
2727

2828
if err := runDecryptWorkflowTUIForTest(t, ctx, fixture.Config, fixture.ConfigPath); err != nil {
@@ -85,7 +85,7 @@ func TestRunDecryptWorkflowTUI_AbortAtSecretPrompt(t *testing.T) {
8585
fixture := createDecryptTUIEncryptedFixture(t)
8686
withTimedSimAppSequence(t, abortDecryptTUISequence())
8787

88-
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
88+
ctx, cancel := context.WithTimeout(context.Background(), 18*time.Second)
8989
defer cancel()
9090

9191
err := runDecryptWorkflowTUIForTest(t, ctx, fixture.Config, fixture.ConfigPath)

0 commit comments

Comments
 (0)