Skip to content

refactor: clean up & setup test utils#193

Merged
luxass merged 13 commits intomainfrom
test-utils
Aug 9, 2025
Merged

refactor: clean up & setup test utils#193
luxass merged 13 commits intomainfrom
test-utils

Conversation

@luxass
Copy link
Member

@luxass luxass commented Aug 9, 2025

🔗 Linked issue

📚 Description

This PR cleans some of the tooling projects up, and at the same time creates a new test utils package (currently named "test-utils-internal", since we may introduce a public test-utils package in the future).

By doing this we can introduce new test utilities that depends on other pieces, without interfering with the amount of dependencies in the root. Since root dependencies will allow sub packages to also import from there.

Summary by CodeRabbit

  • New Features

    • Added documentation and licensing files for internal tooling packages, including ESLint and test utilities.
    • Introduced internal test utilities package for consistent testing across the repository.
  • Bug Fixes

    • Updated test imports to use the new internal test utilities package, improving reliability and consistency.
  • Refactor

    • Updated TypeScript configuration and path aliases for better structure and maintainability.
    • Migrated and streamlined configuration files for ESLint and TypeScript tooling.
    • Enhanced and reorganized package metadata and scripts for internal tooling.
  • Documentation

    • Added and improved README files for internal tooling packages with usage instructions and licensing information.
  • Chores

    • Upgraded and added dependencies across multiple packages for improved compatibility and security.
    • Removed obsolete files and aliases related to previous test utilities.

luxass added 9 commits August 9, 2025 07:03
* Introduced associations for `tsconfig.json` and related files to improve syntax highlighting and editing experience in VSCode.
- Added "test/utils" to pnpm workspace packages.
- Updated dependencies in pnpm-workspace.yaml:
  - vitest-testdirs to ^4.1.1
  - testdirs to ^3.1.1
  - @cloudflare/vitest-pool-workers to ^0.8.61
  - @luxass/eslint-config to ^5.3.0
  - eslint to ^9.33.0
  - @luxass/unicode-utils to ^0.11.0
  - zod to ^4.0.16
  - @ai-sdk/openai to ^2.0.7
  - ai to ^5.0.8
  - tsdown to ^0.13.4
  - typescript to 5.9.2
  - wrangler to ^4.28.1
  - hono to ^4.9.0
  - @cloudflare/workers-types to ^4.20250809.0
  - vite to ^7.1.1
  - @cloudflare/vite-plugin to ^1.11.2
  - @tanstack/react-router to ^1.131.2
  - @tanstack/react-router-devtools to ^1.131.2
  - @tanstack/router-plugin to ^1.131.2
- Created new package @ucdjs/test-utils-internal with initial setup.
- Updated tooling/tsconfig package.json with author info and scripts.
* Moved MSW server setup to `src/msw/global-setup.ts` for better structure.
* Updated import paths in `msw.ts` to reflect new locations.
* Created new ESLint configuration file for test utilities.
* Removed obsolete `index.ts` file and added new `src/index.ts`.
* Added TypeScript configuration for test utilities.
* Updated Vitest configuration to use new paths for setup files.
* Added LICENSE file for tooling configuration.
* Added `LICENSE` and `README.md` files for documentation and licensing.
* Introduced `eslint.config.js` for ESLint configuration.
* Created `src/factory.ts` for defining the base configuration and factory function.
* Updated `package.json` to reflect new structure and added linting scripts.
* Removed obsolete `index.ts` file.
* Adjusted `tsconfig.json` to include only the `src` directory.
@changeset-bot
Copy link

changeset-bot bot commented Aug 9, 2025

⚠️ No Changeset found

Latest commit: 27362e6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 9, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Caution

Review failed

The pull request is closed.

Walkthrough

This change restructures internal test utility usage by introducing a new @ucdjs/test-utils-internal package, updates all relevant imports, and removes legacy test utility files and aliases. It also updates TypeScript and ESLint configurations, adds and revises documentation and license files, and makes several package metadata and dependency adjustments across the monorepo.

Changes

