test: configure automated server tests (CM-968)#4156
Conversation
- Add shared test infrastructure - Configure backend and microservice test setup Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces an initial server-side test foundation for CDP by adding a root Vitest setup, a shared @crowd/test-kit package with a Postgres-backed fixture, and CI automation to run server tests. It also relocates QueryExecutor into @crowd/database (with compatibility re-exports) and removes problematic native dependencies from the backend.
Changes:
- Add root-level Vitest configuration and root
pnpmscripts for running server tests. - Introduce
@crowd/test-kitwith a Postgres worker DB clone/reset baseline (withQx) and shared DB template preparation scripts. - Move
QueryExecutorinto@crowd/databasewith transitional re-exports from@crowd/data-access-layer, and droperlpack/zlib-syncfrom backend deps.
Reviewed changes
Copilot reviewed 20 out of 22 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | Adds root Vitest configuration and a dedicated “server” project. |
| package.json | Adds root test scripts and devDependencies for Vitest/Vite. |
| .github/workflows/server-tests.yml | Adds CI workflow to prepare Postgres template DB and run server tests. |
| .env.test | Adds local test env defaults for DB connection. |
| services/libs/test-kit/package.json | Introduces @crowd/test-kit package and its dependencies. |
| services/libs/test-kit/tsconfig.json | Adds TS config for the new test-kit library. |
| services/libs/test-kit/src/types.ts | Defines shared types for test Postgres connection info. |
| services/libs/test-kit/src/postgres.ts | Implements worker DB cloning, reset, and baseline seeding utilities. |
| services/libs/test-kit/src/fixtures.ts | Adds withQx fixture to provide a reset, seeded QueryExecutor per test. |
| services/libs/database/src/queryExecutor.ts | Moves/defines QueryExecutor + pg-promise implementation in database lib. |
| services/libs/database/src/index.ts | Re-exports queryExecutor from @crowd/database. |
| services/libs/database/src/connection.ts | Removes formatQuery from connection module (now in queryExecutor). |
| services/libs/data-access-layer/src/queryExecutor.ts | Re-exports pg-promise QueryExecutor from @crowd/database and keeps Sequelize-backed executor. |
| services/libs/data-access-layer/src/auditLogs/index.ts | Updates QueryExecutor construction to use pgpQx. |
| services/libs/data-access-layer/vitest.config.ts | Removes per-package Vitest config (now using root config). |
| services/libs/data-access-layer/package.json | Removes vitest scripts/dependency from this package. |
| services/apps/data_sink_worker/src/bin/fix-member-attributes.ts | Updates QueryExecutor construction to use pgpQx. |
| scripts/scaffold.test.yaml | Adds local test Postgres compose scaffold. |
| scripts/prepare-test-template-db.sh | Adds shared script to build and migrate the test_template DB. |
| scripts/cli | Adds down-test scaffold command and reuses shared template-prep script. |
| backend/package.json | Removes native deps (erlpack, zlib-sync) from backend. |
| pnpm-lock.yaml | Updates lockfile for Vitest/Vite additions and dependency removals. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
ulemons
left a comment
There was a problem hiding this comment.
I like how the withQx fixture interface is composed.
Moving QueryExecutor into @crowd/database makes sense: test-kit only pulls in what it needs without dragging all of data-access-layer along.
couple of things things worth considering:
- hookTimeout: 300_000 is very generous; consider lowering to 60–90s so CI fails fast if the clone hangs
- The Sequin volume in scaffold.test.yaml deserves an inline comment — it's not obvious why the test DB needs it
- The Flyway image is rebuilt on every CI run; some layer caching would help
None of these are blockers. Great Job
Summary
Adds the first server-side test foundation for CDP.
This sets up root-level Vitest, a GitHub Actions workflow for server tests, and
@crowd/test-kitas the shared package for composable test building blocks. The first fixture iswithQx, which gives tests an isolated Postgres database cloned from a migratedtest_templateand reset before each test.Local and CI database preparation both build the same
test_templateshape, but use environment-specific entry points: local prep is handled by./scripts/cli scaffold up-testagainst the Docker Compose test database, while CI uses.github/scripts/prepare-test-template-db.shagainst the GitHub Actions Postgres service.As part of this,
QueryExecutormoved into@crowd/database, with temporary re-exports from@crowd/data-access-layerto keep the migration low-risk. The backend also drops unused legacy native packages (erlpack,zlib-sync) that were breaking installs on newer macOS toolchains.