forked from alan2207/bulletproof-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smoke.ts
211 lines (166 loc) · 4.71 KB
/
smoke.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
import {
userGenerator,
discussionGenerator,
commentGenerator,
} from '../../src/test/data-generators';
describe('smoke', () => {
it('should handle normal app flow', () => {
const user = userGenerator();
const discussion = discussionGenerator();
// registration:
cy.visit('http://localhost:3000/auth/register');
cy.findByRole('textbox', {
name: /first name/i,
}).type(user.firstName);
cy.findByRole('textbox', {
name: /last name/i,
}).type(user.lastName);
cy.findByRole('textbox', {
name: /email address/i,
}).type(user.email);
cy.findByLabelText(/password/i).type(user.password);
cy.findByRole('textbox', {
name: /team name/i,
}).type(user.teamName);
cy.findByRole('button', {
name: /register/i,
}).click();
cy.findByRole('heading', {
name: `Welcome ${user.firstName} ${user.lastName}`,
}).should('exist');
// log out:
cy.findByRole('button', {
name: /open user menu/i,
}).click();
cy.findByRole('menuitem', {
name: /sign out/i,
}).click();
// log in:
cy.visit('http://localhost:3000/auth/login');
cy.findByRole('textbox', {
name: /email address/i,
}).type(user.email);
cy.findByLabelText(/password/i).type(user.password);
cy.findByRole('button', {
name: /log in/i,
}).click();
cy.findByRole('heading', {
name: `Welcome ${user.firstName} ${user.lastName}`,
}).should('exist');
cy.findByRole('link', {
name: /discussions/i,
}).click();
// create discussion:
cy.findByRole('button', {
name: /create discussion/i,
}).click();
cy.findByRole('dialog').within(() => {
cy.findByRole('textbox', {
name: /title/i,
}).type(discussion.title);
cy.findByRole('textbox', {
name: /body/i,
}).type(discussion.body);
cy.findByRole('button', {
name: /submit/i,
}).click();
});
cy.checkAndDismissNotification(/discussion created/i);
cy.findByRole('dialog').should('not.exist');
cy.wait(200);
// visit discussion page:
cy.findByRole('link', {
name: /view/i,
}).click();
cy.findByRole('heading', {
name: discussion.title,
}).should('exist');
// update discussion:
cy.findByRole('button', {
name: /update discussion/i,
}).click();
const updatedDiscussion = discussionGenerator();
cy.findByRole('dialog').within(() => {
cy.findByRole('textbox', {
name: /title/i,
})
.clear()
.type(updatedDiscussion.title);
cy.findByRole('textbox', {
name: /body/i,
})
.clear()
.type(updatedDiscussion.body);
cy.findByRole('button', {
name: /submit/i,
}).click();
});
cy.checkAndDismissNotification(/discussion updated/i);
cy.findByRole('heading', {
name: updatedDiscussion.title,
}).should('exist');
// create comment:
const comment = commentGenerator();
cy.findByRole('button', {
name: /create comment/i,
}).click();
cy.findByRole('dialog').within(() => {
cy.findByRole('textbox', {
name: /body/i,
}).type(comment.body, { force: true }); // for some reason it requires force to be set to true
cy.findByRole('button', {
name: /submit/i,
}).click();
});
cy.checkAndDismissNotification(/comment created/i);
cy.findByRole('list', {
name: 'comments',
}).within(() => {
cy.findByText(comment.body).should('exist');
});
cy.wait(200);
// delete comment:
cy.findByRole('list', {
name: 'comments',
}).within(() => {
cy.findByRole('listitem', {
name: `comment-${comment.body}-0`,
}).within(() => {
cy.findByRole('button', {
name: /delete comment/i,
}).click();
});
});
cy.findByRole('dialog').within(() => {
cy.findByRole('button', {
name: /delete comment/i,
}).click();
});
cy.wait(200);
cy.checkAndDismissNotification(/comment deleted/i);
cy.findByRole('list', {
name: 'comments',
}).within(() => {
cy.findByText(comment.body).should('not.exist');
});
// go back to discussions list:
cy.findByRole('link', {
name: /discussions/i,
}).click();
cy.wait(200);
// delete discussion:
cy.findByRole('button', {
name: /delete discussion/i,
}).click();
cy.findByRole('dialog').within(() => {
cy.findByRole('button', {
name: /delete discussion/i,
}).click();
});
cy.checkAndDismissNotification(/discussion deleted/i);
cy.wait(200);
cy.findByRole('cell', {
name: updatedDiscussion.title,
}).should('not.exist');
});
});