mock-flow-api.ts
1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import type { Page } from '@playwright/test'
export async function mockFlowBootstrap(page: Page) {
await page.route('**/admin/**', async (route) => {
const url = route.request().url()
if (url.includes('a=flow_version') && url.includes('m=mod')) {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
code: 1,
data: [
{
id: 1,
code: 1,
status: '1',
note: '基线版本',
},
],
}),
})
return
}
if (url.includes('a=flow_nodes') && url.includes('m=srv')) {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
code: 1,
data: {
nodes: [
{
id: 'start',
text: '开始节点',
shape: 'start',
x: 120,
y: 180,
},
{
id: 'approve',
text: '审批节点',
activity: 'approval',
shape: 'activity',
x: 320,
y: 180,
},
],
edges: [
{
source: 'start',
target: 'approve',
shape: 'flow-polyline-round',
text: '提交审批',
},
],
},
}),
})
return
}
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
code: 1,
data: {},
}),
})
})
}