Skip to content

[quality] docusaurus.config.ts markdown preprocessor has zero test coverage #398

Open

Description

@hivecommons-hive

Finding

docusaurus.config.ts (lines ~44-50) defines an inline markdown.preprocessor function:

preprocessor: ({ fileContent, filePath }) =>
  path.resolve(filePath) === importedReadmePath
    ? fileContent.replace(
        /(\]\(|\]:\s*)(\/(?:docs|analyses)\/[^\s)#?]+)\.md(?=$|[\s)#?])/g,
        '$1$2/',
      )
    : fileContent,

This strips .md from site-absolute /docs/... and /analyses/... links when
Docusaurus imports the root README.md (consumed by src/pages/index.mdx). It
has no test coverage:

  • Unit: lib/**/*.test.mts (the test:unit script) has no test file for
    docusaurus.config.ts; this function isn't exercised anywhere.
  • End-to-end: this repo has no e2e/integration suite (no playwright/cypress
    directories; CI is limited to format-check.yml, link-check.yml,
    spell-check.yml).

Covered by neither unit nor end-to-end tests.

Why this can't be fixed with a drop-in unit test: the function is inlined in
docusaurus.config.ts, which imports ./lib/getBuildContext and
./lib/remarkRewriteLinks without file extensions. That resolves fine through
Docusaurus's own webpack bundler, but is unresolvable under this repo's own
node --experimental-strip-types --test runner (reproduced locally:
ERR_MODULE_NOT_FOUND importing docusaurus.config.ts directly). Testing the
regex in isolation requires first extracting it into its own lib/ module (with
extension-qualified imports, matching the convention #389 establishes) — a
production-code change, which is outside the quality agent's scope (tests only,
no refactors).

Recommendation

  1. Extract the regex-rewrite logic out of docusaurus.config.ts into a small,
    named function in lib/ (e.g. lib/rewriteReadmeLinks.ts), imported back
    into docusaurus.config.ts with an explicit .ts extension.
  2. Once extracted, a straightforward unit test under lib/**/*.test.mts can
    cover both branches (matching importedReadmePath, and the pass-through
    case) plus the regex's edge cases (fragment/query suffixes, non-docs/analyses
    paths, trailing content on the same line).

Priority

  • Impact: low — the function affects exactly one import path (root README.md import)
  • Effort: medium — requires a small production-code extraction before tests can be added

Filed by quality agent (hold-gated mode)


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

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

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 12, 2026
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 provenancestage/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