-
Notifications
You must be signed in to change notification settings - Fork 10
Add comprehensive test suite for agent-loader module #3
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
Open
KeshavA (InfamousBolt)
wants to merge
5
commits into
photon-hq:main
Choose a base branch
from
InfamousBolt:claude/analyze-repo-WqsjT
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d65e0ea
Add comprehensive test suite for agent-loader module
claude 952333c
Fix integration test for invalid agent validation
claude 1ffba4f
Add GitHub Actions CI/CD pipeline
claude 41b502b
Add flux status health check command
claude 755dc40
Fix test failures for status and agent-loader tests
claude 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, develop] | ||
| pull_request: | ||
| branches: [main, develop] | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Test | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Bun | ||
| uses: oven-sh/setup-bun@v1 | ||
| with: | ||
| bun-version: latest | ||
|
|
||
| - name: Install dependencies | ||
| run: bun install | ||
|
|
||
| - name: Run tests | ||
| run: bun test | ||
|
|
||
| build: | ||
| name: Build | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Bun | ||
| uses: oven-sh/setup-bun@v1 | ||
| with: | ||
| bun-version: latest | ||
|
Comment on lines
+39
to
+40
|
||
|
|
||
| - name: Install dependencies | ||
| run: bun install | ||
|
|
||
| - name: Build | ||
| run: bun run build | ||
|
|
||
| - name: Check build output | ||
| run: | | ||
| if [ ! -f "dist/index.js" ]; then | ||
| echo "Build failed: dist/index.js not found" | ||
| exit 1 | ||
| fi | ||
| echo "✅ Build successful" | ||
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 |
|---|---|---|
|
|
@@ -2,3 +2,4 @@ node_modules | |
| dist | ||
| .env | ||
| *.log | ||
| test-temp-* | ||
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,92 @@ | ||
| # Flux Tests | ||
|
|
||
| This directory contains tests for the Flux CLI. | ||
|
|
||
| ## Running Tests | ||
|
|
||
| ```bash | ||
| # Run all tests | ||
| bun test | ||
|
|
||
| # Run tests in watch mode (re-runs on file changes) | ||
| bun test --watch | ||
|
|
||
| # Run specific test file | ||
| bun test src/__tests__/agent-loader.test.ts | ||
| ``` | ||
|
|
||
| ## Test Structure | ||
|
|
||
| - `__tests__/` - Test files (*.test.ts) | ||
| - `__tests__/fixtures/` - Test fixtures and sample agent files | ||
|
|
||
| ## Coverage | ||
|
|
||
| ### agent-loader.test.ts | ||
|
|
||
| Tests for agent discovery, validation, and loading functionality: | ||
|
|
||
| **findAgentFile()** | ||
| - ✅ Returns null when no agent file exists | ||
| - ✅ Finds agent.ts in current directory | ||
| - ✅ Finds agent.js in current directory | ||
| - ✅ Prefers agent.ts over agent.js when both exist | ||
|
|
||
| **validateAgentFile()** | ||
| - ✅ Validates correct TypeScript agent files | ||
| - ✅ Validates correct JavaScript agent files | ||
| - ✅ Rejects agents without default export | ||
| - ✅ Rejects agents without invoke method | ||
| - ✅ Rejects agents where invoke is not a function | ||
| - ✅ Handles invalid syntax gracefully | ||
| - ✅ Handles non-existent files | ||
| - ✅ Handles empty files | ||
|
|
||
| **loadAgent()** | ||
| - ✅ Loads valid TypeScript agents | ||
| - ✅ Loads valid JavaScript agents | ||
| - ✅ Returns invokable agent | ||
| - ✅ Handles TypeScript features (interfaces, types) | ||
|
|
||
| **Integration Tests** | ||
| - ✅ Complete workflow: find → validate → load → invoke | ||
| - ✅ Handles workflow with invalid agent | ||
|
|
||
| ## Test Fixtures | ||
|
|
||
| Test fixtures are located in `fixtures/` directory: | ||
|
|
||
| - `valid-agent.ts` - Valid TypeScript agent for testing | ||
| - `valid-agent.js` - Valid JavaScript agent for testing | ||
| - `no-default-export.ts` - Agent missing default export | ||
| - `no-invoke-method.ts` - Agent missing invoke method | ||
| - `invoke-not-function.ts` - Agent where invoke is not a function | ||
| - `invalid-syntax.ts` - Agent with syntax errors | ||
|
|
||
| ## Writing New Tests | ||
|
|
||
| When adding new test files: | ||
|
|
||
| 1. Name files with `.test.ts` extension | ||
| 2. Import from `bun:test`: `import { describe, it, expect } from "bun:test"` | ||
| 3. Use `beforeEach`/`afterEach` for setup/cleanup | ||
| 4. Group related tests in `describe` blocks | ||
| 5. Make test descriptions clear and specific | ||
|
|
||
| Example: | ||
|
|
||
| ```typescript | ||
| import { describe, it, expect } from "bun:test"; | ||
|
|
||
| describe("myModule", () => { | ||
| it("should do something specific", () => { | ||
| expect(true).toBe(true); | ||
| }); | ||
| }); | ||
| ``` | ||
|
|
||
| ## Notes | ||
|
|
||
| - Tests use Bun's built-in test runner (no additional dependencies needed) | ||
| - Temporary test directories are automatically cleaned up | ||
| - The `tsx` warning messages during tests are expected and don't affect test results |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
bun-version: latestmay cause builds to break unexpectedly if Bun introduces breaking changes in future releases. Consider pinning to a specific Bun version (e.g.,bun-version: 1.0.0) to ensure consistent and reproducible builds across time.