Skip to content

test: improve chat test stability on CI#1145

Merged
serbangeorge-m merged 4 commits intokortex-hub:mainfrom
serbangeorge-m:test-fix
Mar 23, 2026
Merged

test: improve chat test stability on CI#1145
serbangeorge-m merged 4 commits intokortex-hub:mainfrom
serbangeorge-m:test-fix

Conversation

@serbangeorge-m
Copy link
Copy Markdown
Contributor

No description provided.

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>
@serbangeorge-m serbangeorge-m requested a review from a team as a code owner March 23, 2026 10:21
@serbangeorge-m serbangeorge-m requested review from bmahabirbu and fbricon and removed request for a team March 23, 2026 10:21
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

Refactored 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

Cohort / File(s) Summary
Chat Page Test Utilities
tests/playwright/src/model/pages/chat-page.ts
Replaced clearLastUsedModel() with waitForModelResponse() for explicit response waiting. Changed message editing from index-based (clickEditOnUserMessage(index)) to content-based (clickEditOnUserMessage(messageText)). Refactored message dimming verification from index-based to content-based locator matching. Added verifyMessagesAfterEditAreNotDimmed() helper.
Chat Smoke Test Specs
tests/playwright/src/specs/provider-specs/chat-smoke.spec.ts
Removed clearLastUsedModel() setup call. Updated test cases to use waitForModelResponse() and content-based message editing. Changed assertions from index-based message graying to content-based dimming verification.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The pull request has no description provided, which is a lenient check that passes as long as content is not off-topic; however, an empty description provides no context about the changes. Add a description explaining why these test changes improve stability (e.g., replacing index-based selectors with text-based ones, removing localStorage manipulation for better isolation).
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: refactoring chat tests to improve stability on CI by replacing flaky patterns (index-based selectors, localStorage manipulation) with more reliable ones (text-based selectors, proper wait conditions).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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 and verifySendButtonVisible use TIMEOUTS.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: Using force: true may mask actual visibility issues.

The force: true option 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2a09493 and 2fe2f27.

📒 Files selected for processing (2)
  • tests/playwright/src/model/pages/chat-page.ts
  • tests/playwright/src/specs/provider-specs/chat-smoke.spec.ts

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@serbangeorge-m serbangeorge-m merged commit 63b07b3 into kortex-hub:main Mar 23, 2026
15 checks passed
@serbangeorge-m serbangeorge-m deleted the test-fix branch March 24, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants