Skip to content

test: cover http/client retry+timeout, avatar geometry/clip, Arabic wrapping - #78

Merged
otnc merged 4 commits into
mainfrom
test/http-client-avatar-geometry-and-rtl
Aug 29, 2026
Merged

test: cover http/client retry+timeout, avatar geometry/clip, Arabic wrapping#78
otnc merged 4 commits into
mainfrom
test/http-client-avatar-geometry-and-rtl

Conversation

@otnc

@otnc otnc commented Aug 29, 2026

Copy link
Copy Markdown
Owner

What does this change?

Three independent test-coverage additions found during a codebase review, each its own commit. Test-only — no production code changed.

  1. http/client.test.ts (new): createClient had no dedicated test file. api/client.test.ts exercises it but pins retry: 0 in every case, so the retry loop, retryable-vs-non-retryable status handling, and the timeout → TimeoutError path had never actually run.
  2. avatar.test.ts: coverRect/containRect (pure aspect-ratio math) and drawAvatar's shape: 'circle' clip had no direct tests, only indirect exercise through pipeline.test.ts's pixel-comparing render tests.
  3. 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 ci passes (Biome lint and format)
  • npm run typecheck passes
  • npm run test passes
  • npm run build && npm run check:build passes
  • Tests cover the change
  • README updated, if the public API changed

otnc added 4 commits August 29, 2026 21:10
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
@otnc
otnc merged commit d42049f into main Aug 29, 2026
7 checks passed
@otnc
otnc deleted the test/http-client-avatar-geometry-and-rtl branch August 29, 2026 12:27
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.

1 participant