Skip to content

test: add browser tests for agent inspector#938

Merged
avi-alpert merged 5 commits intoaws:mainfrom
avi-alpert:aalpert/browser-tests
Apr 24, 2026
Merged

test: add browser tests for agent inspector#938
avi-alpert merged 5 commits intoaws:mainfrom
avi-alpert:aalpert/browser-tests

Conversation

@avi-alpert
Copy link
Copy Markdown
Contributor

@avi-alpert avi-alpert commented Apr 23, 2026

Description

Adds a Playwright-based browser test suite for the agent inspector web UI served by agentcore dev. The tests create a temporary Strands project, start the dev server, and exercise the inspector through a real Chromium browser.

Test coverage:

  • Inspector loads — page renders, header visible, agent status shows project name
  • Start agent — agent reaches running status, chat input enabled, no errors
  • Chat invocation — send a message and verify assistant response appears
  • Resources — resource panel shows the agent, toggle hides the panel
  • Traces — send a message, switch to Traces tab, verify trace and spans appear

Infrastructure changes:

  • Global setup/teardown creates a temp project via agentcore create --json, starts agentcore dev via node-pty, waits for the web UI port, and cleans up afterward
  • Custom Playwright fixture (testEnv) provides port, project path, and project name to tests
  • PTY output and dev server logs are captured as test artifacts for debugging CI failures
  • Added AGENT_INSPECTOR_PATH env var support to resolveUIDistDir() so tests (and developers) can point at a local agent-inspector build
  • resolveUIDistDir exported for testability, with unit tests added
  • Browser tests added to the e2e-tests-full CI workflow
  • ESLint config relaxed for browser-tests/ (same treatment as other test dirs)
  • tsconfig.json includes browser-tests/

Bug fix:

  • Moved runningAgents.set() in the start handler to after the waitForServerReady check passes. Previously, /api/status could report an agent as running before the agent was actually accepting connections, causing the frontend to send invocations that hit ECONNREFUSED. The readiness check itself remains TCP-based (createConnection) to avoid polluting agent telemetry with health-check HTTP spans.

Type of Change

  • New feature
  • Bug fix
  • Other (please describe): test infrastructure

Testing

  • I ran npm run test:unit and npm run test:integ
  • I ran npm run typecheck
  • I ran npm run lint

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

@github-actions github-actions Bot added the size/m PR size: M label Apr 23, 2026
Comment thread browser-tests/global-setup.ts Fixed
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Apr 23, 2026
@jesseturner21
Copy link
Copy Markdown
Contributor

/strands review

@github-actions
Copy link
Copy Markdown
Contributor

Review Summary

Thanks for adding browser tests for the agent inspector! This is a solid implementation that follows Playwright best practices and integrates well with the existing testing infrastructure.

✅ Strengths

  1. Well-structured test suite - Clean separation of concerns with global setup/teardown, fixtures, and focused test files
  2. Proper error handling - Good use of PTY output capture and debug artifacts for CI troubleshooting
  3. Smart environment variable additions - AGENTCORE_NO_OPEN and AGENT_INSPECTOR_PATH are well-placed and useful
  4. Good test coverage - Covers key user flows: inspector loads, agent start, chat, resources, and traces
  5. Appropriate timeouts - Different operations have suitable timeouts (30s for UI, 60s for agent start)
  6. CI integration - Properly added to e2e-tests-full workflow with browser installation and debug output

💡 Suggestions

High Priority

  1. Add unit tests for resolveUIDistDir() - Since you're exporting this function now, it would be good to have unit tests verifying the path resolution logic, especially the new AGENT_INSPECTOR_PATH env var handling.

Medium Priority

  1. Consider retry logic - Browser tests can be flaky. Consider adding retries: 1 or retries: 2 in playwright.config.ts to handle intermittent failures.

  2. Update docs/TESTING.md - Add a section about browser tests similar to the TUI integration tests section. Include:

    • How to run browser tests locally
    • Required dependencies (AWS credentials, uv)
    • Troubleshooting tips
    • Reference to browser-tests/README.md (if you create one)

Low Priority

  1. Enhanced error messages in global setup - When project creation fails, consider adding more context about common issues (e.g., missing uv, AWS credentials not configured).

📝 Code-Specific Feedback

browser-tests/global-setup.ts (lines 76-86)

// Consider wrapping the entire create command in a more descriptive try-catch
// that explains what went wrong and provides troubleshooting steps

playwright.config.ts (line 19)

retries: 0,
// Consider: retries: 1, // Browser tests can be flaky

global-teardown.ts

  • Looks good! The log copying and cleanup logic is solid.

🎯 Questions

  1. Have you tested the browser tests in CI yet? If not, might be worth doing a test run to ensure the Playwright installation step works correctly.
  2. Did you consider using Playwright's codegen tool to generate some of these tests? It can be helpful for complex interactions.

Overall Assessment

This is a high-quality PR that adds valuable test coverage for the agent inspector. The implementation is solid, follows best practices, and integrates well with the existing codebase. The suggestions above are mostly enhancements rather than blockers. Once you address the high-priority items (especially unit tests for resolveUIDistDir), this will be ready to merge.

Great work! 🎉

@avi-alpert avi-alpert marked this pull request as ready for review April 23, 2026 19:43
@avi-alpert avi-alpert requested a review from a team April 23, 2026 19:43
@github-actions github-actions Bot added size/l PR size: L and removed size/m PR size: M labels Apr 23, 2026
@avi-alpert avi-alpert force-pushed the aalpert/browser-tests branch from 3ef2f64 to f36b7b4 Compare April 24, 2026 19:23
@github-actions github-actions Bot added size/l PR size: L and removed size/l PR size: L labels Apr 24, 2026
@avi-alpert avi-alpert marked this pull request as draft April 24, 2026 19:45
@avi-alpert avi-alpert force-pushed the aalpert/browser-tests branch from f36b7b4 to a6164fa Compare April 24, 2026 19:49
@github-actions github-actions Bot added size/l PR size: L and removed size/l PR size: L labels Apr 24, 2026
@avi-alpert avi-alpert marked this pull request as ready for review April 24, 2026 19:51
@avi-alpert
Copy link
Copy Markdown
Contributor Author

/strands review

Comment thread .github/workflows/e2e-tests-full.yml
Comment thread src/cli/operations/dev/web-ui/__tests__/resolve-ui-dist-dir.test.ts
@avi-alpert avi-alpert merged commit 7a4104d into aws:main Apr 24, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/l PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants