Skip to content

Which regression tests should cover both chat response decoders and the local pending answer slot?

Test the chat endpoint as a response union: a confirmed non-streaming completion and an accepted durable job requiring follow-up. Decode the HTTP status and body together. Do not assume every successful AISwapLab chat response contains choices or that every 202 body is a failed completion.

TEST THE CUSTOMER API CONTRACTAISwapLab team · Editorial methodPublished 2 min read
Open API documentationExplore 67 Image SkillsPrivate keys · Explicit credit approval
Article workflow: Build separate test envelopes; Assert different UI outcomes; Complete the deferred path.
Workflow diagram: Build separate test envelopes → Assert different UI outcomes → Complete the deferred path. Read the article for evidence and limits.

Two shapes need two paths

A UI tested only with the immediate answer can break exactly when the gateway outcome becomes uncertain. The durable-job branch must preserve the user's conversation association and avoid adding an empty assistant message that later masquerades as a real answer. Treat valid response-envelope decoding as a prerequisite. The distinct regression target is the pending assistant slot: a valid deferred branch and later fixture content must attach once to the correct conversation turn, without an empty fabricated answer or duplicate local message.

What to do next

  1. 01

    Build separate test envelopes

    Create one fixture for the documented confirmed completion and one for the documented uncertain job. Include the response status in the fixture, and validate required fields for each variant instead of casting both into one type.

  2. 02

    Assert different UI outcomes

    For confirmed completion, attach the returned answer to its conversation turn. For the job variant, show that the response is still being confirmed and retain the associated task without presenting invented text.

  3. 03

    Complete the deferred path

    Drive the uncertain-job fixture through follow-up completion and private JSON retrieval in your test environment. Verify that the eventual assistant response fills the original pending turn once, rather than creating a second unrelated conversation message.

A concrete example

Illustrative example: a test sends one user turn and receives 202 with a job. The conversation displays one pending assistant slot. When the fixture later yields the confirmed stored answer, that slot is completed without another paid submission.

Before you call it ready

  • Both response statuses are covered.
  • Pending turns contain no fabricated answer.
  • Deferred completion attaches exactly once.

When to stop or choose another method

Stop shipping a chat integration whose only success test assumes choices is present immediately on every successful HTTP response.

Sources

One task. A recoverable workflow.

Check the contract, approve the quote and retain the job.

Open API documentation