From 4c6b8f9229f4b73c8c246b4a88d3a3f8c1e230f2 Mon Sep 17 00:00:00 2001 From: lif <1835304752@qq.com> Date: Thu, 9 Apr 2026 11:31:13 +0800 Subject: [PATCH] test: add e2e scenarios for app creation and sign-out (#34285) Signed-off-by: majiayu000 <1835304752@qq.com> --- e2e/features/apps/create-chatbot-app.feature | 11 ++++++++ e2e/features/apps/create-workflow-app.feature | 10 ++++++++ e2e/features/auth/sign-out.feature | 8 ++++++ .../step-definitions/apps/create-app.steps.ts | 24 ++++++++++++++++++ .../step-definitions/auth/sign-out.steps.ts | 25 +++++++++++++++++++ 5 files changed, 78 insertions(+) create mode 100644 e2e/features/apps/create-chatbot-app.feature create mode 100644 e2e/features/apps/create-workflow-app.feature create mode 100644 e2e/features/auth/sign-out.feature create mode 100644 e2e/features/step-definitions/auth/sign-out.steps.ts diff --git a/e2e/features/apps/create-chatbot-app.feature b/e2e/features/apps/create-chatbot-app.feature new file mode 100644 index 0000000000..4f506e4f40 --- /dev/null +++ b/e2e/features/apps/create-chatbot-app.feature @@ -0,0 +1,11 @@ +@apps @authenticated +Feature: Create Chatbot app + Scenario: Create a new Chatbot app and redirect to the configuration page + Given I am signed in as the default E2E admin + When I open the apps console + And I start creating a blank app + And I expand the beginner app types + And I select the "Chatbot" app type + And I enter a unique E2E app name + And I confirm app creation + Then I should land on the app configuration page diff --git a/e2e/features/apps/create-workflow-app.feature b/e2e/features/apps/create-workflow-app.feature new file mode 100644 index 0000000000..b88d94d899 --- /dev/null +++ b/e2e/features/apps/create-workflow-app.feature @@ -0,0 +1,10 @@ +@apps @authenticated +Feature: Create Workflow app + Scenario: Create a new Workflow app and redirect to the workflow editor + Given I am signed in as the default E2E admin + When I open the apps console + And I start creating a blank app + And I select the "Workflow" app type + And I enter a unique E2E app name + And I confirm app creation + Then I should land on the workflow editor diff --git a/e2e/features/auth/sign-out.feature b/e2e/features/auth/sign-out.feature new file mode 100644 index 0000000000..0f377ea133 --- /dev/null +++ b/e2e/features/auth/sign-out.feature @@ -0,0 +1,8 @@ +@auth @authenticated +Feature: Sign out + Scenario: Sign out from the apps console + Given I am signed in as the default E2E admin + When I open the apps console + And I open the account menu + And I sign out + Then I should be on the sign-in page diff --git a/e2e/features/step-definitions/apps/create-app.steps.ts b/e2e/features/step-definitions/apps/create-app.steps.ts index b8e76c6f06..6bc9ae30b6 100644 --- a/e2e/features/step-definitions/apps/create-app.steps.ts +++ b/e2e/features/step-definitions/apps/create-app.steps.ts @@ -24,6 +24,30 @@ When('I confirm app creation', async function (this: DifyWorld) { await createButton.click() }) +When('I select the {string} app type', async function (this: DifyWorld, appType: string) { + const dialog = this.getPage().getByRole('dialog') + const appTypeTitle = dialog.getByText(appType, { exact: true }) + + await expect(appTypeTitle).toBeVisible() + await appTypeTitle.click() +}) + +When('I expand the beginner app types', async function (this: DifyWorld) { + const page = this.getPage() + const toggle = page.getByRole('button', { name: 'More basic app types' }) + + await expect(toggle).toBeVisible() + await toggle.click() +}) + Then('I should land on the app editor', async function (this: DifyWorld) { await expect(this.getPage()).toHaveURL(/\/app\/[^/]+\/(workflow|configuration)(?:\?.*)?$/) }) + +Then('I should land on the workflow editor', async function (this: DifyWorld) { + await expect(this.getPage()).toHaveURL(/\/app\/[^/]+\/workflow(?:\?.*)?$/) +}) + +Then('I should land on the app configuration page', async function (this: DifyWorld) { + await expect(this.getPage()).toHaveURL(/\/app\/[^/]+\/configuration(?:\?.*)?$/) +}) diff --git a/e2e/features/step-definitions/auth/sign-out.steps.ts b/e2e/features/step-definitions/auth/sign-out.steps.ts new file mode 100644 index 0000000000..935b73c3af --- /dev/null +++ b/e2e/features/step-definitions/auth/sign-out.steps.ts @@ -0,0 +1,25 @@ +import { Then, When } from '@cucumber/cucumber' +import { expect } from '@playwright/test' +import type { DifyWorld } from '../../support/world' + +When('I open the account menu', async function (this: DifyWorld) { + const page = this.getPage() + const trigger = page.getByRole('button', { name: 'Account' }) + + await expect(trigger).toBeVisible() + await trigger.click() +}) + +When('I sign out', async function (this: DifyWorld) { + const page = this.getPage() + + await expect(page.getByText('Log out')).toBeVisible() + await page.getByText('Log out').click() +}) + +Then('I should be on the sign-in page', async function (this: DifyWorld) { + await expect(this.getPage()).toHaveURL(/\/signin/) + await expect(this.getPage().getByRole('button', { name: /^Sign in$/i })).toBeVisible({ + timeout: 30_000, + }) +})