Skip to content

Conversation

@Adarsh0427
Copy link
Contributor

@Adarsh0427 Adarsh0427 commented Sep 3, 2025

Resolves #2173

Description

The problem is in SortBy.test.py unit test file.
This is the specific line used in four different test cases which failed:

const select = screen.getByLabelText('Sort By :')

SortBy.tsx file uses <Select> component imported from heroui library whose internal implementation changed in the latest update which cased problem is selecting the target element in the SortBy.test.tsx file.

Proposed change

Used sortButton to get dropdown button for sort by:

const sortButton = screen.getByRole('button', { name: /Sort By/ })

Used hiddenSelect to get hidden accessible element for testing functionality.

const hiddenSelect = screen.getByRole('combobox', { hidden: true })

Also Upgraded dependencies.

Checklist

  • I've read and followed the contributing guidelines.
  • I've run make check-test locally; all checks and tests passed.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 3, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • frontend/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Summary by CodeRabbit

  • Tests

    • Updated Sort By component tests to align with the new custom dropdown UI, ensuring accessibility and selection behavior remain covered.
  • Chores

    • Upgraded frontend dependencies (UI components, observability, types, and tooling) to the latest patch/minor versions for improved stability and compatibility.
  • Notes

    • No user-facing changes in this release.

Walkthrough

Updated SortBy unit test to use the new custom dropdown UI (button + hidden combobox) and bumped frontend dependencies (including heroui packages and tooling) in frontend/package.json.

Changes

