fix: update tests for creative MC and flaky mock answer checks

Creative challenges now have auto-generated MC choices with correct
answers. Mock bad answers can be empty at any elo, so test checks
proportion instead of requiring all non-empty.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-09 08:38:53 +00:00
co-authored by Claude Opus 4.6
parent 3c95adb545
commit 9fdf7a6720
2 changed files with 16 additions and 5 deletions
+8 -2
View File
@@ -48,11 +48,17 @@ describe('pickChallenge', () => {
}
})
it('creative challenges have no answers', () => {
it('creative challenges have MC choices and a correct answer', () => {
for (let i = 0; i < 100; i++) {
const c = pickChallenge(new Set(), null)
if (c.scoring === 'creative') {
expect(!c.answers || c.answers.length === 0).toBe(true)
// Creative challenges now have auto-generated MC choices with a correct answer
expect(c.choices).toBeDefined()
expect(c.choices!.length).toBe(4)
expect(c.answers).toBeDefined()
expect(c.answers!.length).toBe(1)
// The correct answer must be among the choices
expect(c.choices).toContain(c.answers![0])
}
}
})
+8 -3
View File
@@ -74,16 +74,21 @@ describe('mockResponse', () => {
expect(highAvg).toBeLessThan(lowAvg)
})
it('creative challenges return non-empty answers', () => {
it('creative challenges return answers (most non-empty at high elo)', () => {
let nonEmpty = 0
let total = 0
for (let i = 0; i < 50; i++) {
const challenge = pickChallenge(new Set(), null)
if (challenge.scoring !== 'creative') continue
const resp = mockResponse(challenge, 'witty', 1500)
const resp = mockResponse(challenge, 'witty', 1800)
if (!resp.timedOut && !resp.error) {
expect(resp.answer.length).toBeGreaterThan(0)
total++
if (resp.answer.length > 0) nonEmpty++
}
}
// At elo 1800, bad answer chance is very low; most should be non-empty
expect(nonEmpty).toBeGreaterThan(total * 0.7)
})
it('trash talk is always a string', () => {