From 1340bef096627cc301d59412a8da5b6949e5b563 Mon Sep 17 00:00:00 2001 From: yyh <92089059+lyzno1@users.noreply.github.com> Date: Wed, 8 Jul 2026 18:32:57 +0800 Subject: [PATCH] test: scope agent build draft e2e selector (#38563) --- .../step-definitions/agent-v2/build-draft.steps.ts | 11 +++++++---- .../components/orchestrate/build-draft-bar.tsx | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) 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 87901434035..7a4c738ea73 100644 --- a/e2e/features/step-definitions/agent-v2/build-draft.steps.ts +++ b/e2e/features/step-definitions/agent-v2/build-draft.steps.ts @@ -1,4 +1,4 @@ -import type { Response } from '@playwright/test' +import type { Page, Response } from '@playwright/test' import type { DifyWorld } from '../../support/world' import { readFile } from 'node:fs/promises' import { Given, Then, When } from '@cucumber/cucumber' @@ -34,6 +34,9 @@ import { const BUILD_DRAFT_RUNTIME_STEP_TIMEOUT_MS = 180_000 +const getBuildDraftBar = (page: Page) => + page.getByRole('group', { name: 'Build draft' }) + Given( 'an Agent v2 Build draft adds the supported E2E files, skills, and env', async function (this: DifyWorld) { @@ -138,7 +141,7 @@ When( await page.getByRole('button', { name: 'Start build' }).click() expect((await checkoutResponsePromise).ok()).toBe(true) expect((await chatResponsePromise).ok()).toBe(true) - await expect(page.getByText('Build draft')).toBeVisible({ timeout: 120_000 }) + await expect(getBuildDraftBar(page)).toBeVisible({ timeout: 120_000 }) await expect(page.getByRole('button', { exact: true, name: 'Apply' })).toBeEnabled({ timeout: 120_000 }) await expect(page.getByRole('button', { exact: true, name: 'Discard' })).toBeEnabled() }, @@ -245,7 +248,7 @@ Then('Agent v2 Build chat unavailable Skill and Tool recovery should be availabl Then('I should see the Agent v2 Build draft pending changes', async function (this: DifyWorld) { const page = this.getPage() - await expect(page.getByText('Build draft')).toBeVisible({ timeout: 30_000 }) + await expect(getBuildDraftBar(page)).toBeVisible({ timeout: 30_000 }) await expect(page.getByRole('button', { exact: true, name: 'Apply' })).toBeEnabled() await expect(page.getByRole('button', { exact: true, name: 'Discard' })).toBeEnabled() }) @@ -401,7 +404,7 @@ Then( Then('the Agent v2 Build draft should no longer be active', async function (this: DifyWorld) { const page = this.getPage() - await expect(page.getByText('Build draft')).not.toBeVisible() + await expect(getBuildDraftBar(page)).not.toBeVisible() await expect(page.getByRole('button', { name: 'Apply' })).not.toBeVisible() await expect(page.getByRole('button', { name: 'Discard' })).not.toBeVisible() }) diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/build-draft-bar.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/build-draft-bar.tsx index f053d47287d..c3284e75b1c 100644 --- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/build-draft-bar.tsx +++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/build-draft-bar.tsx @@ -55,6 +55,8 @@ export function AgentBuildDraftBar({