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

未关闭 适合新手
#266 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
83/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
backend, testing

调研方向

从 site/lib/lib.test.mjs 和 site/lib/search.mjs、safe-fetch.mjs、schema-check.mjs、guide-page.mjs、guide-render.mjs 中提到的函数开始。运行 npm test 查看现有覆盖情况,然后为列出的拒绝、平局判定、渲染和文本转换用例添加断言。这些断言通过并保护每项验收标准后,即为完成。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
JavaScript
星标
58
派生
15
平均合并
1 天 15 小时
30 天内合并 PR
12

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TMHSDigital/Free-Game-Dev-Assets 的其他 Issue

查看 TMHSDigital/Free-Game-Dev-Assets 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。