test: improve chat test stability on CI#1145
Conversation
Signed-off-by: serbangeorge-m <serbangeorge.m@gmail.com>
Signed-off-by: serbangeorge-m <serbangeorge.m@gmail.com>
Signed-off-by: serbangeorge-m <serbangeorge.m@gmail.com>
Signed-off-by: serbangeorge-m <serbangeorge.m@gmail.com>
📝 WalkthroughWalkthroughRefactored Playwright test utilities in the chat page model to replace index-based message targeting with content-based operations. Replaced localStorage manipulation with explicit response waiting logic and updated test specs to use the new helper method signatures. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
tests/playwright/src/model/pages/chat-page.ts (2)
326-329: Potential race condition: double-wait may exceed reasonable timeouts.Both
modelConversationMessages.first()visibility check andverifySendButtonVisibleuseTIMEOUTS.MODEL_RESPONSE(90s). In worst case, if the model message appears just before timeout and the send button takes additional time, total wait could approach 180s. Consider whether one of these should use a shorter timeout since once the model response appears, the send button should follow shortly.♻️ Suggested refinement
async waitForModelResponse(): Promise<void> { await expect(this.modelConversationMessages.first()).toBeVisible({ timeout: TIMEOUTS.MODEL_RESPONSE }); - await this.verifySendButtonVisible(TIMEOUTS.MODEL_RESPONSE); + await this.verifySendButtonVisible(TIMEOUTS.STANDARD); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/playwright/src/model/pages/chat-page.ts` around lines 326 - 329, The double-wait in waitForModelResponse (checking this.modelConversationMessages.first() then calling verifySendButtonVisible) both use TIMEOUTS.MODEL_RESPONSE causing a potential combined wait of ~180s; update waitForModelResponse to use the long TIMEOUTS.MODEL_RESPONSE only for the modelConversationMessages visibility and pass a much shorter timeout (e.g., a new or existing short/ui timeout like TIMEOUTS.SHORT or TIMEOUTS.UI_UPDATE) into verifySendButtonVisible so the send-button check does not duplicate the full MODEL_RESPONSE duration; keep identifiers: waitForModelResponse, modelConversationMessages.first(), verifySendButtonVisible, and TIMEOUTS.MODEL_RESPONSE.
331-335: Usingforce: truemay mask actual visibility issues.The
force: trueoption bypasses actionability checks. If the edit button isn't actually visible or clickable due to a UI bug, this won't catch it. Consider whether the hover should be sufficient to make the button actionable without forcing.♻️ Suggested improvement
async clickEditOnUserMessage(messageText: string): Promise<void> { const messageLocator = this.userConversationMessages.filter({ hasText: messageText }); await messageLocator.hover(); - await messageLocator.getByLabel('Edit message').click({ force: true }); + const editButton = messageLocator.getByLabel('Edit message'); + await expect(editButton).toBeVisible(); + await editButton.click(); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/playwright/src/model/pages/chat-page.ts` around lines 331 - 335, The clickEditOnUserMessage method should not bypass actionability checks with force: true; remove the { force: true } from the getByLabel('Edit message').click call, ensure the hover on this.userConversationMessages.filter({ hasText: messageText }) actually makes the "Edit message" button visible, and if necessary add an explicit wait/assertion (e.g., waitFor or expect to be visible) on the getByLabel('Edit message') locator before clicking so the click fails when the button is not actionable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/playwright/src/model/pages/chat-page.ts`:
- Around line 326-329: The double-wait in waitForModelResponse (checking
this.modelConversationMessages.first() then calling verifySendButtonVisible)
both use TIMEOUTS.MODEL_RESPONSE causing a potential combined wait of ~180s;
update waitForModelResponse to use the long TIMEOUTS.MODEL_RESPONSE only for the
modelConversationMessages visibility and pass a much shorter timeout (e.g., a
new or existing short/ui timeout like TIMEOUTS.SHORT or TIMEOUTS.UI_UPDATE) into
verifySendButtonVisible so the send-button check does not duplicate the full
MODEL_RESPONSE duration; keep identifiers: waitForModelResponse,
modelConversationMessages.first(), verifySendButtonVisible, and
TIMEOUTS.MODEL_RESPONSE.
- Around line 331-335: The clickEditOnUserMessage method should not bypass
actionability checks with force: true; remove the { force: true } from the
getByLabel('Edit message').click call, ensure the hover on
this.userConversationMessages.filter({ hasText: messageText }) actually makes
the "Edit message" button visible, and if necessary add an explicit
wait/assertion (e.g., waitFor or expect to be visible) on the getByLabel('Edit
message') locator before clicking so the click fails when the button is not
actionable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1eba9701-76de-4d7c-8182-ba969e615f3a
📒 Files selected for processing (2)
tests/playwright/src/model/pages/chat-page.tstests/playwright/src/specs/provider-specs/chat-smoke.spec.ts
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
No description provided.