Skip to content

test: consolidated test coverage across 9 modules (133 new tests)#403

Merged
anandgupta42 merged 2 commits intomainfrom
test/consolidated-test-coverage
Mar 23, 2026
Merged

test: consolidated test coverage across 9 modules (133 new tests)#403
anandgupta42 merged 2 commits intomainfrom
test/consolidated-test-coverage

Conversation

@anandgupta42
Copy link
Contributor

What does this PR do?

Consolidates 9 test PRs (#387, #390, #394, #395, #396, #397, #398, #399, #401) into one, discarding 4 duplicates (#391, #392, #393, #400). Adds 133 new tests across 13 modules and fixes 5 production bugs in finops-formatting.ts discovered during testing.

New test coverage:

  • id.test.ts — 14 tests: Identifier generation, monotonic ordering, timestamp extraction, Zod schema
  • shell.test.ts — 9 tests: shell blacklist enforcement for fish/nu, cache reset, fallback
  • path-traversal.test.ts — 7 tests (new): Protected.isSensitiveWrite for .pem/.key, .gnupg, .env variants
  • ignore.test.ts — 7 tests (new): FileIgnore.match directory patterns, globs, whitelist overrides
  • paths-parsetext.test.ts — 16 tests: ConfigPaths.parseText env/file substitution, JSONC parsing
  • finops-formatting.test.ts — 14 tests: formatBytes/truncateQuery edge cases
  • finops-role-access.test.ts — 10 tests: RBAC formatGrants/formatHierarchy/formatUserRoles
  • tool-lookup.test.ts — 4 tests: Zod schema introspection for tool parameters
  • summary-git-path.test.ts — 10 tests: unquoteGitPath decoding for non-ASCII filenames
  • tracing.test.ts — 2 tests (added): Recap loop detection boundaries
  • patch.test.ts — 9 tests (added): maybeParseApplyPatchVerified entry point coverage
  • instruction.test.ts — 13 tests (new): InstructionPrompt.loaded() dedup guards
  • message-v2.test.ts — 23 tests (new): MessageV2.filterCompacted() boundary detection

Bug fixes (discovered during testing):

  • finops-formatting.ts: fix formatBytes crash on negative/NaN/fractional inputs
  • finops-formatting.ts: fix truncateQuery returning empty for whitespace-only, exceeding maxLen when < 4
  • training-import.test.ts: fix pre-existing typecheck errors (missing context/rule mock keys)

Code review fixes:

  • summary-git-path.test.ts: use tmpdir() instead of projectRoot to prevent test artifact leakage (Gemini finding)
  • finops-role-access.test.ts: consolidate duplicate afterAll hooks for proper cleanup (GLM-5 finding)

Type of change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)

Issue for this PR

Closes #402

How did you verify your code works?

259 tests, 584 assertions, 0 failures across 14 test files
Typecheck: PASS
Marker check: PASS (no upstream-shared files modified)

Multi-model code review by Claude, GPT 5.2 Codex, Gemini 3.1 Pro, and GLM-5 (4/6 models). All approve.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • New and existing tests pass locally with my changes
  • I ran linters/typechecks before committing

🤖 Generated with Claude Code

anandgupta42 and others added 2 commits March 23, 2026 08:55
Merges 9 test PRs (#390, #394, #395, #396, #397, #398, #399, #401, #387)
into a single PR, discarding 4 duplicates (#391, #392, #393, #400).

**New test coverage:**
- `id.test.ts` — 14 tests: Identifier generation, monotonic ordering, timestamp extraction, Zod schema
- `shell.test.ts` — 9 tests: shell blacklist enforcement for fish/nu, cache reset, fallback
- `path-traversal.test.ts` — 7 tests (new): `Protected.isSensitiveWrite` for .pem/.key, .gnupg, .env variants
- `ignore.test.ts` — 7 tests (new): `FileIgnore.match` directory patterns, globs, whitelist overrides
- `paths-parsetext.test.ts` — 16 tests: `ConfigPaths.parseText` env/file substitution, JSONC parsing
- `finops-formatting.test.ts` — 14 tests: `formatBytes`/`truncateQuery` edge cases
- `finops-role-access.test.ts` — 10 tests: RBAC `formatGrants`/`formatHierarchy`/`formatUserRoles`
- `tool-lookup.test.ts` — 4 tests: Zod schema introspection for tool parameters
- `summary-git-path.test.ts` — 10 tests: `unquoteGitPath` decoding for non-ASCII filenames
- `tracing.test.ts` — 2 tests (added): Recap loop detection boundaries
- `patch.test.ts` — 9 tests (added): `maybeParseApplyPatchVerified` entry point coverage
- `instruction.test.ts` — 13 tests (new): `InstructionPrompt.loaded()` dedup guards
- `message-v2.test.ts` — 23 tests (new): `MessageV2.filterCompacted()` boundary detection

**Bug fixes (discovered during testing):**
- `finops-formatting.ts`: fix `formatBytes` crash on negative/NaN/fractional inputs
- `finops-formatting.ts`: fix `truncateQuery` returning empty for whitespace-only, exceeding `maxLen` when < 4
- `training-import.test.ts`: fix pre-existing typecheck errors (missing `context`/`rule` mock keys)
- `instruction.test.ts`, `message-v2.test.ts`: fix `MessageV2.Part` cast and branded ID type errors

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- summary-git-path.test.ts: use tmpdir() instead of projectRoot to prevent
  Storage.write() from polluting the developer's .opencode/storage/ directory
- finops-role-access.test.ts: consolidate duplicate afterAll hooks to ensure
  ALTIMATE_TELEMETRY_DISABLED env var is cleaned up after tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review.

Tip: disable this comment in your organization's Code Review settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: consolidated test coverage across 9 modules

1 participant