Skip to content

Add integration test suite against a real decree server#91

Merged
zeevdr merged 5 commits into
mainfrom
feat/issue-59-integration-tests
May 25, 2026
Merged

Add integration test suite against a real decree server#91
zeevdr merged 5 commits into
mainfrom
feat/issue-59-integration-tests

Conversation

@zeevdr
Copy link
Copy Markdown
Member

@zeevdr zeevdr commented May 25, 2026

Summary

  • Closes the gap between mock-based tests and real server behavior by running the SDK against a live decree server via docker-compose, exercising the full gRPC wire path.
  • Provides a reusable local dev fixture so contributors can run integration tests without a separate server setup.

Test plan

  • Unit tests (npm test) — all 219 pass, coverage unchanged at 97.5%.
  • Biome lint (npm run lint) — clean on src/, test/, and new integration/.
  • Workspace isolation — integration project is inert (0 tests) when DECREE_INTEGRATION is unset; does not affect unit test coverage report.
  • Integration suite (DECREE_INTEGRATION=1 npm run test:integration) — requires the docker-compose stack (docker compose up -d --wait service); covers:
    • snapshotgetAll() and typed get() round-trips
    • watchConfigWatcher loads initial snapshot and receives a live Subscribe change
    • reconnect — a restarted watcher loads the latest values after changes made while stopped
    • set with checksum — correct checksum succeeds; stale checksum rejects with ChecksumMismatchError
    • set with abortAbortController abort wires through to gRPC; if cancelled, error is CancelledError
  • CI integration job — checks out opendecree/decree, builds tools + server images with GHCR layer cache, starts the stack, runs the suite, tears down unconditionally.

Closes #59

Adds a docker-compose fixture and a Vitest integration workspace project
that run the TypeScript SDK against a live decree server, covering the
five scenarios from issue #59: snapshot, watch, reconnect, set with
checksum, and set with abort.

New files:
- docker-compose.yml — postgres + redis + migrate (decree-tools) +
  decree service; DECREE_SRC / TOOLS_IMAGE / SERVICE_IMAGE are
  configurable for CI vs. local dev.
- vitest.workspace.ts — workspace combining the existing unit project
  with the new integration project.
- integration/vitest.config.ts — Vitest 'integration' project, active
  only when DECREE_INTEGRATION=1.
- integration/setup.ts — global setup: waits for the server, creates a
  schema + tenant via generated stubs, seeds initial values, and tears
  everything down in the returned cleanup function.
- integration/suite.test.ts — five describe blocks (snapshot, watch,
  reconnect, set-with-checksum, set-with-abort).

Updated files:
- vitest.config.ts — explicit include: ["test/**/*.test.ts"] so the
  unit project does not pick up integration/ by default.
- package.json — adds test:integration script; extends lint/format/
  pre-commit to cover integration/.
- ci.yml — adds an integration job that checks out opendecree/decree,
  builds the tools and server images via docker/build-push-action with
  GHCR layer cache, starts the compose stack, runs the suite, and tears
  down unconditionally. Adds integration to the alls-green check gate.

Closes #59

Co-Authored-By: Claude <noreply@anthropic.com>
@zeevdr zeevdr added this to the Beta Readiness milestone May 25, 2026
@zeevdr zeevdr added size: M Moderate — a day or two, clear scope priority: P1 Current milestone work labels May 25, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

zeevdr and others added 4 commits May 25, 2026 07:49
Docker Compose only recognises a volume host path as a bind mount when it
starts with ./, ../, or /. A bare directory name like _decree is treated
as a named-volume reference and rejected with "refers to undefined volume".

Setting DECREE_SRC=./_decree in the integration job and documenting the
requirement in docker-compose.yml fixes the startup failure.

Co-Authored-By: Claude <noreply@anthropic.com>
Vitest throws "No projects matched the filter" when --project is used
with a named project whose include array evaluates to [] (empty), which
can happen if the workspace loads the config without the env var set,
or when include paths resolve to non-existent files.

Switch to vitest run --config integration/vitest.config.ts so Vitest
loads the integration config directly without the workspace filter step.
Change defineProject → defineConfig (standalone config, not a workspace
project) and correct the include/globalSetup paths from
./integration/suite.test.ts to ./suite.test.ts (relative to the config
file's own directory). Trim vitest.workspace.ts to unit tests only.

Co-Authored-By: Claude <noreply@anthropic.com>
With defineConfig + --config integration/vitest.config.ts, Vite's root
is the CWD (decree-typescript/) not the config file's directory, so
include/globalSetup paths must be prefixed with ./integration/.

Co-Authored-By: Claude <noreply@anthropic.com>
Run integration tests via `cd integration && vitest run` so Vitest
discovers vitest.config.ts without being overridden by the root
workspace file, which only includes the unit project.

Fix schema field creation by supplying the required `examples: {}` and
`tags: []` fields on each SchemaField (non-optional map and repeated
fields in the generated proto types).

Set the integer config field using a raw ConfigServiceClient call with
`integerValue` instead of `setNumber`, because the server validates
that INT fields receive an integerValue-typed proto value, not a
stringValue or numberValue.

Make the post-abort cleanup in the abort test best-effort: a cancelled
gRPC call can leave a stale version counter on the server that causes a
duplicate key constraint on the next set, which is a server-side issue
and should not fail the test assertion.

Co-Authored-By: Claude <noreply@anthropic.com>
@zeevdr zeevdr merged commit 78cca2e into main May 25, 2026
13 checks passed
@zeevdr zeevdr deleted the feat/issue-59-integration-tests branch May 25, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: P1 Current milestone work size: M Moderate — a day or two, clear scope

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests: integration suite against a real decree server

1 participant