Skip to content

PDX-502: add context-aware comparisonType enum validator#199

Merged
mrdailey99 merged 1 commit into
developfrom
feature/PDX-502-comparisontype-validator
Jun 2, 2026
Merged

PDX-502: add context-aware comparisonType enum validator#199
mrdailey99 merged 1 commit into
developfrom
feature/PDX-502-comparisontype-validator

Conversation

@mrdailey99
Copy link
Copy Markdown
Collaborator

Summary

  • Adds a context-aware comparisonType enum validator that fires at ERROR / load-blocking tier (not a best-practices quality warning), so the load-blocker is caught locally even offline / in local_fallback — previously only the Quality Hub back-end covered it.
  • New rule COMPARISON-TYPE-001 (ERROR), context-aware:
    • AssertValues (assertValuesComparison) validated against the 16-value subset.
    • UI Assert (uiAttributeAssertion) validated against the 6-value subset.
  • A value valid in one context but not the other (e.g. NotEqualTo on a UI Assert) now makes the test case is_valid: false, mirroring the runtime IllegalArgumentException: No enum constant …ComparisonType.<value>.
  • Single source of truth: new src/mcp/rules/comparisonTypeSets.ts holds both subsets (same canonical sets confirmed in PDX-501); the validator and tests import from it — no hand-duplicated lists.
  • Deep-walks the test case, so nested steps (a UiAssert under a UiWithScreen substeps clause, an AssertValues inside If/ForEach) are covered too. Variable / compound comparisonType references are skipped (cannot be checked statically).

Implementation note

The ticket suggested registering the check in the best-practices VALIDATOR_REGISTRY. BP-engine violations are quality-tier (critical/major/minor/info) and never flip is_valid, so they cannot express the load-blocking ERROR tier the ticket requires ("not a quality warning"). The check is therefore implemented on the schema-validator ERROR path in testCaseValidate.ts — exactly how the other load-blocking rules (SETVALUES-STRUCTURE-001, UI-TARGET-001) are handled. Behaviour matches the acceptance criteria.

Jira

https://provartesting.atlassian.net/browse/PDX-502

Test plan

  • yarn compile passes
  • yarn test:only passes (1320 passing; 5 new tests)
  • mcp-smoke.cjs passes (58/58)
  • yarn lint passes

Tests (per ticket acceptance criteria)

  • every valid AssertValues constant (incl. NotEqualTo) PASSES on an AssertValues step
  • every valid UI constant PASSES on a UI Assert step
  • NotEqualTo on a UI Assert step fires ERROR (and flips is_valid)
  • a constant in neither set (NotEqualToo) fires ERROR on both step types
  • variable-reference comparisonType does not fire (negative case)

Changes

  • src/mcp/rules/comparisonTypeSets.ts (new): canonical step-scoped subsets.
  • src/mcp/tools/testCaseValidate.ts: validateComparisonTypes deep-walk + COMPARISON-TYPE-001 ERROR issues.
  • docs/mcp.md: COMPARISON-TYPE-001 error-code entry.
  • scripts/mcp-smoke.cjs: smoke entry exercising the UI-Assert load-blocker path (expected count auto-increments).
  • test/unit/mcp/testCaseValidate.test.ts: 5 new tests.

RCA: A comparisonType used outside the subset its step type allows (e.g. NotEqualTo on a UI Assert) is load-blocking, but nothing caught it locally — offline / local_fallback sessions had no comparisonType coverage at all, so the load-blocker slipped through.
Fix: Add a context-aware COMPARISON-TYPE-001 ERROR-tier check in testCaseValidate that validates AssertValues against the 16-value subset and uiAttributeAssertion against the 6-value subset, sourced from a single shared comparisonTypeSets module; deep-walks nested steps. Adds unit tests, a smoke entry, and the docs/mcp.md error-code entry.
Copilot AI review requested due to automatic review settings June 2, 2026 18:27
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

Quality Orchestrator

🟢 LOW · 19 / 100 · 1 file(s) with no test coverage detected.


🧪 Tests to Run · Running 1 of 54 tests

  • unit/mcp/testCaseValidate.test.ts
▶ Run command
npx vitest run \
  unit/mcp/testCaseValidate.test.ts

⚠️ Missing Coverage · 1 file

These source files have no mapped test — consider adding coverage before merge.

  • src/mcp/rules/comparisonTypeSets.ts

💡 Run locally: qo stub src/mcp/rules/comparisonTypeSets.ts to generate a test scaffold.


⚡ quality-orchestrator  ·  /qo stub <file>  ·  qo analyze-local

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a load-blocking, context-aware validator for comparisonType values in test case XML so invalid enum constants are caught locally (including local_fallback), matching Provar’s runtime load failure behavior.

Changes:

  • Introduces COMPARISON-TYPE-001 (ERROR) and validates comparisonType against step-specific allowed subsets (AssertValues vs UI Assert).
  • Centralizes the allowed subsets in a single shared module (comparisonTypeSets.ts) and reuses them across validator + tests.
  • Updates docs and smoke coverage to keep the new load-blocking path exercised.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/mcp/rules/comparisonTypeSets.ts Adds canonical, shared step-scoped comparisonType subsets and set helpers.
src/mcp/tools/testCaseValidate.ts Implements deep-walk validation emitting COMPARISON-TYPE-001 at ERROR tier.
test/unit/mcp/testCaseValidate.test.ts Adds unit tests covering both allowed sets, cross-context invalid values, and variable-reference skip behavior.
scripts/mcp-smoke.cjs Adds a smoke invocation that exercises the new ERROR-tier validator path.
docs/mcp.md Documents COMPARISON-TYPE-001 behavior, scope, and allowed value sets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mrdailey99 mrdailey99 merged commit f8e7966 into develop Jun 2, 2026
5 checks passed
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.

2 participants