test: add missing tests for toolbox pre and pos slots in RoomHeader#39480
test: add missing tests for toolbox pre and pos slots in RoomHeader#39480sahillllllllll-bit wants to merge 1 commit intoRocketChat:developfrom
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
WalkthroughTwo new test cases were added to RoomHeader.spec.tsx to verify the rendering of toolbox slots. The tests check that the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested labels
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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.
1 issue found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/meteor/client/views/room/Header/RoomHeader.spec.tsx">
<violation number="1" location="apps/meteor/client/views/room/Header/RoomHeader.spec.tsx:66">
P2: The new pre/pos slot tests only assert global text presence and do not verify that slot content is rendered inside the toolbar in the intended order.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/meteor/client/views/room/Header/RoomHeader.spec.tsx (1)
64-71: Scope these assertions to the toolbar.On Line 66 and Line 71,
getByTextonly proves the slot content exists somewhere in the document. It would miss a regression wheretoolbox.pre/toolbox.posrender outsideHeaderToolbar, which is the behavior this PR is meant to cover.🔍 Suggested test tightening
-import { render, screen } from '@testing-library/react'; +import { render, screen, within } from '@testing-library/react'; … it('should render toolbox pre slot', () => { render(<RoomHeader room={mockedRoom} slots={{ toolbox: { pre: <div>Pre Item</div> } }} />, { wrapper: appRoot }); - expect(screen.getByText('Pre Item')).toBeInTheDocument(); + expect(within(screen.getByLabelText('Toolbox_room_actions')).getByText('Pre Item')).toBeInTheDocument(); }); it('should render toolbox pos slot', () => { render(<RoomHeader room={mockedRoom} slots={{ toolbox: { pos: <div>Pos Item</div> } }} />, { wrapper: appRoot }); - expect(screen.getByText('Pos Item')).toBeInTheDocument(); + expect(within(screen.getByLabelText('Toolbox_room_actions')).getByText('Pos Item')).toBeInTheDocument(); });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/meteor/client/views/room/Header/RoomHeader.spec.tsx` around lines 64 - 71, The assertions in RoomHeader.spec.tsx are too broad — replace global getByText checks with queries scoped to the HeaderToolbar so we verify toolbox.pre and toolbox.pos render inside the toolbar. Import and use within from `@testing-library/react`, locate the toolbar element rendered by RoomHeader (e.g., query the HeaderToolbar via role/testid/class used in RoomHeader) and then assert using within(toolbarElement).getByText('Pre Item') and within(toolbarElement).getByText('Pos Item') for the two tests (update both tests referencing toolbox pre/pos and ensure you locate the same HeaderToolbar element in each).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/meteor/client/views/room/Header/RoomHeader.spec.tsx`:
- Around line 64-71: The assertions in RoomHeader.spec.tsx are too broad —
replace global getByText checks with queries scoped to the HeaderToolbar so we
verify toolbox.pre and toolbox.pos render inside the toolbar. Import and use
within from `@testing-library/react`, locate the toolbar element rendered by
RoomHeader (e.g., query the HeaderToolbar via role/testid/class used in
RoomHeader) and then assert using within(toolbarElement).getByText('Pre Item')
and within(toolbarElement).getByText('Pos Item') for the two tests (update both
tests referencing toolbox pre/pos and ensure you locate the same HeaderToolbar
element in each).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6d0610de-61a1-4820-97b6-2d00fcda6cae
📒 Files selected for processing (1)
apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📜 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). (1)
- GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{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/client/views/room/Header/RoomHeader.spec.tsx
🧠 Learnings (11)
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Utilize Playwright fixtures (`test`, `page`, `expect`) for consistency in test files
Applied to files:
apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Prefer web-first assertions (`toBeVisible`, `toHaveText`, etc.) in Playwright tests
Applied to files:
apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2026-02-24T19:36:55.089Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/page-objects/fragments/home-content.ts:60-82
Timestamp: 2026-02-24T19:36:55.089Z
Learning: In RocketChat/Rocket.Chat e2e tests (apps/meteor/tests/e2e/page-objects/fragments/home-content.ts), thread message preview listitems do not have aria-roledescription="message", so lastThreadMessagePreview locator cannot be scoped to messageListItems (which filters for aria-roledescription="message"). It should remain scoped to page.getByRole('listitem') or mainMessageList.getByRole('listitem').
Applied to files:
apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure tests run reliably in parallel without shared state conflicts
Applied to files:
apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Maintain test isolation between test cases in Playwright tests
Applied to files:
apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Group related tests in the same file
Applied to files:
apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use `expect` matchers for assertions (`toEqual`, `toContain`, `toBeTruthy`, `toHaveLength`, etc.) instead of `assert` statements in Playwright tests
Applied to files:
apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2025-12-10T21:00:54.909Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:54.909Z
Learning: Rocket.Chat monorepo: Jest testMatch pattern '<rootDir>/src/**/*.spec.(ts|js|mjs)' is valid in this repo and used across multiple packages (e.g., packages/tools, ee/packages/omnichannel-services). Do not flag it as invalid in future reviews.
Applied to files:
apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : All test files must be created in `apps/meteor/tests/e2e/` directory
Applied to files:
apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to **/*.spec.ts : Use descriptive test names that clearly communicate expected behavior in Playwright tests
Applied to files:
apps/meteor/client/views/room/Header/RoomHeader.spec.tsx
📚 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/client/views/room/Header/RoomHeader.spec.tsx
While working on my GSoC proposal related to Room Header button ordering, I was exploring the
RoomHeadercomponent and its associated tests. During this review, I noticed that the component supports additional toolbox slot props (toolbox.preandtoolbox.pos) but the current test suite does not verify their rendering.Specifically, the
RoomHeaderimplementation renders these slots insideHeaderToolbar:However, the existing tests only cover:
default toolbox rendering
hidden toolbox behavior
custom
toolbox.contentThere are no tests validating that
toolbox.preandtoolbox.posare rendered correctly.Changes
This PR adds two small test cases to improve coverage:
slots.toolbox.prerenders inside the toolbar.slots.toolbox.posrenders inside the toolbar.Summary by CodeRabbit