Skip to content

chore: improve tests#1602

Open
Crunchyman-ralph wants to merge 4 commits intonextfrom
ralph/fix/tests.1
Open

chore: improve tests#1602
Crunchyman-ralph wants to merge 4 commits intonextfrom
ralph/fix/tests.1

Conversation

@Crunchyman-ralph
Copy link
Collaborator

@Crunchyman-ralph Crunchyman-ralph commented Jan 22, 2026

What type of PR is this?

  • 🐛 Bug fix
  • ✨ Feature
  • 🔌 Integration
  • 📝 Docs
  • 🧹 Refactor
  • Other:

Description

Related Issues

How to Test This

# Example commands or steps

Expected result:

Contributor Checklist

  • Created changeset: npm run changeset
  • Tests pass: npm test
  • Format check passes: npm run format-check (or npm run format to fix)
  • Addressed CodeRabbit comments (if any)
  • Linked related issues (if any)
  • Manually tested the changes

Changelog Entry


For Maintainers

  • PR title follows conventional commits
  • Target branch correct
  • Labels added
  • Milestone assigned (if applicable)

Summary by CodeRabbit

  • Chores
    • CI now detects changed packages and runs per-package test jobs to avoid unnecessary work and speed feedback.
  • Tests
    • Unit and integration tests are separated and run as distinct phases; integration tests run serialized for stability.
    • Testing switched to a project-based workspace with per-package test configurations and shared unit/integration settings.

Note

Medium Risk
CI/test orchestration changes can cause missed or mis-scoped test runs if the paths filters or Vitest workspace config are incorrect, but no production runtime logic changes are included.

Overview
Refactors CI to only run tests for changed workspaces by adding a detect-changes job and gating new test-core, test-cli, test-mcp, and test-root jobs on those outputs.

Standardizes test execution by splitting unit (.spec.ts) vs integration (.test.ts) runs across packages: package test:* scripts now point to shared vitest.unit.config.ts/vitest.integration.config.ts, per-package vitest.config.ts files are removed, and root vitest.config.ts becomes a Vitest workspace with per-project settings (including longer CLI integration timeouts). Root turbo:test/turbo:test:integration now run integration tests with --concurrency=1.

Also pins task-master-ai in package-lock.json from * to 0.42.0-rc.0 for the extension workspace lockfile.

Written by Cursor Bugbot for commit 2bdd656. This will update automatically on new commits. Configure here.

@changeset-bot
Copy link

changeset-bot bot commented Jan 22, 2026

⚠️ No Changeset found

Latest commit: 2bdd656

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.

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 Jan 22, 2026

📝 Walkthrough

Walkthrough

Adds a detect-changes job to CI to gate per-package test jobs, replaces the single test job with multiple conditional test jobs, centralizes Vitest into a workspace projects config, removes package-local Vitest configs, and splits tests into unit vs integration with serialized integration runs.

Changes

Cohort / File(s) Summary
CI workflow
​.github/workflows/ci.yml
Add detect-changes job (path filters: core, cli, mcp, root) and conditional per-package test jobs (test-core, test-cli, test-mcp, test-root) that run checkout, setup-node, cache, install, and unit/integration tests gated by detect-changes outputs.
Root package.json
package.json
Change turbo:test to run turbo test:unit && turbo test:integration --concurrency=1; add --concurrency=1 to integration to serialize integration runs.
Top-level Vitest configs
vitest.config.ts, vitest.unit.config.ts, vitest.integration.config.ts
Replace global Vitest config with workspace-style test.projects in vitest.config.ts; add vitest.unit.config.ts and vitest.integration.config.ts to define unit vs integration defaults.
Removed per-package Vitest configs
apps/cli/vitest.config.ts, apps/mcp/vitest.config.ts, packages/tm-core/vitest.config.ts
Delete package-local Vitest configuration files that previously merged root config with package-specific overrides.
Per-package test script updates
Apps/Packages
apps/cli/package.json, apps/mcp/package.json, packages/tm-core/package.json
Replace glob-based vitest invocations with explicit config references for unit/integration (e.g., vitest run --config ../../vitest.unit.config.ts and --config ../../vitest.integration.config.ts).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant GH as GitHub Actions
  participant Detect as detect-changes job
  participant Orchestrator as Workflow controller
  participant Runner as Job runner
  participant Cache as Node modules cache
  participant Registry as Package registry
  participant Tests as Per-package test jobs

  GH->>Detect: on push/PR trigger
  Detect->>Detect: evaluate path filters (core, cli, mcp, root)
  Detect-->>Orchestrator: emit outputs (core=true/false, cli=..., mcp=..., root=...)
  Orchestrator->>Runner: start conditional test job (e.g., test-core) if output true
  Runner->>Cache: restore node_modules cache (if present)
  Runner->>Registry: install dependencies
  Runner->>Tests: run unit tests
  Tests->>Runner: unit tests complete
  Runner->>Tests: run integration tests (serialized via --concurrency=1)
  Tests->>Cache: save updated node_modules cache
  Tests-->>GH: report job result
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • eyaltoledano
  • maxtuzz
🚥 Pre-merge checks | ✅ 2 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (62 files):

⚔️ .github/workflows/ci.yml (content)
⚔️ CHANGELOG.md (content)
⚔️ apps/cli/package.json (content)
⚔️ apps/cli/src/command-registry.ts (content)
⚔️ apps/cli/src/commands/briefs.command.ts (content)
⚔️ apps/cli/src/commands/list.command.ts (content)
⚔️ apps/cli/src/commands/loop.command.spec.ts (content)
⚔️ apps/cli/src/commands/loop.command.ts (content)
⚔️ apps/cli/src/commands/tags.command.ts (content)
⚔️ apps/cli/src/ui/components/index.ts (content)
⚔️ apps/docs/capabilities/task-structure.mdx (content)
⚔️ apps/extension/package.json (content)
⚔️ apps/mcp/package.json (content)
⚔️ apps/mcp/src/shared/utils.ts (content)
⚔️ apps/mcp/src/tools/autopilot/index.ts (content)
⚔️ docs/examples/claude-code-usage.md (content)
⚔️ mcp-server/src/core/direct-functions/update-subtask-by-id.js (content)
⚔️ mcp-server/src/core/direct-functions/update-task-by-id.js (content)
⚔️ mcp-server/src/tools/update-subtask.js (content)
⚔️ mcp-server/src/tools/update-task.js (content)
⚔️ package-lock.json (content)
⚔️ package.json (content)
⚔️ packages/claude-code-plugin/commands/add-dependency.md (content)
⚔️ packages/claude-code-plugin/commands/expand-task.md (content)
⚔️ packages/tm-bridge/src/update-bridge.ts (content)
⚔️ packages/tm-core/package.json (content)
⚔️ packages/tm-core/src/common/errors/task-master-error.ts (content)
⚔️ packages/tm-core/src/common/interfaces/storage.interface.ts (content)
⚔️ packages/tm-core/src/common/types/index.ts (content)
⚔️ packages/tm-core/src/common/utils/id-generator.ts (content)
⚔️ packages/tm-core/src/common/utils/index.ts (content)
⚔️ packages/tm-core/src/index.ts (content)
⚔️ packages/tm-core/src/modules/loop/index.ts (content)
⚔️ packages/tm-core/src/modules/loop/loop-domain.ts (content)
⚔️ packages/tm-core/src/modules/loop/presets/__snapshots__/presets.spec.ts.snap (content)
⚔️ packages/tm-core/src/modules/loop/presets/default.ts (content)
⚔️ packages/tm-core/src/modules/loop/presets/duplication.ts (content)
⚔️ packages/tm-core/src/modules/loop/presets/entropy.ts (content)
⚔️ packages/tm-core/src/modules/loop/presets/linting.ts (content)
⚔️ packages/tm-core/src/modules/loop/presets/test-coverage.ts (content)
⚔️ packages/tm-core/src/modules/loop/services/loop.service.spec.ts (content)
⚔️ packages/tm-core/src/modules/loop/services/loop.service.ts (content)
⚔️ packages/tm-core/src/modules/loop/types.ts (content)
⚔️ packages/tm-core/src/modules/storage/adapters/api-storage.ts (content)
⚔️ packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts (content)
⚔️ packages/tm-core/src/modules/tasks/entities/task.entity.ts (content)
⚔️ packages/tm-core/src/modules/tasks/services/tag.service.ts (content)
⚔️ packages/tm-core/src/modules/tasks/services/task-file-generator.service.spec.ts (content)
⚔️ packages/tm-core/src/modules/tasks/tasks-domain.ts (content)
⚔️ packages/tm-core/tests/integration/storage/task-metadata-extraction.test.ts (content)
⚔️ packages/tm-profiles/src/slash-commands/commands/solo/add-dependency.ts (content)
⚔️ packages/tm-profiles/src/slash-commands/commands/solo/expand-task.ts (content)
⚔️ scripts/modules/commands.js (content)
⚔️ scripts/modules/task-manager/update-subtask-by-id.js (content)
⚔️ scripts/modules/task-manager/update-task-by-id.js (content)
⚔️ scripts/modules/ui.js (content)
⚔️ scripts/modules/utils.js (content)
⚔️ src/prompts/expand-task.json (content)
⚔️ src/schemas/base-schemas.js (content)
⚔️ tests/setup.js (content)
⚔️ tests/unit/scripts/modules/task-manager/analyze-task-complexity.test.js (content)
⚔️ vitest.config.ts (content)

