test(integration): un-skip impersonation-audit logging tests (#3320)#3328
Merged
Conversation
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
1 task
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3320
Summary
The
Impersonation Audit Logging Testsdescribe inserver/tests/integration/impersonation-audit.test.tswas permanentlydescribe.skip'd becausePOST /api/addie/chatreturns 503 when the test fires —initializeChatClientruns viasetTimeout5s after module load, so the endpoint is unready. Completing theAddieClaudeClientmock to satisfyinitializeChatClientrequires mocking 7+ tool-handler factory modules and is brittle.The behavior under test — that
addie_threads.impersonator_user_idandaddie_threads.impersonation_reasonare written whenreq.user.impersonatoris set — is fully exercisable at theThreadServicelayer without the HTTP shell.This PR also corrects the 3 schema tests, which were checking
addie_conversations/addie_messages(migration 050 legacy tables) instead ofaddie_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: Removedescribe.skipblock and all itsvi.mockscaffolding. Replace with 4ThreadService.getOrCreateThread()unit tests that write to and read fromaddie_threads. Merge bothdescribeblocks under a single outerdescribe.skipIf(!process.env.DATABASE_URL)wrapper so the pool lifecycle is managed once. Update schema test to checkaddie_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_messageshas 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)
req.user.impersonator.email → impersonator_user_idinaddie-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 aKnown gapcomment in the file; tracked for a follow-up that extracts it into a testable pure helper.getOrCreateThread'sON CONFLICT DO UPDATEdoes not update impersonation fields on subsequent calls to the sameexternal_id. No test covers this path (noted in file comment); covered separately inthread-service.test.tscontext.Pre-PR review
nextExternalId()counter is soundSession: https://claude.ai/code/session_01SYxDAk3cwxjmCzND6nTLGM
Generated by Claude Code