Skip to content

fix: search criteria not preserved#889

Open
priscila-moneo wants to merge 1 commit intomasterfrom
fix/search-criteria-not-preserved
Open

fix: search criteria not preserved#889
priscila-moneo wants to merge 1 commit intomasterfrom
fix/search-criteria-not-preserved

Conversation

@priscila-moneo
Copy link
Copy Markdown

@priscila-moneo priscila-moneo commented Apr 22, 2026

ref: https://app.clickup.com/t/86b9hhg65

Summary by CodeRabbit

  • Bug Fixes

    • Sponsor list search, pagination, and sorting parameters are now correctly applied when retrieving data, ensuring results sync with current filter and sort settings.
  • Tests

    • Added unit test for sponsor list page verifying search filtering, pagination, and sorting functionality work as expected.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

Warning

Rate limit exceeded

@priscila-moneo has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 14 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 51 minutes and 14 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 147f1ef9-8e9c-4119-adde-3dd6191ead4f

📥 Commits

Reviewing files that changed from the base of the PR and between d9c4979 and 3c921ae.

📒 Files selected for processing (2)
  • src/pages/sponsors/__tests__/sponsor-list-page.test.js
  • src/pages/sponsors/sponsor-list-page.js
📝 Walkthrough

Walkthrough

New unit test added for SponsorListPage component validating search term retention and correct action invocation with filter parameters. Component's useEffect hook modified to pass filter and pagination parameters to getSponsors and re-trigger on parameter changes.

Changes

Cohort / File(s) Summary
Test Addition
src/pages/sponsors/__tests__/sponsor-list-page.test.js
New unit test verifying SponsorListPage renders correctly with Redux store state, retains search term in input field, displays matching/non-matching sponsors, and invokes getSponsors with correct parameters (term, currentSummitId, perPage, order, orderDir).
Component Enhancement
src/pages/sponsors/sponsor-list-page.js
Modified useEffect hook to pass filter and pagination parameters (term, DEFAULT_CURRENT_PAGE, perPage, order, orderDir) to getSponsors instead of calling without arguments. Expanded dependency array to re-trigger fetch when term, perPage, order, or orderDir change.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • caseylocker
  • matiasperrone-exo
  • martinquiroga-exo
  • smarcet

Poem

🐰 With whiskers twitched and paws held high,
A test hops in with watchful eye!
Parameters passed, dependencies keen,
The sponsor list now stays pristine! ✨

🚥 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 'fix: search criteria not preserved' directly and clearly summarizes the main change: fixing a bug where search criteria were not being preserved during sponsor list operations.
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.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/search-criteria-not-preserved

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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/pages/sponsors/__tests__/sponsor-list-page.test.js (2)

53-60: Comment on Line 56 is misleading.

DEFAULT_CURRENT_PAGE is passed by the component regardless of the seeded currentPage: 1 — the fact that they happen to both equal 1 hides a potential bug where the effect ignores the preserved currentPage. Consider seeding currentPage to a non-default value (e.g. 2) to make the test's intent explicit: the effect deliberately resets to DEFAULT_CURRENT_PAGE on mount. Or, if the desired behavior is to preserve the page too, the assertion (and the production code) should reflect that.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/sponsors/__tests__/sponsor-list-page.test.js` around lines 53 - 60,
The test is misleading because it passes DEFAULT_CURRENT_PAGE implicitly (both
are 1), masking whether the component effect resets or preserves currentPage;
update the test for clarity by seeding the mocked preserved state with a
non-default currentPage (e.g., currentPage: 2) and then assert the intended
behavior: if the effect should reset, assert getSponsors was called with
DEFAULT_CURRENT_PAGE, otherwise update the expectation to use the preserved
currentPage value; reference the test helpers/state setup where currentPage is
seeded and the getSponsors expectation in sponsor-list-page.test.js to change
the seeded value or the expected argument accordingly.

49-51: Weak negative assertion.

queryByText("OTHER") passes trivially since no sponsor with that name was ever seeded into state — the assertion doesn't validate any filtering logic (and the component doesn't filter client-side anyway; filtering happens server-side via getSponsors). Consider either removing this line, or seeding a second sponsor and verifying that the list only renders what the reducer provides, to avoid a misleading "only FNTECH is visible" comment.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/sponsors/__tests__/sponsor-list-page.test.js` around lines 49 - 51,
The negative assertion using screen.queryByText("OTHER") is misleading because
no "OTHER" sponsor was ever seeded; update the test in sponsor-list-page.test.js
to either remove that queryByText line or better: seed a second sponsor (e.g.,
an "OTHER" fixture) into the mocked getSponsors/reducer state and assert that
only the reducer-provided sponsors are rendered (use screen.getByText("FNTECH")
and expect(screen.queryByText("OTHER")).not.toBeInTheDocument()). Locate the
seeding/mocking logic around the test setup (where getSponsors or the sponsors
reducer is mocked) and add the second sponsor there so the negative assertion
actually verifies filtering/rendering behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/pages/sponsors/sponsor-list-page.js`:
- Around line 63-67: The effect currently depends on currentSummit, term,
perPage, order, and orderDir which causes duplicate/conflicting fetches because
handlers like handleSearchDebounced, handlePerPageChange, and handleSort call
getSponsors and then Redux updates re-trigger the effect; change the effect to
only run on mount/summit change (e.g., the useEffect with useEffect(() => { if
(currentSummit) getSponsors(term, DEFAULT_CURRENT_PAGE, perPage, order,
orderDir); }, [currentSummit]) or add a firstLoad/summitChanged boolean gate) so
that handlers (handleSearchDebounced, handlePerPageChange, handleSort) remain
the single source of subsequent fetches and you avoid duplicate/contradictory
requests involving DEFAULT_CURRENT_PAGE and currentPage.

