test: integration coverage, mock client, 80% thresholds#34
Merged
Conversation
- Add @vitest/coverage-v8 with global 80% statement/branch/function/line thresholds (vite.config.ts) and a `pnpm test:coverage` script. - Introduce src/test-utils/MockChatApiClient: typed FIFO mock for ChatApiClient with mockReply/mockError/mockTimeout/mockNetworkError/ mockPending helpers and call-history inspection. - Add src/__tests__/chatFlow.integration.test.tsx covering the full chat flow against the real ChatWidget: open → typing indicator → assistant reply, sources rendering, network-error → inline Retry → recovery, non-recoverable validation error hides Retry, and sessionStorage persistence across remounts. - Fill coverage gaps: theme=auto matchMedia subscription and the full translation-routing matrix in useChat (TIMEOUT, NETWORK_ERROR, both RATE_LIMITED paths, unknown codes). Aggregate coverage now 94.71% / 87.42% / 97.70% / 97.49% (stmts / branches / functions / lines), 184 tests passing. Closes #14 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Deploying chat-widget with
|
| Latest commit: |
1c745a2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8e747bc4.chat-widget-ejc.pages.dev |
| Branch Preview URL: | https://14-unit-and-integration-test-9w3a.chat-widget-ejc.pages.dev |
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 #14
Summary
@vitest/coverage-v8with a global 80% threshold across statements/branches/functions/lines and a newpnpm test:coveragescript.MockChatApiClient(src/test-utils/MockChatApiClient.ts) with FIFOmockReply/mockError/mockTimeout/mockNetworkError/mockPendinghelpers and call-history inspection. Self-tested insrc/test-utils/__tests__/.src/__tests__/chatFlow.integration.test.tsxexercising the full flow against the realChatWidget: open → typing indicator → assistant reply, sources rendering, network-error → inline Retry → recovery, non-recoverable validation error hides Retry, and sessionStorage persistence across remounts.theme="auto"matchMedia subscription and the full translation-routing matrix inuseChat(TIMEOUT, NETWORK_ERROR, both RATE_LIMITED paths, unknown-code fallback).Coverage
184 tests passing (was 167).
Test plan
pnpm test:coverage— 184/184 pass, all four thresholds satisfiedpnpm exec tsc --noEmitcleancoverage/html report renders the same numbers as the CLI table🤖 Generated with Claude Code