Add tests for board rendering, drag and drop, and settings toggles
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 72/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript
- 领域
- testing
调研方向
Start with tests/ and the existing test setup, then read the referenced sections of js/utils.js, js/board.js, js/drag.js, and js/main.js. Run npm test and npm run lint to see current conventions and coverage. Add tests for each listed behavior and make the drag handlers importable; done when the acceptance criteria pass.
由索引模型根据 Issue 内容生成。
描述
Summary
Drag and drop is the default input method and the most recently changed area, yet it has no automated check. js/drag.js has no CommonJS export and js/main.js is a single DOMContentLoaded handler, so neither can be loaded by the current tests.
Where
js/drag.js:285-288(onlywindow.initDragAndDropis exposed),js/drag.js:186-283js/main.js:7-80js/board.js:13,js/board.js:39,js/board.js:99,js/board.js:153js/utils.js:10-27,js/utils.js:60-82
Suggested fix
-
utils:algebraicToCoordsreturnsnullfor'i1','a9','a0','',null,'e44'and accepts'E4';coordsToAlgebraic(8,0)and(-1,0)returnnull;isWithinBoundsat 0, 7, -1, 8 -
deepClone: a nested board clone is independent of the source -
board:createBoardmakes 64 squares withdata-rowanddata-col;renderPiecesplaces 32 pieces at the start;updateBoardVisualsmarks the selected square, the possible moves and the king in check -
handleBoardClickEvent: a click on a piece inside a square selects it; it is ignored whilewindow.dragJustEndedis true -
drag: export the handlers for tests; mousedown, mousemove, mouseup over a legal square callsmakeMoveonce; a drop on an illegal square or outside the board leaves the position unchanged and clears the selection; mousedown without movement falls through to click selection (#23) -
main: toggles read and write their storage keys with the documented defaults - Optional: one browser smoke test, since jsdom has no layout for
elementsFromPoint
Acceptance criteria
-
drag.jshandlers are importable in tests - Each item above has a test
Getting started
- Relevant files:
js/drag.js,js/board.js,js/main.js,js/utils.js,tests/ - How to run tests:
npm install, thennpm testandnpm run lint - Related docs:
docs/ARCHITECTURE.md,.github/CONTRIBUTING.md
Filed by repo-audit/full-audit at 8a2c86c. Severity: low. Effort: M. audit-key: testing|js/drag.js|handleDragEnd
- 主要语言
- JavaScript
- 星标
- 4
- 派生
- 2
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TMHSDigital/Static_Chess 的其他 Issue
-
enhancement good first issue severity: medium
难度 2/5 1-3 小时 新手友好度 78/100
TMHSDigital/Static_Chess#53 ·
-
documentation good first issue severity: low
难度 2/5 1-3 小时 新手友好度 72/100
TMHSDigital/Static_Chess#49 ·
-
documentation good first issue severity: low
难度 2/5 1-3 小时 新手友好度 83/100
TMHSDigital/Static_Chess#48 ·
-
documentation severity: medium
难度 2/5 1-3 小时 新手友好度 78/100
TMHSDigital/Static_Chess#47 ·
-
documentation good first issue severity: low
难度 2/5 1-3 小时 新手友好度 82/100
TMHSDigital/Static_Chess#46 ·
查看 TMHSDigital/Static_Chess 的全部 Issue
相似的 Issue
-
good first issue tests
难度 1/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 90/100
-
1️⃣ phase/under-investigation flaky/confirmed flaky/needs-decision type/bug
难度 2/5 1-3 小时 新手友好度 65/100
growilabs/growi#12246 · 3 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 72/100
TMHSDigital/Free-Game-Dev-Assets#301 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 79/100