ci(test): run unit tests in CI + add backend test suite (P0 #9) - #8
Closed
sathyaprakash000 wants to merge 2 commits into
Closed
ci(test): run unit tests in CI + add backend test suite (P0 #9)#8sathyaprakash000 wants to merge 2 commits into
sathyaprakash000 wants to merge 2 commits into
Conversation
CI previously only ran `node --check` (backend) and `npm run build` (frontend) — the 3 existing frontend vitest suites never ran and the backend had no tests. - CI: backend job now runs `npm test`; frontend job runs `npm run test:unit` (the Playwright e2e stays out of the PR gate). - backend: add `npm test` -> `node --test test/` (Node's built-in runner, zero new dependencies — important for a source-available repo). - backend tests (20): crypto encrypt/decrypt round-trip + tamper/garbage handling + maskSecret; permissions isAdmin/hasPermission/effectivePages incl. grant/revoke; access.adminOnly allows admin / 403s non-admin; webhook X-Hub-Signature-256 verify (valid/forged/missing-secret/malformed/no-body). - Extract the webhook signature helpers (safeEqual, verifyMetaSignature) into util/webhookSignature.js so they're unit-testable without pulling in the BullMQ/Redis side-effects of the route module. webhook.js imports them; no behaviour change. Closes the last P0 from the readiness review (lane 26). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: KingArthur000 <sathyaprakashelango@gmail.com>
gitleaks flagged the hardcoded FORGECRM_ENCRYPTION_KEY test fixture (generic-api-key rule). Generate the key at runtime via crypto.randomBytes instead of a literal, and rename the EAA*-prefixed sample tokens so no scanner mistakes them for real Meta access tokens. No change to what's tested. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: KingArthur000 <sathyaprakashelango@gmail.com>
Contributor
Author
|
Superseded by a squashed, gitleaks-clean branch (the original branch's first commit contained a secret-shaped test literal that gitleaks flagged in history). Re-opened as a single clean commit. |
This was referenced May 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Closes the last P0 from the source-available readiness review (lane 26): CI never executed any tests. It ran only
node --check(backend) andnpm run build(frontend), so the 3 existing frontend vitest suites never ran and the backend had zero tests.Changes
npm test; frontend job runsnpm run test:unit(Playwright e2e intentionally stays out of the PR gate to keep it fast/hermetic).npm test→node --test test/— Node 20's built-in test runner, zero new dependencies (matters for a source-available repo / supply chain).crypto: encrypt/decrypt round-trip, random-IV uniqueness, tamper →null, garbage →null,maskSecret.permissions:isAdmin,hasPermission(admin vsbda_sales),effectivePagesgrant/revoke overrides.access:adminOnlylets admins through, 403sbda_sales/viewer.webhookSignature:verifyMetaSignaturevalid / forged / missing-secret(null) / malformed-header / no-body;safeEqual.safeEqual+verifyMetaSignatureintoutil/webhookSignature.jsso they're testable without importing the BullMQ/Redis side-effects of the webhook route.webhook.jsimports them — no behaviour change.Verification (local, mirrors CI)
npm ci --omit=dev && npm test→ 20/20 passnpm ci && npm run test:unit→ 51/51 pass (3 files)node --checkpasses onwebhook.js+webhookSignature.js.