Add direct tests for idle-close and reply-token flows#14
Conversation
harleyjj
left a comment
There was a problem hiding this comment.
Thank you for tackling this! I'd like to request some changes:
BLOCKING: tests/reply-token.test.ts misses the production index invariant for reply-token GC.
Concrete problem: the inbound test proves that comment metadata exists after webhook processing (tests/reply-token.test.ts:190-196), but it never asserts that the resulting commentId was added to STATE_KEYS.commentMetaIndex. The GC test then hand-seeds that same index (tests/reply-token.test.ts:250-255) before running reply-token-gc, so the suite would still pass if the real inbound path stored reply-token metadata but stopped indexing it. That is the production failure mode that matters: unindexed inbound tokens would never be swept by reply-token-gc, even though these tests stay green.
Proposed fix: after the webhook/process-event path captures commentId, assert harness.getState(replyTokenIndexScope()) contains { companyId: COMPANY_ID, commentId }. For stronger coverage, make the GC test consume an entry created through the inbound webhook path, then age that captured meta before running JOB_KEYS.replyTokenGc, so the GC assertion depends on the same index path production uses.
Pull Request Description
Summary
onCloseThreadhook.line.ack_with_reply_token, expired tokens, and reply-token GC.Closes #8
Validation
npm testnpm run typechecknpm run build