Skip to content

PM-5895: refresh review opportunities after auth changes - #7269

Merged
jmgasper merged 1 commit into
developfrom
PM-5895-1
Aug 24, 2026
Merged

PM-5895: refresh review opportunities after auth changes#7269
jmgasper merged 1 commit into
developfrom
PM-5895-1

Conversation

@jmgasper

Copy link
Copy Markdown
Collaborator

What was broken

The earlier PM-5895 fix forwarded the current bearer token to review-opportunity listing and detail requests. QA then created a challenge in the Hide Challenges group and found that its open review opportunity was still absent for both admins and members of that group.

A caller-specific restricted result could also remain in the Redux cache after logout.

Root cause

Community app authentication is refreshed asynchronously after the challenge listing mounts. The Open for Review waypoint could finish its first request before tokenV3 arrived, which made that request anonymous even though the prior implementation was capable of forwarding a token.

The review-opportunity cache and its allReviewOpportunitiesLoaded flag were not invalidated when tokenV3 changed. Once the anonymous request completed, the bucket therefore had no reason to request page zero again for the authenticated admin or group member.

The dev API was also rechecked: authenticated access returns the grouped opportunities that anonymous access removes, and the QA example user is present in the Hide Challenges group. No review-api change is required.

What was changed

  • Added a dedicated dropReviewOpportunities action and reducer handler that clears only review-opportunity rows, pagination, loading, and completion state.
  • Clear that caller-specific cache whenever tokenV3 changes.
  • If Open for Review is active, immediately load page zero with the new token.
  • If another bucket is active, leave Open for Review cleared so it remains lazy-loaded when selected.
  • This also removes restricted cached rows and reloads anonymously after logout.

Any added/updated tests

  • Added Listing.reviewOpportunities.jsx lifecycle tests for delayed login, logout, and token changes while another bucket is active.
  • Added reducer coverage confirming the review-opportunity cache resets without changing normal challenge buckets.
  • npm run jest -- tests/shared/containers/challenge-listing/Listing.reviewOpportunities.jsx tests/shared/reducers/challenge-listing/index.js — 2 suites, 4 tests passed.
  • npm test — 157 suites passed, 376 tests passed, 4 suites/23 tests skipped.
  • npm run lint — passed.
  • npm run build — passed.

What was broken

Group-restricted review opportunities remained missing for admins and eligible
group members even after the earlier fix began forwarding bearer tokens. A
restricted result already loaded for one caller could also remain cached after
the caller logged out.

Root cause

Community app authentication is populated asynchronously. The Open for Review
bucket could therefore complete its first request anonymously before tokenV3
arrived. The review-opportunity rows and all-loaded pagination flag were never
invalidated when authentication changed, so the authenticated request was not
made and the anonymous result set stayed on screen.

What was changed

- Added a focused action and reducer path that clears only review-opportunity
  rows, pagination, loading, and completion state.
- Clear that caller-specific cache whenever tokenV3 changes.
- Immediately reload page zero with the current token when Open for Review is
  active; inactive buckets remain lazy-loaded.

Any added/updated tests

- Added lifecycle coverage for delayed authentication, logout, and auth changes
  while another bucket is active.
- Added reducer coverage proving the review-opportunity cache resets without
  changing other challenge buckets.
- Verified the full test suite, lint, and production build.
@jmgasper
jmgasper requested a review from kkartunov as a code owner August 23, 2026 20:07
@jmgasper
jmgasper merged commit 678c38d into develop Aug 24, 2026
7 checks passed
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.

1 participant