Skip to content

Conversation

@dougfabris
Copy link
Member

@dougfabris dougfabris commented Nov 13, 2025

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Tests
    • Refactored admin user end-to-end tests to use a centralized search action for locating users, making searches verify a single result.
    • Made the search input no longer directly accessed by tests and updated delete and role/status flows to rely on the centralized search.
    • Improves reliability and reduces duplication across multiple user-management scenarios.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Nov 13, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Nov 13, 2025

⚠️ No Changeset found

Latest commit: 84bb663

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

@dougfabris dougfabris added this to the 7.13.0 milestone Nov 13, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 13, 2025

Walkthrough

Replaces direct test interactions with the users search input by introducing and using a new AdminUsers.page-object method searchUser(username); makes the raw search input private and updates test specs to call the new method where they previously filled the input and asserted visibility.

Changes

Cohort / File(s) Summary
Page object: AdminUsers
apps/meteor/tests/e2e/page-objects/admin-users.ts
Made inputSearchUsers private; changed getUserRowByUsername() to return the first match; added searchUser(username: string): Promise<void> that performs the search and verifies a single result; updated deleteUser() to use searchUser.
Test specs: use new search method
apps/meteor/tests/e2e/admin-users.spec.ts, apps/meteor/tests/e2e/admin-users-custom-fields.spec.ts, apps/meteor/tests/e2e/admin-users-role-management.spec.ts, apps/meteor/tests/e2e/admin-users-status-management.spec.ts, apps/meteor/tests/e2e/administration.spec.ts
Replaced direct inputSearchUsers.fill(...) + immediate getUserRowByUsername(...).toBeVisible()/toHaveCount(1) checks with calls to admin.searchUser(username); subsequent actions unchanged.

Sequence Diagram(s)

sequenceDiagram
  participant Test as E2E Test
  participant PO as AdminUsers (page-object)
  participant UI as Browser / DOM

  Note over Test,PO: New flow uses page-object abstraction
  Test->>PO: searchUser(username)
  activate PO
  PO->>UI: inputSearchUsers.fill(username)
  UI-->>PO: input updated
  PO->>UI: expect(getUserRowByUsername(username).first()).toHaveCount(1)
  UI-->>PO: row visible
  PO-->>Test: resolved
  deactivate PO
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Changes are consistent and repetitive across tests.
  • Key file to inspect: apps/meteor/tests/e2e/page-objects/admin-users.ts for correctness of new searchUser behavior.
  • Spot-check a couple of updated specs to confirm no regression in subsequent actions.

Possibly related PRs

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • MartinSchoeler
  • juliajforesti

Poem

🐰 I hopped through tests with nimble feet,
Replaced raw fills with a method neat,
Inputs tucked private, search now in one place,
Hooray for tidy hops across the test space! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'test: Flaky admin search users' is vague and does not clearly convey the specific technical change being made. While it references a general area (admin search users), it uses the term 'flaky' without explaining what specific improvement or fix is being applied. Replace with a more specific title that describes the actual technical change, such as 'test: Refactor admin user search with dedicated searchUser method' or 'test: Extract admin search logic into reusable searchUser method'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test/flaky-search-users

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7d3e846 and 84bb663.

📒 Files selected for processing (1)
  • apps/meteor/tests/e2e/admin-users-status-management.spec.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-23T19:22:59.217Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 36987
File: apps/meteor/tests/e2e/page-objects/fragments/room-toolbar.ts:10-20
Timestamp: 2025-09-23T19:22:59.217Z
Learning: In Playwright e2e tests, prefer stable selectors like data-qa-id attributes over localized text in getByRole() or getByText() calls to prevent test failures when UI language changes. Test translations separately by validating actual text content after ensuring UI interactions work with stable selectors.

Applied to files:

  • apps/meteor/tests/e2e/admin-users-status-management.spec.ts
⏰ 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 comments (1)
apps/meteor/tests/e2e/admin-users-status-management.spec.ts (1)

62-64: Review comment is incorrect. Both concerns are unfounded.

The getTabByName() method has a default parameter = 'All', so calling it without arguments is intentional and consistent with the design—not an inconsistency.

Additionally, the searchUser() method already includes the assertion await expect(this.getUserRowByUsername(username)).toHaveCount(1);, which verifies the user is found and visible. The test step is complete and correct as-is.

Likely an incorrect or invalid review comment.


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.

