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

Offen
#43 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
72/100
Issue-Typ
Feature
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
javascript
Bereich
testing

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
JavaScript
Sterne
4
Forks
2
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus TMHSDigital/Static_Chess

Alle Issues in TMHSDigital/Static_Chess

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.