Untested reject branches in search, safe-fetch and schema-check, and no guide-page test

Open Beginner friendly
#266 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
83/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, node.js
Domain
backend, testing

Research direction

Start with site/lib/lib.test.mjs and the named functions in site/lib/search.mjs, safe-fetch.mjs, schema-check.mjs, guide-page.mjs and guide-render.mjs. Run npm test to see the existing coverage, then add assertions for the listed reject, tie-break, rendering and text conversion cases. Done when those assertions pass and protect each acceptance criterion.

Written by the indexing model from the issue text.

Description

good first issue priority: low tests

Summary

V8 block coverage shows a handful of reject and tie-break branches in otherwise well-tested modules never run, and the guide page renderer has no unit test at all.

Where

  • site/lib/search.mjs:100-101, :169-178
  • site/lib/safe-fetch.mjs:66-67, :99-101
  • site/lib/schema-check.mjs:30, :34, :47-49
  • site/lib/guide-page.mjs:10-57
  • site/lib/guide-render.mjs:209 (plainText)

Details

The behaviour was checked by hand and is correct today; only the regression guards are missing.

Impact

A future edit could silently break these branches.

Suggested fix

Add the assertions below to site/lib/lib.test.mjs.

Acceptance criteria

  • passesFilters rejects a perspective mismatch and a licence-family mismatch
  • SORTS.license and SORTS.verified break ties by name
  • isPrivateAddress: 198.18.0.1, 198.19.255.255, 198.51.100.7, ::ffff:198.18.0.1 true; 198.20.0.1 false
  • refusalFor("not a url") returns "not a valid URL"
  • schemaErrors with $ref: "http://x" or a missing #/defs/y throws naming the ref
  • Guide page: <&"> in the title is escaped in <title>, breadcrumb and h1; modified: null omits dateModified; long first paragraph clipped to 160 chars in the description; no titleId gives an h1 with no id; edit link is ${repo}/blob/main/${path}
  • plainText strips tags and decodes entities

Getting started

  • Relevant files: site/lib/lib.test.mjs
  • Run the tests: npm test; the full local gate is npm run check (Node 22+, no install step)
  • Related docs: CONTRIBUTING.md, site/README.md

Filed by repo-audit/full-audit at 4adb944. Severity: low. Effort: S. audit-key: testing|site/lib/search.mjs|reject-branches

Dominant language
JavaScript
Stars
58
Forks
15
Avg merge
1d 15h
Merged PRs (30d)
12

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from TMHSDigital/Free-Game-Dev-Assets

All issues in TMHSDigital/Free-Game-Dev-Assets

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.