Skip to content

Commit 697856d

Browse files
jeffcrouseclaude
andcommitted
fix: make AI chat disabled-state E2E test more robust
Wait for the status API response before checking UI state, and increase timeout for condition checks so the test is not flaky on faster (self-hosted) runners. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 65faecc commit 697856d

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

packages/web/e2e/ai-chat-mocked.spec.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,22 @@ test.describe('AI Chat (Mocked)', () => {
199199
});
200200
});
201201

202-
// Reload page to pick up new mock
203-
await page.reload();
202+
// Reload page to pick up new mock, waiting for the status response to be received
203+
await Promise.all([
204+
page.waitForResponse('**/api/v1/chat/status'),
205+
page.reload(),
206+
]);
204207
await ensureProfile(page);
205208
// Re-open chat panel after reload
206209
await openChatPanel(page);
207210

208211
// The chat input should be disabled or there's a configuration message
209212
const chatInput = getChatInput(page);
210-
const isInputDisabled = await chatInput.isDisabled().catch(() => false);
211-
212213
const configureMessage = page.locator('text=/configure|api key|not configured|unavailable/i').first();
213-
const hasConfigMessage = await configureMessage.isVisible({ timeout: 3000 }).catch(() => false);
214+
215+
// Wait for either condition to be true (up to 5s for UI to reflect status)
216+
const isInputDisabled = await chatInput.isDisabled({ timeout: 5000 }).catch(() => false);
217+
const hasConfigMessage = await configureMessage.isVisible({ timeout: 5000 }).catch(() => false);
214218

215219
// Either input is disabled OR there's a config message
216220
expect(isInputDisabled || hasConfigMessage).toBe(true);

0 commit comments

Comments
 (0)