dify/e2e/features/step-definitions/apps/duplicate-app.steps.ts
yyh d66de8a47b
test(e2e): harden behavior coverage and CI gates (#39043)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-16 07:32:11 +00:00

32 lines
1.3 KiB
TypeScript

import type { DifyWorld } from '../../support/world'
import { Given, When } from '@cucumber/cucumber'
import { expect } from '@playwright/test'
import { createTestApp } from '../../../support/api'
import { createE2EResourceName } from '../../../support/naming'
Given('there is an existing E2E app available for testing', async function (this: DifyWorld) {
const name = createE2EResourceName('App', 'Test')
const app = await createTestApp(name, 'completion')
this.lastCreatedAppName = app.name
this.createdAppIds.push(app.id)
})
When('I open the options menu for the last created E2E app', async function (this: DifyWorld) {
const appName = this.lastCreatedAppName
if (!appName) throw new Error('No app name stored. Run "I enter a unique E2E app name" first.')
const page = this.getPage()
const appLink = page.getByRole('link', { name: appName, exact: true })
await expect(appLink).toBeVisible()
await appLink.hover()
await page.getByRole('button', { name: `More actions for ${appName}`, exact: true }).click()
})
When('I click {string} in the app options menu', async function (this: DifyWorld, label: string) {
await this.getPage().getByRole('menuitem', { name: label }).click()
})
When('I confirm the app duplication', async function (this: DifyWorld) {
await this.getPage().getByRole('button', { name: 'Duplicate' }).click()
})