Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

test(e2e): stabilize Agent access toggles (#41282)

yyh06482af260b5
diff --git a/e2e/features/step-definitions/agent-v2/access-point.steps.ts b/e2e/features/step-definitions/agent-v2/access-point.steps.ts
index 1490f252cfa..38706e41a7d 100644
--- a/e2e/features/step-definitions/agent-v2/access-point.steps.ts
+++ b/e2e/features/step-definitions/agent-v2/access-point.steps.ts
@@ -11,6 +11,34 @@ import {
getWebAppCard,
} from './access-point-helpers'
+const toggleAgentAccess = async (
+ world: DifyWorld,
+ surface: AccessSurfaceName,
+ enabled: boolean,
+) => {
+ const agentId = getCurrentAgentId(world)
+ const client = world.getConsoleClient()
+ const toggle = getAccessSurfaceCard(world, surface).getByLabel(`Toggle ${surface} access`)
+
+ await expect(toggle).toBeEnabled()
+ await toggle.click()
+ await expect(toggle).toHaveAttribute('aria-checked', String(enabled))
+
+ await expect
+ .poll(async () => {
+ if (surface === 'Web app') {
+ const agent = await client.agent.byAgentId.get({ params: { agent_id: agentId } })
+ return agent.enable_site
+ }
+
+ const apiAccess = await client.agent.byAgentId.apiAccess.get({
+ params: { agent_id: agentId },
+ })
+ return apiAccess.enabled
+ })
+ .toBe(enabled)
+}
+
Given('the Agent v2 draft has been published via API', async function (this: DifyWorld) {
await publishAgentWithPublishableDraft(this.getConsoleClient(), getCurrentAgentId(this))
})
@@ -73,14 +101,14 @@ When(
this.agentBuilder.accessPoint.webAppURL = href
}
- await accessSurfaceCard.getByLabel(`Toggle ${surface} access`).click()
+ await toggleAgentAccess(this, surface, false)
},
)
When(
/^I enable Agent v2 (Web app|Backend service API) access$/,
async function (this: DifyWorld, surface: AccessSurfaceName) {
- await getAccessSurfaceCard(this, surface).getByLabel(`Toggle ${surface} access`).click()
+ await toggleAgentAccess(this, surface, true)
},
)
@@ -88,8 +116,11 @@ Then(
/^Agent v2 (Web app|Backend service API) access should be out of service$/,
async function (this: DifyWorld, surface: AccessSurfaceName) {
const accessSurfaceCard = getAccessSurfaceCard(this, surface)
+ const toggle = accessSurfaceCard.getByLabel(`Toggle ${surface} access`)
await expect(accessSurfaceCard.getByText('Out of service')).toBeVisible({ timeout: 30_000 })
+ await expect(toggle).toBeEnabled()
+ await expect(toggle).toHaveAttribute('aria-checked', 'false')
if (surface === 'Web app')
await expect(accessSurfaceCard.getByRole('button', { name: 'Launch' })).toBeDisabled()
},
@@ -99,8 +130,11 @@ Then(
/^Agent v2 (Web app|Backend service API) access should be in service$/,
async function (this: DifyWorld, surface: AccessSurfaceName) {
const accessSurfaceCard = getAccessSurfaceCard(this, surface)
+ const toggle = accessSurfaceCard.getByLabel(`Toggle ${surface} access`)
await expect(accessSurfaceCard.getByText('In service')).toBeVisible({ timeout: 30_000 })
+ await expect(toggle).toBeEnabled()
+ await expect(toggle).toHaveAttribute('aria-checked', 'true')
if (surface === 'Web app')
await expect(accessSurfaceCard.getByRole('link', { name: 'Launch' })).toBeVisible()
},