test(client): add vitest coverage for Loop SDK#3
Merged
Conversation
The README's 'Status & roadmap' section was claiming Phase 3 items were deferred when they're all shipping in production: - Digest aggregation cron (/api/cron/digest, every 6h in vercel.json) - Idempotency enforcement (partial unique index + lib/ingest.ts lookup) - Read API (/api/read, Bearer-authed via LOOP_READ_KEY) - To-Do / Remind buttons (action handlers + reminders cron every 5min) Rewrites Status to list everything actually shipping (including the 0.4.0 client + tuple exports) and trims Open list to the genuinely open items: client/service tests, uptime monitoring, agent-seo reroute, and a DB backup restore drill. Also adds a note in 'Sending events' pointing at the new 0.4.0 LOOP_CATEGORIES / LOOP_SEVERITIES / LOOP_ACTIONS / LOOP_EVENT_TYPES / LOOP_EVENT_STATUSES tuple exports for admin dropdowns. No CLAUDE.md in this repo, so nothing to sweep there. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds vitest test suite for the @mattdecrevel/loop client package covering the full public surface: - typed helpers (signup, subscription, feedback, cron, booking, contact, infra, error, generic, raw) — assert URL, bearer auth, content-type, and exact request body for each - optional LoopExtras flow-through (severity, category override, links, footerNote, digest, idempotencyKey, actions) and verification that extras spread onto the envelope rather than the payload - fail-open behavior: helpers resolve (never throw) on network errors, HTTP 500/4xx responses, and AbortController-driven timeouts; all paths log to console.error - as-const tuples (LOOP_CATEGORIES, LOOP_SEVERITIES, LOOP_ACTIONS, LOOP_EVENT_TYPES, LOOP_EVENT_STATUSES) — runtime values match the canonical Loop taxonomy and derived types align at compile time Wires CI via a new test-client.yml workflow that runs on PRs touching packages/client/**. No build step needed — vitest consumes the raw TS source directly since the client ships as-is. 42 tests, 4 files, ~340ms locally. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Deployment failed with the following error: Learn More: https://vercel.link/3Fpeeb1 |
mattdecrevel
added a commit
that referenced
this pull request
May 28, 2026
…ipped Three items from the open list landed in the last hour: - Client tests: PR #3 (42 vitest tests covering typed helpers, fail-open, AbortController timeout, LoopExtras flow-through, tuple alignment) - agent-seo SEO digest reroute: discovered already shipping in mattdecrevel.com (lib/seo/agent/adapters/base.ts) — the engine's notifySlack ignores its own payload and routes via notifyLoop() as a seo_report event - Uptime monitoring: PR #342 on mattdecrevel.com adds a 5-min cron at /api/cron/loop-uptime with both a Loop infra event AND a fallback Slack webhook (so a Loop outage doesn't kill its own alert path) Open list is now down to service tests + DB backup drill. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Adds the first vitest test suite for the
@mattdecrevel/loopclient package. 42 tests across 4 files, ~340ms local runtime.Test files
packages/client/test/typed-helpers.test.ts— every typed helper (signup,subscription,feedback,cron,booking,contact,infra,error,generic,raw, rawnotify). Verifies URL, bearer auth header, content-type, and the exact request body Loop receives. Includes parametrized cases for eachsubscription.kind(new, cancel, payment_failed, addon) and eachfeedback.category(bug, question, feature, general), and bothcron.okbranches.packages/client/test/optional-fields.test.ts—LoopExtras(severity, category override, links, footerNote, digest, idempotencyKey, actions) flow onto the envelope, not the payload. Includes a@ts-expect-errorguard that extras can't override the lockedtypefield.packages/client/test/fail-open.test.ts— confirms the SDK never throws into caller code: network rejection, HTTP 500, HTTP 401, and AbortController-driven timeout all resolve withundefinedand log viaconsole.error. The timeout test asserts the call returns well before the simulated slow response.packages/client/test/tuples.test.ts— as-const tuples (LOOP_CATEGORIES,LOOP_SEVERITIES,LOOP_ACTIONS,LOOP_EVENT_TYPES,LOOP_EVENT_STATUSES) match the canonical Loop taxonomy as hardcoded sets (intentional guardrail — taxonomy drift requires touching this file). Adds compile-timesatisfieschecks so derived types stay aligned with tuple values.packages/client/test/helpers.ts—installFetchMock+bodyOf/urlOf/headerOfaccessors so each test file stays declarative.CI
New
.github/workflows/test-client.ymlruns on PRs touchingpackages/client/**(and pushes to main). Uses pnpm + Node 22, callspnpm --filter @mattdecrevel/loop test.Local test output
Notes
mswor heavy mocking lib —vi.spyOn(globalThis, 'fetch')is enough.packages/client/README.md— the SDK shape doc already lives there and the user noted no update was required.🤖 Generated with Claude Code