dify/e2e/features/step-definitions/agent-v2/configure.steps.ts

50 lines
1.8 KiB
TypeScript

import type { DifyWorld } from '../../support/world'
import { Given, Then, When } from '@cucumber/cucumber'
import { expect } from '@playwright/test'
import {
createTestAgent,
getAgentConfigurePath,
saveAgentComposerDraft,
} from '../../../support/agent'
Given('an Agent v2 test agent has been created via API', async function (this: DifyWorld) {
const agent = await createTestAgent()
this.createdAgentIds.push(agent.id)
this.lastCreatedAgentName = agent.name
this.lastCreatedAgentRole = agent.role
})
Given('a minimal Agent v2 composer draft has been synced', 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 saveAgentComposerDraft(agentId)
})
When('I open the Agent v2 configure page', 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 this.getPage().goto(getAgentConfigurePath(agentId))
})
Then('I should be on the Agent v2 configure page', 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(?:\\?.*)?$`),
)
})
Then('I should see the Agent v2 configure workspace', async function (this: DifyWorld) {
const page = this.getPage()
await expect(page.getByRole('region', { name: 'Configure' })).toBeVisible({ timeout: 30_000 })
await expect(page.getByRole('heading', { name: 'Configure' })).toBeVisible()
await expect(page.getByText(this.lastCreatedAgentName!)).toBeVisible()
})