Skip to content

test: expand backend test coverage for documents, risk-assessment, verification, and stellar modules - #1221

Merged
mftee merged 5 commits into
CodeGirlsInc:mainfrom
ayshadogo:test/expand-coverage
Aug 26, 2026
Merged

test: expand backend test coverage for documents, risk-assessment, verification, and stellar modules#1221
mftee merged 5 commits into
CodeGirlsInc:mainfrom
ayshadogo:test/expand-coverage

Conversation

@ayshadogo

Copy link
Copy Markdown
Contributor

Closes #978
Closes #979
Closes #980
Closes #981

ayshadogo and others added 5 commits August 25, 2026 15:23
Add tests for controller access control (owner vs admin vs attacker),
hash computation determinism, duplicate-content idempotency, status
transitions (verify rejects already-verified docs), validation
rejection (missing file, non-existent doc), and verification lookup.
Add service tests for findById, findByOwnerPaginated (pagination,
filtering, ordering), findAllWithCoordinates, and edge cases.
Fix pre-existing TS compilation errors in controller and pipe files.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
…ring

Test each risk flag (MISSING_PARCEL_ID, OVERLAPPING_CLAIM,
FORGED_SIGNATURE_INDICATOR, EXPIRED_DOCUMENT, INCOMPLETE_OWNERSHIP_CHAIN,
UNKNOWN_ISSUER) in isolation with triggering and non-triggering inputs.
Test score aggregation with weighted sum, range clamping [0, 100],
determinism (identical input → identical output), and boundary cases
(no flags, all flags, conflicting signals).

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
…oint

Test verification record creation, retrieval (by document and latest),
and status updates. Test the public verify-by-hash controller: hash
format validation, clear negatives for unanchored documents and missing
docs, confirmed records returning stellar proof, idempotency (read-only
endpoint never creates duplicates), and the failure path when no
verification record exists (reports "not verified", never "verified").

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
…ication

Mock stellar-sdk and Horizon HTTP layer — tests never hit a live network.
Test transaction construction (manageData operation with sanitized key),
account loading, signing, and submission. Test network failure, timeout,
and malformed-response handling — each produces InternalServerErrorException,
never an unhandled rejection. Verify failed anchoring never reports success.
Test testnet vs mainnet configuration selection, confirming testnet default.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
Cast sharp import to avoid TS2349 error with sharp's type definitions,
allowing the file-validation pipe spec to compile and run.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
@vercel

vercel Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

@ayshadogo is attempting to deploy a commit to the Mftee's projects Team on Vercel.

A member of the Team first needs to authorize it.

@mftee mftee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed. This is a valuable PR:

  • Fixes a genuine, longstanding parse error in file-validation.pipe.ts: the file on main currently has two implementations concatenated together (a naive size/mimetype check with an early return value; immediately followed by more import statements inside the function body, then a second class declaration) — this is what's been causing the 'Parsing error: '}' expected' CI failure I saw when I first looked at this repo. This PR removes the garbled naive remnant and leaves the correct, already-written content-sniffing implementation (magic-byte detection, PDF active-content rejection, image metadata stripping) intact.
  • Also fixes two real (req as any).requestId type-safety casts in documents.controller.ts and adds solid, non-trivial test coverage across documents/risk-assessment/stellar/verification (pagination edge cases, coordinate filtering, non-existent-id handling) — spot-checked several against the real service/controller implementations and they match actual behavior, not an imagined API.

One thing worth flagging that this PR's tests incidentally reveal (pre-existing, not introduced here, and out of scope for this diff): VerificationController.verifyByHash returns verified: true for any verification record that exists, regardless of whether its status is CONFIRMED or FAILED — a document whose Stellar anchor actually failed would still show as verified to the public verify endpoint. Worth a dedicated fix given this is a document-fraud-prevention product.

Approving.

@mftee
mftee merged commit 51a2092 into CodeGirlsInc:main Aug 26, 2026
1 of 6 checks passed
mftee added a commit to tolulopedd26/SMALDA that referenced this pull request Aug 26, 2026
Resolve conflicts in file-validation.pipe.ts/.spec.ts against
CodeGirlsInc#1221 (already merged) - both PRs independently fixed the same
garbled duplicate-implementation corruption in the .ts file, so kept
the equivalent already-merged version.

For the spec file, discovered that CodeGirlsInc#1221's merged version still
contained 4 leftover broken tests from the pre-fix naive
implementation: they called the pipe's now-async transform()
synchronously and asserted stale error-message text ('File size
exceeds', 'Invalid file type') that no longer matches the real
messages. Replaced with this PR's clean async test suite (which
covers the same cases correctly) plus kept two additional valid
tests from main's version (oversized JPEG, metadata stripping) that
this PR didn't have.
mftee added a commit that referenced this pull request Aug 26, 2026
…improvements

Merging per repo maintainer review. Resolved a conflict in file-validation.pipe.ts/.spec.ts against #1221; while resolving, discovered and removed 4 stale/broken tests that #1221's merge had left behind (synchronous assertions against the now-async pipe, stale error-message text) — replaced with this PR's correct async test suite plus two additional valid tests. Pre-existing CI failures otherwise predate this PR.
mftee added a commit to TomikeDS/SMALDA that referenced this pull request Aug 26, 2026
Resolve conflicts:
- file-validation.pipe.ts/.spec.ts: kept the already-merged, verified
  version from CodeGirlsInc#1221/CodeGirlsInc#1222 (same underlying corruption fix).
- brute-force.guard.spec.ts (add/add): CodeGirlsInc#1220's already-merged version
  tested the old in-memory Map-based guard synchronously; this PR
  legitimately rewrote the guard to be Redis-backed and async, making
  that test obsolete. Kept this PR's version, which mocks ioredis and
  matches the new async, ConfigService-injected implementation.
mftee added a commit that referenced this pull request Aug 26, 2026
…e-queue-tests

Merging per repo maintainer review. Resolved conflicts against #1221/#1222 (file-validation.pipe) and #1220 (brute-force.guard.spec.ts, now obsolete after this PR's legitimate Redis rewrite). Pre-existing CI failures otherwise predate this PR.
mftee added a commit to amberly-d/SMALDA that referenced this pull request Aug 26, 2026
…tion

Resolve add/add conflict in verification.service.spec.ts against
CodeGirlsInc#1221: both versions are compatible with the merged service (verified
create()'s duplicate-check only fires when payload.status ===
CONFIRMED, which neither of CodeGirlsInc#1221's existing tests trigger), so
combined into one file with all unique coverage including this PR's
new duplicate-confirmed-rejection test.
mftee added a commit that referenced this pull request Aug 26, 2026
…hip-risk-pagination

Merging per repo maintainer review. Fixes two real IDOR vulnerabilities on dispute filing/access. Resolved an add/add test-file conflict against #1221 (both compatible, combined). Pre-existing CI failures otherwise predate this PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants