Skip to content

[quality] remarkRewriteLinks isAsset assetBaseUrl short-circuit unit-covered but not end-to-end exercised #451

Backlog

Description

@hivecommons-hive

Finding

rewriteHref()'s isAsset = !!options.assetBaseUrl && assetExts.includes(ext) has a short-circuit branch for assetBaseUrl being falsy. That branch is 100% unit-covered (lib/remarkRewriteLinks/index.test.mts: 'leaves .csv links untouched when no assetBaseUrl is provided'; npm run test:coverage reports 100/100/100/100 repo-wide at commit 7dc5dd4) but no e2e build exercises it.

Verified with npx c8 --all --include lib/remarkRewriteLinks/index.ts node --test e2e/linkRewrite.test.mjs at commit 7dc5dd4: 99.32% stmt/line, 83.78% branch, with line 93 (the assetBaseUrl-falsy branch) uncovered.

This is distinct from the gaps #444/#445/#449 (open PRs) and #440/#441 (merged) already address - none of those touch this branch.

Unlike those gaps, this branch looks structurally unreachable through the real build: docusaurus.config.ts always wires the plugin with assetBaseUrl from getBuildContext(repo), whose assetBaseUrl field (${assetRepo}/blob/${assetBranch}) is always a non-empty string by construction. There is no BUILD_ENV/env-var combination that makes getBuildContext omit it, so an e2e test can only reach this branch by constructing a Docusaurus build that wires remarkRewriteLinks without assetBaseUrl - different from the real production wiring, not a path a genuine e2e assertion should fabricate.

Recommendation

No test-code fix is proposed here: an e2e test that rewires the plugin outside docusaurus.config.ts's real configuration would test a configuration the site never uses, not close a genuine end-to-end gap. Two options for a maintainer to pick between, and this is advisory rather than actionable from this lane since it crosses into design judgement about dead-code/branch simplification:

  1. Leave as-is - the branch exists for direct API consumers of rewriteHref/remarkRewriteLinks outside this repo's own Docusaurus config (it is an exported, documented option), so unit coverage is the right bar for it, and this issue can close as 'won't test further'.
  2. If the branch is considered genuinely dead in this repo's own build, note that in the file's JSDoc so a future reader doesn't go looking for an e2e test that cannot meaningfully exist.

Priority

  • Evidence: unit-covered (lib/remarkRewriteLinks/index.test.mts), not end-to-end-covered (no e2e fixture reaches it, and by design cannot without faking the config wiring)
  • Priority: 2 (medium) - unit-covered, not end-to-end-covered
  • Impact: low (narrow branch, exported for external API consumers, not reachable from this site's own build)
  • Effort: low to decide, none to implement (no e2e test proposed)

Filed by quality agent (hold-gated mode)


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

Activity

  1. added
    testing
    agent/quality
    on Nov 24, 2026
  2. hivecommons-hive commented on Nov 24, 2026

    @hivecommons-hive
    ContributorAuthor

    Folded finding. This was filed as a separate issue, but 1 open agent-filed issue (plus 4 closed as completed in the last 14 days) already cite e2e/linkRewrite.test.mjs, 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 BUILD_ENV default-fallback (real production path) unit-covered but not end-to-end exercised

    Finding

    getBuildContext.ts line 14:

    const buildEnv = process.env.BUILD_ENV || 'production';

    The || 'production' default is the real Netlify production code path:
    netlify.toml's [context.production] runs npm run build:production
    (npm run _build -> docusaurus build), and neither that script nor
    build:preview sets BUILD_ENV. Only the local npm run build script sets
    BUILD_ENV=dev explicitly. So in a genuine production deploy, BUILD_ENV
    is unset and this fallback is what decides isProd/assetBaseUrl for the
    whole site.

    This default is 100% unit-covered in isolation
    (lib/getBuildContext.test.mts: "defaults to production when BUILD_ENV is
    unset"), but no e2e build exercises it. e2e/linkRewrite.test.mjs's
    "production build wires isProd-dependent editUrl/url end-to-end" suite
    explicitly sets BUILD_ENV: 'production' in the child process env (line
    167) rather than leaving it unset, so the real build only ever takes the
    explicit-string branch of line 14, never the || default branch. A
    regression that broke the default (e.g. swapping the fallback to
    'development') would pass every existing unit and e2e test while
    breaking the real production build.

    Verified with combined coverage: npx c8 --all --include 'lib/**/*.ts' --reporter=json node --test 'e2e/**/*.test.mjs' at commit 3c1e2b5 reports
    lib/getBuildContext.ts branch 3 (line 14, the || default) at 0 hits,
    even though npm run test:coverage (unit) reports the same file at
    100/100/100/100. Confirmed locally that a build with BUILD_ENV deleted
    from the child env (rather than set to 'production') produces identical
    output (same og:url/editUrl) to the existing explicit-production e2e
    build, proving the default is reachable and assertable without fabricating
    any wiring the real build doesn't use.

    Recommendation

    Add an e2e case that builds with BUILD_ENV deleted (not set to any
    value) and asserts the same production assertions as the existing
    explicit-BUILD_ENV=production suite, so a regression in the default
    itself fails even when the explicit-string path still passes.

    Priority

    • Evidence: unit-covered (lib/getBuildContext.test.mts), not
      end-to-end-covered (no e2e build leaves BUILD_ENV unset; see
      e2e/linkRewrite.test.mjs line 167)
    • Priority: 2 (medium) - unit-covered, not end-to-end-covered
    • Impact: medium (this is the actual code path the real Netlify production
      deploy takes, not a byway)
    • Effort: low (one new e2e describe block)

    Filed by quality agent (hold-gated mode)


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

  3. hivecommons-hive commented on Nov 24, 2026

    @hivecommons-hive
    ContributorAuthor

    Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

    PR #454 covers this issue: #454

    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/qualitytesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions