Add tests for board rendering, drag and drop, and settings toggles

未关闭
#43 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 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 内容生成。

描述

help wanted severity: low testing

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 (only window.initDragAndDrop is exposed), js/drag.js:186-283
  • js/main.js:7-80
  • js/board.js:13, js/board.js:39, js/board.js:99, js/board.js:153
  • js/utils.js:10-27, js/utils.js:60-82

Suggested fix

  • utils: algebraicToCoords returns null for 'i1', 'a9', 'a0', '', null, 'e44' and accepts 'E4'; coordsToAlgebraic(8,0) and (-1,0) return null; isWithinBounds at 0, 7, -1, 8
  • deepClone: a nested board clone is independent of the source
  • board: createBoard makes 64 squares with data-row and data-col; renderPieces places 32 pieces at the start; updateBoardVisuals marks 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 while window.dragJustEnded is true
  • drag: export the handlers for tests; mousedown, mousemove, mouseup over a legal square calls makeMove once; 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.js handlers 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, then npm test and npm 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

环境准备

从这里开始

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

TMHSDigital/Static_Chess 的其他 Issue

查看 TMHSDigital/Static_Chess 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

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