Skip to content

Expand unit test coverage for metric-engine and rule-engine#49

Merged
aymenfurter merged 2 commits into
mainfrom
copilot/testing-add-unit-tests-metric-engine-rule-engine
May 25, 2026
Merged

Expand unit test coverage for metric-engine and rule-engine#49
aymenfurter merged 2 commits into
mainfrom
copilot/testing-add-unit-tests-metric-engine-rule-engine

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 24, 2026

The core evaluation engines (metric-engine.ts, rule-engine.ts) were only exercised indirectly through antipatterns-e2e.test.ts, leaving regressions invisible to the test suite.

Changes

  • metric-engine.test.ts (+20 tests)

    • evaluateMetric edge cases: empty datasets, no matches, missing/null fields, default example fallback, avg(field) aggregation, 3-row example cap.
    • Threshold-override coverage for evaluateTrigger, calibrate, and runTestCases.
    • calibrate edge cases: empty rows, non-numeric filter field (null distribution), sessions scope derivation.
    • serializeCalibration / stripCalibration round-trip, including the no-distribution and no-op branches.
    • parseRuleExtensions with inline-array requires, malformed JSON test cases (skipped silently), and bodies without frontmatter.
    • parseMetric defaults (scope, aggregation, version) and missing-id rejection.
  • rule-engine.test.ts (+1 test)

    • evaluateRule returns pct: '0%' when count > 0 but total === 0 (avoids divide-by-zero in templates).

Coverage on metric-engine.ts moves from ~86% lines to near-complete; rule-engine.ts remains at ~98% with the divide-by-zero branch now pinned.

Copilot AI changed the title [WIP] Add unit tests for metric-engine.ts and rule-engine.ts Expand unit test coverage for metric-engine and rule-engine May 24, 2026
Copilot AI requested a review from aymenfurter May 24, 2026 12:27
@github-actions
Copy link
Copy Markdown

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@aymenfurter aymenfurter requested a review from san360 May 24, 2026 12:46
@aymenfurter aymenfurter added enhancement New feature or request testing Test coverage or test infrastructure and removed enhancement New feature or request labels May 24, 2026
@aymenfurter aymenfurter marked this pull request as ready for review May 25, 2026 12:36
@aymenfurter aymenfurter merged commit 271d6e0 into main May 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Test coverage or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

testing: add unit tests for metric-engine.ts and rule-engine.ts

3 participants