-
Notifications
You must be signed in to change notification settings - Fork 8
Introduce Testing Plan and Implement Runtime Module Tests for NodeJs #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ed8c2dc
add unit tests
mrunalhirve128 e1741ea
fix tests
mrunalhirve128 cee0c19
fix
mrunalhirve128 dab357c
changes
mrunalhirve128 4e5a29c
fix
mrunalhirve128 d5b6738
fix
mrunalhirve128 529ca90
Merge branch 'main' of https://github.com/microsoft/Agent365-nodejs i…
mrunalhirve128 78108c0
fix tests
mrunalhirve128 21bedc3
fix
mrunalhirve128 29e6bb3
fix md
mrunalhirve128 e0cefc9
Fix coverage
mrunalhirve128 c7ea9d8
fix comments
mrunalhirve128 f888cca
all coverage
mrunalhirve128 24cc78c
fix readme
mrunalhirve128 6f50d49
fix
mrunalhirve128 50b1b3d
Update tests/TEST_PLAN.md
mrunalhirve128 a53a51f
fix
mrunalhirve128 2a6a256
Merge branch 'main' of https://github.com/microsoft/Agent365-nodejs i…
mrunalhirve128 65ba33f
restore
mrunalhirve128 09b13d9
fix it
mrunalhirve128 356f8be
Merge branch 'main' into users/mrunalhirve/NodeJsUnitTests
mrunalhirve128 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Microsoft Agent 365 SDK Tests | ||
|
|
||
| Unit and integration tests for the Microsoft Agent 365 SDK - Node.js/TypeScript. This test suite ensures reliability, maintainability, and quality across all modules including runtime, tooling, notifications, and observability extensions. | ||
|
|
||
| ## Usage | ||
|
|
||
| For detailed instructions on running tests and generating coverage reports, see: | ||
|
|
||
| - **[Test Plan](TEST_PLAN.md)** - Comprehensive testing strategy and implementation roadmap | ||
| - **[Running Tests](RUNNING_TESTS.md)** - Complete guide for installation, running tests, generating coverage reports, and troubleshooting | ||
|
|
||
| ## Support | ||
|
|
||
| For issues, questions, or feedback: | ||
|
|
||
| - File issues in the [GitHub Issues](https://github.com/microsoft/Agent365-nodejs/issues) section | ||
| - See the [main documentation](../README.md) for more information | ||
|
|
||
| ## Trademarks | ||
|
|
||
| *Microsoft, Windows, Microsoft Azure and/or other Microsoft products and services referenced in the documentation may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries. The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks. Microsoft's general trademark guidelines can be found at <http://go.microsoft.com/fwlink/?LinkID=254653>.* | ||
|
|
||
| ## License | ||
|
|
||
| Copyright (c) Microsoft Corporation. All rights reserved. | ||
|
|
||
| Licensed under the MIT License - see the [LICENSE](../LICENSE.md) file for details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| # Running Unit Tests for Agent365-nodejs SDK | ||
|
|
||
| --- | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| 1. **Node.js 18+**: `node --version` | ||
| 2. **pnpm**: `npm install -g pnpm` | ||
| 3. **Dependencies**: `pnpm install` (from repository root) | ||
| 4. **Build packages**: `pnpm build` (required before running tests) | ||
|
|
||
| --- | ||
|
|
||
| ## Test Structure | ||
|
|
||
| ```plaintext | ||
| tests/ | ||
| ├── runtime/ # Runtime tests | ||
| ├── observability/ # Observability tests | ||
| ├── tooling/ # Tooling tests | ||
| └── notifications/ # Notifications tests | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Running Tests | ||
|
|
||
| ### Command Line | ||
|
|
||
| ```powershell | ||
| # From repository root | ||
| pnpm test | ||
|
|
||
| # From tests directory | ||
| cd tests | ||
| pnpm test # All tests | ||
| pnpm test:verbose # Verbose output | ||
| pnpm test:watch # Watch mode | ||
| pnpm test:runtime # Runtime tests only | ||
| pnpm test:observability # Observability tests only | ||
|
mrunalhirve128 marked this conversation as resolved.
Outdated
|
||
|
|
||
| # Run specific test file | ||
| pnpm test -- runtime/power-platform-api-discovery.test.ts | ||
|
|
||
| # Additional options | ||
| pnpm test -- --testPathPattern=observability | ||
| pnpm test -- --testNamePattern="should return" | ||
| pnpm test -- --bail # Stop on first failure | ||
| pnpm test -- --onlyFailures # Re-run failed tests only | ||
| ``` | ||
|
|
||
| ### VS Code Test Explorer (Optional) | ||
|
|
||
| 1. Install Jest extension (Orta.vscode-jest) | ||
| 2. Click beaker icon or `Ctrl+Shift+P` → "Test: Focus on Test Explorer View" | ||
| 3. Click play button to run tests or right-click → "Debug Test" | ||
|
|
||
| --- | ||
|
|
||
| ## Coverage Reports | ||
|
|
||
| **⚠️ TODO**: Coverage shows 0% due to Jest + ts-jest + moduleNameMapper limitation in monorepos. Tests execute correctly and validate functionality, but coverage metrics aren't collected. | ||
|
|
||
| ```powershell | ||
| cd tests | ||
|
|
||
| # Generate coverage reports | ||
| pnpm test:coverage # All formats | ||
| pnpm test:coverage:html # HTML only | ||
|
mrunalhirve128 marked this conversation as resolved.
Outdated
|
||
| pnpm test:ci # CI mode | ||
|
|
||
| # View HTML report | ||
|
mrunalhirve128 marked this conversation as resolved.
Outdated
|
||
| start coverage\index.html # Windows | ||
| open coverage/index.html # Mac/Linux | ||
| ``` | ||
|
|
||
| **Report Formats**: HTML (`coverage/index.html`), LCOV (`lcov.info`), Cobertura (`cobertura-coverage.xml`) | ||
|
|
||
| --- | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Quick Fixes | ||
|
|
||
| | Issue | Solution | | ||
| |-------|----------| | ||
| | Test loading failed | `pnpm install && pnpm build`, restart VS Code | | ||
| | Cannot find module | `pnpm build` from repository root | | ||
| | Tests not discovered | Check `.vscode/settings.json`, reload window | | ||
|
|
||
| ### Complete Reset | ||
|
|
||
| ```powershell | ||
| # From repository root | ||
| pnpm install | ||
| pnpm build | ||
| pnpm test -- --clearCache | ||
|
|
||
| # Restart VS Code: Ctrl+Shift+P → "Developer: Reload Window" | ||
| ``` | ||
|
|
||
| ### VS Code Configuration | ||
|
|
||
| Create `.vscode/settings.json` if Test Explorer doesn't work: | ||
|
|
||
| ```json | ||
| { | ||
| "jest.rootPath": "tests", | ||
| "jest.jestCommandLine": "pnpm test", | ||
| "jest.autoRun": "off" | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| # Test Plan for Agent365-nodejs SDK | ||
|
|
||
| > **Note:** This plan is under active development. Keep updating as testing progresses. | ||
|
|
||
| **Version:** 1.0 | ||
| **Date:** November 25, 2025 | ||
|
mrunalhirve128 marked this conversation as resolved.
Outdated
|
||
| **Status:** Draft | ||
|
|
||
| --- | ||
|
|
||
| ## Overview | ||
|
|
||
| ### Current State | ||
| - ✅ Unit tests exist for `observability` and `runtime` modules | ||
| - ❌ Missing tests for `tooling` and `notifications` modules | ||
| - ❌ No integration tests or CI/CD automation | ||
|
|
||
| ### Goals | ||
| - Achieve **80%+ code coverage** across all modules | ||
| - Implement integration tests for cross-module functionality | ||
| - Integrate testing into CI/CD pipeline with coverage enforcement | ||
|
|
||
| --- | ||
|
|
||
| ## Testing Strategy | ||
|
|
||
| **Framework:** `Jest` with `ts-jest` | ||
| **Coverage:** `Jest Coverage` | ||
| **Mocking:** `jest.mock` | ||
| **Async:** Native async/await | ||
|
|
||
| **Test Pattern:** AAA (Arrange → Act → Assert) | ||
| **Test File Naming:** `<filename>.test.ts` (e.g., `power-platform-api-discovery.test.ts`) | ||
| **Test Naming Convention:** `'should <expected_result> when <condition>'` | ||
|
|
||
| --- | ||
|
|
||
| ## Implementation Roadmap | ||
|
|
||
| | Phase | Deliverables | Priority | | ||
| |-------|-------------|----------| | ||
| | 1.1 | Runtime unit tests | ✅ Partial | | ||
| | 1.2 | Tooling unit tests | HIGH | | ||
| | 1.3 | Notifications unit tests | HIGH | | ||
| | 1.4 | Expand observability tests | MEDIUM | | ||
| | 1.5 | Tooling extension tests | MEDIUM | | ||
| | 2 | Integration tests | MEDIUM | | ||
| | 3 | CI/CD automation | HIGH | | ||
|
|
||
| --- | ||
|
|
||
| ## Phase 1: Unit Tests | ||
|
|
||
| ### 1.1 Runtime Module | ||
|
|
||
| **Priority:** HIGH | ||
|
|
||
| | Module | Test File | Status | | ||
| |--------|-----------|--------| | ||
| | `power-platform-api-discovery.ts` | `power-platform-api-discovery.test.ts` | ✅ Complete | | ||
| | `utility.ts` | `utility.test.ts` | ✅ Complete | | ||
| | `environment-utils.ts` | `environment-utils.test.ts` | ✅ Complete | | ||
| | `agentic-authorization-service.ts` | `agentic-authorization-service.test.ts` | ✅ Complete | | ||
|
|
||
| --- | ||
|
|
||
| ### 1.2 Tooling Module | ||
|
|
||
| **Priority:** HIGH | ||
|
|
||
| | Module | Test File | Status | | ||
| |--------|-----------|--------| | ||
| | `Utility.ts` | `Utility.test.ts` | ❌ Missing | | ||
| | `McpToolServerConfigurationService.ts` | `McpToolServerConfigurationService.test.ts` | ❌ Missing | | ||
|
|
||
| --- | ||
|
|
||
| ### 1.3 Notifications Module | ||
|
|
||
| **Priority:** HIGH | ||
|
|
||
| | Module | Test File | Status | | ||
| |--------|-----------|--------| | ||
| | `agent-notification.ts` | `agent-notification.test.ts` | ❌ Missing | | ||
| | `models/*` | Model tests | ❌ Missing | | ||
| | `extensions/*` | Extension tests | ❌ Missing | | ||
|
|
||
| --- | ||
|
|
||
| ### 1.4 Observability Extensions | ||
|
|
||
| **Priority:** MEDIUM | ||
|
|
||
| | Extension | Status | | ||
| |-----------|--------| | ||
| | `openai` | ✅ Expand existing | | ||
| | `tokencache` | ✅ Expand existing | | ||
|
|
||
| --- | ||
|
|
||
| ### 1.5 Tooling Extensions | ||
|
|
||
| **Priority:** LOW | ||
|
|
||
| | Extension | Status | | ||
| |-----------|--------| | ||
| | Claude | ❌ Missing | | ||
| | LangChain | ❌ Missing | | ||
| | OpenAI | ❌ Missing | | ||
|
|
||
| --- | ||
|
|
||
| ## Phase 2: Integration Tests | ||
|
|
||
| **Priority:** MEDIUM | ||
|
|
||
| | Integration | Status | | ||
| |-------------|--------| | ||
| | Runtime + Observability | ❌ Missing | | ||
| | Tooling + Runtime | ❌ Missing | | ||
| | Notifications + Runtime | ❌ Missing | | ||
| | OpenAI full flow | ✅ Complete | | ||
| | Claude full flow | ❌ Missing | | ||
| | LangChain full flow | ❌ Missing | | ||
|
|
||
| --- | ||
|
|
||
| ## Phase 3: CI/CD Integration | ||
|
|
||
| **Priority:** HIGH | ||
|
|
||
| | Component | Status | | ||
| |-----------|--------| | ||
| | GitHub Actions workflow | ❌ Missing | | ||
| | Node.js matrix (18.x, 20.x, 22.x) | ❌ Missing | | ||
| | Coverage enforcement (80%+) | ❌ Missing | | ||
| | Codecov integration | ❌ Missing | | ||
| | PR blocking on failures | ❌ Missing | | ||
|
|
||
| --- | ||
|
|
||
| ## Success Criteria | ||
|
|
||
| - ✅ 80%+ code coverage for all modules | ||
| - ✅ All tests pass independently | ||
| - ✅ Full suite completes in < 30 seconds (unit) / < 5 minutes (full) | ||
| - ✅ Automated test execution on all PRs | ||
| - ✅ Coverage reports visible and enforced | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.