Repository navigation
test(web-shared): make web-shared independent of apps/web - #7058
Closed
chrarnoldus wants to merge 6 commits into
Closed
chrarnoldus wants to merge 6 commits into
chrarnoldus wants to merge 6 commits into
Conversation
Test helpers are about to live in packages/web-shared/src/tests; exclude them from tsconfig.lib.json and Storybook like apps/web/src/tests.
git mv the apps/web test helpers that web-shared tests use (user, organization, microdollar-usage, approval, payment-method, openrouter-models, fake-r2) to packages/web-shared/src/tests/helpers, and the self-contained constant modules they or web-shared tests need (lib/auth/constants, lib/organizations/constants, lib/ai-gateway/latest-model-aliases) to the same paths in web-shared. Script output only, followed by oxfmt: every specifier that resolved to a moved file now uses @kilocode/web-shared/<path> (405 specifiers in 326 files), and the moved files' own @/ imports of web-shared modules use the package specifier (8 specifiers in 4 files).
git mv apps/web/src/lib/balanceCache.ts, which only depends on web-shared modules and is used by web-shared tests, and point its importers at @kilocode/web-shared/lib/balanceCache (script output, followed by oxfmt).
…ps/web Every test case is kept; only its file changes. - Whole files: kilo-pass-org/consumption.test.ts (its fixtures use the apps/web Kilo Pass org service) and model-stats/model-stats-cache.test.ts (drives the apps/web /api/models/stats routes) move to the same paths in apps/web. - removeUserFromOrganization cases, and the organizations and usage cases that use it, move to organization-member-removal(-usage).test.ts. - next-auth-options, passkey and platform-admin-grant cases from user/server.test.ts move to user/next-auth-options.test.ts, and the getProfileRedirectPath cases to user/profile-redirect-path.test.ts. - The subscription-accounting cases from kilo-pass/issuance.test.ts move to kilo-pass/subscription-accounting.test.ts; their shared createTestSubscription fixture becomes tests/helpers/kilo-pass.helper.ts. - The upstream-budget assertion from trpc/control-plane-budget.test.ts moves to bounded-service-fetch.test.ts.
packages/web-shared/tsconfig.json and tsconfig.lib.json no longer map @/, so neither runtime code nor tests can import apps/web through it, and `pnpm --filter @kilocode/web-shared typecheck` now also typechecks the tests with tsconfig.json. An oxlint rule rejects @/ and relative apps/web imports anywhere in the package.
7 tasks done
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (357 files)
Verified: no duplicate paths across Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0 Review guidance: REVIEW.md from base branch |
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
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.
Summary
Second preparation PR for #7051, stacked on #7056. It makes
packages/web-sharedindependent ofapps/web, tests included, while the@/fallback for consumers still exists. These are the web-shared test-isolation commits from #7051, replayed before the consumer-wide specifier rewrite instead of after it.apps/webtest helpers that web-shared tests use move withgit mvtopackages/web-shared/src/tests/helpers: user, organization, microdollar-usage, approval, payment-method, openrouter-models and fake-r2.lib/auth/constants,lib/organizations/constantsandlib/ai-gateway/latest-model-aliases.lib/balanceCache, which only depends on web-shared modules.@kilocode/web-shared/<path>, whether it used an@/alias or a relative path before.apps/webcode move intoapps/web. Every test case is kept; only its file changes.kilo-pass-org/consumption.test.tsandmodel-stats/model-stats-cache.test.tsmove whole.removeUserFromOrganization,next-auth-options, passkey, platform-admin-grant,getProfileRedirectPath, subscription-accounting and control-plane-budget cases move next to theapps/webcode they drive.packages/web-shared/tsconfig.jsonandtsconfig.lib.jsonno longer map@/.pnpm --filter @kilocode/web-shared typechecknow checks tests as well, withtsconfig.json.src/testsstays out of the runtimetsconfig.lib.jsoncheck and the Storybook program. An oxlint rule rejects@/and relativeapps/webimports anywhere in the package.packages/web-shared/AGENTS.mdsays that nothing in web-shared importsapps/web, and where shared test helpers andapps/web-dependent test cases live.Script
The moves use the script below. It resolves every
@/and relative module specifier withts.resolveModuleNameagainst the tsconfig that owns the importing file, before the move. It rewrites specifiers that resolve to a moved file, then runsgit mv. Afterwards, the moved files' own@/imports of web-shared modules were converted with the--only packages/web-sharedcodemod from #7056, thenoxfmtran.@/self-imports in 4 moved filesbalanceCache(1 file moved)@/self-importsThe moved files and the test-case moves match the corresponding commits on #7051. The one exception is a comment in
fake-r2.helper.ts, which the docs commit updates.Verification
cd apps/web && pnpm exec tsgo --noEmit,pnpm --filter @kilocode/web-shared typecheck(nowtsconfig.lib.jsonandtsconfig.json), and theapps/ai-gatewayandapps/storybooktypechecks: all passpnpm --filter @kilocode/trpc build:dist/index.d.tsanddist/mobile.d.tsare byte-identical to themainbuild.apps/mobiletypecheck passesoxlintonapps/web/src,packages/web-shared/srcandapps/ai-gateway/src: no findings, including under the new web-shared rule.oxfmt --list-differentandgit diff --checkare cleanservices/cloud-agent-nextreport-consumer.glanceable.test.ts, which loads apps/web code withvi.mock: 14 passed. CI runs the full suitescd apps/web && NODE_ENV=test pnpm exec jest --listTests: lists all 166 remainingpackages/web-sharedtests (168 before, minus the 2 files that moved toapps/web)Visual Changes
N/A
Reviewer Notes
oxfmtonly. To see the content moves alone, rungit show -M <sha> --stat.Move script source (
move-to-web-shared.mjs, run asnode move-to-web-shared.mjs . <apps/web/src/...>…)