Skip to content

test(realtime): add integration tests for collaborative whiteboard features (#60)#97

Open
pithva007 wants to merge 2 commits into
KENZY004:mainfrom
pithva007:feat/realtime-integration-tests
Open

test(realtime): add integration tests for collaborative whiteboard features (#60)#97
pithva007 wants to merge 2 commits into
KENZY004:mainfrom
pithva007:feat/realtime-integration-tests

Conversation

@pithva007

Copy link
Copy Markdown
Contributor

Description

This PR addresses Issue #60 by establishing a comprehensive automated integration testing suite targeting the core Socket.IO real-time features on both the frontend and backend. It strictly guarantees deterministic test execution by avoiding live ports or real database dependencies.

Backend Testing (Jest + socket.io-client)

  • Engineered a reusable socketTestClient.js helper that seamlessly binds our Express backend to dynamic ports on-the-fly.
  • Implemented robust test coverage validating successful JWT connection lifecycles, unauthorized connection rejections, room membership separation, and the realtime propagation of drawings/strokes across concurrent clients.
  • Fully mocked mongoose payloads containing method chaining (like .populate()) to avert any MongoDB cloud lookups.

Frontend Testing (Vitest + React Testing Library)

  • Set up lightweight frontend unit tests leveraging Vitest.
  • Heavily mocked socket.io-client with a synthetic event emitter architecture allowing test suites to validate internal Whiteboard.jsx state transitions (e.g. broadcasting clear-canvas correctly).
  • Asserts strict listener cleanup procedures on component unmount to prevent React memory leaks.

Related Issues

Closes #60

Testing Checklist

  • Backend WebSocket connection testing implemented.
  • Room isolation and multiple-client connectivity verified.
  • Sync events (drawing-stroke, draw-element) verified.
  • Frontend synthetic event simulation passes.
  • Zero usage of magic sleep functions; tests are strictly event-driven.

CI Workflow Summary

  • Created .github/workflows/realtime-tests.yml to automatically execute on push and pull_request against main.
  • Strategized npm cache sharing to dramatically optimize workflow velocity.
  • Workflow enforces a strict Node.js 18.x LTS baseline matrix and will block merges upon any test suite failures across either directory.

Copilot AI review requested due to automatic review settings May 21, 2026 12:17
@vercel

vercel Bot commented May 21, 2026

Copy link
Copy Markdown

@pithva007 is attempting to deploy a commit to the MINHA's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@KENZY004

Copy link
Copy Markdown
Owner

Nice work on this! I tested it locally and all 3 tests are failing because of an Invalid token error. JWT_SECRET is being read before dotenv loads, so move it inside createClient().

Also, stopServer() should properly close the socket server, otherwise Jest force exits because of open handles.

Fix these two and it should be good to go!

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.

[Testing] Integration Tests for Real-time Collaboration

3 participants