-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.ts
128 lines (101 loc) · 3.22 KB
/
home.ts
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import {
Rig
} from '../../../rig';
import { topic } from '../fixtures';
export default class Home {
private static selectField = (field: string) =>
cy.get('topic-form')
.contains(field)
.parent()
.parent()
.click({ force: true });
private static inputField = (field: string, input: string) =>
this.selectField(field)
.clear()
.type(input);
private static selectTopic = (name: string) =>
cy.get('async-source topic-card')
.contains(name)
.parentsUntil('topic-card');
private static clickTopicButton = (name: string, idx: number) =>
this.selectTopic(name)
.find('button')
.eq(idx)
.click();
private static save = () =>
cy.get('topic-editor')
.contains('Save')
.click({ force: true });
private static add = (name: string, description: string) =>
it(`Add Topic ${name}`, () => {
this.inputField('Name', name);
this.inputField('Description', description);
this.save();
cy.wait(1000);
this.clickTopicButton(name, 0);
})
private static edit = (name: string, update: string) =>
it(`Edit Topic ${name} -> ${update}`, () => {
this.clickTopicButton(name, 0);
this.inputField('Name', update);
this.save();
cy.wait(1000);
})
private static delete = (name: string) =>
it(`Delete Topic ${name}`, () => {
this.clickTopicButton(name, 1);
cy.get('mat-dialog-actions')
.find('button')
.eq(1)
.click();
})
private static init = (rig: Rig) => {
before(() => {
cy.then(() =>
rig.initializeDatabase().then(() =>
cy.log('Database initialized')
)
);
cy.then(() =>
rig.startProcess().then(() =>
cy.log('API Process started')
)
);
cy.then(() =>
rig.seed(topic, 'seedTopic').then(() =>
cy.log('Topic seeded')
)
);
});
after(() => {
cy.then(() =>
rig.killProcess().then(() =>
cy.log('API Process disposed')
)
);
cy.then(() =>
rig.destroyDatabase().then(() =>
cy.log('Database disposed')
)
);
});
}
static test = () =>
describe('Brainstorm Test', () => {
const rig = new Rig();
this.init(rig);
it('Navigates to Home', () => {
cy.visit('/')
.contains('Brainstorm');
cy.wait(2400);
});
this.add('Reminder', 'Things that you should remember');
this.edit('Reminder', 'Remember');
this.delete('Remember');
it ('Captures Home', () => {
cy.screenshot('brainstorm', {
capture: 'fullPage'
});
});
});
}