Skip to content

refactor(frontend): consolidate account-overrides prefetch helper (closes #198)#852

Open
cristim wants to merge 2 commits into
mainfrom
fix/198-wave15
Open

refactor(frontend): consolidate account-overrides prefetch helper (closes #198)#852
cristim wants to merge 2 commits into
mainfrom
fix/198-wave15

Conversation

@cristim

@cristim cristim commented May 28, 2026

Copy link
Copy Markdown
Member

Summary

  • Extract fetchOverridesForAccounts() into frontend/src/lib/overrides.ts, replacing two near-identical inline Promise.all prefetch blocks in openFanOutModal and openPurchaseModal
  • Both callers now use a single 1-line await; the helper is 100% covered by existing tests
  • Add one extra await Promise.resolve() tick in the mixed-SP DOM test to account for the extra async function boundary introduced by the new helper

Test plan

  • npx tsc --noEmit -- clean
  • npm test -- 65 suites, 2142 passed, 1 pre-existing skip, 0 failures
  • src/lib/overrides.ts shows 100% statement/branch/function/line coverage

Summary by CodeRabbit

  • Bug Fixes
    • Improved modal rendering reliability in bulk purchase and fan-out flows, ensuring DOM content is populated before validations and UI state checks.
  • Refactor
    • Consolidated account service overrides fetching into a shared helper used across purchase-modal and fan-out-modal flows.
  • Tests
    • Reduced flakiness by adding an extra microtask tick in recommendations async modal tests before asserting DOM content.

@cristim cristim added triaged Item has been triaged priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline impact/internal Team-internal only effort/xs Trivial / one-liner type/chore Maintenance / non-user-visible labels May 28, 2026
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 56 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4a66e305-b848-4e6d-95e3-bb15021df568

📥 Commits

Reviewing files that changed from the base of the PR and between 14ef08a and 0a3e762.

📒 Files selected for processing (3)
  • frontend/src/__tests__/recommendations.test.ts
  • frontend/src/lib/overrides.ts
  • frontend/src/recommendations.ts
📝 Walkthrough

Walkthrough

Adds a shared helper for parallel account-override retrieval, uses it in both purchase modal flows, and updates fan-out tests to wait an additional microtask before asserting rendered DOM state.

Changes

Override Fetching Consolidation

Layer / File(s) Summary
Override fetching helper
frontend/src/lib/overrides.ts
Adds fetchOverridesForAccounts, which concurrently fetches overrides, returns successful results in a map keyed by account ID, and ignores individual failures.
Apply helper to modal override fetching
frontend/src/recommendations.ts
Uses the shared helper in openFanOutModal and openPurchaseModal, replacing duplicated inline fetching while preserving downstream payment-seeding behavior.
Test async timing adjustment
frontend/src/__tests__/recommendations.test.ts
Adds one microtask tick to five fan-out modal tests before asserting bucket titles, labels, breakdowns, and exclusions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • LeanerCloud/CUDly#193: Overlaps the override-prefetching logic and related recommendation test timing.
  • LeanerCloud/CUDly#325: Modifies the purchase-modal flow containing the refactored override retrieval.
  • LeanerCloud/CUDly#838: Uses the same override-prefetching path and includes related fan-out payment-seeding tests.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main refactor: consolidating account-overrides prefetch logic into a shared helper.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/198-wave15

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

@cristim

cristim commented May 28, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Actionable comments posted: 0

@cristim

cristim commented May 30, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Full review triggered.

@cristim

cristim commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 39 minutes and 42 seconds before sending another message.

@cristim

cristim commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
cristim changed the base branch from feat/multicloud-web-frontend to main June 9, 2026 15:44
@cristim

cristim commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

cristim added 2 commits July 17, 2026 21:29
…oses #198)

Extract fetchOverridesForAccounts() into frontend/src/lib/overrides.ts,
replacing two near-identical inline Promise.all blocks in openFanOutModal
and openPurchaseModal. Update the mixed-SP DOM test for the extra async
boundary introduced by the new function.
fetchOverridesForAccounts adds one extra async boundary vs the old
inline Promise.all; DOM-querying tests in #111 (issue j) and #132
(mixed-SP, umbrella-SP) need 4 Promise.resolve() ticks, not 3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/xs Trivial / one-liner impact/internal Team-internal only priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/chore Maintenance / non-user-visible urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant