test: cover http/client retry+timeout, avatar geometry/clip, Arabic wrapping - #78
Merged
Merged
Conversation
client.ts is the shared HTTP layer for avatars, emoji, API calls and update checks, but had no dedicated test file — the only place it was exercised was api/client.test.ts, and every case there pins retry: 0, so the retry loop, retryable-vs-non-retryable status codes and the timeout -> TimeoutError path had never actually run in the test suite. Covers: GET/POST success, HTTPError thrown by default vs. throwHttpErrors: false, retrying a retryable status until it succeeds, giving up once the retry budget runs out, not retrying a non-retryable status, TimeoutError on a hung request, and getBuffer.
…hape clip coverRect and containRect are pure aspect-ratio math with no test of their own — only exercised indirectly through pipeline.test.ts's pixel-comparing render tests, which don't isolate wide-image-in-a-square-box vs. tall-image-in-a-square-box vs. matching-aspect-ratio cases. Added direct cases for all three, for both functions. drawAvatar's shape: 'circle' clip and shape: 'rectangle' no-clip path also had no test of their own; added one checking a box corner stays transparent under circle clipping and stays painted without it.
Every non-Latin case in breakpoint.test.ts was Japanese/Chinese; Arabic (one of the default script-fallback fonts, IBM Plex Sans Arabic) had no coverage at all. Added two cases: spaces break the same way they do for any other space-delimited script, and a single unspaced word gets no fallback break (Arabic uses spaces between words, unlike CJK, so this is expected, not a gap — Hangul's similar-looking but different case is tracked separately and intentionally not addressed here).
…ar-geometry-and-rtl # Conflicts: # src/render/avatar.test.ts
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.
What does this change?
Three independent test-coverage additions found during a codebase review, each its own commit. Test-only — no production code changed.
http/client.test.ts(new):createClienthad no dedicated test file.api/client.test.tsexercises it but pinsretry: 0in every case, so the retry loop, retryable-vs-non-retryable status handling, and the timeout →TimeoutErrorpath had never actually run.avatar.test.ts:coverRect/containRect(pure aspect-ratio math) anddrawAvatar'sshape: 'circle'clip had no direct tests, only indirect exercise throughpipeline.test.ts's pixel-comparing render tests.breakpoint.test.ts: Arabic (RTL, one of the default script-fallback fonts) had zero coverage — every non-Latin case was Japanese/Chinese. Added the space-break case and the "single unspaced word gets no fallback break" case (expected, since Arabic uses spaces unlike CJK).Note: Hangul's CJK-regex fallback-break gap (a related but separate finding) is intentionally not addressed here — deferred pending further discussion.
Checklist
npm run cipasses (Biome lint and format)npm run typecheckpassesnpm run testpassesnpm run build && npm run check:buildpasses