Testing¶
No tests exist.
package.jsonhas onlystart/devscripts (bothnodemon 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
isOnProcessresets correctly
2. Content-pipeline integration tests¶
Why: the value of designer-api is end-to-end content generation. Tests:
- Insert a
tTopicsrow → runcontent_generation_bot.js'sgetsubjectcopies()→ verifytLibraryhas new entries - Insert a
tAutoDesignPostrow → runjob_post_approved.js→ verify S3 upload happened,attachedLibraryset
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¶
vitestfor unit/integration (modern, fast)supertestagainst the Express app- A seeded MySQL via
docker-composefor integration tests - Optionally
@testcontainers/mysqlfor 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:
yarn installyarn lint(no lint currently — add ESLint)yarn test(against a Docker-MySQL test fixture)- 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.