Skip to content

test: configure automated server tests (CM-968)#4156

Open
skwowet wants to merge 6 commits into
mainfrom
improve/CM-968-foundation
Open

test: configure automated server tests (CM-968)#4156
skwowet wants to merge 6 commits into
mainfrom
improve/CM-968-foundation

Conversation

@skwowet
Copy link
Copy Markdown
Collaborator

@skwowet skwowet commented Jun 1, 2026

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-kit as the shared package for composable test building blocks. The first fixture is withQx, which gives tests an isolated Postgres database cloned from a migrated test_template and reset before each test.

Local and CI database preparation both build the same test_template shape, but use environment-specific entry points: local prep is handled by ./scripts/cli scaffold up-test against the Docker Compose test database, while CI uses .github/scripts/prepare-test-template-db.sh against the GitHub Actions Postgres service.

As part of this, QueryExecutor moved into @crowd/database, with temporary re-exports from @crowd/data-access-layer to keep the migration low-risk. The backend also drops unused legacy native packages (erlpack, zlib-sync) that were breaking installs on newer macOS toolchains.

- Add shared test infrastructure
- Configure backend and microservice test setup

Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
@skwowet skwowet self-assigned this Jun 1, 2026
Copilot AI review requested due to automatic review settings June 1, 2026 06:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 pnpm scripts for running server tests.
  • Introduce @crowd/test-kit with a Postgres worker DB clone/reset baseline (withQx) and shared DB template preparation scripts.
  • Move QueryExecutor into @crowd/database with transitional re-exports from @crowd/data-access-layer, and drop erlpack/zlib-sync from 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.

Comment thread vitest.config.ts Outdated
Comment thread .github/workflows/server-tests.yml Outdated
Comment thread services/libs/test-kit/src/postgres.ts Outdated
Comment thread scripts/prepare-test-template-db.sh Outdated
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 1, 2026 08:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 22 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread services/libs/test-kit/src/postgres.ts
Comment thread services/libs/test-kit/src/postgres.ts
Comment thread .github/workflows/server-tests.yml
skwowet added 2 commits June 1, 2026 14:26
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 1, 2026 09:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 22 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread scripts/cli Outdated
@skwowet skwowet requested review from mbani01, themarolt and ulemons June 1, 2026 09:18
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@ulemons ulemons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants