Skip to content

[Test Improver] test(shared): add unit tests for DependencyGraph, normalizeCriteria, FileSystemCriteriaProviderΒ #369

Open

Description

Original author: @github-actions[bot]

πŸ€– Test Improver β€” automated AI assistant for test improvements.

Goal and Rationale

Three core modules in packages/shared had no tests despite containing meaningful logic:

  • DependencyGraph β€” cycle detection, topological sort, BFS ancestor/descendant traversal, and root-failure filtering. This is the core evaluation ordering engine used by both the criteria system and the prompt-features system. Bugs here silently corrupt run evaluation order.
  • normalizeCriteria β€” v1/v2 format dispatch and whitespace trimming. Part of the criteria loading pipeline; easy to mis-handle edge cases.
  • FileSystemCriteriaProvider β€” YAML file loading, field validation, depends_on/dependsOn normalisation, and transitive ancestor resolution via BFS.

Approach

File Tests Strategy
graph/dependency-graph.test.ts 32 Pure unit; construction, cycle detection, topological sort, ancestor/descendant BFS, getRootFailures (both result formats), deprecated aliases
criteria/normalize-criteria.test.ts 10 Pure unit; v1 string array, v2 passthrough, trimming, sequential IDs, dependsOn init
criteria/criteria-provider-fs.test.ts 18 Creates/destroys temp dirs per test; YAML loading, both extensions, snake/camelCase dependsOn, duplicate IDs, missing fields, resolveWithAncestors with diamond deduplication

Coverage Impact

Metric Before After
Test files 59 62
Tests 678 732
New tests β€” +54

Trade-offs

  • FileSystemCriteriaProvider tests use mkdtempSync + afterEach cleanup β€” reliable and fast, exercises real I/O with temp dirs for higher fidelity than mocking fs
  • No mocking of external services; pure unit tests where possible

Reproducibility

npm install -g pnpm --prefix $HOME
export PATH="$HOME/bin:$PATH"
pnpm install --frozen-lockfile
pnpm --filter shared --filter github-auth build
pnpm test

Test Status

βœ… All 62 test files pass, 732 tests pass.

(2 pre-existing process.exit warnings in apps/version-checkers/ are unrelated to these changes.)

Generated by Daily Test Improver Β· β—·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/daily-test-improver.md@ee86d0ffcb1705d4ee4146e92125227bf9136aae

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • 169.254.169.254

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "169.254.169.254"

See Network Configuration for more information.


Note

This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch test-assist/shared-unit-tests-2-04fb050e56c59418.

Click here to create the pull request

To fix the permissions issue, go to Settings β†’ Actions β†’ General and enable Allow GitHub Actions to create and approve pull requests.

Show patch preview (491 of 491 lines)
From 0eb1786fb6b7ea676c4bb91832607ecb43191fd2 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Mon, 23 Mar 2026 06:51:19 +0000
Subject: [PATCH] test(shared): add unit tests for DependencyGraph,
 normalizeCriteria, FileSystemCriteriaProvider

- DependencyGraph (32 tests): construction, cycle detection (direct/indirect),
  topological sort, ancestor/descendant BFS, getRootFailures with both
  criterionId/passed and featureId/detected formats, deprecated aliases
- normalizeCriteria (10 tests): v1 string->CriteriaConfig conversion, v2
  passthrough, whitespace trimming, sequential id generation, dependsOn init
- FileSystemCriteriaProvider (18 tests): YAML loading (.yaml/.yml), depends_on/
  dependsOn normalisation, duplicate id detection, missing field validation,
  resolveWithAncestors with transitive parents and diamond deduplication

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 .../src/criteria/criteria-provider-fs.test.ts | 156 ++++++++++++
 .../src/criteria/normalize-criteria.test.ts   |  53 ++++
 .../shared/src/graph/dependency-graph.test.ts | 235 ++++++++++++++++++
 3 files changed, 444 insertions(+)
 create mode 100644 packages/shared/src/criteria/criteria-provider-fs.test.ts
 create mode 100644 packages/shared/src/criteria/normalize-criteria.test.ts
 create mode 100644 packages/shared/src/graph/dependency-graph.test.ts

diff --git a/packages/shared/src/criteria/criteria-provider-fs.test.ts b/packages/shared/src/criteria/criteria-provider-fs.test.ts
new file mode 100644
index 0000000..663e4b6
--- /dev/null
+++ b/packages/shared/src/criteria/criteria-provider-fs.test.ts
@@ -0,0 +1,156 @@
+import { describe, it, expect, afterEach } from 'vitest';
+import { mkdtempSync, writeFileSync, mkdirSync, rmSync } from 'fs';
+import { join } from 'path';
+import { tmpdir } from 'os';
+import { FileSystemCriteriaProvider } from './criteria-provider-fs.js';
+
+let tempDir: string | undefined;
... (truncated)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentic-workflowsgh aw driven workflows that automate repository tasks. DOT NOT RENAME.topic: testingTest coverage, test infrastructure, and validation quality.type: automationChanges that automate recurring tasks or workflows.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions