Implement Scene 7 evidence goal flow

This commit is contained in:
2026-08-22 16:02:42 +02:00
parent 34aa23237e
commit a7f99a2a39
31 changed files with 1620 additions and 52 deletions
+55
View File
@@ -0,0 +1,55 @@
import { expect, test } from '@playwright/test'
test('pasting one Google Patents screenshot verifies the Scene 7 objective', async ({ page, request }) => {
test.setTimeout(60_000)
const levels = await (await request.get('/api/levels')).json() as { id:string }[]
const sceneSeven = levels.find(level => level.id.startsWith('barricelli-inventor-proof-case-'))
if (!sceneSeven) throw new Error('Scene 7 playable clone was not seeded')
await page.goto(`/level/${sceneSeven.id}`)
await expect(page.getByRole('heading', { name:'The Barricelli Files' })).toBeVisible()
await expect(page.locator('.brief-panel')).toBeVisible()
await expect(page.locator('.brief-goals')).toContainText('Prove Nils Aall Barricelli was an inventor')
await expect(page.locator('.brief-goals section')).toHaveClass(/\bpending\b/)
await page.getByRole('button', { name:'BEGIN INVESTIGATION',exact:true }).click()
const uploadResponse = page.waitForResponse(response => response.request().method() === 'POST'
&& response.url().includes(`/api/levels/${sceneSeven.id}/documents`) && response.status() === 201)
await page.evaluate(async () => {
const canvas = document.createElement('canvas')
canvas.width = 1280
canvas.height = 520
const context = canvas.getContext('2d')!
context.fillStyle = '#fff'
context.fillRect(0, 0, canvas.width, canvas.height)
context.fillStyle = '#111'
context.font = 'bold 56px Arial, sans-serif'
context.fillText('GB695913A', 70, 95)
context.font = '48px Arial, sans-serif'
context.fillText('Improved chest of drawers', 70, 175)
context.font = '34px Arial, sans-serif'
context.fillText('Inventor', 70, 280)
context.font = 'bold 52px Arial, sans-serif'
context.fillText('Nils Aall Barricelli', 70, 355)
context.font = '30px Arial, sans-serif'
context.fillText('Priority date 1951-05-31 Publication date 1953-08-19', 70, 445)
const blob = await new Promise<Blob>((resolve, reject) => canvas.toBlob(value => value ? resolve(value) : reject(new Error('Could not render screenshot')), 'image/png'))
const transfer = new DataTransfer()
transfer.items.add(new File([blob], 'google-patents.png', { type:'image/png' }))
window.dispatchEvent(new ClipboardEvent('paste', { clipboardData:transfer,bubbles:true,cancelable:true }))
})
const uploaded = await (await uploadResponse).json()
expect(uploaded.analysis).toMatchObject({ extractionStatus:'succeeded',matchedFlags:['scene7.nils_inventor_proved'],
goals:[expect.objectContaining({ key:'barricelli.inventor-proof',status:'complete',newlyCompleted:true })] })
await expect(page.locator('.source-file-widget')).toHaveCount(1)
await expect(page.locator('.source-file-widget')).toHaveClass(/\barriving\b/)
const complete = page.locator('.goal-complete-card')
await expect(complete).toBeVisible({ timeout:20_000 })
await expect(complete).toContainText('SOURCE VERIFIED — NILS AALL BARRICELLI: INVENTOR')
await expect(complete.getByRole('button', { name:/RETURN TO BOARD/ })).toBeVisible()
const level = await (await request.get(`/api/levels/${sceneSeven.id}`)).json()
expect(level.goals).toEqual([expect.objectContaining({ key:'barricelli.inventor-proof',status:'complete',newlyCompleted:false })])
expect(level.exhibits.filter((exhibit: { type:string }) => exhibit.type === 'document')).toHaveLength(1)
})