Skip to content

Commit 0a35963

Browse files
Jingyi-Difyasukaminato0721
authored andcommitted
test(e2e): add publish app happy path scenario (langgenius#35503)
1 parent 4dec0f8 commit 0a35963

4 files changed

Lines changed: 76 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@apps @authenticated @core
2+
Feature: Publish app
3+
4+
Scenario: Publish a workflow app for the first time
5+
Given I am signed in as the default E2E admin
6+
And a "workflow" app has been created via API
7+
And a minimal workflow draft has been synced
8+
When I open the app from the app list
9+
And I open the publish panel
10+
And I publish the app
11+
Then the app should be marked as published
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { DifyWorld } from '../../support/world'
2+
import { Then, When } from '@cucumber/cucumber'
3+
import { expect } from '@playwright/test'
4+
5+
When('I open the publish panel', async function (this: DifyWorld) {
6+
await this.getPage().getByRole('button', { name: 'Publish' }).first().click()
7+
})
8+
9+
When('I publish the app', async function (this: DifyWorld) {
10+
await this.getPage().getByRole('button', { name: /Publish Update/ }).click()
11+
})
12+
13+
Then('the app should be marked as published', async function (this: DifyWorld) {
14+
await expect(this.getPage().getByRole('button', { name: 'Published' })).toBeVisible({ timeout: 30_000 })
15+
})
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { DifyWorld } from '../../support/world'
2+
import { Given, When } from '@cucumber/cucumber'
3+
import { expect } from '@playwright/test'
4+
import { createTestApp, syncMinimalWorkflowDraft } from '../../../support/api'
5+
6+
Given('a {string} app has been created via API', async function (this: DifyWorld, mode: string) {
7+
const app = await createTestApp(`E2E ${Date.now()}`, mode)
8+
this.createdAppIds.push(app.id)
9+
this.lastCreatedAppName = app.name
10+
})
11+
12+
Given('a minimal workflow draft has been synced', async function (this: DifyWorld) {
13+
const appId = this.createdAppIds.at(-1)!
14+
await syncMinimalWorkflowDraft(appId)
15+
})
16+
17+
When('I open the app from the app list', async function (this: DifyWorld) {
18+
const page = this.getPage()
19+
await page.goto('/apps')
20+
await expect(page.getByRole('button', { name: 'Create from Blank' })).toBeVisible()
21+
await page.getByText(this.lastCreatedAppName!).click()
22+
})

e2e/support/api.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,34 @@ export async function createTestApp(name: string, mode = 'workflow'): Promise<Ap
4343
}
4444
}
4545

46+
export async function syncMinimalWorkflowDraft(appId: string): Promise<void> {
47+
const ctx = await createApiContext()
48+
try {
49+
await ctx.post(`/console/api/apps/${appId}/workflows/draft`, {
50+
data: {
51+
graph: {
52+
nodes: [
53+
{
54+
id: '1',
55+
type: 'custom',
56+
position: { x: 80, y: 282 },
57+
data: { id: '1', type: 'start', title: 'Start', variables: [] },
58+
},
59+
],
60+
edges: [],
61+
viewport: { x: 0, y: 0, zoom: 1 },
62+
},
63+
features: {},
64+
environment_variables: [],
65+
conversation_variables: [],
66+
},
67+
})
68+
}
69+
finally {
70+
await ctx.dispose()
71+
}
72+
}
73+
4674
export async function deleteTestApp(id: string): Promise<void> {
4775
const ctx = await createApiContext()
4876
try {

0 commit comments

Comments
 (0)