Skip to content

test(integration): un-skip impersonation-audit logging tests (#3320)#3328

Merged
bokelley merged 1 commit into
mainfrom
claude/issue-3320-impersonation-audit-skip
Apr 27, 2026
Merged

test(integration): un-skip impersonation-audit logging tests (#3320)#3328
bokelley merged 1 commit into
mainfrom
claude/issue-3320-impersonation-audit-skip

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Closes #3320

Summary

The Impersonation Audit Logging Tests describe in server/tests/integration/impersonation-audit.test.ts was permanently describe.skip'd because POST /api/addie/chat returns 503 when the test fires — initializeChatClient runs via setTimeout 5s after module load, so the endpoint is unready. Completing the AddieClaudeClient mock to satisfy initializeChatClient requires mocking 7+ tool-handler factory modules and is brittle.

The behavior under test — that addie_threads.impersonator_user_id and addie_threads.impersonation_reason are written when req.user.impersonator is set — is fully exercisable at the ThreadService layer without the HTTP shell.

This PR also corrects the 3 schema tests, which were checking addie_conversations/addie_messages (migration 050 legacy tables) instead of addie_threads (the live table since migration 064). Those tests were giving a false green: the columns they checked exist but are never populated by the live code path.

Changes

  • server/tests/integration/impersonation-audit.test.ts: Remove describe.skip block and all its vi.mock scaffolding. Replace with 4 ThreadService.getOrCreateThread() unit tests that write to and read from addie_threads. Merge both describe blocks under a single outer describe.skipIf(!process.env.DATABASE_URL) wrapper so the pool lifecycle is managed once. Update schema test to check addie_threads.impersonator_user_id + impersonation_reason.
  • .changeset/fix-impersonation-audit-tests.md: Empty changeset (test-only; no protocol impact).

Non-breaking justification

Test-only changes. No production code touched. addie_thread_messages has no impersonation column; the 2 "message-level impersonation" tests from the original describe were testing a feature that no longer exists in the current schema, so they are dropped rather than ported.

Acknowledged gaps (follow-up)

  1. HTTP-mapping coverage: req.user.impersonator.email → impersonator_user_id in addie-chat.ts (lines 759, 1044) remains untested. That mapping is the only wire connecting a live WorkOS impersonation session to a stored audit record. Covered by a Known gap comment in the file; tracked for a follow-up that extracts it into a testable pure helper.
  2. UPSERT "get" path: getOrCreateThread's ON CONFLICT DO UPDATE does not update impersonation fields on subsequent calls to the same external_id. No test covers this path (noted in file comment); covered separately in thread-service.test.ts context.

Pre-PR review

  • code-reviewer: approved — pool lifecycle consolidation and fallback-string removal address the two blockers; test isolation via nextExternalId() counter is sound
  • internal-tools-strategist: approved for draft — HTTP-mapping gap is documented and acceptable for a draft PR; acknowledged gaps are trackable

Triage-managed PR. This bot does not currently iterate on
review comments or PR conversation threads (only on the source
issue). To unblock:

  • Push fixup commits directly: gh pr checkout <num>
    fix → push.
  • Or re-trigger: comment /triage execute on the source
    issue.

See #3121
for context.

Session: https://claude.ai/code/session_01SYxDAk3cwxjmCzND6nTLGM


Generated by Claude Code

Replace brittle describe.skip (POST /api/addie/chat returned 503 due to
timer-deferred AddieClaudeClient init) with ThreadService unit tests that
write directly to addie_threads. Also update schema assertions from the
legacy addie_conversations / addie_messages tables to the live addie_threads
table (migration 064).

https://claude.ai/code/session_01SYxDAk3cwxjmCzND6nTLGM
@bokelley bokelley added the claude-triaged Issue has been triaged by the Claude Code triage routine. Remove to re-triage. label Apr 26, 2026
@bokelley bokelley marked this pull request as ready for review April 27, 2026 11:09
@bokelley bokelley merged commit 27e377b into main Apr 27, 2026
13 checks passed
@bokelley bokelley deleted the claude/issue-3320-impersonation-audit-skip branch April 27, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude-triaged Issue has been triaged by the Claude Code triage routine. Remove to re-triage.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(integration): impersonation-audit — chat-driven describe needs working AddieClaudeClient init or unit-level rework

2 participants