Skip to content

Add comprehensive E2E tests for trace viewer with adversarial cases#353

Open
anandgupta42 wants to merge 3 commits intomainfrom
claude/fix-tracer-tabs-bug-ogtsH
Open

Add comprehensive E2E tests for trace viewer with adversarial cases#353
anandgupta42 wants to merge 3 commits intomainfrom
claude/fix-tracer-tabs-bug-ogtsH

Conversation

@anandgupta42
Copy link
Contributor

Summary

Added extensive end-to-end tests for the trace viewer HTML renderer using Playwright, covering both normal user workflows and adversarial edge cases. Also fixed several bugs in the viewer's event handling and styling discovered during test development.

Changes:

Test Suite (tracing-viewer-e2e.test.ts):

  • 1100+ lines of comprehensive E2E tests using Playwright with real Chromium browser
  • User perspective tests: Tab switching, span selection, detail panel display, waterfall/tree/log/chat views
  • Adversarial tests: XSS injection, empty data, duplicate IDs, null/undefined values, very long names, 100+ spans, deeply nested trees, circular references, unicode handling, negative durations, etc.
  • Tests verify correct HTML escaping, state management across view switches, and proper error handling

Viewer Fixes (viewer.ts):

  • Fixed tab click handler to use .closest('.tab') for more robust event delegation
  • Added .sel styling for log entries to show selection state (matching waterfall/tree behavior)
  • Added cursor: pointer to log entries to indicate clickability
  • Improved event target validation to prevent crashes on edge cases

Dependencies:

  • Added playwright-core 1.58.2 to dev dependencies for browser automation

Test Plan

The new test suite provides comprehensive coverage:

  • E2E tests pass: 30+ tests covering normal workflows (tab switching, clicking spans, detail panels)
  • Adversarial tests pass: 20+ tests covering edge cases (XSS, empty data, 100+ spans, unicode, etc.)
  • No JS errors: All tests verify the page renders without console errors
  • Existing functionality preserved: Tests confirm waterfall, tree, log, and chat views work correctly

Tests are skipped gracefully if Chromium is not available in the environment.

Checklist

  • Tests added/updated (1100+ lines of comprehensive E2E tests)
  • Documentation updated (not needed)
  • CHANGELOG updated (not user-facing, internal testing improvement)

https://claude.ai/code/session_01G3S1w3PzzCwdAMb6GkD8sV

claude added 2 commits March 21, 2026 20:48
- Tab switching: use closest('.tab') instead of ev.target.dataset for
  robust event delegation, fix variable shadowing of 't' trace data
- Waterfall view: switch from per-row onclick closures to event
  delegation with data-idx, preventing potential closure bugs
- Tree view: use index-based span lookup (data-idx) instead of
  spanId-based lookup (data-sid), fixing duplicate spanId edge case
- Log view: make entries clickable with detail panel support, add
  selection highlighting (.log-entry.sel)
- All views now use consistent event delegation pattern with
  closest() for click handling

https://claude.ai/code/session_01G3S1w3PzzCwdAMb6GkD8sV
Add 39 Playwright-based tests covering:
- E2E user flows: tab switching, waterfall/tree/log clicks, detail panel,
  chat view, summary cards, header tags, rapid tab switching
- Adversarial cases: empty spans, single session, duplicate spanIds,
  XSS in names/metadata, special chars in spanId, null/undefined spanIds,
  very long names (10K chars), 100+ spans, error status, orphaned spans,
  deeply nested tree (5 levels), missing metadata/summary, circular refs,
  DE attributes, negative/zero durations, live mode, unicode

https://claude.ai/code/session_01G3S1w3PzzCwdAMb6GkD8sV
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review.

@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2026

Warning

Rate limit exceeded

@anandgupta42 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 44 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0fd70395-acef-4723-83b0-70acb9b65dcc

📥 Commits

Reviewing files that changed from the base of the PR and between 623d1ac and 16a35a4.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • package.json
  • packages/opencode/package.json
  • packages/opencode/src/altimate/observability/viewer.ts
  • packages/opencode/test/altimate/tracing-viewer-e2e.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fix-tracer-tabs-bug-ogtsH

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

… expanding

- Waterfall: shows tool input summary (command, file path, query) and generation model/tokens inline
- Tree: adds preview line below each span name with the same smart summaries
- Log: shows tool input preview and generation model inline alongside existing output preview
- New getPreview() helper extracts the most useful field from span input based on kind

https://claude.ai/code/session_01G3S1w3PzzCwdAMb6GkD8sV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants