Skip to content

test: add policy-service coverage and related service tests#6123

Open
mariana-andruk-qa wants to merge 2 commits into
hashgraph:developfrom
mariana-andruk-qa:test/6102-policy-service-coverage
Open

test: add policy-service coverage and related service tests#6123
mariana-andruk-qa wants to merge 2 commits into
hashgraph:developfrom
mariana-andruk-qa:test/6102-policy-service-coverage

Conversation

@mariana-andruk-qa
Copy link
Copy Markdown

@mariana-andruk-qa mariana-andruk-qa commented May 26, 2026

Summary

Adds unit and contract test coverage for policy-service, plus a couple of related tests in guardian-service and api-gateway.

  • policy-service: unit tests for block validators, blocks, helpers, decorators, errors, and policy-engine utilities, plus V8/c8 coverage tooling (run-coverage.mjs, coverage-report.mjs, COVERAGE_NOTES.md) and a block-about contract test.
  • guardian-service: new build-documentation-urls helper with accompanying unit tests.
  • api-gateway: dmrv service test (alias resolution) using esmock.

Test results

Run against freshly built dist/ output:

Service Passing Failing
api-gateway 12 0
guardian-service 16 0
policy-service 1254 0

The policy-service tests that were previously failing are now fixed:

  • ORM-dependent validators no longer need a live database. schema-validator (and its property test) mock the ESM module via esmock.strict, and orchestrator-validators neutralises DatabaseServer reads on the real singleton instead of the non-working module mock. A .mocharc.json registers the esmock loader before mocha starts so the mock survives mocha's re-spawn.
  • PolicyValidator argument mismatch: dropped the stray leading id argument so policy/isDryRun line up with the constructor signature.
  • CommonBlock-delegating validators with mandatory options (TransformationUIAddon, HttpRequestUIAddon) now use per-block fixtures that supply the required fields.
  • PolicyUtils expectations match the implementation: getDocumentType returns the DocumentType enum values (VerifiablePresentation/VerifiableCredential/DID) and DocumentSignature.NEW is numeric 0.

Notes

  • yarn.lock changes were intentionally excluded (unrelated dependency churn).

Add unit and contract tests for policy-service block validators, blocks, helpers, decorators, errors, and policy-engine utilities, plus V8/c8 coverage tooling. Also add the guardian-service build-documentation-urls helper with its tests and an api-gateway dmrv service test.
@mariana-andruk-qa mariana-andruk-qa requested review from a team as code owners May 26, 2026 15:35
@dariy-rised dariy-rised self-requested a review May 28, 2026 20:00
@dariy-rised
Copy link
Copy Markdown
Contributor

  1. orchestrator-validators.test.mjs in @unit PolicyValidator
    Six tests call the constructor with a string 't-1' as the first argument.
    But the real constructor signature is:
    constructor(policy: Policy, isDruRun: boolean = false, ...) → 2 tests fail

Fix: remove 't-1'

  1. orchestrator-validators.test.mjs and schema-validator.test.mjs: Module._load doesn't intercept ESM imports → ORM hits real DB → 3 tests fail

Fix: replace the Module._load block with esmock

  1. policy-utils.test.mjs: getDocumentType returns enum strings, not 'vp-document', 'vc-document', 'did-document'.
    → 3 tests fail

Fix: update all three expected values to match the actual enum 'VerifiablePresentation', 'VerifiableCredential', 'DID'

  1. policy-utils.test.mjs: DocumentSignature.NEW is numeric 0, not string 'NEW' → 2 tests fail

real enum is:

 export enum DocumentSignature {                                                                                                                                                                                
      NEW,      // = 0                                                                                                                                                                                         
      VERIFIED, // = 1
      INVALID,  // = 2
  }

Fix: replace 'NEW' to 0

  1. common-only-validators-batch3.test.mjs: two validators require mandatory fields that the shared refOK fixture omits → 2 tests fail

TransformationUIAddon: requires options.expression
HttpRequestUIAddon: requires options.url and options.method

Fix: use per-block fixtures for the validators that have mandatory fields

  1. also I have 13th test fail in http-request-block.test.mjs: IPv6 bracket handling bug
    This is the code bug and we will fix it soon.

- orchestrator-validators: drop the stray PolicyValidator id arg and
  neutralise DatabaseServer reads instead of the non-working module mock
- schema-validator(+property): mock the ESM module via esmock.strict so
  the validators no longer require an initialized ORM
- policy-utils: align expectations with the real DocumentType enum and
  numeric DocumentSignature.NEW
- common-only-validators-batch3: give validators with mandatory options
  per-block fixtures
- add .mocharc.json to register the esmock loader before mocha starts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants