fix(bots): explain unavailable route tests

This commit is contained in:
RockChinQ
2026-08-25 22:03:57 +08:00
parent 792d961d28
commit 69ca7e21cd
7 changed files with 127 additions and 5 deletions
+68 -1
View File
@@ -346,6 +346,53 @@ test.describe('bot advanced flows', () => {
body: JSON.stringify({ code: -1, msg: 'Internal server error' }),
}),
);
await page.route(
'**/api/v1/platform/bots/*/event-routes/dry-run',
(route) =>
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
code: 0,
msg: 'ok',
data: {
matched: true,
event_type: 'message.received',
matched_binding_id: 'binding-1',
matched_binding_index: 0,
target: {
target_type: 'agent',
target_uuid: 'agent-1',
target_name: 'NewAgent',
},
diagnostic_steps: ['Matched route 1'],
diagnostic_details: [],
},
}),
}),
);
await page.route('**/api/v1/platform/bots/*/event-routes/test', (route) =>
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
code: 0,
msg: 'ok',
data: {
dispatched: false,
event_type: 'message.received',
failure_code: 'bot_runtime_unavailable',
reason: 'Bot runtime is unavailable',
suppressed_outputs: [],
route_status: {
routes: [],
unmatched_events: [],
stale_routes: [],
},
},
}),
}),
);
await page.goto('/home/bots?id=new');
await selectPlaywrightAdapter(page);
@@ -397,8 +444,28 @@ test.describe('bot advanced flows', () => {
routeDialog.getByRole('button', { name: 'Preview match' }),
).toBeVisible();
await expect(
routeDialog.getByRole('button', { name: 'Run saved configuration' }),
routeDialog.getByRole('button', { name: 'Run full test' }),
).toBeVisible();
await routeDialog.getByRole('button', { name: 'Preview match' }).click();
await expect(routeDialog.getByText('Matched route')).toBeVisible();
await routeDialog.getByRole('button', { name: 'Run full test' }).click();
await expect(routeDialog.getByText('Matched route')).toHaveCount(0);
await expect(
routeDialog.getByText(
'The bot is not running. Check its platform settings and enable it before running a full test.',
),
).toBeVisible();
await expect(routeDialog.getByText('Internal server error')).toHaveCount(0);
await routeDialog.getByRole('button', { name: 'Preview match' }).click();
await expect(
routeDialog.getByText(
'The bot is not running. Check its platform settings and enable it before running a full test.',
),
).toHaveCount(0);
await expect(routeDialog.getByText('Matched route')).toBeVisible();
const dialogBox = await routeDialog.boundingBox();
expect(dialogBox).not.toBeNull();
expect(dialogBox!.height).toBeLessThan(500);