Cohort / File(s) Summary
Tests: SortBy component
frontend/__tests__/unit/components/SortBy.test.tsx
Replaced native select queries/interactions with button-based queries and a hidden combobox; adjusted event firing, selected-value assertions, and accessibility checks to target hidden combobox and button.
Dependency updates
frontend/package.json
Bumped multiple frontend dependencies (heroui/* packages, @sentry/nextjs, @types/leaflet.markercluster, @typescript-eslint/*, jest-environment-jsdom, etc.). No script or public API changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Assessment against linked issues

Objective Addressed Explanation
Upgrade heroui/* dependencies (#2173)
Fix tests broken by heroui updates (#2173)

Out-of-scope changes

(no out-of-scope changes detected)

Possibly related PRs

Suggested reviewers

  • arkid15r
  • kasya
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 1

🧹 Nitpick comments (7)
frontend/package.json (1)

107-109: Align jest-environment-jsdom version with Jest
In jest.config.ts (line 33) the testEnvironment uses [email protected], but your Jest version is ^29.7.0—either downgrade jest-environment-jsdom to ^29.7.0 or upgrade Jest to ^30.x to avoid potential CI flakiness.

frontend/__tests__/unit/components/SortBy.test.tsx (6)

25-28: Avoid relying on data-slot; assert within the button instead.

Using [data-slot="value"] couples the test to internal markup. Query within the visible control.

Apply:

-    const sortButton = screen.getByRole('button', { name: /Sort By/ })
-    expect(sortButton).toBeInTheDocument()
-    const selectedOption = screen.getByText('Name', { selector: '[data-slot="value"]' })
-    expect(selectedOption).toBeInTheDocument()
+    const sortButton = screen.getByRole('button', { name: /Sort By/ })
+    expect(sortButton).toBeInTheDocument()
+    expect(sortButton).toHaveTextContent('Name')

35-41: This test duplicates the previous one; make it validate the list options.

Open the menu and assert options by role rather than re-checking the selected value.

Suggested change:

-    const sortButton = screen.getByRole('button', { name: /Sort By/ })
-    expect(sortButton).toBeInTheDocument()
-    // The dropdown options aren't directly visible in the DOM
-    // We're checking for the selected value instead
-    const selectedOption = screen.getByText('Name', { selector: '[data-slot="value"]' })
-    expect(selectedOption).toBeInTheDocument()
+    const sortButton = screen.getByRole('button', { name: /Sort By/ })
+    await act(async () => {
+      sortButton.click()
+    })
+    expect(await screen.findByRole('option', { name: 'Name' })).toBeInTheDocument()
+    expect(await screen.findByRole('option', { name: 'Date' })).toBeInTheDocument()

47-50: Prefer userEvent over manual change on hidden select.

Drive the UI like a user: open the menu and click the option. This makes the test resilient to internal changes.

Apply:

-    await act(async () => {
-      const hiddenSelect = screen.getByRole('combobox', { hidden: true })
-      fireEvent.change(hiddenSelect, { target: { value: 'date' } })
-    })
+    const user = userEvent.setup()
+    await act(async () => {
+      await user.click(screen.getByRole('button', { name: /Sort By/ }))
+      const dateOption = await screen.findByRole('option', { name: 'Date' })
+      await user.click(dateOption)
+    })

And update imports:

-import { render, screen, fireEvent } from '@testing-library/react'
+import { render, screen } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'

59-61: Don’t assert FontAwesome classes; assert accessible text/labels instead.

Class names are implementation details. Prefer the tooltip text or an aria-label on the order button (e.g., “Ascending” / “Descending”).

If SortBy doesn’t expose an accessible label, consider adding one (aria-label or title) so these tests can assert it reliably.

Also applies to: 68-70


76-80: Avoid relying on button index; target the order toggle explicitly.

Index-based selection is brittle. Use a named control or derive the button from a nearby landmark.

Suggested change:

-    await act(async () => {
-      // Get the second button (the sort order button)
-      const buttons = screen.getAllByRole('button')
-      fireEvent.click(buttons[1])
-    })
+    const user = userEvent.setup()
+    const sortButton = screen.getByRole('button', { name: /Sort By/ })
+    // Choose the other button in the same container
+    const container = sortButton.closest('[role="group"], div')!
+    const orderButton = Array.from(container.querySelectorAll('button')).find(b => b !== sortButton)!
+    await act(async () => {
+      await user.click(orderButton)
+    })

If possible, expose a stable aria-label (e.g., “Toggle sort order”) on the order button and query it directly.


88-94: Drop tagName and container assertions; assert semantics instead.

Checking tagName === 'SELECT' and closest('div') is brittle. Assert ARIA semantics:

-    const hiddenSelect = screen.getByRole('combobox', { hidden: true })
-    expect(hiddenSelect.tagName).toBe('SELECT')
+    const hiddenSelect = screen.getByRole('combobox', { hidden: true })
+    expect(hiddenSelect).toBeInTheDocument()

Optionally, if the combobox is labelled by the Sort By control:

expect(hiddenSelect).toHaveAccessibleName(/Sort By/)
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear 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 90d0b5a and 87d4c35.

⛔ Files ignored due to path filters (2)
  • backend/poetry.lock is excluded by !**/*.lock
  • frontend/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • frontend/__tests__/unit/components/SortBy.test.tsx (3 hunks)
  • frontend/package.json (4 hunks)
🔇 Additional comments (2)
frontend/package.json (2)

26-26: Misc dependency bumps—LGTM.

  • @fortawesome/react-fontawesome, @sentry/nextjs: patch updates should be safe.
  • @typescript-eslint/* and typescript-eslint: minor bumps aligned.

Also applies to: 39-39, 93-94, 119-119


28-36: Approve HeroUI version bumps
Lockfile confirms all @heroui packages’ peerDependencies (system ≥2.4.18, theme ≥2.4.17, React ≥18/≥19.0.0-rc.0, Framer-Motion ≥11.5.6) are satisfied—no warnings expected.

@github-actions github-actions bot removed the backend label Sep 3, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 3, 2025

@arkid15r arkid15r enabled auto-merge September 3, 2025 23:51
Copy link
Collaborator

@arkid15r arkid15r left a comment

Choose a reason for hiding this comment

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

LGTM

@arkid15r arkid15r added this pull request to the merge queue Sep 3, 2025
Merged via the queue into OWASP:main with commit c78201d Sep 4, 2025
25 checks passed
arkid15r added a commit that referenced this pull request Sep 4, 2025
* fixed SortBy component testcases

* fixed bot suggestions

* Update code

---------

Co-authored-by: Arkadii Yakovets <[email protected]>
Dishant1804 pushed a commit to Dishant1804/Nest that referenced this pull request Sep 6, 2025
* fixed SortBy component testcases

* fixed bot suggestions

* Update code

---------

Co-authored-by: Arkadii Yakovets <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update heroui/* dependencies and fix tests

2 participants