dify/e2e/features/step-definitions/agent-v2/agent-roster.steps.ts
yyh 1b3e8e9943
chore(agent-v2): sync daily changes (#38298)
Signed-off-by: yyh <yuanyouhuilyz@gmail.com>
Co-authored-by: 盐粒 Yanli <mail@yanli.one>
Co-authored-by: Joel <iamjoel007@gmail.com>
Co-authored-by: zyssyz123 <916125788@qq.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: 盐粒 Yanli <yanli@dify.ai>
Co-authored-by: 林玮 (Jade Lin) <linw1995@icloud.com>
2026-07-05 08:09:38 +00:00

49 lines
2.1 KiB
TypeScript

import type { AgentAppDetailWithSite } from '@dify/contracts/api/console/agent/types.gen'
import type { DifyWorld } from '../../support/world'
import { Then, When } from '@cucumber/cucumber'
import { expect } from '@playwright/test'
import { createE2EResourceName } from '../../../support/naming'
When('I create an Agent v2 test agent from the Agent Roster', async function (this: DifyWorld) {
const page = this.getPage()
const agentName = createE2EResourceName('Agent', 'roster-ui')
const agentRole = 'E2E roster-created assistant'
const agentDescription = 'Created by Dify E2E through the Agent Roster UI.'
await page.goto('/roster')
await page.getByRole('button', { name: 'Create agent' }).click()
const dialog = page.getByRole('dialog', { name: 'Create agent' })
await expect(dialog).toBeVisible()
await dialog.getByRole('textbox', { name: 'Name' }).fill(agentName)
await dialog.getByRole('textbox', { name: /Role.*optional/ }).fill(agentRole)
await dialog.getByRole('textbox', { name: /Description.*optional/ }).fill(agentDescription)
const createResponsePromise = page.waitForResponse(response => (
response.request().method() === 'POST'
&& new URL(response.url()).pathname.endsWith('/console/api/agent')
))
await dialog.getByRole('button', { name: 'Create' }).click()
const createResponse = await createResponsePromise
expect(createResponse.ok()).toBe(true)
const createdAgent = await createResponse.json() as AgentAppDetailWithSite
this.createdAgentIds.push(createdAgent.id)
this.lastCreatedAgentName = createdAgent.name
this.lastCreatedAgentRole = createdAgent.role ?? undefined
})
Then('the created Agent v2 should open in Configure', async function (this: DifyWorld) {
const agentId = this.createdAgentIds.at(-1)
if (!agentId)
throw new Error('No Agent v2 ID found. Create an Agent v2 test agent first.')
await expect(this.getPage()).toHaveURL(
new RegExp(`/roster/agent/${agentId}/configure(?:\\?.*)?$`),
{ timeout: 30_000 },
)
await expect(this.getPage().getByRole('heading', { name: 'Configure' }))
.toBeVisible({ timeout: 30_000 })
})