dify/e2e/features/step-definitions/agent-v2/preflight.steps.ts
yyh 1ae2f95f7c
test(e2e): add agent v2 core coverage (#38209)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-02 06:18:38 +00:00

212 lines
7.3 KiB
TypeScript

import type { DifyWorld } from '../../support/world'
import { Given } from '@cucumber/cucumber'
import {
skipMissingPreseededAgentBackendApiKey,
skipMissingPreseededAgentPublishedWebApp,
skipMissingPreseededAgentWorkflowReference,
} from '../../agent-v2/support/preflight/access'
import {
skipMissingPreseededAgent,
skipMissingPreseededAgentDriveSkill,
skipMissingPreseededAgentFileTreeFixture,
skipMissingPreseededAgentFlatFileFixtureConfiguration,
skipMissingPreseededDualRetrievalAgentConfiguration,
skipMissingPreseededFullConfigAgentCoreConfiguration,
skipMissingPreseededToolStatesAgentConfiguration,
skipMissingPreseededWorkflow,
} from '../../agent-v2/support/preflight/agents'
import {
skipMissingIndexingPreseededDataset,
skipMissingPreseededDataset,
skipMissingReadyPreseededDataset,
} from '../../agent-v2/support/preflight/datasets'
import {
skipMissingAgentBuilderBrokenChatModel,
skipMissingAgentBuilderStableChatModel,
} from '../../agent-v2/support/preflight/models'
import { skipMissingPreseededTool } from '../../agent-v2/support/preflight/tools'
Given('the Agent Builder stable chat model is available', async function (this: DifyWorld) {
const stableModel = await skipMissingAgentBuilderStableChatModel(this)
if (stableModel === 'skipped')
return stableModel
this.agentBuilder.preflight.stableModel = stableModel
})
Given('the Agent Builder broken chat model is available', async function (this: DifyWorld) {
const brokenModel = await skipMissingAgentBuilderBrokenChatModel(this)
if (brokenModel === 'skipped')
return brokenModel
this.agentBuilder.preflight.brokenModel = brokenModel
})
Given(
'the Agent Builder preseeded Agent {string} is available',
async function (this: DifyWorld, resourceName: string) {
const resource = await skipMissingPreseededAgent(this, resourceName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[resourceName] = resource
},
)
Given(
'the Agent Builder preseeded workflow {string} is available',
async function (this: DifyWorld, resourceName: string) {
const resource = await skipMissingPreseededWorkflow(this, resourceName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[resourceName] = resource
},
)
Given(
'the Agent Builder preseeded dataset {string} is available',
async function (this: DifyWorld, resourceName: string) {
const resource = await skipMissingPreseededDataset(this, resourceName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[resourceName] = resource
},
)
Given(
'the Agent Builder preseeded dataset {string} is indexed and ready',
async function (this: DifyWorld, resourceName: string) {
const resource = await skipMissingReadyPreseededDataset(this, resourceName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[resourceName] = resource
},
)
Given(
'the Agent Builder preseeded dataset {string} is indexing',
async function (this: DifyWorld, resourceName: string) {
const resource = await skipMissingIndexingPreseededDataset(this, resourceName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[resourceName] = resource
},
)
Given(
'the Agent Builder preseeded tool {string} is available',
async function (this: DifyWorld, resourceName: string) {
const resource = await skipMissingPreseededTool(this, resourceName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[resourceName] = resource
},
)
Given(
'the Agent Builder preseeded Agent {string} includes drive skill {string}',
async function (this: DifyWorld, agentName: string, skillName: string) {
const resource = await skipMissingPreseededAgentDriveSkill(this, agentName, skillName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[`${agentName} / ${skillName}`] = resource
},
)
Given(
'the Agent Builder preseeded Agent {string} includes the core fixture configuration',
async function (this: DifyWorld, agentName: string) {
const resource = await skipMissingPreseededFullConfigAgentCoreConfiguration(this, agentName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[`${agentName} / core fixture configuration`] = resource
},
)
Given(
'the Agent Builder preseeded Agent {string} includes the tool state fixture configuration',
async function (this: DifyWorld, agentName: string) {
const resource = await skipMissingPreseededToolStatesAgentConfiguration(this, agentName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[`${agentName} / tool state fixture configuration`]
= resource
},
)
Given(
'the Agent Builder preseeded Agent {string} includes the dual retrieval fixture configuration',
async function (this: DifyWorld, agentName: string) {
const resource = await skipMissingPreseededDualRetrievalAgentConfiguration(this, agentName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[`${agentName} / dual retrieval fixture configuration`]
= resource
},
)
Given(
'the Agent Builder preseeded Agent {string} includes the file tree fixture files',
async function (this: DifyWorld, agentName: string) {
const resource = await skipMissingPreseededAgentFileTreeFixture(this, agentName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[`${agentName} / file tree fixture`] = resource
},
)
Given(
'the Agent Builder preseeded Agent {string} includes the current flat file fixture configuration',
async function (this: DifyWorld, agentName: string) {
const resource = await skipMissingPreseededAgentFlatFileFixtureConfiguration(this, agentName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[`${agentName} / flat file fixture configuration`]
= resource
},
)
Given(
'the Agent Builder preseeded Agent {string} has Backend service API access with an API key',
async function (this: DifyWorld, agentName: string) {
const resource = await skipMissingPreseededAgentBackendApiKey(this, agentName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[`${agentName} / Backend service API key`] = resource
},
)
Given(
'the Agent Builder preseeded Agent {string} has published Web app access',
async function (this: DifyWorld, agentName: string) {
const resource = await skipMissingPreseededAgentPublishedWebApp(this, agentName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[`${agentName} / Web app`] = resource
},
)
Given(
'the Agent Builder preseeded Agent {string} is referenced by workflow {string}',
async function (this: DifyWorld, agentName: string, workflowName: string) {
const resource = await skipMissingPreseededAgentWorkflowReference(this, agentName, workflowName)
if (resource === 'skipped')
return resource
this.agentBuilder.preflight.preseededResources[`${agentName} / ${workflowName}`] = resource
},
)