/
creator.js
90 lines (81 loc) · 1.77 KB
/
creator.js
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
export function createCrudTest (context) {
const cy = context.cy
it('打开', () => {
if (context.url) {
cy.openCrud(context.url)
} else {
cy.openMenu(context)
}
})
it('翻页', () => {
// 翻页
cy.log('翻页')
cy.get('.el-pagination ul.el-pager li').contains('2').click()
cy.checkId(context, '1', false)
cy.get('.el-pagination ul.el-pager li').contains('1').click()
cy.checkId(context, '1')
})
it('添加', () => {
// 添加
cy.log('添加')
cy.openAdd(context)
// 测试添加
if (context.doAdd) {
context.doAdd(context)
}
cy.closeDialog(context)
cy.checkId(context, '1', false)
if (context.checkAdd) {
context.checkAdd(context)
}
})
if (!context.editDisabled) {
it('编辑', () => {
cy.log('编辑')
cy.openEdit(context)
if (context.doEdit) {
context.doEdit(context)
}
cy.closeDialog(context)
cy.wait(1000)
if (context.checkEdit) {
context.checkEdit(context)
}
})
}
if (!context.viewDisabled) {
it('查看', () => {
cy.log('查看')
cy.openView(context)
if (context.doView) {
context.doView(context)
}
cy.closeDialog(context)
})
}
if (!context.deleteDisabled) {
it('删除', () => {
cy.log('删除')
cy.doDelete(context)
if (context.checkDelete) {
context.checkDelete(context)
}
})
}
if (context.doSearch) {
it('查询', () => {
cy.log('查询')
context.doSearch(context)
})
}
if (context.doAfter) {
it('其他特性', () => {
cy.log('其他特性')
context.doAfter(context)
})
}
it('异常检查', () => {
cy.log('异常检查')
cy.checkError(context)
})
}