@dougfabris dougfabris changed the title test: Flaky search users test: Flaky admin search users Nov 13, 2025
@dougfabris dougfabris force-pushed the test/flaky-search-users branch from 1dce961 to 9c9b09a Compare November 13, 2025 15:25
@dougfabris dougfabris marked this pull request as ready for review November 13, 2025 15:29
@dougfabris dougfabris requested a review from a team as a code owner November 13, 2025 15:29
Copy link
Contributor

@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.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c0dee8d and 7d3e846.

📒 Files selected for processing (6)
  • apps/meteor/tests/e2e/admin-users-custom-fields.spec.ts (3 hunks)
  • apps/meteor/tests/e2e/admin-users-role-management.spec.ts (2 hunks)
  • apps/meteor/tests/e2e/admin-users-status-management.spec.ts (1 hunks)
  • apps/meteor/tests/e2e/admin-users.spec.ts (1 hunks)
  • apps/meteor/tests/e2e/administration.spec.ts (2 hunks)
  • apps/meteor/tests/e2e/page-objects/admin-users.ts (4 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-23T19:22:59.217Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 36987
File: apps/meteor/tests/e2e/page-objects/fragments/room-toolbar.ts:10-20
Timestamp: 2025-09-23T19:22:59.217Z
Learning: In Playwright e2e tests, prefer stable selectors like data-qa-id attributes over localized text in getByRole() or getByText() calls to prevent test failures when UI language changes. Test translations separately by validating actual text content after ensuring UI interactions work with stable selectors.

Applied to files:

  • apps/meteor/tests/e2e/admin-users-role-management.spec.ts
⏰ 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). (2)
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (7)
apps/meteor/tests/e2e/page-objects/admin-users.ts (3)

31-33: Good encapsulation by making the search input private.

Making inputSearchUsers private and exposing searchUser() as the public API is a solid design choice that centralizes search logic and prevents direct input manipulation in tests.


63-66: Excellent solution for addressing flaky user search tests.

The searchUser() method addresses flakiness by:

  1. Filling the search input
  2. Explicitly waiting for exactly 1 matching result via toHaveCount(1)

This prevents race conditions where tests might proceed before search results load.

Note: toHaveCount(1) checks that exactly one element exists in the DOM, but doesn't verify visibility (CSS display/visibility properties). If visibility is a requirement for your tests, consider adding an additional toBeVisible() check:

async searchUser(username: string): Promise<void> {
    await this.inputSearchUsers.fill(username);
    const row = this.getUserRowByUsername(username);
    await expect(row).toHaveCount(1);
    await expect(row).toBeVisible();  // Optional: if visibility matters
}

39-41: Adding .first() is safe—all callers use searchUser() first.

Verification confirms that every usage of getUserRowByUsername() across all test files is preceded by searchUser(), which asserts toHaveCount(1). The concern about silent ambiguous selection does not apply to the current codebase. The .first() provides defensive programming but is not strictly necessary given the existing usage patterns.

apps/meteor/tests/e2e/administration.spec.ts (2)

68-70: Clean refactor to use the centralized search method.

The test now properly uses searchUser() to find the user, improving reliability and consistency with other tests.


104-104: Proper usage pattern: search before interacting with user row.

apps/meteor/tests/e2e/admin-users-custom-fields.spec.ts (1)

64-64: Consistent adoption of the centralized search method across all test cases.

All three test cases properly use searchUser() before interacting with user rows, following the established pattern and improving test reliability.

Also applies to: 94-94, 143-143

apps/meteor/tests/e2e/admin-users-role-management.spec.ts (1)

33-33: Proper usage of the centralized search abstraction.

Both tests correctly use searchUser() to locate users before performing role management actions, improving reliability and consistency.

Also applies to: 51-51

@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.96%. Comparing base (c390d5c) to head (84bb663).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #37501      +/-   ##
===========================================
- Coverage    68.98%   68.96%   -0.02%     
===========================================
  Files         3358     3358              
  Lines       114240   114240              
  Branches     20537    20537              
===========================================
- Hits         78803    78790      -13     
- Misses       33345    33362      +17     
+ Partials      2092     2088       -4     
Flag Coverage Δ
e2e 57.42% <ø> (-0.05%) ⬇️
e2e-api 42.85% <ø> (+0.03%) ⬆️

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.

@tassoevan tassoevan merged commit 09874ae into develop Nov 13, 2025
49 checks passed
@tassoevan tassoevan deleted the test/flaky-search-users branch November 13, 2025 17:20
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.

3 participants