Skip to content

Add direct tests for idle-close and reply-token flows#14

Open
NahuelGenchi wants to merge 1 commit into
Bandruption-Platform:mainfrom
NahuelGenchi:scout/issue-8-reply-idle-tests
Open

Add direct tests for idle-close and reply-token flows#14
NahuelGenchi wants to merge 1 commit into
Bandruption-Platform:mainfrom
NahuelGenchi:scout/issue-8-reply-idle-tests

Conversation

@NahuelGenchi
Copy link
Copy Markdown

Pull Request Description

Summary

  • Add direct idle-close job tests for stale threads, fresh threads, and the onCloseThread hook.
  • Add reply-token cache tests for inbound webhook capture, line.ack_with_reply_token, expired tokens, and reply-token GC.
  • Keep the change tests-only with no production code changes.

Closes #8

Validation

  • npm test
  • npm run typecheck
  • npm run build

Copy link
Copy Markdown
Member

@harleyjj harleyjj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tests/idle-close.test.ts and tests/reply-token.test.ts

2 participants