Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughConverted multiple relative imports to top-level aliased imports (e.g., Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
✨ 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 |
🌏 Preview Deployments
Built from commit: 🤖 This comment will be updated automatically when you push new commits to this PR. |
There was a problem hiding this comment.
Pull request overview
This pull request updates import paths in the API package from relative imports to path aliases, removes unused imports, and adds test mocking for getRawUnicodeAsset. The changes standardize the codebase to use the #lib/* and #types import aliases defined in the package.json imports field, improving maintainability and consistency.
Changes:
- Standardized all imports to use
#lib/*and#typesaliases instead of relative paths - Removed unused imports (UNICODE_DRAFT_VERSION, UNICODE_VERSION_METADATA) from $version.ts
- Inlined a temporary variable assignment in utils.ts
- Added mock for getRawUnicodeAsset function in test file
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| apps/api/test/routes/v1_versions/list.test.ts | Added getRawUnicodeAsset mock and updated getCurrentDraftVersion mock to forward arguments; added mock return values to all test cases |
| apps/api/src/routes/well-known/ucd-config.json.ts | Changed HonoEnv import from relative to #types alias |
| apps/api/src/routes/well-known/router.ts | Changed HonoEnv import from relative to #types alias |
| apps/api/src/routes/v1_versions/utils.ts | Changed imports to use #lib/* and #types aliases; inlined text variable into getCurrentDraftVersion call |
| apps/api/src/routes/v1_versions/router.ts | Changed HonoEnv import from relative to #types alias |
| apps/api/src/routes/v1_versions/list.ts | Changed imports from relative paths to #lib/* and #types aliases |
| apps/api/src/routes/v1_versions/$version.ts | Changed imports to #lib/* and #types aliases; removed unused UNICODE_DRAFT_VERSION and UNICODE_VERSION_METADATA imports |
| apps/api/src/routes/v1_schemas/router.ts | Changed HonoEnv import from relative to #types alias |
| apps/api/src/routes/v1_files/router.ts | Changed HonoEnv import from relative to #types alias |
| apps/api/src/routes/v1_files/$wildcard.ts | Changed imports to use #lib/* and #types aliases |
| apps/api/src/routes/tasks/routes.ts | Changed HonoEnv import from relative to #types alias |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| vi.mock("#lib/files", () => ({ | ||
| getRawUnicodeAsset: vi.fn((path) => getRawUnicodeAsset(path)), | ||
| })); | ||
|
|
There was a problem hiding this comment.
The mock implementation creates a circular reference by calling the imported getRawUnicodeAsset function. This defeats the purpose of mocking since the mock is trying to call the real implementation, which is from the module being mocked. The mock should either return a function that doesn't call the real implementation, or use importOriginal similar to how the @unicode-utils/core mock is set up above.
| vi.mock("#lib/files", () => ({ | |
| getRawUnicodeAsset: vi.fn((path) => getRawUnicodeAsset(path)), | |
| })); | |
| vi.mock("#lib/files", async (importOriginal) => { | |
| const original = await importOriginal<typeof import("#lib/files")>(); | |
| return { | |
| ...original, | |
| getRawUnicodeAsset: vi.fn((path) => original.getRawUnicodeAsset(path)), | |
| }; | |
| }); |
🔗 Linked issue
📚 Description
Summary by CodeRabbit
Chores
Tests