Some changes to the narrative intergation

This commit is contained in:
2026-08-22 18:27:06 +02:00
parent af0ffe055e
commit 917bb0248e
5 changed files with 26 additions and 101 deletions
+13 -4
View File
@@ -144,8 +144,12 @@ suite('narrative graph runtime', () => {
const mysteries = await (await authFetch(`${baseUrl}/api/admin/mysteries`, adminAuthorization)).json() as { id:string;slug:string }[]
const mysteryId = mysteries.find(mystery => mystery.slug === 'goal-mystery')!.id
expect((await authFetch(`${baseUrl}/api/admin/mysteries/${mysteryId}/graph`, adminAuthorization, { method:'POST',headers:json,
body:JSON.stringify({ entry:'level',nodes:[{ key:'level',type:'level',label:'Prove it',templateSlug:'goal-chapter',x:0,y:0,
terminals:[{ key:'continue',label:'Continue',to:null }] }] }) })).status).toBe(201)
body:JSON.stringify({ entry:'level',nodes:[
{ key:'level',type:'level',label:'Prove it',templateSlug:'goal-chapter',x:0,y:0,
terminals:[{ key:'continue',label:'Continue',to:'merit' }] },
{ key:'merit',type:'merit',label:'Inventor Merit',awardsFlag:'demo.inventor-merit',x:200,y:0,
terminals:[{ key:'continue',label:'Accept',to:null }] },
] }) })).status).toBe(201)
const created = await authFetch(`${baseUrl}/api/playthroughs`, undefined, { method:'POST',headers:json,body:JSON.stringify({ mystery:'goal-mystery' }) })
expect(created.status).toBe(201)
@@ -167,10 +171,15 @@ suite('narrative graph runtime', () => {
const completed = await authFetch(`${baseUrl}/api/playthroughs/${playthroughId}/advance`, undefined, { method:'POST',headers:json,body:'{}' })
expect(completed.status).toBe(200)
expect((await completed.json() as PlaythroughState).playthrough.status).toBe('finished')
expect(await (await authFetch(`${baseUrl}/api/playthroughs/${playthroughId}/achievements`, undefined)).json()).toContain('demo.inventor-proved')
expect(await completed.json()).toMatchObject({ playthrough:{ status:'active' },node:{ kind:'merit',label:'Inventor Merit',awardsFlag:'demo.inventor-merit' } })
expect(await (await authFetch(`${baseUrl}/api/playthroughs/${playthroughId}/achievements`, undefined)).json())
.toEqual(expect.arrayContaining(['demo.inventor-proved','demo.inventor-merit']))
const achievement = await appPool.query<{ awarded_by_node_id:string | null }>(
'SELECT awarded_by_node_id FROM osint.achievements WHERE playthrough_id=$1 AND flag_key=$2', [playthroughId,'demo.inventor-proved'])
expect(achievement.rows[0].awarded_by_node_id).toBe(atLevel.node!.id)
const finished = await authFetch(`${baseUrl}/api/playthroughs/${playthroughId}/advance`, undefined, { method:'POST',headers:json,body:'{}' })
expect(finished.status).toBe(200)
expect((await finished.json() as PlaythroughState).playthrough.status).toBe('finished')
})
})