diff --git a/features/agent.feature b/features/agent.feature index f2f650af..b9c9c01b 100644 --- a/features/agent.feature +++ b/features/agent.feature @@ -58,7 +58,6 @@ Feature: Agent Workflow - Tool Usage and Multi-Round Conversation When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']" When I type "在 wiki 里创建一个新笔记,内容为 test" in "chat input" element with selector "[data-testid='agent-message-input']" And I press "Enter" key - And I wait for 0.2 seconds Then I should see 6 messages in chat history # Verify there's an error message about workspace not found (in one of the middle messages) And I should see a "workspace not exist error" element with selector "[data-testid='message-bubble']:has-text('default'):has-text('不存在')" diff --git a/features/stepDefinitions/agent.ts b/features/stepDefinitions/agent.ts index 2d082612..87c53023 100644 --- a/features/stepDefinitions/agent.ts +++ b/features/stepDefinitions/agent.ts @@ -115,11 +115,18 @@ Then('I should see {int} messages in chat history', async function(this: Applica const messageSelector = '[data-testid="message-bubble"]'; try { + // Adjust timeouts and attempts for CI vs local runs + const isCI = Boolean(process.env.CI); + const selectorTimeout = isCI ? 15000 : 5000; // wait longer in CI for selector + const waitTimeout = isCI ? 5000 : 2000; // wait between attempts + const attemptsMultiplier = isCI ? 5 : 3; + // Wait for messages to reach expected count, checking periodically for streaming - for (let attempt = 1; attempt <= expectedCount * 3; attempt++) { + const maxAttempts = Math.max(3, expectedCount * attemptsMultiplier); + for (let attempt = 1; attempt <= maxAttempts; attempt++) { try { // Wait for at least one message to exist - await currentWindow.waitForSelector(messageSelector, { timeout: 5000 }); + await currentWindow.waitForSelector(messageSelector, { timeout: selectorTimeout }); // Count current messages const messages = currentWindow.locator(messageSelector); @@ -132,11 +139,11 @@ Then('I should see {int} messages in chat history', async function(this: Applica } // If not enough messages yet, wait a bit more for streaming - if (attempt < expectedCount * 3) { - await currentWindow.waitForTimeout(2000); + if (attempt < maxAttempts) { + await currentWindow.waitForTimeout(waitTimeout); } } catch (timeoutError) { - if (attempt === expectedCount * 3) { + if (attempt === maxAttempts) { throw timeoutError; } }