Skip to content

test(sdk): Add integration tests for Teams adapter class methods #772

@diberry

Description

@diberry

Context

PR #768 added 32 unit tests for the Teams adapter's pure helper functions (escapeHtml, stripHtml, formatTeamsMessage, parseTokens, base64url, validateGraphId). These cover the exported utilities well.

However, the class methods remain untested:

  • ensureAuthenticated() — token lifecycle (cache/refresh/PKCE/device code)
  • ensureChat() — chat creation/lookup
  • postUpdate() — message posting to chats and channels
  • pollForReplies() — message polling with filtering

These require Graph API mocking but are the highest-risk code paths.

What to do

Add integration tests using a mocked fetch (e.g., vi.stubGlobal('fetch', ...) or msw) that cover:

  1. Token refresh flow (expired → refresh → success)
  2. Token refresh failure → re-auth fallback
  3. postUpdate to chat vs channel
  4. pollForReplies filtering out own messages
  5. pollForReplies error → warning logged + empty array returned
  6. ensureChat with recipientUpn vs me mode

Origin

Flagged by FIDO (quality review) during PR #768 review — Round 2 non-blocking note.

Severity: MEDIUM (future work)
Related PR: #768

Metadata

Metadata

Assignees

No one assigned

    Labels

    go:needs-researchNeeds investigationsquadSquad triage inbox — Lead will assign to a membersquad:fidoAssigned to FIDO (Quality Owner)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions