Skip to content

Api tests#522

Merged
luxass merged 2 commits intomainfrom
api-tests
Feb 21, 2026
Merged

Api tests#522
luxass merged 2 commits intomainfrom
api-tests

Conversation

@luxass
Copy link
Member

@luxass luxass commented Feb 21, 2026

🔗 Linked issue

📚 Description

Summary by CodeRabbit

  • Chores

    • Refactored module import structure for improved code organization and maintainability.
  • Tests

    • Enhanced test coverage with improved mocking for asset retrieval across API operations.

@luxass luxass marked this pull request as ready for review February 21, 2026 14:37
Copilot AI review requested due to automatic review settings February 21, 2026 14:37
@luxass luxass merged commit bddd2b4 into main Feb 21, 2026
15 of 21 checks passed
@luxass luxass deleted the api-tests branch February 21, 2026 14:37
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 21, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Converted multiple relative imports to top-level aliased imports (e.g., #types, #lib/*) across API route modules; added logging and Sentry aliased imports in versioning routes; updated tests to mock new file asset dependency. No exported signatures or runtime logic behavior changed.

Changes

Cohort / File(s) Summary
HonoEnv Type Import Conversion
apps/api/src/routes/tasks/routes.ts, apps/api/src/routes/v1_files/router.ts, apps/api/src/routes/v1_schemas/router.ts, apps/api/src/routes/v1_versions/router.ts, apps/api/src/routes/well-known/router.ts, apps/api/src/routes/well-known/ucd-config.json.ts
Replaced relative ../../types import for HonoEnv with aliased #types across multiple routers and config file; no logic changes.
v1 Files Routes
apps/api/src/routes/v1_files/$wildcard.ts
Replaced relative imports with aliased imports: types (UnicodeAssetOptions, HonoEnv) and value import getUnicodeAsset now from #lib/files.
v1 Versions Routes
apps/api/src/routes/v1_versions/$version.ts, apps/api/src/routes/v1_versions/list.ts, apps/api/src/routes/v1_versions/utils.ts
Switched HonoEnv to #types; moved logger and Sentry-related imports to #lib/logger and #lib/sentry; added getRawUnicodeAsset import from #lib/files; inlined draft text retrieval in versions util.
v1 Versions Test
apps/api/test/routes/v1_versions/list.test.ts
Added/updated mocks for getRawUnicodeAsset and adjusted getCurrentDraftVersion mock forwarding; tests now mock draft ReadMe asset responses for multiple scenarios.
Misc manifest
package.json
Minor line changes referenced in several router files (path resolution updates reflected).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

apps: api

Poem

🐰 Hopping through code with a twitch of my nose,

I swap every ../../ where the clean alias grows.
Logs now arrive from a central tree,
Tests mock the assets for the drafts we see,
A tidy import trail where the spring breeze blows.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch api-tests

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.

❤️ Share

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

@github-actions
Copy link
Contributor

🌏 Preview Deployments

Application Status Preview URL
API ⏳ In Progress N/A
Store ⏳ In Progress N/A
Website ⏳ In Progress N/A
Documentation ⏳ In Progress N/A

Built from commit: add10822a86a0e7a5f037709d1260d17726dcb73


🤖 This comment will be updated automatically when you push new commits to this PR.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 #types aliases 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.

Comment on lines +25 to +28
vi.mock("#lib/files", () => ({
getRawUnicodeAsset: vi.fn((path) => getRawUnicodeAsset(path)),
}));

Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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)),
};
});

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants