aws-samples / aws-samples/sample-agent-assisted-sdlc

feat: add tests and CI coverage for agentcore-sdlc-inspector

Open
#79 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
42
Forks
9
PR merge metrics
No merged PRs in 30d

Description

## Description

The `agentcore-sdlc-inspector/` POC currently has no tests and is not included in CI. As the inspector graduates from POC to a maintained tool, it needs test coverage and CI integration.

## Scope

### API Tests (`agentcore-sdlc-inspector/api/`)

- [ ] Unit tests for event stream parser (`aws/agentcore.ts`) — mock binary event stream frames, verify stdout/stderr/exitCode extraction
- [ ] Unit tests for DDB scan logic (`aws/dynamodb.ts`) — mock DynamoDB responses, verify grouping/filtering
- [ ] Unit tests for SigV4 signing helper (`aws/sign.ts`) — verify request construction and header inclusion
- [ ] Integration tests for routes:
- `GET /api/health` → returns `{ ok: true, checked_at: string }`
- `GET /api/sessions?window=0` → verifies falsy-zero fix (window=0 triggers full scan)
- `POST /api/check-claude` → mock AgentCore response, verify CLAUDE_RUNNING/NOT_RUNNING parsing
- `POST /api/stop-session` → mock AgentCore response, verify stopped/not-stopped return
- `POST /api/runtime-lifecycle` → mock uptime response, verify seconds parsing
- [ ] Test framework: vitest or jest (pick one, pin version)

### Frontend Tests (`agentcore-sdlc-inspector/web/`)

- [ ] Component tests for `SessionCard` — render with mock data, verify buttons/badges/status
- [ ] Component tests for `SessionList` — verify grouping logic (skipped invocations in history, non-skipped as primary)
- [ ] Component tests for `App` — verify time window filter, auto-refresh, dark mode toggle
- [ ] Test framework: vitest + @testing-library/react

### CI Integration

- [ ] Add to `.github/workflows/ci.yml` (or new workflow):
```yaml
inspector:
runs-on: ubuntu-latest
defaults:
run:
working-directory: agentcore-sdlc-inspector
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm install
- run: cd api && npx tsc --noEmit
- run: cd web && npx tsc --noEmit
- run: cd api && npm test
- run: cd web && npm test
```
- [ ] Add `test` script to both `api/package.json` and `web/package.json`
- [ ] Ensure `npx cdk synth --quiet` still passes (inspector not included in CDK build)

## Files to Create / Modify

```
agentcore-sdlc-inspector/api/src/__tests__/ NEW — API unit/integration tests
agentcore-sdlc-inspector/web/src/__tests__/ NEW — Component tests
agentcore-sdlc-inspector/api/package.json MODIFY — add test deps + script
agentcore-sdlc-inspector/web/package.json MODIFY — add test deps + script
.github/workflows/ci.yml MODIFY — add inspector job
```

## Test Priorities (highest first)

1. Event stream parser — most complex logic, most likely to regress
2. Falsy-zero window handling — already caught one bug here
3. Session grouping (skipped vs. non-skipped primary selection)
4. Route handlers (mock AWS SDK, verify request/response shapes)
5. Frontend component rendering

## Constraints

- Pin all test dependencies to exact versions
- Mock AWS SDK calls (never hit real DynamoDB/AgentCore in tests)
- Tests must pass without AWS credentials configured
- TypeScript strict mode for test files
- No snapshot tests (they create noise on Cloudscape version bumps)

Contributor guide

Open the contributing guide

Research direction

Start with agentcore-sdlc-inspector/api/src and web/src, then review api/package.json, web/package.json, and .github/workflows/ci.yml to choose and pin the test frameworks. Add the listed API and component tests, scripts, and inspector CI job; done means both test suites and type checks pass without AWS credentials and cdk synth still succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, github-actions, react, typescript
Domain
api, ci-cd, frontend, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.