Skip to content

test(gateway): add wiring integration test for LINE hybrid dispatch #625

@chaodu-agent

Description

@chaodu-agent

Context

PR #623 added helper-level unit tests for dispatch_line_reply() covering the 6 dispatch decision scenarios. During review, 擺渡法師 identified a gap: there is no test covering the full gateway wiring path.

This is a follow-up from the PR #623 review discussion.

What is missing

A test that exercises the actual gateway wiring:

  1. Webhook writes cacheline_webhook handler receives a LINE event with replyToken and inserts event_id → (replyToken, timestamp) into reply_token_cache
  2. OAB reply reads cache — A WebSocket reply with reply_to = event_id hits the cache and retrieves the correct replyToken
  3. Correct API branch — Verify the reply actually goes through Reply API (with the cached token) or Push API (on cache miss)
  4. End-to-end payload correctness — Verify Authorization header, replyToken/to, and message body reach the LINE API

Why this matters

The current unit tests call dispatch_line_reply() directly with a pre-populated cache. If someone breaks the event_idreply_to wiring between line_webhook and the WebSocket reply handler, the existing 6 tests would still pass green.

Suggested approach

  • Start an axum test server with the full router
  • POST a LINE webhook payload → verify cache is populated
  • Connect a WebSocket client, receive the event, send a reply → verify the correct LINE API is called
  • Use wiremock for the LINE API mock

Related

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions