test: add theme selection and prompt tagging verification tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-09 08:11:08 +00:00
co-authored by Claude Opus 4.6
parent 0c6a775e30
commit cb5e5a1cc9
+34
View File
@@ -1,5 +1,7 @@
import { describe, it, expect } from 'vitest' import { describe, it, expect } from 'vitest'
import { pickChallenge, pickRankedChallenge, getAllChallengeTypes, getAnswerPool, roundToDifficulty } from './challenges.js' import { pickChallenge, pickRankedChallenge, getAllChallengeTypes, getAnswerPool, roundToDifficulty } from './challenges.js'
import { TEMPLATES } from './challenge-data.js'
import { EXTRA_PROMPTS } from './challenges-extra.js'
describe('pickChallenge', () => { describe('pickChallenge', () => {
it('returns a valid challenge', () => { it('returns a valid challenge', () => {
@@ -211,6 +213,38 @@ describe('pickChallenge with roundNumber', () => {
}) })
}) })
describe('theme selection', () => {
it('theme bias parameter increases themed prompt selection', () => {
let bitcoinWithBias = 0
let bitcoinWithout = 0
const runs = 500
for (let i = 0; i < runs; i++) {
const biased = pickChallenge(new Set(), null, 'bitcoin')
const unbiased = pickChallenge(new Set(), null)
// Check if prompt text contains bitcoin-related content
// Theme-biased should prefer bitcoin prompts when available
if (biased.prompt.toLowerCase().includes('bitcoin') || biased.prompt.toLowerCase().includes('blockchain')) bitcoinWithBias++
if (unbiased.prompt.toLowerCase().includes('bitcoin') || unbiased.prompt.toLowerCase().includes('blockchain')) bitcoinWithout++
}
// With bias, should get more bitcoin prompts
expect(bitcoinWithBias).toBeGreaterThanOrEqual(bitcoinWithout)
})
it('all prompts have theme tags after tagging', () => {
let tagged = 0
let total = 0
for (const t of TEMPLATES) {
const extras = EXTRA_PROMPTS[t.type] || []
for (const p of [...t.prompts, ...extras]) {
total++
if (p.theme) tagged++
}
}
// All prompts should have themes
expect(tagged).toBe(total)
})
})
describe('prompt data integrity', () => { describe('prompt data integrity', () => {
it('all 800 prompts are accessible via pickChallenge', () => { it('all 800 prompts are accessible via pickChallenge', () => {
// Run enough picks to verify the system works // Run enough picks to verify the system works