Skip to content

Conversation

@ryoppippi
Copy link
Member

@ryoppippi ryoppippi commented Dec 22, 2025

Summary

Improves test coverage from 85% to 93% and refactors error classes into separate files for better code organisation and searchability.

What Changed

Refactoring:

  • Split errors.ts into error-stackone.ts and error-stackone-api.ts
  • Updated all imports to use direct paths (removed re-export file)

Test Coverage:

  • Added comprehensive tests for StackOneError and StackOneAPIError
  • Added tests for BaseTool RPC/local config and error handling
  • Added tests for StackOneToolSet dryRun mode and parameter extraction
  • Excluded type-only files from coverage (index.ts, type.ts)

Coverage Improvements

Metric Before After Change
Statements 85.29% 92.50% +7.21%
Branch 70.61% 84.05% +13.44%
Lines 85.95% 93.51% +7.56%

Testing

All 427 tests pass across 32 test files.


Summary by cubic

Boosts test coverage to ~93% and splits error classes into dedicated files for clearer imports and easier search.

  • Refactors

    • Split errors.ts into error-stackone.ts and error-stackone-api.ts.
    • Removed the re-export file and updated all imports to direct paths.
    • Adjusted index exports to reference the new error files.
  • Test Coverage

    • Added comprehensive tests for StackOneError, StackOneAPIError, BaseTool (RPC/local), and StackOneToolSet (dryRun, parameter mapping).
    • Updated vitest config to exclude type-only files (index.ts, type.ts) from coverage.
    • Coverage: Statements 92.50%, Branches 84.05%, Lines 93.51%; all 427 tests pass.

Written for commit 9b56837. Summary will update automatically on new commits.

- Split StackOneError into error-stackone.ts
- Split StackOneAPIError into error-stackone-api.ts
- Remove re-export file errors.ts
- Update all imports to use direct paths

Improves searchability and code organisation.
- Add comprehensive tests for StackOneError and StackOneAPIError
- Add tests for BaseTool RPC/local config and error handling
- Add tests for StackOneToolSet dryRun mode and parameter extraction
- Exclude type-only files from coverage (index.ts, type.ts)

Coverage improvements:
- Statements: 85.29% → 92.50%
- Branch: 70.61% → 84.05%
- Lines: 85.95% → 93.51%
Copilot AI review requested due to automatic review settings December 22, 2025 13:20
@ryoppippi ryoppippi requested a review from a team as a code owner December 22, 2025 13:20
@ryoppippi ryoppippi changed the title test: improve test coverage and refactor error files test: improve coverage 85%→93% and split error files Dec 22, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 22, 2025

Open in StackBlitz

npm i https://pkg.pr.new/StackOneHQ/stackone-ai-node/@stackone/ai@261

commit: 9b56837

@ryoppippi ryoppippi changed the title test: improve coverage 85%→93% and split error files test: add error classes tests and improve coverage 85%→93% Dec 22, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 18 files

@ryoppippi ryoppippi changed the title test: add error classes tests and improve coverage 85%→93% test: add error handling and edge case tests, improve coverage 85%→93% Dec 22, 2025
Copy link

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 improves test coverage from 85% to 93% and refactors error classes into separate files for better code organization and maintainability.

  • Splits error classes into dedicated files (error-stackone.ts and error-stackone-api.ts)
  • Adds comprehensive test coverage for error classes and tool execution paths
  • Excludes type-only files from coverage metrics to focus on executable code

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.

Show a summary per file
File Description
vitest.config.ts Excludes type-only files (index.ts, type.ts) from coverage calculation
src/utils/error-stackone.ts New file containing base StackOneError class
src/utils/error-stackone-api.ts Refactored to import StackOneError from separate file instead of defining it locally
src/utils/error-stackone.test.ts New comprehensive tests for StackOneError class
src/utils/error-stackone-api.test.ts New comprehensive tests for StackOneAPIError class including toString formatting
src/toolsets.test.ts Added tests for dryRun mode, parameter extraction, and error handling
src/tool.test.ts Added tests for RPC/local config metadata, execution options, and error handling
src/utils/try-import.ts Updated import path from ./errors to ./error-stackone
src/utils/try-import.test.ts Updated import path from ./errors to ./error-stackone
src/toolsets.ts Updated import path from ./utils/errors to ./utils/error-stackone
src/tool.ts Updated import path from ./utils/errors to ./utils/error-stackone
src/rpc-client.ts Updated import path from ./utils/errors to ./utils/error-stackone-api
src/rpc-client.test.ts Updated import path from ./utils/errors to ./utils/error-stackone-api
src/requestBuilder.ts Updated import path from ./utils/errors to ./utils/error-stackone-api
src/requestBuilder.test.ts Updated import path from ./utils/errors to ./utils/error-stackone-api
src/index.ts Updated exports to import from new separate error files
src/feedback.ts Updated import path from ./utils/errors to ./utils/error-stackone
src/feedback.test.ts Updated import path from ./utils/errors to ./utils/error-stackone

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


it('should include endpoint URL when present in message', () => {
const error = new StackOneAPIError(
'Request failed for https://api.stackone.com/unified/hris/employees',
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should have unified endpoints related tests

Copy link
Member Author

Choose a reason for hiding this comment

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

oh yes you are absolutely right!

Copy link
Member Author

Choose a reason for hiding this comment

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

Apply review feedback from @glebedel - this SDK should not have
unified endpoints related tests. Changed the test URL from
/unified/hris/employees to /tools/execute.
@ryoppippi ryoppippi requested a review from glebedel December 22, 2025 13:38
Copy link
Contributor

@glebedel glebedel left a comment

Choose a reason for hiding this comment

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

LGTM

@ryoppippi ryoppippi merged commit 149c5c0 into main Dec 23, 2025
21 checks passed
@ryoppippi ryoppippi deleted the feat/improve-test-coverage branch December 23, 2025 09:29
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.

3 participants