Testing and evals
The backend and web app unit suites, the agent evaluation scenarios that run against a real model, and the campaign check.
eDGR is checked in three ways. Unit suites in both apps run in seconds with every outside dependency faked. Agent evaluations run the real reply agent against a real model and a real database, by hand, when the agent changes. A campaign check validates every stored campaign. There is no end-to-end or integration suite: no test starts the API over HTTP against a database, and no test drives a browser.
- 1 While you work Unit tests for the area you change, in seconds
- 2 Before a commit Both unit suites, lint and the build
- 3 On push CI runs the backend suite with coverage
- 4 Agent changes Eval scenarios against a real model, by hand
- 5 Campaign rules change The campaign check over every stored campaign
| Suite | Runner | Command | Last run |
|---|---|---|---|
| Backend | Jest | cd backend && bun run test | 1253 tests in 142 suites, under 30 seconds |
| Web app | Vitest, in Node | cd frontend && bun run test | 144 tests in 19 files, about 1 second |
The numbers are from a run on 2026-11-12, and the times vary with the machine they run on.
Backend tests
The backend tests need no database, Redis, Restate or network. Every outside dependency is a mock or a fake. They do need the generated database client, so run bun x prisma generate once on a fresh checkout.
cd backend
bun run test # everything
bun run test agent # test files whose path matches
bun run test -t "<test name>" # tests whose name matches
bun run test:cov # with coverageA test file sits next to the code it tests. The shared helpers give a test:
- a test module with the database client already replaced by a deep mock,
- builders for entities such as a person,
- a fake campaign workflow context wired to mocked services, for testing campaign steps,
- a fake model that replays queued responses, so a whole agent turn runs without calling a model.
The run logs errors from the tests that check failure paths: agent turns that ended without a reply or a hand-off, a stalled model stream, a failed knowledge ingest, a failed CSV import and a failing inbound message. They are expected, and every one of those tests passes.
CI runs the backend suite only, on pushes and pull requests to main that change the backend. It does not lint, type-check, build, or run the web app tests.
Web app tests
The web app tests cover pure logic: reading the sign-in token, the stale-tab reload, query helpers, the inbox timeline and snooze rules, how campaign compile errors map onto the builder, and the report helpers. No test renders a component. The type check in the build is the only check on component code.
cd frontend
bun run test # once
bun run test:watch # watch modeThe type check skips test files, so a type error in a test shows up only when the test runs.
Agent evaluations
Four scenarios drive the real reply agent along the same path an inbound message takes, then read the outcome back from the database. They share one harness and one set of fixtures.
The harness starts the backend's accounts, CRM, content and agent areas without listening on a port. It leaves out the campaign engine, which would register with Restate under a running backend, and analytics, which would start the timed jobs.
| Scenario | What it measures |
|---|---|
| KB1, languages | The same five messages in each of six languages (Vietnamese, English, Thai, Indonesian, Malay, Chinese), each run with the product’s knowledge and again with it removed as a control |
| KB2, intent and scoring | 20 labelled conversations: intent classification, BANT fit scoring and lead memory |
| KB3, adversarial | 24 cases of prompt injection, long context and CRM actions, with the CRM compared before and after each turn and whether the expected tool was called |
| KB4, several products | Four product knowledge bases: whether the agent searched the right product and gave the expected facts, plus a safety pass |
Each scenario writes its results as JSON lines into an evaluation folder that is not in the repository, and neither are the scenario descriptions the scripts refer to.
Running a scenario
The scripts need bun and the source tree, so run them in the dev container or on the host, against a database whose workspace has a working chat model and embedding model:
docker compose exec backend-dev bun run scripts/eval-lang-scenario.ts # KB1
docker compose exec backend-dev bun run scripts/eval-intent-scoring-scenario.ts # KB2
docker compose exec backend-dev bun run scripts/eval-adversarial-scenario.ts # KB3
docker compose exec backend-dev bun run scripts/eval-multiproduct-scenario.ts # KB4On the host, run the same scripts from the backend folder with backend/.env loaded into the shell. Test people get plus-addressed emails built from a base address. The default base is a team member’s address, so give one you own:
docker compose exec -e EVAL_EMAIL_BASE=you@example.com backend-dev bun run scripts/eval-lang-scenario.tsEvery turn is a real model call billed to the workspace’s provider key. KB4 also needs the three other products (manufacturing, BFSI and cloud) with their documents created in the app first, and warns about any it cannot find by name.
Campaign check
The campaign check loads every campaign in the database, in every workspace, and runs it through the same validation whose errors the campaign builder shows. Its database address is fixed to the local dev database, so run it from the host against the dev stack:
cd backend && bun run scripts/__verify-campaigns.ts