Skip to content

Testing

No tests exist.

  • package.json has only start / dev scripts (both nodemon server.js)
  • No test framework in dependencies
  • No __tests__/, test/, spec/, e2e/ directories

What "verification" looks like today

  • Running the bots and watching their console.log
  • Running the FE (Someli-Designer) and exercising features manually
  • Checking Slack notifications for content-missing alerts (teamsnotification.js)

Where to start, if testing is to be added

For a backend with 269 routes + 57 jobs + 6 bots, the test-investment ROI is highest at:

1. Job idempotency tests

Why: many jobs are scheduled every 1-5 minutes. If a tick fails mid-way, the next tick should not duplicate work. Tests:

  • Per job: seed DB → run handler → verify row state → run handler again → verify no double-processing
  • Per job: simulate a crash mid-handler → verify isOnProcess resets correctly

2. Content-pipeline integration tests

Why: the value of designer-api is end-to-end content generation. Tests:

  • Insert a tTopics row → run content_generation_bot.js's getsubjectcopies() → verify tLibrary has new entries
  • Insert a tAutoDesignPost row → run job_post_approved.js → verify S3 upload happened, attachedLibrary set

3. Polotno render smoke tests

Why: Polotno + headless Chrome is the heaviest moving part. Tests:

  • Given a known-good Polotno JSON → render → assert PNG > N bytes
  • Given a broken JSON → render → assert graceful failure (not a hung process)

4. Route smoke tests

Why: 269 endpoints; without tests, refactor confidence is zero. Tests:

  • Per endpoint: assert 200 / 401 / 404 based on token presence
  • Sample 20-30 high-traffic endpoints for deeper assertions

Tooling

  • vitest for unit/integration (modern, fast)
  • supertest against the Express app
  • A seeded MySQL via docker-compose for integration tests
  • Optionally @testcontainers/mysql for isolated DB per test

Effort

For a backend this size:

  • 5-7 engineer-days for an initial harness + 20 high-value tests (auth, idempotency, content pipeline)
  • 2-3 weeks for ~80-100 tests covering the bots and most routes

CI integration

When tests exist:

  1. yarn install
  2. yarn lint (no lint currently — add ESLint)
  3. yarn test (against a Docker-MySQL test fixture)
  4. Optional: a smoke test that spins up Polotno and verifies a render

Cross-component status

Same as the rest of the platform — no automated tests at audit time. If the platform invests in test infrastructure, designer-api would benefit disproportionately from job-idempotency tests because of the 57-job sprawl.