Bring CI onto the current template archetype and add unit tests#32
Merged
Conversation
…ore logic Declares this repo's static-app archetype, replaces the old scaffold-era workflows with the current merged CI/lint/accessibility/security/CodeQL/ deploy templates, and extracts the DOM-free clock logic (random time generation, hand-angle math, answer checking, hint text, value wrapping) into clock-logic.js so it can be unit tested with Vitest independently of the browser. Also fixes two accessibility regression suite defects found already present in index.html while bringing the accessibility gate up: an assertive aria-live override on the polite feedback region (S-08), and a missing main landmark (S-09). Narrows the bundler-free deploy allow-list to this project's actual runtime files, since the template's default /scripts/*** and /data/*** includes would otherwise publish this repo's internal developer tooling scripts to the public site.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.github/ci-archetype=static-app, replaces this repo's old scaffold-era workflows with the current merged template versions (ci.yml,lint.yml,accessibility.yml,security.yml,codeql.yml,deploy.yml), and adds.github/lint-tools/..github/accessibility-tools/was already current and left unchanged. Rootpa11y.jsonwas already customised (chromeLaunchConfig, ignore-list comments) and kept as-is.clock-practice.jsinto a new module,clock-logic.js— random time generation, hand-angle math, time formatting, answer checking, hint text, and hour/minute value wrapping.index.html's script tag becomestype="module"soclock-practice.jscan import from it. This was a SMALL extraction (pulling out already-separable pure functions), not a structural refactor.testscript (vitest run), matching the estate pattern used by Braille Reference and the Braille Name Generator.Deploy allow-list (bundler-free repo)
Clock Practice has a
package.jsonfor lint tooling only, with no build script, so it falls into the template's BUNDLED job, which auto-falls-back to the allow-list assembly step when nodist/is produced. This repo's runtime files (index.html,clock-practice.js,clock-logic.js,styles.css,favicon.svg) live at the repo root rather than instyles//scripts/subfolders, so each is allow-listed by its own anchored include, alongside/assets/***for the analytics script.The template's default
/scripts/***and/data/***includes were deliberately dropped: this repo'sscripts/folder holds internal developer tooling (next-q.sh,record-backport.sh, etc.), not runtime JavaScript, and including it would have published those scripts to the public site. Confirmed with a local rsync dry-run —_site/contains exactly the six runtime files and nothing else (nonode_modules, no internal scripts).Test coverage
33 Vitest unit tests in
tests/clock-logic.test.js, asserting against an independent reference (the standard analog-clock hand-angle formula, computed separately fromhandAngles, plus the game's own stated rules for correctness and value wrapping) rather than echoing the implementation:randomTime: hour always an integer 1-12; minute always a multiple of five, 0-55; produces more than one distinct value over repeated sampling.handAngles: matches the standard clock formula across a table of times including 12 o'clock, quarter past, half past, and near-midnight (11:55); explicit checks for the o'clock, half-past, and quarter-past cases.formatTime: leading-zero minute padding, no hour padding, the o'clock case, and a two-digit minute.isCorrectAnswer: accepts an exact match, rejects hour-only-wrong, minute-only-wrong, and both-wrong, and accepts 12:00 (noon/midnight representation).getHint: all three hint branches (both wrong, hour wrong, minute wrong).wrapHour/wrapMinute: normal increment/decrement plus both wrap-around directions (12->1, 1->12, 55->0, 0->55).Accessibility regression suite (docs/patterns/accessibility-regression-suite.md)
Ran the static front-end suite's automated checks and inspected the checked-out HTML for the manual entries. Found and fixed two pre-existing defects (present before this PR, unrelated to the extraction) while bringing the honest accessibility gate online:
#feedbackcarried bothrole="status"and an explicitaria-live="assertive"override. Removed the explicitaria-live, leavingrole="status"alone (implies polite), matching the suite's fixed pattern.<main>or<header>element existed. Wrapped the<h1>in<header>and the game content in<main>.clock-practice.jsandclock-logic.jsreturn a non-empty--print-configoutput;lint:jsnow covers both files plustests/.aria-hidden, no modal).Checks run locally
npm ci— clean.npm test(Vitest) — 33/33 passing.npm run build --if-present— no-op as expected (bundler-free); nodist/produced.npm run lint(html-validate, stylelint, eslint) — clean.--config pa11y.json) against the served repo root — 0 issues, both before and after the S-08/S-09 fixes.--tags wcag2a,wcag2aa,wcag2aaa,wcag22aa,wcag22aaa --exit) against the same URL — 0 violations, both before and after the fixes.wrapHour), and Check My Answer renders live feedback correctly._site/contains exactlyindex.html,clock-practice.js,clock-logic.js,styles.css,favicon.svg, andassets/analytics/count.js— nonode_modules, no internal tooling scripts.No design-level accessibility blockers found; nothing to route to Simon.
No secrets or personal data included.