Testing¶
Running the test suite¶
npm test
Tests use Jest with ts-jest, live under tests/unit/, and never require network access, a real
Jira site or a real Kimai instance.
What is unit tested¶
- Duration/date conversion —
tests/unit/validation.test.ts - Idempotency and mapping merges —
tests/unit/idempotency.test.ts - Webhook signature verification —
tests/unit/verify-signature.test.ts - Loop prevention (
selfGenerated) and duplicate suppression —tests/unit/jira-to-kimai.test.ts - Issue key resolution from Kimai timesheet payloads —
tests/unit/resolve-issue-key.test.ts
Writing new tests¶
- Place unit tests under
tests/unit/, mirroring thesrc/module they cover. - Mock Forge-provided modules (
@forge/kvs,@forge/api) withjest.mock(...)rather than calling out to a real Forge runtime; seetests/unit/jira-to-kimai.test.tsfor an example that mockssrc/storage/mappings.ts. - Prefer testing the
sync/*andwebhooks/verify-signature.tsmodules directly, since they hold the synchronization policy described in Synchronization Model.
Manual end-to-end test¶
Once deployed to a demo site (see Development):
- Open a Jira issue and start the Kimai timer.
- Wait, then stop the timer.
- Verify the timesheet was created in Kimai and, once created, that a Jira worklog is created.
- Edit the Jira worklog and verify Kimai updates.
- Edit the Kimai timesheet and verify Jira updates.
- Replay the same Kimai webhook payload and verify no duplicate worklog is created.