Skip to content

Add integration tests for CLI-to-socket communication#17

Open
cv wants to merge 42 commits intonicobailon:mainfrom
cv:integration-tests
Open

Add integration tests for CLI-to-socket communication#17
cv wants to merge 42 commits intonicobailon:mainfrom
cv:integration-tests

Conversation

@cv
Copy link
Contributor

@cv cv commented Jan 18, 2026

Summary

Adds comprehensive integration tests for the CLI-to-socket communication layer, addressing issue #6.

Changes

  • New test file: test/integration/cli-socket.test.ts
  • 84 integration tests covering 76 unique commands
  • Table-driven test format using it.each() for maintainability
  • Tests run against a mock Unix socket server

Test Coverage

Commands tested:

  • Navigation: navigate, back, forward
  • Aliases: gonavigate, snapscreenshot, readpage.read, netnetwork, findsearch
  • Click: element refs (e5), coordinates, selectors
  • Input: type, key, hover, drag
  • Scroll: scroll, scroll.top, scroll.bottom, scroll.to, scroll.info
  • Page: page.read, page.text, page.state
  • Tab: tab.list, tab.new, tab.switch, tab.close, tab.name, tab.reload, tab.named, tab.unname
  • Window: window.new, window.list, window.focus, window.close, window.resize
  • Wait: wait.element, wait.url, wait.network, wait.load, wait.dom
  • Locate: locate.role, locate.text, locate.label
  • Network: network.get, network.body, network.clear, network.stats, network.origins, network.curl
  • Dialog: dialog.accept, dialog.dismiss, dialog.info
  • Cookie: cookie.list, cookie.get, cookie.set, cookie.clear
  • Frame: frame.list, frame.switch, frame.main, frame.js
  • Emulation: emulate.network, emulate.device, emulate.cpu, emulate.viewport, emulate.touch, emulate.geo
  • History/Bookmark: history.list, history.search, bookmark.list, bookmark.add, bookmark.remove
  • Other: js, form.fill, search, perf.metrics, perf.start, perf.stop, health, zoom
  • Global options: --tab-id, --window-id

Error handling:

  • Socket not available (ENOENT)
  • Server error response

Test Results

Test Files  5 passed
Tests       212 passed (128 unit + 84 integration)
Duration    ~5s

Notes

  • Tests back up any existing /tmp/surf.sock to avoid breaking running surf instances
  • Some commands (console, network base) read from local files and are excluded from socket tests
  • AI commands require special handling and are not included

Closes #6

cv added 30 commits January 17, 2026 12:34
cv added 12 commits January 17, 2026 13:27
…ke, console, network

- Tab group commands: tab.group, tab.ungroup, tab.groups
- Wait base command with duration
- Upload with ref and files
- Resize with dimensions
- Smoke with urls array and routes/fail-fast
- Console base command with limit and clear options
- Network base command with various filters (origin, method, status, format, verbose)
- Updated assertion to use toEqual() for array comparisons
- Add @types/node dependency
- Add 'node' to tsconfig types
- Add explicit types for socket, chunk, code parameters
- Use fileURLToPath for ESM-compatible __dirname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add integration tests

1 participant