These conflicts must be resolved before merging into next.
Resolve conflicts locally and push changes to this branch.
Title check ❓ Inconclusive The title 'chore: improve tests' is vague and generic, using non-descriptive language that does not convey meaningful information about the substantial structural changes made to the test infrastructure. Consider a more specific title that reflects the main changes, such as 'chore: refactor CI and Vitest configuration to per-package test jobs' or 'chore: migrate to workspace-based Vitest config with detect-changes gating'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ralph/fix/tests.1
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch ralph/fix/tests.1
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

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

- Fix loop.command.spec.ts mock return types (checkSandboxAuth returns {ready: boolean})
- Fix config-loader.service.spec.ts fs/promises mocking approach
- Fix runtime-state-manager.service.spec.ts module path and field name mismatches
- Fix config-manager.spec.ts mock constructors and API expectations
- Fix loop.service.spec.ts for sandbox opt-in and appendFile behavior
- Update task-id.ts regex to support sub-subtasks (1.2.3) and variable-length prefixes
- Increase generate.tool.test.ts timeout for 2-call test
- Add turbo:test, turbo:test:unit, turbo:test:integration scripts
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.github/workflows/ci.yml:
- Around line 186-190: The checkout step uses a shallow clone which prevents
dorny/paths-filter (id: filter) from seeing diffs across multi-commit pushes;
update the actions/checkout@v4 step to fetch full history by adding with:
fetch-depth: 0 (i.e., use actions/checkout@v4 with fetch-depth: 0) so the
dorny/paths-filter@v3 step can correctly detect changes across commits.
- Around line 191-210: The CI root filter currently omits package.json so
changes to the repo root package.json won't trigger the root job; update the
filters block for the root key (the YAML mapping labeled "root" alongside
"core", "cli", "mcp") to include 'package.json' (similar to existing
'package-lock.json') so modifications to root package metadata/scripts/deps will
run the root tests and related workflows.

- Split the main Vitest configuration into separate unit and integration configurations for better clarity and management.
- Update CLI and MCP package scripts to use the new configuration files.
- Remove legacy configuration files from CLI and MCP packages.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.github/workflows/ci.yml:
- Around line 194-198: In the CI workflow 'core' file-glob list update the
incorrect filename: replace the non-existent 'vitest.workspace.ts' entry with
the actual config file name 'vitest.config.ts' so the workflow references the
correct Vitest config; edit the list containing 'packages/tm-core/**',
'package-lock.json', 'tsconfig.json' and change the 'vitest.workspace.ts' item
to 'vitest.config.ts'.
🧹 Nitpick comments (2)
.github/workflows/ci.yml (1)

334-340: Root test job condition is correct but complex.

The if condition on line 340 is well-constructed:

  • always() ensures evaluation even if upstream jobs are skipped
  • !cancelled() prevents running if workflow was cancelled
  • !contains(needs.*.result, 'failure') blocks on any failure
  • Final gate on detect-changes.outputs.root

Consider adding a brief inline comment in the YAML to document this logic for future maintainers.

vitest.config.ts (1)

17-72: Consider extracting shared alias configuration.

The resolve.alias block is duplicated between core:unit (lines 24-42) and core:integration (lines 52-70). While this works, extracting a shared constant would reduce maintenance burden.

♻️ Optional: Extract shared aliases
+const coreAliases = {
+	'@': path.resolve(__dirname, './packages/tm-core/src'),
+	'@/types': path.resolve(__dirname, './packages/tm-core/src/types'),
+	'@/providers': path.resolve(__dirname, './packages/tm-core/src/providers'),
+	'@/storage': path.resolve(__dirname, './packages/tm-core/src/storage'),
+	'@/parser': path.resolve(__dirname, './packages/tm-core/src/parser'),
+	'@/utils': path.resolve(__dirname, './packages/tm-core/src/utils'),
+	'@/errors': path.resolve(__dirname, './packages/tm-core/src/errors')
+};
+
 export default defineConfig({
 	test: {
 		projects: [
 			// Core package
 			{
 				test: {
 					name: 'core:unit',
 					root: './packages/tm-core',
 					include: ['tests/**/*.spec.ts', 'src/**/*.spec.ts'],
 					setupFiles: ['./tests/setup.ts']
 				},
-				resolve: {
-					alias: {
-						'@': path.resolve(__dirname, './packages/tm-core/src'),
-						// ... duplicated aliases
-					}
-				}
+				resolve: { alias: coreAliases }
 			},
 			{
 				test: {
 					name: 'core:integration',
 					// ...
 				},
-				resolve: {
-					alias: {
-						'@': path.resolve(__dirname, './packages/tm-core/src'),
-						// ... duplicated aliases
-					}
-				}
+				resolve: { alias: coreAliases }
 			},

Comment on lines +194 to +198
core:
- 'packages/tm-core/**'
- 'package-lock.json'
- 'tsconfig.json'
- 'vitest.workspace.ts'
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check for vitest config files at repo root
fd -d 1 'vitest' --type f

Repository: eyaltoledano/claude-task-master

Length of output: 142


Update CI workflow to reference correct vitest config file.

Line 198 references vitest.workspace.ts, which does not exist in the repository. The actual file is vitest.config.ts. Update this line to reference the correct filename.

🤖 Prompt for AI Agents
In @.github/workflows/ci.yml around lines 194 - 198, In the CI workflow 'core'
file-glob list update the incorrect filename: replace the non-existent
'vitest.workspace.ts' entry with the actual config file name 'vitest.config.ts'
so the workflow references the correct Vitest config; edit the list containing
'packages/tm-core/**', 'package-lock.json', 'tsconfig.json' and change the
'vitest.workspace.ts' item to 'vitest.config.ts'.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

restoreMocks: true,
mockReset: true
}
});
Copy link

Choose a reason for hiding this comment

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

Core setupFiles missing from standalone test configs

Low Severity

The standalone vitest.unit.config.ts and vitest.integration.config.ts configs (used by CI via npm run test:unit -w @tm/core) lack the setupFiles: ['./tests/setup.ts'] that the workspace config and the deleted per-package config both included. The setup file suppresses console.error during core tests. This creates an inconsistency between local runs (using the workspace config) and CI runs (using standalone configs).

Additional Locations (1)

Fix in Cursor Fix in Web

'@/utils': path.resolve(__dirname, './packages/tm-core/src/utils'),
'@/errors': path.resolve(__dirname, './packages/tm-core/src/errors')
}
}
Copy link

Choose a reason for hiding this comment

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

Duplicated alias configuration blocks in workspace config

Low Severity

The resolve.alias block is identically duplicated between the core:unit and core:integration project definitions. This increases the maintenance burden — if an alias is added or changed, it needs to be updated in both places, risking inconsistency. Extracting the shared alias map into a variable would eliminate the duplication.

Additional Locations (1)

Fix in Cursor Fix in Web

clearMocks: true,
restoreMocks: true,
mockReset: true
]
Copy link

Choose a reason for hiding this comment

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

Workspace config projects missing mock cleanup settings

Low Severity

The new workspace config's project definitions are missing clearMocks: true, restoreMocks: true, and mockReset: true. The old root config had these settings and they were inherited by per-package configs via mergeConfig. The standalone configs (vitest.unit.config.ts and vitest.integration.config.ts) correctly include them, but the workspace config projects do not. This creates an inconsistency where tests behave differently depending on which config is used — mocks won't be automatically cleaned up between tests when running via the workspace config.

Fix in Cursor Fix in Web

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.

1 participant