---

Nitpick comments:
In `@src/pages/sponsors/__tests__/sponsor-list-page.test.js`:
- Around line 53-60: The test is misleading because it passes
DEFAULT_CURRENT_PAGE implicitly (both are 1), masking whether the component
effect resets or preserves currentPage; update the test for clarity by seeding
the mocked preserved state with a non-default currentPage (e.g., currentPage: 2)
and then assert the intended behavior: if the effect should reset, assert
getSponsors was called with DEFAULT_CURRENT_PAGE, otherwise update the
expectation to use the preserved currentPage value; reference the test
helpers/state setup where currentPage is seeded and the getSponsors expectation
in sponsor-list-page.test.js to change the seeded value or the expected argument
accordingly.
- Around line 49-51: The negative assertion using screen.queryByText("OTHER") is
misleading because no "OTHER" sponsor was ever seeded; update the test in
sponsor-list-page.test.js to either remove that queryByText line or better: seed
a second sponsor (e.g., an "OTHER" fixture) into the mocked getSponsors/reducer
state and assert that only the reducer-provided sponsors are rendered (use
screen.getByText("FNTECH") and
expect(screen.queryByText("OTHER")).not.toBeInTheDocument()). Locate the
seeding/mocking logic around the test setup (where getSponsors or the sponsors
reducer is mocked) and add the second sponsor there so the negative assertion
actually verifies filtering/rendering behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 56060623-e6b9-4e01-9a03-382a56c77a31

📥 Commits

Reviewing files that changed from the base of the PR and between 70d9882 and d9c4979.

📒 Files selected for processing (2)
  • src/pages/sponsors/__tests__/sponsor-list-page.test.js
  • src/pages/sponsors/sponsor-list-page.js

Comment thread src/pages/sponsors/sponsor-list-page.js Outdated
Comment on lines +63 to +67
useEffect(() => {
if (currentSummit) {
getSponsors();
getSponsors(term, DEFAULT_CURRENT_PAGE, perPage, order, orderDir);
}
}, [currentSummit]);
}, [currentSummit, term, perPage, order, orderDir]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Risk of duplicate/conflicting fetches from overlapping effect + handler calls.

Because term, perPage, order, and orderDir are now effect dependencies, and the REQUEST_SPONSORS reducer writes these back into Redux props (see src/reducers/sponsors/sponsor-list-reducer.js), every handler that calls getSponsors will also re-trigger this effect, causing a second fetch:

  • handleSearchDebounced (Line 71) calls getSponsors(term, 1, perPage, order, orderDir) → Redux updates term → effect re-runs with the same args (duplicate request).
  • handlePerPageChange (Line 97) → effect re-fires (duplicate request with same args).
  • handleSort (Line 100) calls getSponsors(term, currentPage, perPage, key, dir), but the effect then re-fires with DEFAULT_CURRENT_PAGE, clobbering the user's page and issuing a conflicting request.

Consider scoping the effect to only the mount/summit-change case (e.g., keep only currentSummit as a dependency, or gate on a "first load / summit changed" flag) and let the handlers remain the single source of truth for subsequent fetches. That preserves the original bug fix (seeding the list with the preserved term on mount) without introducing redundant/racing requests.

Proposed scoping of the effect
   useEffect(() => {
     if (currentSummit) {
       getSponsors(term, DEFAULT_CURRENT_PAGE, perPage, order, orderDir);
     }
-  }, [currentSummit, term, perPage, order, orderDir]);
+  }, [currentSummit?.id]);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
useEffect(() => {
if (currentSummit) {
getSponsors();
getSponsors(term, DEFAULT_CURRENT_PAGE, perPage, order, orderDir);
}
}, [currentSummit]);
}, [currentSummit, term, perPage, order, orderDir]);
useEffect(() => {
if (currentSummit) {
getSponsors(term, DEFAULT_CURRENT_PAGE, perPage, order, orderDir);
}
}, [currentSummit?.id]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/sponsors/sponsor-list-page.js` around lines 63 - 67, The effect
currently depends on currentSummit, term, perPage, order, and orderDir which
causes duplicate/conflicting fetches because handlers like
handleSearchDebounced, handlePerPageChange, and handleSort call getSponsors and
then Redux updates re-trigger the effect; change the effect to only run on
mount/summit change (e.g., the useEffect with useEffect(() => { if
(currentSummit) getSponsors(term, DEFAULT_CURRENT_PAGE, perPage, order,
orderDir); }, [currentSummit]) or add a firstLoad/summitChanged boolean gate) so
that handlers (handleSearchDebounced, handlePerPageChange, handleSort) remain
the single source of subsequent fetches and you avoid duplicate/contradictory
requests involving DEFAULT_CURRENT_PAGE and currentPage.

Comment thread src/pages/sponsors/sponsor-list-page.js Outdated
useEffect(() => {
if (currentSummit) {
getSponsors();
getSponsors(term, DEFAULT_CURRENT_PAGE, perPage, order, orderDir);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

we should also preserve currentPage

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@priscila-moneo priscila-moneo force-pushed the fix/search-criteria-not-preserved branch from d9c4979 to a639fe3 Compare April 23, 2026 20:22
@priscila-moneo priscila-moneo force-pushed the fix/search-criteria-not-preserved branch from a639fe3 to 3c921ae Compare April 23, 2026 20:25
Copy link
Copy Markdown

@santipalenque santipalenque left a comment

Choose a reason for hiding this comment

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

LGTM

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