Skip to content

Add test coverage for message size validation#169

Merged
mattieruth merged 7 commits intomessage-too-large-handlingfrom
copilot/sub-pr-168
Jan 14, 2026
Merged

Add test coverage for message size validation#169
mattieruth merged 7 commits intomessage-too-large-handlingfrom
copilot/sub-pr-168

Conversation

Copy link
Contributor

Copilot AI commented Jan 14, 2026

Adds missing test coverage for messageSizeWithinLimit() utility function and _sendMessage() wrapper introduced in #168.

Test coverage added:

  • messageSizeWithinLimit() validation for messages within/exceeding limits, complex objects, and boundary conditions
  • _sendMessage() error handling: MessageTooLargeError thrown, onError callback invoked with correct message
  • Edge cases: exact size limit, one byte over

Supporting changes:

  • Jest setup file to polyfill TextEncoder for jsdom environment
  • Helper functions to reduce test duplication
  • Named constants for test data sizes

Example test structure:

test("should throw MessageTooLargeError for oversized messages", async () => {
  await client.connect();
  const largeData = createOversizedData();
  expect(() => {
    client.sendClientMessage("test", { data: largeData });
  }).toThrow(MessageTooLargeError);
});

All 15 tests passing. No security issues detected.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Update error handling for large message payloads Add test coverage for message size validation Jan 14, 2026
Copilot AI requested a review from mattieruth January 14, 2026 21:27
@mattieruth mattieruth marked this pull request as ready for review January 14, 2026 22:07
@mattieruth mattieruth merged commit b3a74cf into message-too-large-handling Jan 14, 2026
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.

2 participants