-
Notifications
You must be signed in to change notification settings - Fork 340
[refactor] Billing DI refactor #395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
brandonkachen
wants to merge
15
commits into
main
Choose a base branch
from
billing-di-refactor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+2,547
−1,723
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add typed mock helpers in common/src/testing/fixtures/: - billing.ts: createGrantCreditsDbMock, createOrgBillingDbMock, etc. - fetch.ts: createMockFetch, wrapMockAsFetch, etc. - database.ts: createVersionQueryDbMock, createExistsQueryDbMock - agent-runtime.ts: mockAnalytics, mockBigQuery, mockRandomUUID - index.ts: barrel exports - Refactor billing package to use DI: - Add optional conn parameter to grant-credits, org-billing, credit-delegation - Add injectable function parameters to usage-service - Update all 4 test files to use typed mock helpers - Refactor agent-runtime tests to use shared mock helpers: - Replace inline spyOn calls with mockAnalytics/mockBigQuery/mockRandomUUID - Update 8 test files - Refactor SDK code-search to use DI: - Export SpawnFn type and codeSearchWithSpawn function - Update tests to use typed mock spawn - Refactor CLI tests to use wrapMockAsFetch: - Update codebuff-api, use-usage-query, and integration tests - Add SDK build step to init-worktree.ts for fresh worktree setup - Add barrel export for testing/fixtures in common/package.json Eliminates ~30 mockModule calls and ~50 "as unknown as" type casts. All 100+ affected tests pass.
The 2000 credit cap was a temporary migration safeguard that is no longer needed.
Update imports to use @codebuff/common/testing/fixtures barrel file instead of individual module paths.
- Remove .optional() from NEXT_PUBLIC_POSTHOG_API_KEY - Remove .optional() from NEXT_PUBLIC_STRIPE_CUSTOMER_PORTAL - Remove conditional check in usage-section.tsx since portal URL is now required - All required vars have dummy values in .env.example
- Remove .default() from NEXT_PUBLIC_CB_ENVIRONMENT - Remove .default() from NEXT_PUBLIC_CODEBUFF_APP_URL - Remove .default() from NEXT_PUBLIC_WEB_PORT - Keep defaults only for SUPPORT_EMAIL and POSTHOG_HOST_URL - Add NEXT_PUBLIC_WEB_PORT to .env.example
4ad0ebe to
3144056
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.