diff --git a/e2e/features/datasets/create-dataset.feature b/e2e/features/datasets/create-dataset.feature new file mode 100644 index 00000000000000..3d39d6fea6f5ec --- /dev/null +++ b/e2e/features/datasets/create-dataset.feature @@ -0,0 +1,10 @@ +@datasets @authenticated @core +Feature: Create dataset + Scenario: Create a new empty dataset + Given I am signed in as the default E2E admin + When I open the datasets page + And I start creating a new dataset + And I select "Create an empty dataset" + And I enter a unique E2E dataset name + And I confirm dataset creation + Then I should land on the dataset document page diff --git a/e2e/features/step-definitions/datasets/create-dataset.steps.ts b/e2e/features/step-definitions/datasets/create-dataset.steps.ts new file mode 100644 index 00000000000000..dff9b93eb27dfe --- /dev/null +++ b/e2e/features/step-definitions/datasets/create-dataset.steps.ts @@ -0,0 +1,36 @@ +import type { DifyWorld } from '../../support/world' +import { Then, When } from '@cucumber/cucumber' +import { expect } from '@playwright/test' + +When('I open the datasets page', async function (this: DifyWorld) { + await this.getPage().goto('/datasets') +}) + +When('I start creating a new dataset', async function (this: DifyWorld) { + const page = this.getPage() + await expect(page.getByRole('button', { name: 'Create Dataset' })).toBeVisible() + await page.getByRole('button', { name: 'Create Dataset' }).click() +}) + +When('I select {string}', async function (this: DifyWorld, option: string) { + const page = this.getPage() + await expect(page.getByText(option)).toBeVisible() + await page.getByText(option).click() +}) + +When('I enter a unique E2E dataset name', async function (this: DifyWorld) { + const datasetName = `E2E Dataset ${Date.now()}` + this.lastCreatedDatasetName = datasetName + await this.getPage().getByPlaceholder('Dataset name').fill(datasetName) +}) + +When('I confirm dataset creation', async function (this: DifyWorld) { + const page = this.getPage() + const createButton = page.getByRole('button', { name: 'Create' }).last() + await expect(createButton).toBeEnabled() + await createButton.click() +}) + +Then('I should land on the dataset document page', async function (this: DifyWorld) { + await expect(this.getPage()).toHaveURL(/\/datasets\/[^/]+\/documents(?:\?.*)?$/) +}) diff --git a/e2e/features/support/world.ts b/e2e/features/support/world.ts index b53087171f52c5..9e6dbe2c23cf74 100644 --- a/e2e/features/support/world.ts +++ b/e2e/features/support/world.ts @@ -13,6 +13,7 @@ export class DifyWorld extends World { scenarioStartedAt: number | undefined session: AuthSessionMetadata | undefined lastCreatedAppName: string | undefined + lastCreatedDatasetName: string | undefined createdAppIds: string[] = [] capturedDownloads: Download[] = [] shareURL: string | undefined @@ -26,6 +27,7 @@ export class DifyWorld extends World { this.consoleErrors = [] this.pageErrors = [] this.lastCreatedAppName = undefined + this.lastCreatedDatasetName = undefined this.createdAppIds = [] this.capturedDownloads = [] this.shareURL = undefined