This repository was archived by the owner on May 9, 2026. It is now read-only.
test(sdk): coverage audit (priority 7)#137
Merged
Merged
Conversation
8d70eaf to
02dc2b9
Compare
Adds 103 tests across 7 new files, no production-code changes. Targets
the highest-value gaps in @clearcms/sdk after a public-surface review:
- errors.test.ts (10 tests) — ClearSdkError code/cause contract +
factory tagging. Adapters branch on err.code; pin the values.
- index.test.ts (13 tests) — isResolvedRef / getResolved edge cases
(null _resolved, arrays, primitives, missing keys).
- client.test.ts (15 tests) — bucket-direct listPage offset cursors
(clamp, NaN/negative limits, malformed cursor tolerance, hasMore),
listAll exhaustion, lazy adapter-load config errors, unknown backend.
- adapters/shared.test.ts (24 tests) — LRU eviction + promotion + delete,
pMapBounded order/concurrency cap/empty input, all parsers (valid,
invalid JSON, schema-fail, unicode).
- adapters/rest.test.ts (21 tests) — query-param forwarding (locale,
status, expand, limit, cursor), Bearer auth, draft-without-token
guard, 401/403/404/5xx code mapping, fetch network error wrapping,
malformed JSON parse error, nested page slug encoding,
metaEffective stripping, favicon URL→bucket-key reverse translation,
nav 410 subsystem-off fallback, theme-tokens default fallback,
trailing-slash adminUrl stripping, Z2 cursor pagination shape.
- adapters/config.test.ts (10 tests) — config validation for r2
(accountId, bucket, credentials.{accessKeyId,secretAccessKey}),
s3 (endpoint, bucket, region), fs (root). Errors fire on first call
(lazy load), not factory time — pin that contract.
- adapters/fs.test.ts (13 tests) — empty-bucket defaults
(DEFAULT_IDENTITY/NAV/THEME_TOKENS), bucket-direct draft invisibility
on listItems/getItem/pages.list/pages.get, sort-order contract
(publishedAt desc, slug asc tiebreak), locale filter, missing
collection prefix, corrupt-JSON tolerance (parse error on get,
skip-and-continue on list), nested page slug round-trip.
Verification:
- pnpm --filter @clearcms/sdk test → 118 passed (was 15)
- pnpm --filter @clearcms/sdk typecheck → clean
- pnpm pack → no *.test.* files in tarball (verified via tar -tzf)
No new dependencies. No production code touched. No changeset (this is
internal quality work, not a publishable change).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
8c55abd to
eb0aadf
Compare
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Non-PLAN quality work — priority 7 from the lead's task list. Independent of the v1 sequence.
Summary
15 → 118 tests (+103) across 7 new files in
packages/sdk/src/.Coverage gaps closed
errors.ts— code/cause contract + 5 error factories (was 0 tests)index.ts—isResolvedRef+getResolvedpredicatesclient.ts— bucket-direct offset cursors,listAllexhaustion, lazy-load config errors, unknown-backend exhaustive switchadapters/shared.ts— LRU eviction/promotion/delete,pMapBounded, all 6 byte-parsersadapters/rest.ts— auth, error mapping (401/403/404/5xx), pagination, slug encoding, theme-tokens fallback, nav 410 fallbackadapters/r2.ts/s3.ts— config validationadapters/fs.ts— empty bucket, draft invisibility, sort order, locale filter, corrupt-JSON toleranceNot yet covered (next-time targets)
s3-core.ts::parseListResponseXML edge casesVerification
pnpm --filter @clearcms/sdk test— 118/118 passpnpm --filter @clearcms/sdk typecheck— cleanpnpm pack— tarball excludes*.test.*🤖 Generated with Claude Code