Cohort / File(s) Change Summary
Test Utilities Package Introduction & Adoption
tooling/test-utils/*, tooling/test-utils/src/msw/*, tooling/test-utils/LICENSE, tooling/test-utils/README.md, tooling/test-utils/package.json, tooling/test-utils/tsconfig.json, tooling/test-utils/eslint.config.js, test/utils/index.ts, vitest.config.ts, packages/*/test/*.test.ts, packages/*/package.json, package.json
Introduces @ucdjs/test-utils-internal as a dedicated internal test utilities package, migrates all imports from local aliases to this package, removes the obsolete test/utils/index.ts, and updates all relevant package devDependencies and test setup configurations accordingly.
TypeScript & Path Config Updates
tooling/tsconfig/base.json, tooling/tsconfig/package.json, tooling/tsconfig/README.md, tooling/tsconfig/LICENSE, tooling/tsconfig/eslint.config.js
Refactors TypeScript path mappings to remove #test-utils and add new aliases for the internal test-utils and other packages. Updates package metadata, documentation, and adds license and ESLint config files.
ESLint Plugin Enhancements
tooling/eslint-plugin/*
Adds a README and LICENSE, introduces a tsconfig, updates package metadata and scripts, and configures ESLint to use pnpm.
TSDown Config Refactor
tooling/tsdown-config/*
Moves createTsdownConfig implementation to src/factory.ts, updates exports, scripts, and package metadata. Adds README and LICENSE, refines tsconfig include/exclude patterns, and adds ESLint config. Removes legacy index.ts.
Schema-gen Model Type Update
packages/schema-gen/src/fields.ts, packages/schema-gen/src/index.ts, packages/schema-gen/test/fields.test.ts
Updates type annotations from LanguageModelV1 to LanguageModel, adjusts test mocks to new structure, and removes obsolete TypeScript comments.
Dependency & Version Bumps
pnpm-workspace.yaml
Updates and adds package versions across multiple catalogs (testing, linting, prod, dev, workers, web) and introduces a new package.
VSCode Settings
.vscode/settings.json
Adds file associations for TypeScript config files to be treated as JSONC in VSCode.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test File
    participant Utils as @ucdjs/test-utils-internal/msw
    participant MSW as MSW Server

    Test->>Utils: import { mockFetch, HttpResponse }
    Test->>Utils: call mockFetch(handler)
    Utils->>MSW: register handler
    Test->>MSW: execute test, MSW intercepts fetch
    MSW->>Utils: use registered mock handler
    MSW->>Test: return mocked response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Possibly related PRs

Poem

In the warren where code bunnies dwell,
Test helpers moved to a package as well!
Paths are now tidy, configs are neat,
Licensing carrots make the docs complete.
With every import now squeaky and clean,
The repo’s the coziest burrow you’ve seen.
🐇✨

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 280d8ea and 27362e6.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (44)
  • .vscode/settings.json (1 hunks)
  • package.json (1 hunks)
  • packages/cli/package.json (1 hunks)
  • packages/cli/test/cmd/store/init.test.ts (1 hunks)
  • packages/fetch/package.json (1 hunks)
  • packages/fetch/test/index.test.ts (1 hunks)
  • packages/fs-bridge/package.json (1 hunks)
  • packages/fs-bridge/test/bridges/http.test.ts (1 hunks)
  • packages/schema-gen/src/fields.ts (2 hunks)
  • packages/schema-gen/src/index.ts (3 hunks)
  • packages/schema-gen/test/fields.test.ts (3 hunks)
  • packages/ucd-store/package.json (1 hunks)
  • packages/ucd-store/test/analyze.test.ts (1 hunks)
  • packages/ucd-store/test/clean.test.ts (1 hunks)
  • packages/ucd-store/test/file-operations.test.ts (1 hunks)
  • packages/ucd-store/test/init.test.ts (1 hunks)
  • packages/ucd-store/test/internal/files.test.ts (1 hunks)
  • pnpm-workspace.yaml (4 hunks)
  • test/utils/index.ts (0 hunks)
  • tooling/eslint-plugin/LICENSE (1 hunks)
  • tooling/eslint-plugin/README.md (1 hunks)
  • tooling/eslint-plugin/eslint.config.js (1 hunks)
  • tooling/eslint-plugin/package.json (1 hunks)
  • tooling/eslint-plugin/tsconfig.json (1 hunks)
  • tooling/test-utils/LICENSE (1 hunks)
  • tooling/test-utils/README.md (1 hunks)
  • tooling/test-utils/eslint.config.js (1 hunks)
  • tooling/test-utils/package.json (1 hunks)
  • tooling/test-utils/src/msw/global-setup.ts (1 hunks)
  • tooling/test-utils/src/msw/msw.ts (3 hunks)
  • tooling/test-utils/tsconfig.json (1 hunks)
  • tooling/tsconfig/LICENSE (1 hunks)
  • tooling/tsconfig/README.md (1 hunks)
  • tooling/tsconfig/base.json (1 hunks)
  • tooling/tsconfig/eslint.config.js (1 hunks)
  • tooling/tsconfig/package.json (1 hunks)
  • tooling/tsdown-config/LICENSE (1 hunks)
  • tooling/tsdown-config/README.md (1 hunks)
  • tooling/tsdown-config/eslint.config.js (1 hunks)
  • tooling/tsdown-config/index.ts (0 hunks)
  • tooling/tsdown-config/package.json (1 hunks)
  • tooling/tsdown-config/src/factory.ts (2 hunks)
  • tooling/tsdown-config/tsconfig.json (1 hunks)
  • vitest.config.ts (2 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test-utils

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added pkg: cli Changes related to the CLI package. pkg: schema-gen Changes related to the Schema Gen package. pkg: ucd-store Changes related to the UCD Store package. pkg: fetch Changes related to the UCD Store package. pkg: fs-bridge Changes related to the FS Bridge package. labels Aug 9, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2025

Preview Deployment for Web

The Web worker has been deployed successfully.

Preview URL: https://preview.ucdjs.dev

This preview was built from commit 27362e6


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

@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2025

Preview Deployment for Api

The Api worker has been deployed successfully.

Preview URL: https://preview.api.ucdjs.dev

This preview was built from commit 27362e6


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

@codecov
Copy link

codecov bot commented Aug 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

luxass added 3 commits August 9, 2025 07:33
This is not needed anymore, since we are using it from the package export
…W integration

* Moved test-utils to the tooling directory for better organization.
* Added `eslint.config.js` for linting configuration.
* Created `package.json` for test-utils with dependencies and scripts.
* Implemented `msw` setup in `global-setup.ts` for mocking server responses.
* Introduced `mockFetch` utility in `msw.ts` for enhanced fetch mocking capabilities.
* Updated TypeScript configuration files for the new structure.
@luxass luxass marked this pull request as ready for review August 9, 2025 05:49
@luxass luxass requested a review from Copilot August 9, 2025 05:49
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 PR refactors the project's tooling infrastructure and creates a new internal test utilities package. The primary goal is to centralize test utilities while cleaning up existing tooling packages with improved configurations, documentation, and standardized structure.

  • Migrates test utilities from test/utils to a new @ucdjs/test-utils-internal package
  • Restructures and enhances tooling packages (tsdown-config, tsconfig, eslint-plugin) with better organization and documentation
  • Updates dependencies and configurations across the workspace

Reviewed Changes

Copilot reviewed 44 out of 46 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vitest.config.ts Updates test setup to use new test-utils package and removes old alias
tooling/tsdown-config/* Restructures package with src directory, adds factory function, and improves configuration
tooling/tsconfig/* Enhances package metadata and updates path mappings for new test utilities
tooling/test-utils/* Creates new internal test utilities package with MSW setup and documentation
tooling/eslint-plugin/* Adds missing configuration files and documentation
test/utils/index.ts Removes old test utilities (migrated to new package)
packages//test/ Updates all test files to import from new test-utils package
pnpm-workspace.yaml Updates dependency versions across the workspace

@luxass luxass merged commit 1d681c3 into main Aug 9, 2025
7 checks passed
@luxass luxass deleted the test-utils branch August 9, 2025 06:19
This was referenced Aug 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: cli Changes related to the CLI package. pkg: fetch Changes related to the UCD Store package. pkg: fs-bridge Changes related to the FS Bridge package. pkg: schema-gen Changes related to the Schema Gen package. pkg: ucd-store Changes related to the UCD Store package.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant