Skip to content

test: Add SDK integration test with real API #224

Description

@Xhristin3

Problem Statement

The SDK tests (xstreamroll-sdk/__tests__/) only test URL configuration resolution. No test calls the actual HTTP methods (login, register, publishEvent, getStreamStatus) against a stub API server.

Evidence

SDK tests mock apiUrl field access but never test actual HTTP calls.

Impact

The SDK's StreamingClient methods are untested beyond constructor config. Auth flow (login, register, refresh, logout), stream operations (publishEvent, getStreamStatus), and error handling have no automated verification.

Proposed Solution

Add integration tests using nock or msw to stub the API:

  1. Test login with valid credentials → returns AuthTokens
  2. Test login with invalid credentials → throws ApiError
  3. Test register with valid data → returns AuthTokens
  4. Test publishEvent → request body verified
  5. Test getStreamStatus → response parsed correctly
  6. Test auto-refresh on 401 → retries with new token

Acceptance Criteria

  • Login/register tests pass with mocked API responses
  • PublishEvent test verifies request body
  • 401 auto-refresh test verifies retry with new token
  • Error responses parsed correctly

File Map

  • xstreamroll-sdk/__tests__/client.integration.test.ts — new
  • xstreamroll-sdk/package.json — add nock dev dependency

Labels: testing
Priority: Low | Difficulty: Intermediate | Estimated Effort: 1d


Labels: testing
Priority: Low | Difficulty: Intermediate | Estimated Effort: 1d
Backlog ID: REPO-041

Metadata

Metadata

Assignees

Labels

testingTests and test coverage

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions