feat(messaging): Testing area improvements (#37678)

This commit is contained in:
Ben White
2025-09-05 13:54:14 +02:00
committed by GitHub
parent 6d6a756351
commit 3d0314388c
8 changed files with 296 additions and 224 deletions

View File

@@ -480,7 +480,7 @@ export class CdpApi {
const result = await this.hogFlowExecutor.executeCurrentAction(invocation)
res.json({
result,
nextActionId: result.invocation.state.currentAction?.id,
status: result.error ? 'error' : 'success',
errors: result.error ? [result.error] : [],
logs: result.logs,

View File

@@ -223,7 +223,7 @@ describe('Hogflow Executor', () => {
{
level: 'info',
timestamp: expect.any(DateTime),
message: "Workflow moved to action 'exit (exit)'",
message: 'Workflow moved to action [Action:exit]',
},
{
level: 'info',
@@ -297,7 +297,7 @@ describe('Hogflow Executor', () => {
"[Action:function_id_1] Fetch 3, 200",
"[Action:function_id_1] All fetches done!",
"[Action:function_id_1] Function completed in REPLACEDms. Sync: 0ms. Mem: 0.099kb. Ops: 32. Event: 'http://localhost:8000/events/1'",
"Workflow moved to action 'exit (exit)'",
"Workflow moved to action [Action:exit]",
"Workflow completed",
]
`)
@@ -379,7 +379,7 @@ describe('Hogflow Executor', () => {
expect(result1.finished).toBe(false)
expect(result1.invocation.state.currentAction?.id).toBe('function_id_1')
expect(result1.logs.map((log) => log.message)).toEqual([
"Workflow moved to action 'function (function_id_1)'",
'Workflow moved to action [Action:function_id_1]',
])
// Second step: should process function_id_1 and move to exit, but not complete
@@ -390,7 +390,7 @@ describe('Hogflow Executor', () => {
'[Action:function_id_1] Hello, Mr Debug User!',
'[Action:function_id_1] Fetch 1, 200',
expect.stringContaining('[Action:function_id_1] Function completed in'),
"Workflow moved to action 'exit (exit)'",
'Workflow moved to action [Action:exit]',
'Workflow completed',
])
})

View File

@@ -31,6 +31,11 @@ import { ensureCurrentAction, findContinueAction, shouldSkipAction } from './hog
export const MAX_ACTION_STEPS_HARD_LIMIT = 1000
// Special format which the frontend understands and can render as a link
const actionIdForLogging = (action: HogFlowAction) => {
return `[Action:${action.id}]`
}
export class HogFlowExecutorService {
private readonly actionHandlers: Record<HogFlowAction['type'], ActionHandler>
@@ -324,7 +329,7 @@ export class HogFlowExecutorService {
result.logs.push({
level: 'info',
timestamp: DateTime.now(),
message: `Workflow moved to action '${nextAction.name} (${nextAction.id})'`,
message: `Workflow moved to action ${actionIdForLogging(nextAction)}`,
})
this.trackActionMetric(result, currentAction, reason === 'filtered' ? 'filtered' : 'succeeded')
@@ -357,7 +362,7 @@ export class HogFlowExecutorService {
level: LogEntryLevel,
message: string
): void {
this.log(result, level, `[Action:${action.id}] ${message}`)
this.log(result, level, `${actionIdForLogging(action)} ${message}`)
}
private log(