test(core): stub BillingNavComputeGaugeComponent in core.navigation unit tests#4180
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
…nit tests Closes #4129. The real gauge auto-fetches via the billing store on mount, silently coupling navigation unit tests to billing infrastructure. Adding a default stub in mountNav() decouples the suites and enables a positive-path test (meterMode=true → gauge slot renders).
ade9167 to
5a15033
Compare
There was a problem hiding this comment.
Pull request overview
This PR decouples core.navigation unit tests from billing infrastructure by default-stubbing the billing compute gauge component, preventing unintended billing-store side effects when tests enable billing.meterMode.
Changes:
- Refactors the auth store mock to a mutable hoisted
authStoreStateso tests can overrideserverConfigwithout re-mocking. - Extends
mountNav()to acceptstubsOverrideand merges it after default stubs. - Adds a default stub for
BillingNavComputeGaugeComponentand a new positive-path test asserting it renders whenmeterMode=true.
| }); | ||
|
|
||
| it('renders stubbed BillingNavComputeGaugeComponent when meterMode is true', () => { | ||
| // Override auth state so meterMode resolves to true for this test only. | ||
| // beforeEach resets it back to the default (no billing key) for subsequent tests. | ||
| authStoreState.serverConfig = { organizations: { enabled: false }, billing: { meterMode: true } }; | ||
| const wrapper = mountNav(); |
There was a problem hiding this comment.
Addressed in fce91cc: wrapped the meterMode=true override in try/finally so the override cannot leak even if mountNav() throws. Next describes' beforeEach already reset state, but defensive intra-test reset is cleaner.
|
|
||
| // Mock auth store — report logged in + org so the drawer actually renders | ||
| // Mock auth store — report logged in + org so the drawer actually renders. | ||
| // authStoreState is a mutable hoisted ref so individual tests can override |
There was a problem hiding this comment.
Addressed in fce91cc: comment reworded to 'mutable hoisted object' (matches reality — it's a plain hoisted object via vi.hoisted(), not a Vue ref).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4180 +/- ##
=======================================
Coverage 99.55% 99.55%
=======================================
Files 31 31
Lines 1136 1136
Branches 328 328
=======================================
Hits 1131 1131
Misses 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…iew nits) - Reword comment: 'mutable hoisted ref' → 'mutable hoisted object' (it's a plain hoisted object, not a Vue ref). Avoids future-edit confusion. - Wrap the meterMode=true test's authStoreState mutation in try/finally so the override cannot leak into subsequent tests/describes even if mountNav() throws. Next describes' beforeEach already reset state, but defensive intra-test reset is cleaner and resilient to test reordering.
Closes #4129.
Why
The real
BillingNavComputeGaugeComponentauto-fetches compute usage via the billing store on mount (<script>callsuseBillingMeterStoreor equivalent). This silently coupledcore.navigationunit tests to billing infrastructure: any test that flipsmeterMode=truewould trigger network/store side-effects irrelevant to navigation behavior.What
authStoreStateref (mirrors the existingcoreStoreStatepattern). Individual tests can now overrideserverConfig(e.g. enablebilling.meterMode) without re-mocking.mountNav({ ..., stubsOverride })to accept extra stubs; merge them after defaults.BillingNavComputeGaugeComponentto a placeholder<div class=\"stub-billing-nav-compute-gauge\" />— decouples nav tests from billing infra.meterMode=true, the stubbed gauge renders.Verification
All existing tests in the suite preserved (4 prior gauge-slot tests + 16 other). +1 new positive-path test = 20 total.