Skip to content

test: fix channel flaky navigation#40390

Merged
ggazzo merged 6 commits intodevelopfrom
test/fix-flaky-channel-navigation
May 5, 2026
Merged

test: fix channel flaky navigation#40390
ggazzo merged 6 commits intodevelopfrom
test/fix-flaky-channel-navigation

Conversation

@jessicaschelly
Copy link
Copy Markdown
Member

@jessicaschelly jessicaschelly commented May 4, 2026

Proposed changes (including videos or screenshots)

This PR makes a few e2e specs less flaky by avoiding page.goto('/home') + navbar.openChat(...) when the test is not actually about sidebar/search navigation.

Instead, for room-focused tests, it uses direct room navigation with gotoChannel(...) and then waits for the room to be ready with waitForChannel().

Main changes:

  • added gotoChannel(name) to the HomeChannel page object
  • updated the main flaky candidates to use direct channel navigation
  • cleaned up report-message.spec.ts a bit by reusing adminHomeChannel instead of recreating it inside multiple steps

No UI changes.

Issue(s)

FLAKY-1680

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Tests
    • Centralized channel navigation in E2E test setup across multiple suites, removing redundant per-test navigation and ensuring flows (emoji, custom emoji, file uploads, message actions, exports, read receipts, reports, threads, composer/recorder) run in the intended channel context for more consistent, reliable assertions.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented May 4, 2026

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 4, 2026

⚠️ No Changeset found

Latest commit: a8fd63a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 351347c4-b809-4825-a956-fe5c9bfefa68

📥 Commits

Reviewing files that changed from the base of the PR and between 72cdec5 and 7aba1e9.

📒 Files selected for processing (9)
  • apps/meteor/tests/e2e/emojis.spec.ts
  • apps/meteor/tests/e2e/export-messages.spec.ts
  • apps/meteor/tests/e2e/files-management.spec.ts
  • apps/meteor/tests/e2e/message-actions.spec.ts
  • apps/meteor/tests/e2e/message-composer.spec.ts
  • apps/meteor/tests/e2e/page-objects/home-channel.ts
  • apps/meteor/tests/e2e/read-receipts.spec.ts
  • apps/meteor/tests/e2e/report-message.spec.ts
  • apps/meteor/tests/e2e/threads.spec.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • apps/meteor/tests/e2e/threads.spec.ts
  • apps/meteor/tests/e2e/message-composer.spec.ts
  • apps/meteor/tests/e2e/report-message.spec.ts
  • apps/meteor/tests/e2e/read-receipts.spec.ts
  • apps/meteor/tests/e2e/emojis.spec.ts
  • apps/meteor/tests/e2e/message-actions.spec.ts
  • apps/meteor/tests/e2e/export-messages.spec.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/tests/e2e/page-objects/home-channel.ts
  • apps/meteor/tests/e2e/files-management.spec.ts
apps/meteor/tests/e2e/page-objects/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

Utilize existing page objects pattern from apps/meteor/tests/e2e/page-objects/

Files:

  • apps/meteor/tests/e2e/page-objects/home-channel.ts
apps/meteor/tests/e2e/**/*.{ts,spec.ts}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

apps/meteor/tests/e2e/**/*.{ts,spec.ts}: Store commonly used locators in variables/constants for reuse
Follow Page Object Model pattern consistently in Playwright tests

Files:

  • apps/meteor/tests/e2e/page-objects/home-channel.ts
  • apps/meteor/tests/e2e/files-management.spec.ts
**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use .spec.ts extension for test files (e.g., login.spec.ts)

Files:

  • apps/meteor/tests/e2e/files-management.spec.ts
apps/meteor/tests/e2e/**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

apps/meteor/tests/e2e/**/*.spec.ts: All test files must be created in apps/meteor/tests/e2e/ directory
Avoid using page.locator() in Playwright tests - always prefer semantic locators such as page.getByRole(), page.getByLabel(), page.getByText(), or page.getByTitle()
Use test.beforeAll() and test.afterAll() for setup/teardown in Playwright tests
Use test.step() for complex test scenarios to improve organization in Playwright tests
Group related tests in the same file
Utilize Playwright fixtures (test, page, expect) for consistency in test files
Prefer web-first assertions (toBeVisible, toHaveText, etc.) in Playwright tests
Use expect matchers for assertions (toEqual, toContain, toBeTruthy, toHaveLength, etc.) instead of assert statements in Playwright tests
Use page.waitFor() with specific conditions instead of hardcoded timeouts in Playwright tests
Implement proper wait strategies for dynamic content in Playwright tests
Maintain test isolation between test cases in Playwright tests
Ensure clean state for each test execution in Playwright tests
Ensure tests run reliably in parallel without shared state conflicts

Files:

  • apps/meteor/tests/e2e/files-management.spec.ts
🧠 Learnings (6)
📚 Learning: 2025-12-16T17:29:40.430Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37834
File: apps/meteor/tests/e2e/page-objects/fragments/admin-flextab-emoji.ts:12-22
Timestamp: 2025-12-16T17:29:40.430Z
Learning: In all page-object files under apps/meteor/tests/e2e/page-objects/, import expect from ../../utils/test (Playwright's async expect) instead of from Jest. Jest's expect is synchronous and incompatible with web-first assertions like toBeVisible, which can cause TypeScript errors.

Applied to files:

  • apps/meteor/tests/e2e/page-objects/home-channel.ts
📚 Learning: 2026-02-24T19:39:42.247Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/page-objects/fragments/message.ts:7-7
Timestamp: 2026-02-24T19:39:42.247Z
Learning: In RocketChat e2e tests, avoid using data-qa attributes to locate elements. Prefer semantic locators such as getByRole, getByLabel, getByText, getByTitle and ARIA-based selectors. Apply this rule to all TypeScript files under apps/meteor/tests/e2e to improve test reliability, accessibility, and maintainability.

Applied to files:

  • apps/meteor/tests/e2e/page-objects/home-channel.ts
  • apps/meteor/tests/e2e/files-management.spec.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/tests/e2e/page-objects/home-channel.ts
  • apps/meteor/tests/e2e/files-management.spec.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/tests/e2e/page-objects/home-channel.ts
  • apps/meteor/tests/e2e/files-management.spec.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.

Applied to files:

  • apps/meteor/tests/e2e/files-management.spec.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.

Applied to files:

  • apps/meteor/tests/e2e/files-management.spec.ts
🔇 Additional comments (2)
apps/meteor/tests/e2e/page-objects/home-channel.ts (1)

99-102: LGTM — waitForChannel is now bundled in gotoChannel as requested.

The implementation correctly navigates to the channel URL and awaits the channel to be ready before returning, eliminating the need for callers to call both gotoChannel and waitForChannel separately.

apps/meteor/tests/e2e/files-management.spec.ts (1)

18-22: LGTM — beforeEach correctly uses the new gotoChannel helper.

Direct navigation via gotoChannel is cleaner and more reliable than the previous two-step /home + openChat pattern, and the channel-readiness wait is now encapsulated in the page object.


Walkthrough

Shared navigation setup for multiple E2E suites was centralized: a new HomeChannel.gotoChannel(name) page-object method was added, and many tests now call it from their beforeEach hooks instead of using page.goto('/home') plus navbar.openChat(...). Some tests re-navigate to the channel after admin sidebar flows.

Changes

E2E Test Navigation Consolidation

Layer / File(s) Summary
Page Object Enhancement
apps/meteor/tests/e2e/page-objects/home-channel.ts
Added async gotoChannel(name: string): Promise<void> that does page.goto('/channel/${name}') and awaits this.content.waitForChannel().
Test Setup Consolidation
apps/meteor/tests/e2e/emojis.spec.ts, apps/meteor/tests/e2e/export-messages.spec.ts, apps/meteor/tests/e2e/files-management.spec.ts, apps/meteor/tests/e2e/message-actions.spec.ts, apps/meteor/tests/e2e/message-composer.spec.ts, apps/meteor/tests/e2e/read-receipts.spec.ts, apps/meteor/tests/e2e/report-message.spec.ts, apps/meteor/tests/e2e/threads.spec.ts
beforeEach blocks now instantiate HomeChannel and call poHomeChannel.gotoChannel(targetChannel), replacing prior page.goto('/home') + poHomeChannel.navbar.openChat(...) patterns.
Per-test Call Removal / Minor Adjustments
apps/meteor/tests/e2e/emojis.spec.ts, apps/meteor/tests/e2e/export-messages.spec.ts, apps/meteor/tests/e2e/files-management.spec.ts, apps/meteor/tests/e2e/message-actions.spec.ts, apps/meteor/tests/e2e/message-composer.spec.ts, apps/meteor/tests/e2e/read-receipts.spec.ts, apps/meteor/tests/e2e/report-message.spec.ts, apps/meteor/tests/e2e/threads.spec.ts
Removed redundant per-test poHomeChannel.navbar.openChat(targetChannel) calls. In report-message.spec.ts an adminHomeChannel is created once and reused; in emojis.spec.ts tests re-run gotoChannel(targetChannel) after admin sidebar close steps before sending/ asserting custom emoji.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

type: chore

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: fixing flaky channel navigation in e2e tests by introducing direct channel navigation instead of indirect navigation patterns.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • FLAKY-1680: Request failed with status code 401

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.02%. Comparing base (bc959e5) to head (a8fd63a).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40390      +/-   ##
===========================================
- Coverage    70.09%   70.02%   -0.08%     
===========================================
  Files         3301     3301              
  Lines       120462   120462              
  Branches     21579    21583       +4     
===========================================
- Hits         84436    84351      -85     
- Misses       32753    32825      +72     
- Partials      3273     3286      +13     
Flag Coverage Δ
e2e 59.72% <ø> (+0.01%) ⬆️
e2e-api 46.23% <ø> (-0.89%) ⬇️
unit 70.86% <ø> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jessicaschelly jessicaschelly marked this pull request as ready for review May 4, 2026 16:45
@jessicaschelly jessicaschelly requested a review from a team as a code owner May 4, 2026 16:45
Copy link
Copy Markdown
Member

@dougfabris dougfabris left a comment

Choose a reason for hiding this comment

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

LGTM!

@dougfabris dougfabris added the stat: QA assured Means it has been tested and approved by a company insider label May 4, 2026
@dougfabris dougfabris added this to the 8.5.0 milestone May 4, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label May 4, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue May 4, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 4, 2026
Comment thread apps/meteor/tests/e2e/page-objects/home-channel.ts Outdated
@coderabbitai coderabbitai Bot removed the type: chore label May 4, 2026
@ggazzo ggazzo merged commit 3d0b533 into develop May 5, 2026
81 of 84 checks passed
@ggazzo ggazzo deleted the test/fix-flaky-channel-navigation branch May 5, 2026 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants