From 95102479c62526b14280e22e96f767a7a3527277 Mon Sep 17 00:00:00 2001 From: yyh <92089059+lyzno1@users.noreply.github.com> Date: Mon, 6 Jul 2026 09:03:01 +0800 Subject: [PATCH] test(e2e): split agent build draft apply coverage (#38431) --- e2e/features/agent-v2/build-draft.feature | 28 ++++++------------- .../agent-v2/support/agent-build-draft.ts | 11 ++++++++ .../agent-v2/build-draft.steps.ts | 9 +++++- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/e2e/features/agent-v2/build-draft.feature b/e2e/features/agent-v2/build-draft.feature index 9ef9cc3ab17..b3476541e34 100644 --- a/e2e/features/agent-v2/build-draft.feature +++ b/e2e/features/agent-v2/build-draft.feature @@ -75,12 +75,10 @@ Feature: Agent v2 build draft Then I should see the updated E2E prompt in the Agent v2 prompt editor And the Agent v2 Build draft should no longer be active - @external-model @agent-backend-runtime @stable-model @skill-fixture + @core @skill-fixture Scenario: Applying a Build draft updates supported configuration sections Given I am signed in as the default E2E admin - And the Agent Builder stable chat model is available - And the Agent v2 runtime backend is available - And a runnable Agent v2 test agent has been created via API + And a basic configured Agent v2 test agent has been created via API And an Agent v2 Build draft adds the supported E2E files, skills, and env When I open the Agent v2 configure page Then I should see the Agent v2 Build draft pending changes @@ -89,13 +87,8 @@ Feature: Agent v2 build draft And I should see the e2e-summary-skill Skill in the Skills section And I should see the supported E2E environment variable in Advanced Settings And the normal Agent v2 draft should still use the normal E2E prompt - When I apply the Agent v2 Build draft - Then I should see the updated E2E prompt in the Agent v2 prompt editor - And I should see the small Agent v2 file in the Files section - And I should see the e2e-summary-skill Skill in the Skills section - And I should see the supported E2E environment variable in Advanced Settings - And the Agent v2 draft should include the supported Build draft config - And the Agent v2 Build draft should no longer be active + When I apply the Agent v2 Build draft via API + Then the Agent v2 draft should include the supported Build draft config When I refresh the current page Then I should see the updated E2E prompt in the Agent v2 prompt editor And I should see the small Agent v2 file in the Files section @@ -103,24 +96,21 @@ Feature: Agent v2 build draft And I should see the supported E2E environment variable in Advanced Settings And the Agent v2 Build draft should no longer be active - @external-model @agent-backend-runtime @stable-model @skill-fixture + @core @skill-fixture Scenario: Applying a Build draft with an existing Skill keeps a single Skill entry Given I am signed in as the default E2E admin - And the Agent Builder stable chat model is available - And the Agent v2 runtime backend is available - And a runnable Agent v2 test agent has been created via API + And a basic configured Agent v2 test agent has been created via API And an Agent v2 Build draft includes the existing e2e-summary-skill Skill When I open the Agent v2 configure page Then I should see the Agent v2 Build draft pending changes And I should see one e2e-summary-skill Skill in the Skills section And the Agent v2 draft should include one e2e-summary-skill Skill - When I apply the Agent v2 Build draft - Then I should see one e2e-summary-skill Skill in the Skills section - And the Agent v2 draft should include one e2e-summary-skill Skill - And the Agent v2 Build draft should no longer be active + When I apply the Agent v2 Build draft via API + Then the Agent v2 draft should include one e2e-summary-skill Skill When I refresh the current page Then I should see one e2e-summary-skill Skill in the Skills section And the Agent v2 draft should include one e2e-summary-skill Skill + And the Agent v2 Build draft should no longer be active @core Scenario: Pending Build draft remains protected after leaving Configure diff --git a/e2e/features/agent-v2/support/agent-build-draft.ts b/e2e/features/agent-v2/support/agent-build-draft.ts index 68227e39d5f..3e65cd4f75d 100644 --- a/e2e/features/agent-v2/support/agent-build-draft.ts +++ b/e2e/features/agent-v2/support/agent-build-draft.ts @@ -39,6 +39,17 @@ export async function saveAgentBuildDraft( } } +export async function applyAgentBuildDraft(agentId: string): Promise { + const ctx = await createApiContext() + try { + const response = await ctx.post(`/console/api/agent/${agentId}/build-draft/apply`) + await expectApiResponseOK(response, `Apply Agent v2 build draft for ${agentId}`) + } + finally { + await ctx.dispose() + } +} + export async function discardAgentBuildDraft(agentId: string): Promise { const ctx = await createApiContext() try { diff --git a/e2e/features/step-definitions/agent-v2/build-draft.steps.ts b/e2e/features/step-definitions/agent-v2/build-draft.steps.ts index b9e5ff7335b..9443197e6e8 100644 --- a/e2e/features/step-definitions/agent-v2/build-draft.steps.ts +++ b/e2e/features/step-definitions/agent-v2/build-draft.steps.ts @@ -7,7 +7,10 @@ import { getAgentComposerDraft, saveAgentComposerDraft, } from '../../agent-v2/support/agent' -import { saveAgentBuildDraft } from '../../agent-v2/support/agent-build-draft' +import { + applyAgentBuildDraft, + saveAgentBuildDraft, +} from '../../agent-v2/support/agent-build-draft' import { agentBuilderFixedInputs, agentBuilderPreseededResources } from '../../agent-v2/support/agent-builder-resources' import { uploadAgentConfigFileToDraft } from '../../agent-v2/support/agent-drive' import { @@ -184,6 +187,10 @@ When( }, ) +When('I apply the Agent v2 Build draft via API', async function (this: DifyWorld) { + await applyAgentBuildDraft(getCurrentAgentId(this)) +}) + async function skipBuildDraftToolWriteback(world: DifyWorld) { return skipBlockedPrecondition( world,