test(web): align smoke fixtures with current processor UI

This commit is contained in:
dadachann
2026-09-11 04:50:26 +00:00
parent 3b047ab080
commit 4cf25be974
4 changed files with 81 additions and 39 deletions
+33 -14
View File
@@ -89,7 +89,7 @@ test.describe('frontend CRUD smoke flows', () => {
await expect( await expect(
page.locator('[data-processor-kind="pipeline"]'), page.locator('[data-processor-kind="pipeline"]'),
).toContainText( ).toContainText(
'流水线即为经典的“收到消息、请求AI、回复用户”流程,并辅以常用的配置功能。仅处理消息事件,适合步骤明确、需要稳定控制处理过程的场景。', '流水线按“接收消息、调用 AI、回复用户”的固定流程运行,可配置知识库和插件扩展。仅处理消息事件,适合步骤明确、需要控制处理过程的场景。',
); );
}); });
@@ -1034,7 +1034,7 @@ test.describe('agent runner resource selectors', () => {
await expect( await expect(
page.getByText('No Runner extension is installed yet.'), page.getByText('No Runner extension is installed yet.'),
).toBeVisible(); ).toBeVisible();
await expect(page.getByText('Runner Marketplace')).toBeVisible(); await expect(page.getByText('Runner plugins in Marketplace')).toBeVisible();
const selectorPopup = page.locator('[data-slot="select-content"]'); const selectorPopup = page.locator('[data-slot="select-content"]');
await expect( await expect(
selectorPopup.getByText('Runner used by the grouped selector test.', { selectorPopup.getByText('Runner used by the grouped selector test.', {
@@ -1055,20 +1055,35 @@ test.describe('agent runner resource selectors', () => {
}); });
await page await page
.getByRole('option') .getByRole('button', { name: 'Install Marketplace Runner', exact: true })
.filter({ hasText: 'Marketplace Runner' })
.click(); .click();
await expect.poll(() => installRequests).toBe(1); await expect.poll(() => installRequests).toBe(1);
await expect.poll(() => taskPolls).toBeGreaterThan(0); await expect.poll(() => taskPolls).toBeGreaterThan(0);
await expect(
page.getByRole('option', {
name: 'Marketplace Runner Runner used by the grouped selector test.',
exact: true,
}),
).toBeVisible();
await page
.getByRole('option', {
name: 'Marketplace Runner Runner used by the grouped selector test.',
exact: true,
})
.click();
await expect(runnerSelect).toContainText('Marketplace Runner'); await expect(runnerSelect).toContainText('Marketplace Runner');
await runnerSelect.click(); await runnerSelect.click();
await expect( await expect(
page.getByRole('option').filter({ hasText: runnerId }), page.getByRole('option', {
name: 'Marketplace Runner Runner used by the grouped selector test.',
exact: true,
}),
).toBeVisible(); ).toBeVisible();
await expect( await expect(
page.getByText('Runner used by the grouped selector test.', { page.getByRole('button', {
name: 'Install Marketplace Runner',
exact: true, exact: true,
}), }),
).toHaveCount(0); ).toHaveCount(0);
@@ -1130,7 +1145,7 @@ test.describe('agent runner resource selectors', () => {
const runnerSelect = page.getByRole('combobox', { name: 'Runner' }); const runnerSelect = page.getByRole('combobox', { name: 'Runner' });
await runnerSelect.click(); await runnerSelect.click();
await expect(page.getByText('Installed Runners')).toBeVisible(); await expect(page.getByText('Installed Runners')).toBeVisible();
await expect(page.getByText('Runner Marketplace')).toBeVisible(); await expect(page.getByText('Runner plugins in Marketplace')).toBeVisible();
await expect( await expect(
page page
.locator('[data-slot="select-content"]') .locator('[data-slot="select-content"]')
@@ -1139,9 +1154,10 @@ test.describe('agent runner resource selectors', () => {
}), }),
).toBeVisible(); ).toBeVisible();
await expect( await expect(
page page.getByRole('button', {
.getByRole('option') name: 'Install Pipeline Marketplace Runner',
.filter({ hasText: 'Pipeline Marketplace Runner' }), exact: true,
}),
).toBeVisible(); ).toBeVisible();
}); });
@@ -1214,8 +1230,11 @@ test.describe('agent and pipeline save concurrency', () => {
await page.goto('/home/agents?id=agent-save-race'); await page.goto('/home/agents?id=agent-save-race');
const saveButton = page.getByRole('button', { name: /^Save$/ }); const saveButton = page.getByRole('button', { name: /^Save$/ });
await page.getByRole('tab', { name: 'Bindable Event Range' }).click(); await page.getByRole('tab', { name: 'Events & tools' }).click();
const eventPatterns = page.getByLabel('Event Range'); const eventPatterns = page.getByRole('button', {
name: 'Add event',
exact: true,
});
await expect(eventPatterns).toBeVisible(); await expect(eventPatterns).toBeVisible();
await eventPatterns.click(); await eventPatterns.click();
@@ -1231,8 +1250,8 @@ test.describe('agent and pipeline save concurrency', () => {
await eventPatterns.click(); await eventPatterns.click();
await page.getByRole('option').filter({ hasText: 'group.*' }).click(); await page.getByRole('option').filter({ hasText: 'group.*' }).click();
await page await page
.getByRole('option') .getByRole('button', { name: 'Remove event', exact: true })
.filter({ hasText: 'message.received' }) .first()
.click(); .click();
await page.keyboard.press('Escape'); await page.keyboard.press('Escape');
await forceFormSubmit(page, '#agent-form'); await forceFormSubmit(page, '#agent-form');
+12 -2
View File
@@ -725,10 +725,12 @@ async function handleBackendApi(route: Route, state: LangBotApiMockState) {
return fulfillJson(route, { agents: state.pipelines }); return fulfillJson(route, { agents: state.pipelines });
} }
const agentDebugMatch = path.match(/^\/api\/v1\/agents\/([^/]+)\/debug$/); const agentDebugMatch = path.match(
/^\/api\/v1\/agents\/([^/]+)\/debug(?:\/stream)?$/,
);
if (agentDebugMatch) { if (agentDebugMatch) {
const payload = parseJsonBody(route); const payload = parseJsonBody(route);
return fulfillJson(route, { const result = {
event_id: nextId(state, 'event'), event_id: nextId(state, 'event'),
event_type: String(payload.event_type || 'message.received'), event_type: String(payload.event_type || 'message.received'),
conversation_id: String(payload.conversation_id || 'debug-session'), conversation_id: String(payload.conversation_id || 'debug-session'),
@@ -740,8 +742,16 @@ async function handleBackendApi(route: Route, state: LangBotApiMockState) {
text: 'Mock Agent response', text: 'Mock Agent response',
}, },
], ],
};
if (path.endsWith('/stream')) {
return route.fulfill({
status: 200,
contentType: 'application/x-ndjson',
body: JSON.stringify({ kind: 'completed', data: result }) + '\n',
}); });
} }
return fulfillJson(route, result);
}
const agentMatch = path.match(/^\/api\/v1\/agents\/([^/]+)$/); const agentMatch = path.match(/^\/api\/v1\/agents\/([^/]+)$/);
if (agentMatch) { if (agentMatch) {
+1 -1
View File
@@ -11,7 +11,7 @@ const appRoutes = [
{ {
path: '/home/agents', path: '/home/agents',
heading: 'Processors', heading: 'Processors',
bodyText: 'Select an Agent or Pipeline from the sidebar', bodyText: 'Select a processor from the sidebar',
}, },
{ {
path: '/home/extensions', path: '/home/extensions',
@@ -60,8 +60,8 @@ test.describe('processor detail workbench', () => {
const appShell = page.locator('[class*="group/sidebar-wrapper"]'); const appShell = page.locator('[class*="group/sidebar-wrapper"]');
const sidebarInset = page.locator('[data-slot="sidebar-inset"]'); const sidebarInset = page.locator('[data-slot="sidebar-inset"]');
await expect(appShell).toHaveCSS('overflow', 'clip'); await expect(appShell).toHaveCSS('overflow', 'hidden');
await expect(sidebarInset).toHaveCSS('overflow', 'clip'); await expect(sidebarInset).toHaveCSS('overflow', 'hidden');
await appShell.evaluate((element) => { await appShell.evaluate((element) => {
element.scrollTop = 300; element.scrollTop = 300;
}); });
@@ -79,9 +79,7 @@ test.describe('processor detail workbench', () => {
const flow = configPanel.getByRole('tablist'); const flow = configPanel.getByRole('tablist');
await expect(flow.getByRole('tab').nth(0)).toContainText('Runner'); await expect(flow.getByRole('tab').nth(0)).toContainText('Runner');
await expect(flow.getByRole('tab').nth(1)).toContainText('Local Agent'); await expect(flow.getByRole('tab').nth(1)).toContainText('Local Agent');
await expect(flow.getByRole('tab').nth(2)).toContainText( await expect(flow.getByRole('tab').nth(2)).toContainText('Events & tools');
'Bindable Event Range',
);
await expect(flow.getByRole('tab')).toHaveCount(3); await expect(flow.getByRole('tab')).toHaveCount(3);
await expect(flow.getByText('Management')).toHaveCount(0); await expect(flow.getByText('Management')).toHaveCount(0);
@@ -126,19 +124,32 @@ test.describe('processor detail workbench', () => {
await flow.getByRole('tab').nth(2).click(); await flow.getByRole('tab').nth(2).click();
await expect( await expect(
configPanel.getByText('Bindable Event Range', { exact: true }).last(), configPanel.getByText('Events & tools', { exact: true }).last(),
).toBeVisible(); ).toBeVisible();
const eventPicker = configPanel.getByRole('combobox', { const eventPicker = configPanel.getByRole('button', {
name: 'Event Range', name: 'Add event',
exact: true,
}); });
await expect(eventPicker).toBeVisible(); await expect(eventPicker).toBeVisible();
await expect(configPanel.getByRole('textbox')).toHaveCount(0); await expect(configPanel.getByRole('textbox')).toHaveCount(1);
await expect(
configPanel.getByRole('textbox', { name: 'Search tools…' }),
).toBeVisible();
await eventPicker.click(); await eventPicker.click();
await expect( await expect(
page.getByRole('option').filter({ hasText: 'message.received' }), page.getByRole('option').filter({ hasText: 'message.received' }),
).toBeVisible(); ).toBeVisible();
await expect(page.getByRole('group', { name: 'Messages' })).toHaveCount(1); await expect(
await expect(page.getByRole('group', { name: 'Groups' })).toHaveCount(1); page.getByRole('option').filter({ hasText: 'group.*' }),
).toBeVisible();
await expect(
page
.locator('[cmdk-group-heading]')
.getByText('Messages', { exact: true }),
).toBeVisible();
await expect(
page.locator('[cmdk-group-heading]').getByText('Groups', { exact: true }),
).toBeVisible();
await page await page
.getByRole('option') .getByRole('option')
.filter({ hasText: 'message.*' }) .filter({ hasText: 'message.*' })
@@ -189,7 +200,7 @@ test.describe('processor detail workbench', () => {
} }
if ( if (
request.method() === 'POST' && request.method() === 'POST' &&
path === '/api/v1/agents/agent-workbench/debug' path === '/api/v1/agents/agent-workbench/debug/stream'
) { ) {
requests.push('debug'); requests.push('debug');
} }
@@ -237,15 +248,17 @@ test.describe('processor detail workbench', () => {
}) => { }) => {
await installLangBotApiMocks(page, { authenticated: true }); await installLangBotApiMocks(page, { authenticated: true });
await page.route( await page.route(
'**/api/v1/agents/agent-workbench/debug', '**/api/v1/agents/agent-workbench/debug/stream',
async (route) => { async (route) => {
await route.fulfill({ await route.fulfill({
status: 422, status: 200,
contentType: 'application/json', contentType: 'application/x-ndjson',
body: JSON.stringify({ body:
JSON.stringify({
kind: 'error',
code: 'dify.config_invalid', code: 'dify.config_invalid',
msg: 'api-key is required', msg: 'api-key is required',
}), }) + '\n',
}); });
}, },
); );
@@ -454,8 +467,8 @@ test.describe('processor detail workbench', () => {
const appShell = page.locator('[class*="group/sidebar-wrapper"]'); const appShell = page.locator('[class*="group/sidebar-wrapper"]');
const sidebarInset = page.locator('[data-slot="sidebar-inset"]'); const sidebarInset = page.locator('[data-slot="sidebar-inset"]');
await expect(appShell).toHaveCSS('overflow', 'clip'); await expect(appShell).toHaveCSS('overflow', 'hidden');
await expect(sidebarInset).toHaveCSS('overflow', 'clip'); await expect(sidebarInset).toHaveCSS('overflow', 'hidden');
await expect await expect
.poll(() => appShell.evaluate((element) => element.scrollTop)) .poll(() => appShell.evaluate((element) => element.scrollTop))
.toBe(0); .toBe(0);