Skip to content

[quality] npm run test:unit never runs in CI — unit tests have no CI signal #390

Open

Description

@hivecommons-hive

Finding

package.json defines a test:unit script:

"test:unit": "node --experimental-strip-types --test 'lib/**/*.test.mts'"

and a combined test script (check + test:unit), but no workflow under
.github/workflows/ ever invokes npm run test:unit or npm test. CI
currently only runs format-check.yml, link-check.yml, and
spell-check.yml.

This means lib/remarkRewriteLinks/index.test.mts (the repo's existing unit
suite) — and any new suites such as the ones added for
lib/getBuildContext.ts, lib/getCurrentBranch.ts, and
lib/getGitHubRepoUrl.ts in #389 — can regress with zero CI signal. A PR
that breaks these tests still shows all green checks.

Recommendation

Add a new workflow file .github/workflows/unit-test.yml with this exact
content (mirrors the existing format-check.yml pattern/style):

name: Unit tests

on:
  pull_request:

permissions:
  contents: read

jobs:
  unit-test:
    name: UNIT tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: ./.github/actions/npm-ci-via-cached-nvmrc
      - run: npm run test:unit

Why this needs a human (or an ISSUES_PRS_MERGE agent)

This repository's quality-agent lane runs at the contributor token tier,
which does not carry the workflows permission. A push whose diff touches
.github/workflows/** is rejected by GitHub server-side regardless of what
the file contains, so this agent cannot open a PR for this change — the
replacement text above is provided so applying it is mechanical for a human
or a merge-tier agent.

Priority

  • Impact: high — unit test regressions currently ship with all-green CI
  • Effort: low — single new workflow file, copy-paste of an existing pattern

Filed by quality agent (hold-gated mode)


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-boq9 | SHA: unknown

— hive: agent=quality backend=copilot model=claude-opus-4-6

Activity

  1. added
    testingCreated by Hive for agent-filed issue provenance
    agent/qualityCreated by Hive for agent-filed issue provenance
    stage/010-actionableTriaged; eligible for the hive to pick up
    on Nov 11, 2026
  2. hivecommons-hive commented on Nov 12, 2026

    @hivecommons-hive
    ContributorAuthor

    Folded finding. This was filed as a separate issue, but 2 open agent-filed issues (plus 1 closed as completed in the last 14 days) already cite format-check.yml, so it was folded into the oldest of them instead of opening another. Treat this issue as the tracker for that component: prefer one structural fix that covers every folded variant over a PR per variant.

    [quality] getBuildContext/getCurrentBranch branch coverage is non-deterministic (depends on ambient git state)

    Finding

    lib/getBuildContext.test.mts and lib/getCurrentBranch.test.mts (added in #389)
    have one test each that exercises the deploy-preview / git-plumbing fallback
    paths by calling getCurrentBranch() / getGitHubRepoUrl() with no env vars
    set, relying on the ambient git checkout's real state to sometimes produce a
    falsy result. Locally that is non-deterministic:

    • lib/getBuildContext.ts lines 17-18 — the isDeployPreview ? getCurrentBranch() || 'main' : 'main' and ... || repo fallback branches only execute when getCurrentBranch()/getGitHubRepoUrl() return falsy, which the existing test doesn't force.
    • lib/getCurrentBranch.ts line 18 — return branch || undefined; only exercises the || undefined arm in detached-HEAD state (git branch --show-current exits 0 with empty stdout), which the existing test doesn't force either.
    • lib/getCurrentBranch.ts lines 20-21 (the catch around execSync) had no test at all.

    Unit evidence: npm run test:coverage (c8 + node --test, local run against
    HEAD cbee404) showed lib at 97.61% branch / 87.5% function... branch
    coverage before this fix, with getBuildContext.ts at 80% branch and
    getCurrentBranch.ts at 80% branch, 90.9% line. End-to-end evidence: this
    repo has no e2e/integration suite (CI only runs format-check.yml,
    link-check.yml, spell-check.yml), so these branches were covered by
    neither unit nor end-to-end tests — Priority 1.

    Recommendation

    Make the existing tests deterministic instead of relying on ambient state:

    • Run the deploy-preview fallback test from a freshly created temp directory outside any git repository (forces getCurrentBranch()/getGitHubRepoUrl() to undefined).
    • Add a detached-HEAD temp-repo test for getCurrentBranch()'s empty-string case.
    • Add a non-git-tmpdir test for the execSync catch block.

    A PR with this fix is attached. After it, lib/ is 100% statements/branches/functions locally.

    Priority

    • Impact: medium — flaky coverage numbers mask whether these fallback paths (used in real Netlify deploy previews) actually work
    • Effort: low — test-only change to two existing files

    Filed by quality agent (hold-gated mode)


    🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-boq9 | SHA: unknown

    — hive: agent=quality backend=copilot model=claude-opus-4-6 copilot=1.0.88


    Folded finding. This was filed as a separate issue, but 2 open agent-filed issues (plus 1 closed as completed in the last 14 days) already cite format-check.yml, so it was folded into the oldest of them instead of opening another. Treat this issue as the tracker for that component: prefer one structural fix that covers every folded variant over a PR per variant.

    [quality] test:coverage has no --check-coverage regression gate

    Finding

    package.json's test:coverage script (c8 --reporter=text --reporter=lcov npm run test:unit, added in #397) reports coverage text/lcov output but never fails on regression: c8's defaults are 0% for branches/functions/statements and 90% for lines, so a coverage drop is invisible unless someone reads the printed table.

    #396 (closed, merged via #397) explicitly deferred adding --check-coverage thresholds until the in-flight coverage PRs merged, to avoid landing the gate red. With #389/#392/#394/#401 merged, lib/ is now 100% statements/branches/functions/lines, leaving only scripts/add-frontmatter.mjs at 97%/90.9% branch (tracked by #402, currently open).

    Unit evidence: npm run test:coverage on HEAD (2484f9a) reports 99.09% statements, 97.77% branches, 100% functions, 99.09% lines overall. End-to-end evidence: this repo has no e2e/integration suite (CI only runs format-check.yml, link-check.yml, spell-check.yml), so this is local/test-infrastructure only, not a coverage-gap finding.

    Recommendation

    Add --check-coverage with thresholds set at (or just below) the currently achieved levels, so npm run test:coverage exits non-zero the moment coverage regresses below what's already been earned — without requiring #390's CI wiring first, and without forcing 100% today while #402 is still open:

    "test:coverage": "c8 --reporter=text --reporter=lcov --check-coverage --lines 99 --statements 99 --branches 97 --functions 100 npm run test:unit"

    Once #402 merges this can be tightened to --100 (c8's shortcut for 100% on all four metrics) in a follow-up.

    Priority


    Filed by quality agent (hold-gated mode)


    🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-boq9 | SHA: 2484f9a

    — hive: agent=quality backend=copilot model=claude-opus-4-6 copilot=1.0.88


    Folded finding. This was filed as a separate issue, but 2 open agent-filed issues (plus 1 closed as completed in the last 14 days) already cite format-check.yml, so it was folded into the oldest of them instead of opening another. Treat this issue as the tracker for that component: prefer one structural fix that covers every folded variant over a PR per variant.

    [quality] typecheck script is broken (tsc TS5102 on removed baseUrl) and never run in check/test/CI

    Finding

    package.json defines a typecheck script:

    "typecheck": "tsc"
    

    Running it currently fails immediately, before checking a single file:

    tsconfig.json(4,3): error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration.
      Use '"paths": {"*": ["./node_modules/@docusaurus/tsconfig/*"]}' instead.
    

    The repo's own tsconfig.json doesn't set baseUrl itself — it extends
    @docusaurus/tsconfig (pinned via @docusaurus/core/@docusaurus/tsconfig
    3.10.2), and that base config still sets "baseUrl": ".". This repo's
    devDependencies.typescript is ~7.0.2, and TypeScript 7 removed baseUrl
    entirely (it's not just deprecated), so the merged config fails to parse.

    Independently of that breakage, typecheck is not wired into anything:

    • npm run check (the combined check script) doesn't call it.
    • npm test (check + test:unit) doesn't call it either.
    • No workflow under .github/workflows/ calls npm run typecheck,
      npm run check, or npm test directly — format-check.yml,
      link-check.yml, and spell-check.yml each call their own narrower
      check:* script.

    So type errors in lib/*.ts and docusaurus.config.ts currently have zero
    signal anywhere — not locally via npm test, and not in CI — independent of
    whether tsc itself is runnable.

    tsconfig.json carries this comment, which suggests the gap may be at least
    partly intentional:

    // This file is not used in compilation. It is here just for a nice editor experience.
    

    Filing this as an issue rather than a PR because a real fix likely needs a
    dependency-version decision (bump typescript's range to one compatible with
    @docusaurus/tsconfig's baseUrl usage, or bump @docusaurus/core/
    @docusaurus/tsconfig to a release that drops baseUrl) — that's a
    production-dependency change, outside the quality agent's testing-only PR
    scope.

    Recommendation

    1. Confirm whether typecheck is meant to be a real, runnable gate or just
      editor-experience config per the comment above. If the former:
    2. Resolve the typescript/@docusaurus/tsconfig version mismatch so
      tsc --noEmit runs cleanly (e.g. pin typescript to a ~7.x range that
      still supports baseUrl, or wait for/upgrade to a Docusaurus tsconfig
      release without baseUrl).
    3. Wire typecheck into npm run check (or npm test) so type errors have
      local signal.
    4. Wiring it into CI additionally needs a .github/workflows/** change,
      which this lane's contributor-tier token cannot push (same ceiling as
      [quality] npm run test:unit never runs in CI — unit tests have no CI signal #390) — leave that step for a human/merge-tier agent once 1–3 land.

    Priority

    • Impact: medium — .ts type errors in lib/ and docusaurus.config.ts currently ship with zero signal, local or CI
    • Effort: low for the diagnosis; the dependency-version fix itself is a maintainer call

    Filed by quality agent (hold-gated mode)


    🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-boq9 | SHA: unknown

    — hive: agent=quality backend=copilot model=claude-opus-4-6 copilot=1.0.88


    Folded finding. This was filed as a separate issue, but 2 open agent-filed issues (plus 1 closed as completed in the last 14 days) already cite format-check.yml, so it was folded into the oldest of them instead of opening another. Treat this issue as the tracker for that component: prefer one structural fix that covers every folded variant over a PR per variant.

    [quality] typecheck script fails with TS5102 and has no regression test

    Finding

    package.json defines a typecheck script (tsc), but running
    npm run typecheck currently fails immediately:

    tsconfig.json(4,3): error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration.
      Use '"paths": {"*": ["./node_modules/@docusaurus/tsconfig/*"]}' instead.
    

    tsconfig.json extends @docusaurus/tsconfig, which still sets
    baseUrl: ".". This repo's devDependency typescript is pinned to
    ~7.0.2, which removed the baseUrl option entirely, so the inherited
    value now hard-errors instead of merely warning. The typecheck script was
    never invoked by npm run check, npm test, or any
    .github/workflows/*.yml, so this has had zero local or CI signal.

    tsconfig.json's own comment ("This file is not used in compilation. It is
    here just for a nice editor experience.") only refers to the build pipeline
    (Docusaurus/webpack doesn't run tsc); it does not mean the typecheck npm
    script itself is meant to be broken, so this PR fixes the script rather than
    parking the question.

    Fix (already implemented, see linked PR)

    Override the inherited baseUrl to null in tsconfig.json's own
    compilerOptions, which strips it from the merged config TS evaluates:

    {
      "compilerOptions": {
        "baseUrl": null
      }
    }

    npm run typecheck then exits 0 cleanly. A new
    scripts/typecheck.test.mjs regression test shells out to
    npx tsc --noEmit and asserts a zero exit code, so this can't silently
    regress again; it's picked up automatically by the existing
    scripts/**/*.test.mjs glob in test:unit (no CI workflow change
    required).

    Remaining gap (needs a human / ISSUES_PRS_MERGE agent)

    Wiring npm run typecheck into actual CI (e.g. a new
    .github/workflows/type-check.yml, mirroring format-check.yml) still
    requires a .github/workflows/** change this lane's contributor-tier token
    cannot push. The regression test added here catches local/dev regressions,
    but CI still has zero signal that .ts files in lib/ and
    docusaurus.config.ts type-check.

    Priority

    • Impact: medium — type errors in lib/*.ts/docusaurus.config.ts have no
      signal anywhere right now; the broken script itself is also confusing for
      contributors who try to run it
    • Effort: low (fix) / requires workflow access (CI wiring)

    Filed by quality agent (hold-gated mode)


    🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-boq9 | SHA: unknown

    — hive: agent=quality backend=copilot model=claude-opus-4-6 copilot=1.0.88

  3. hivecommons-hive commented on Nov 12, 2026

    @hivecommons-hive
    ContributorAuthor

    PR #401 covers this issue: #401

    The PR body says this is partial/non-closing work (Refs/Part of or leave-open wording), so Hive will not add a closing keyword. GitHub will not show its issue-list PR icon without a closing keyword; the stage comment is the link.

  4. hivecommons-hive commented on Nov 12, 2026

    @hivecommons-hive
    ContributorAuthor

    A merged PR addressed only part of this issue (hive/partially-addressed); it stays open and actionable. Carrying the remainder back here so the next run targets what is still open.

    Not yet touched: .github/workflows/, format-check.yml, link-check.yml, spell-check.yml, lib/getBuildContext.ts, lib/getCurrentBranch.ts, lib/getGitHubRepoUrl.ts, .github/workflows/unit-test.yml

    Remainder from the PR body:

    (folded tracker for format-check.yml-related findings; this PR

    Remainder from the PR body:

    #390's task-list sweep lists package.json among the not-yet-touched items; this PR addresses only that local-tooling portion. The remainder of #390 (adding .github/workflows/unit-test.yml so the unit suite actually runs in CI) still needs a human or an ISSUES_PRS_MERGE agent, since this lane's contributor-tier token cannot push workflow-file changes.

    This comment is edited in place by the task-list sweep on every cycle; it is not duplicated.

  5. hivecommons-hive commented on Nov 12, 2026

    @hivecommons-hive
    ContributorAuthor

    Verified: PR #401 (merged) addressed only the getBuildContext/getCurrentBranch branch-coverage portion that had been folded into this tracker ("Part of #390"). The original finding — npm run test:unit never runs in CI, requiring a new .github/workflows/unit-test.yml — is unaddressed and still needs a human or ISSUES_PRS_MERGE agent, since this lane's contributor-tier token cannot push workflow-file changes. Exact replacement text remains in the issue body above, unchanged.


    🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-boq9 | SHA: unknown

    — hive: agent=quality backend=copilot model=claude-opus-4-6 copilot=1.0.88

  6. hivecommons-hive commented on Nov 13, 2026

    @hivecommons-hive
    ContributorAuthor

    PR #403 covers this issue: #403

    The PR body says this is partial/non-closing work (Refs/Part of or leave-open wording), so Hive will not add a closing keyword. GitHub will not show its issue-list PR icon without a closing keyword; the stage comment is the link.

  7. hivecommons-hive commented on Nov 13, 2026

    @hivecommons-hive
    ContributorAuthor

    PR #405 covers this issue: #405

    The PR body says this is partial/non-closing work (Refs/Part of or leave-open wording), so Hive will not add a closing keyword. GitHub will not show its issue-list PR icon without a closing keyword; the stage comment is the link.

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

    agent/qualityCreated by Hive for agent-filed issue provenancehive/partially-addressedA merged PR addressed only part of this issue; remainder still actionablehive/verified-openstage/040-covered-by-prAn open PR covers this issuetestingCreated by Hive for agent-filed issue provenancetriage/acceptedAssessment request accepted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions