Add puzzle hints and per-word descriptions with sources

Hint is revealed on demand below the board while playing. After the game
ends, each word's description and source link are listed below the
puzzle, and hovering a solved word highlights its entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aidan Dona 2026-10-13 16:44:07 -05:00
parent 4a2309b589
commit b2f8e879ab
7 changed files with 141 additions and 21 deletions

16
test.js
View file

@ -45,3 +45,19 @@ test('checkGuess: correct, one away, wrong, invalid', () => {
assert.ok(checkGuess(groups, ['bass', 'bass', 'pike', 'carp']).error);
assert.ok(checkGuess(groups, 'nope').error);
});
test('hint and per-word details are validated', () => {
const g = good();
g.hint = ' Think water ';
g.groups[0].details = [{ description: 'A fish', source: 'https://example.com/bass' }];
const { game } = validateGame(g);
assert.equal(game.hint, 'Think water');
assert.deepEqual(game.groups[0].details[0], { description: 'A fish', source: 'https://example.com/bass' });
assert.deepEqual(game.groups[0].details[1], { description: '', source: '' });
g.groups[0].details = [{ source: 'javascript:alert(1)' }];
g.hint = 'x'.repeat(201);
const { errors } = validateGame(g);
assert.ok(errors.some((e) => e.includes('http(s) link')));
assert.ok(errors.some((e) => e.includes('Hint')));
});