fix: UI crash on Reaction Logs — API returned 'logs' but UI expected 'reaction_logs'
Unified response key to reaction_logs in engine + tests + UI rebuild.
小橘 🍊(NEKO Team)
This commit is contained in:
parent
452bfba424
commit
cdd735e018
@ -1342,7 +1342,7 @@ export async function listReactionLogs(
|
|||||||
limit: number,
|
limit: number,
|
||||||
offset: number,
|
offset: number,
|
||||||
reactionId?: number,
|
reactionId?: number,
|
||||||
): Promise<{ logs: ReactionLog[]; total: number }> {
|
): Promise<{ reaction_logs: ReactionLog[]; total: number }> {
|
||||||
let countQuery
|
let countQuery
|
||||||
if (reactionId !== undefined) {
|
if (reactionId !== undefined) {
|
||||||
countQuery = db.prepare('SELECT COUNT(*) as count FROM reaction_logs WHERE reaction_id = ?').bind(reactionId)
|
countQuery = db.prepare('SELECT COUNT(*) as count FROM reaction_logs WHERE reaction_id = ?').bind(reactionId)
|
||||||
@ -1395,7 +1395,7 @@ export async function listReactionLogs(
|
|||||||
created_at: row.created_at,
|
created_at: row.created_at,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
return { logs, total }
|
return { reaction_logs: logs, total }
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================
|
// ============================================
|
||||||
|
|||||||
@ -1707,8 +1707,8 @@ describe('Reaction Logs', () => {
|
|||||||
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
||||||
expect(logsRes.status).toBe(200)
|
expect(logsRes.status).toBe(200)
|
||||||
const logsJson = await logsRes.json()
|
const logsJson = await logsRes.json()
|
||||||
expect(logsJson.logs.length).toBeGreaterThanOrEqual(1)
|
expect(logsJson.reaction_logs.length).toBeGreaterThanOrEqual(1)
|
||||||
const successLog = logsJson.logs.find((l: any) => l.status === 'success')
|
const successLog = logsJson.reaction_logs.find((l: any) => l.status === 'success')
|
||||||
expect(successLog).toBeDefined()
|
expect(successLog).toBeDefined()
|
||||||
expect(successLog.projection_def).toBe('current_assignee')
|
expect(successLog.projection_def).toBe('current_assignee')
|
||||||
expect(successLog.action).toBe('webhook')
|
expect(successLog.action).toBe('webhook')
|
||||||
@ -1728,7 +1728,7 @@ describe('Reaction Logs', () => {
|
|||||||
|
|
||||||
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
||||||
const logsJson = await logsRes.json()
|
const logsJson = await logsRes.json()
|
||||||
const skippedLog = logsJson.logs.find((l: any) => l.status === 'skipped')
|
const skippedLog = logsJson.reaction_logs.find((l: any) => l.status === 'skipped')
|
||||||
expect(skippedLog).toBeDefined()
|
expect(skippedLog).toBeDefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -1741,7 +1741,7 @@ describe('Reaction Logs', () => {
|
|||||||
|
|
||||||
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
||||||
const logsJson = await logsRes.json()
|
const logsJson = await logsRes.json()
|
||||||
const log = logsJson.logs.find((l: any) => l.status === 'success')
|
const log = logsJson.reaction_logs.find((l: any) => l.status === 'success')
|
||||||
expect(log).toBeDefined()
|
expect(log).toBeDefined()
|
||||||
expect(log.projection_def).toBe('current_assignee')
|
expect(log.projection_def).toBe('current_assignee')
|
||||||
expect(log.old_value).toBe('')
|
expect(log.old_value).toBe('')
|
||||||
@ -1761,15 +1761,15 @@ describe('Reaction Logs', () => {
|
|||||||
API_TOKEN: API_TOKEN,
|
API_TOKEN: API_TOKEN,
|
||||||
})
|
})
|
||||||
const filteredJson = await filteredRes.json()
|
const filteredJson = await filteredRes.json()
|
||||||
expect(filteredJson.logs.length).toBeGreaterThanOrEqual(1)
|
expect(filteredJson.reaction_logs.length).toBeGreaterThanOrEqual(1)
|
||||||
expect(filteredJson.logs.every((l: any) => l.reaction_id === reactionId)).toBe(true)
|
expect(filteredJson.reaction_logs.every((l: any) => l.reaction_id === reactionId)).toBe(true)
|
||||||
|
|
||||||
const emptyRes = await app.fetch(req('GET', '/reaction-logs?reaction_id=99999'), {
|
const emptyRes = await app.fetch(req('GET', '/reaction-logs?reaction_id=99999'), {
|
||||||
DB: db,
|
DB: db,
|
||||||
API_TOKEN: API_TOKEN,
|
API_TOKEN: API_TOKEN,
|
||||||
})
|
})
|
||||||
const emptyJson = await emptyRes.json()
|
const emptyJson = await emptyRes.json()
|
||||||
expect(emptyJson.logs).toHaveLength(0)
|
expect(emptyJson.reaction_logs).toHaveLength(0)
|
||||||
expect(emptyJson.total).toBe(0)
|
expect(emptyJson.total).toBe(0)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -1859,7 +1859,7 @@ describe('Reaction Handler', () => {
|
|||||||
|
|
||||||
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
||||||
const logsJson = await logsRes.json()
|
const logsJson = await logsRes.json()
|
||||||
const successLog = logsJson.logs.find((l: any) => l.status === 'success')
|
const successLog = logsJson.reaction_logs.find((l: any) => l.status === 'success')
|
||||||
expect(successLog).toBeDefined()
|
expect(successLog).toBeDefined()
|
||||||
expect(successLog.handler_output).toContain('old=')
|
expect(successLog.handler_output).toContain('old=')
|
||||||
expect(successLog.handler_output).toContain('new=')
|
expect(successLog.handler_output).toContain('new=')
|
||||||
@ -1894,7 +1894,7 @@ describe('Reaction Handler', () => {
|
|||||||
|
|
||||||
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
||||||
const logsJson = await logsRes.json()
|
const logsJson = await logsRes.json()
|
||||||
const successLog = logsJson.logs.find((l: any) => l.status === 'success' && l.action === 'handler')
|
const successLog = logsJson.reaction_logs.find((l: any) => l.status === 'success' && l.action === 'handler')
|
||||||
expect(successLog).toBeDefined()
|
expect(successLog).toBeDefined()
|
||||||
expect(successLog.handler_output).toContain('emitted')
|
expect(successLog.handler_output).toContain('emitted')
|
||||||
})
|
})
|
||||||
@ -1916,7 +1916,7 @@ describe('Reaction Handler', () => {
|
|||||||
|
|
||||||
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
||||||
const logsJson = await logsRes.json()
|
const logsJson = await logsRes.json()
|
||||||
const successLog = logsJson.logs.find((l: any) => l.status === 'success')
|
const successLog = logsJson.reaction_logs.find((l: any) => l.status === 'success')
|
||||||
expect(successLog).toBeDefined()
|
expect(successLog).toBeDefined()
|
||||||
expect(successLog.handler_output).toContain('processed')
|
expect(successLog.handler_output).toContain('processed')
|
||||||
expect(successLog.handler_output).toContain('done')
|
expect(successLog.handler_output).toContain('done')
|
||||||
@ -1946,7 +1946,7 @@ describe('Reaction Handler', () => {
|
|||||||
|
|
||||||
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
||||||
const logsJson = await logsRes.json()
|
const logsJson = await logsRes.json()
|
||||||
const handlerLogs = logsJson.logs.filter((l: any) => l.status === 'success' && l.action === 'handler')
|
const handlerLogs = logsJson.reaction_logs.filter((l: any) => l.status === 'success' && l.action === 'handler')
|
||||||
expect(handlerLogs.length).toBe(2)
|
expect(handlerLogs.length).toBe(2)
|
||||||
const outputs = handlerLogs.map((l: any) => l.handler_output)
|
const outputs = handlerLogs.map((l: any) => l.handler_output)
|
||||||
expect(outputs).toContain('count=1')
|
expect(outputs).toContain('count=1')
|
||||||
@ -1970,7 +1970,7 @@ describe('Reaction Handler', () => {
|
|||||||
|
|
||||||
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
||||||
const logsJson = await logsRes.json()
|
const logsJson = await logsRes.json()
|
||||||
const failedLog = logsJson.logs.find((l: any) => l.status === 'failed')
|
const failedLog = logsJson.reaction_logs.find((l: any) => l.status === 'failed')
|
||||||
expect(failedLog).toBeDefined()
|
expect(failedLog).toBeDefined()
|
||||||
expect(failedLog.handler_output).toContain('boom')
|
expect(failedLog.handler_output).toContain('boom')
|
||||||
})
|
})
|
||||||
@ -1993,7 +1993,7 @@ describe('Reaction Handler', () => {
|
|||||||
|
|
||||||
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
const logsRes = await app.fetch(req('GET', '/reaction-logs'), { DB: db, API_TOKEN: API_TOKEN })
|
||||||
const logsJson = await logsRes.json()
|
const logsJson = await logsRes.json()
|
||||||
const failedLog = logsJson.logs.find((l: any) => l.status === 'failed')
|
const failedLog = logsJson.reaction_logs.find((l: any) => l.status === 'failed')
|
||||||
expect(failedLog).toBeDefined()
|
expect(failedLog).toBeDefined()
|
||||||
expect(failedLog.handler_output).toContain('timeout')
|
expect(failedLog.handler_output).toContain('timeout')
|
||||||
}, 10000)
|
}, 10000)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user