Skip to content
This repository was archived by the owner on May 9, 2026. It is now read-only.

test(sdk): coverage audit (priority 7)#137

Merged
slavasolutions merged 1 commit into
release/v1.0from
feat/v1-sdk-test-coverage
May 7, 2026
Merged

test(sdk): coverage audit (priority 7)#137
slavasolutions merged 1 commit into
release/v1.0from
feat/v1-sdk-test-coverage

Conversation

@slavasolutions

Copy link
Copy Markdown
Contributor

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.tsisResolvedRef + getResolved predicates
  • client.ts — bucket-direct offset cursors, listAll exhaustion, lazy-load config errors, unknown-backend exhaustive switch
  • adapters/shared.ts — LRU eviction/promotion/delete, pMapBounded, all 6 byte-parsers
  • adapters/rest.ts — auth, error mapping (401/403/404/5xx), pagination, slug encoding, theme-tokens fallback, nav 410 fallback
  • adapters/r2.ts / s3.ts — config validation
  • adapters/fs.ts — empty bucket, draft invisibility, sort order, locale filter, corrupt-JSON tolerance

Not yet covered (next-time targets)

  • r2/s3 happy paths against mock S3 (sigv4, ListObjectsV2 XML, 403-vs-404)
  • s3-core.ts::parseListResponse XML edge cases

Verification

  • pnpm --filter @clearcms/sdk test — 118/118 pass
  • pnpm --filter @clearcms/sdk typecheck — clean
  • pnpm pack — tarball excludes *.test.*
  • Independence check: zero S1-territory paths

🤖 Generated with Claude Code

@slavasolutions slavasolutions force-pushed the feat/v1-sdk-test-coverage branch 4 times, most recently from 8d70eaf to 02dc2b9 Compare May 7, 2026 10:44
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>
@slavasolutions slavasolutions force-pushed the feat/v1-sdk-test-coverage branch 2 times, most recently from 8c55abd to eb0aadf Compare May 7, 2026 10:48
@slavasolutions slavasolutions merged commit b46a7bc into release/v1.0 May 7, 2026
1 check passed
@slavasolutions slavasolutions deleted the feat/v1-sdk-test-coverage branch May 7, 2026 16:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant