@@ -18,13 +18,16 @@ void surveyQuestionsScreenTest() {
18
18
late Finder questionIndicator;
19
19
late Finder questionText;
20
20
late Finder nextQuestionButton;
21
+ late Finder submitButton;
21
22
late Finder answerDropdown;
22
23
late Finder answerRating;
23
24
late Finder answerEmoji;
24
25
late Finder answerSmiley;
25
26
late Finder answerNps;
26
27
late Finder answerTextArea;
27
28
late Finder answerForm;
29
+ late Finder answerMultipleChoices;
30
+ late Finder quitSurveyConfirmationDialog;
28
31
29
32
setUpAll (() async {
30
33
await TestUtil .setupTestEnvironment ();
@@ -38,13 +41,18 @@ void surveyQuestionsScreenTest() {
38
41
questionText = find.byKey (SurveyQuestionsWidgetId .questionText);
39
42
nextQuestionButton =
40
43
find.byKey (SurveyQuestionsWidgetId .nextQuestionButton);
44
+ submitButton = find.byKey (SurveyQuestionsWidgetId .submitButton);
41
45
answerDropdown = find.byKey (SurveyQuestionsWidgetId .answersDropdown);
42
46
answerRating = find.byKey (SurveyQuestionsWidgetId .answersRating);
43
47
answerEmoji = find.byKey (SurveyQuestionsWidgetId .answersEmoji);
44
48
answerSmiley = find.byKey (SurveyQuestionsWidgetId .answersSmiley);
45
49
answerNps = find.byKey (SurveyQuestionsWidgetId .answersNps);
46
50
answerTextArea = find.byKey (SurveyQuestionsWidgetId .answersTextArea);
47
51
answerForm = find.byKey (SurveyQuestionsWidgetId .answersForm);
52
+ answerMultipleChoices =
53
+ find.byKey (SurveyQuestionsWidgetId .answersMultipleChoices);
54
+ quitSurveyConfirmationDialog =
55
+ find.byKey (SurveyQuestionsWidgetId .quitSurveyConfirmationDialog);
48
56
});
49
57
50
58
Future nextQuestionTest (
@@ -86,6 +94,8 @@ void surveyQuestionsScreenTest() {
86
94
expect (answerNps, findsNothing);
87
95
expect (answerTextArea, findsNothing);
88
96
expect (answerForm, findsNothing);
97
+ expect (answerMultipleChoices, findsNothing);
98
+ expect (quitSurveyConfirmationDialog, findsNothing);
89
99
});
90
100
91
101
testWidgets (
@@ -133,69 +143,123 @@ void surveyQuestionsScreenTest() {
133
143
await answerTest (answerNps, findsNothing);
134
144
await answerTest (answerTextArea, findsNothing);
135
145
await answerTest (answerForm, findsNothing);
146
+ await answerTest (answerMultipleChoices, findsOneWidget);
147
+ await answerTest (nextQuestionButton, findsOneWidget);
148
+ await answerTest (submitButton, findsNothing);
136
149
137
150
await nextQuestionTest (tester, '3/12' );
138
151
await answerTest (answerDropdown, findsNothing);
139
152
await answerTest (answerEmoji, findsNothing);
140
153
await answerTest (answerNps, findsNothing);
141
154
await answerTest (answerTextArea, findsNothing);
142
155
await answerTest (answerForm, findsNothing);
156
+ await answerTest (answerMultipleChoices, findsOneWidget);
157
+ await answerTest (nextQuestionButton, findsOneWidget);
158
+ await answerTest (submitButton, findsNothing);
143
159
144
160
await nextQuestionTest (tester, '4/12' );
145
161
await answerTest (answerDropdown, findsNothing);
146
162
await answerTest (answerEmoji, findsNothing);
147
163
await answerTest (answerNps, findsOneWidget);
148
164
await answerTest (answerTextArea, findsNothing);
149
165
await answerTest (answerForm, findsNothing);
166
+ await answerTest (answerMultipleChoices, findsNothing);
167
+ await answerTest (nextQuestionButton, findsOneWidget);
168
+ await answerTest (submitButton, findsNothing);
150
169
151
170
await nextQuestionTest (tester, '5/12' );
152
171
await answerTest (answerDropdown, findsNothing);
153
172
await answerTest (answerEmoji, findsOneWidget);
154
173
await answerTest (answerNps, findsNothing);
155
174
await answerTest (answerTextArea, findsNothing);
156
175
await answerTest (answerForm, findsNothing);
176
+ await answerTest (answerMultipleChoices, findsNothing);
177
+ await answerTest (nextQuestionButton, findsOneWidget);
178
+ await answerTest (submitButton, findsNothing);
157
179
158
180
await nextQuestionTest (tester, '6/12' );
159
181
await answerTest (answerDropdown, findsNothing);
160
182
await answerTest (answerEmoji, findsOneWidget);
161
183
await answerTest (answerNps, findsNothing);
162
184
await answerTest (answerTextArea, findsNothing);
163
185
await answerTest (answerForm, findsNothing);
186
+ await answerTest (answerMultipleChoices, findsNothing);
187
+ await answerTest (nextQuestionButton, findsOneWidget);
188
+ await answerTest (submitButton, findsNothing);
164
189
165
190
await nextQuestionTest (tester, '7/12' );
166
191
await answerTest (answerDropdown, findsNothing);
167
192
await answerTest (answerEmoji, findsOneWidget);
168
193
await answerTest (answerNps, findsNothing);
169
194
await answerTest (answerTextArea, findsNothing);
170
195
await answerTest (answerForm, findsNothing);
196
+ await answerTest (answerMultipleChoices, findsNothing);
197
+ await answerTest (nextQuestionButton, findsOneWidget);
198
+ await answerTest (submitButton, findsNothing);
171
199
172
200
await nextQuestionTest (tester, '8/12' );
173
201
await answerTest (answerDropdown, findsNothing);
174
202
await answerTest (answerEmoji, findsOneWidget);
175
203
await answerTest (answerNps, findsNothing);
176
204
await answerTest (answerTextArea, findsNothing);
177
205
await answerTest (answerForm, findsNothing);
206
+ await answerTest (answerMultipleChoices, findsNothing);
207
+ await answerTest (nextQuestionButton, findsOneWidget);
208
+ await answerTest (submitButton, findsNothing);
178
209
179
210
await nextQuestionTest (tester, '9/12' );
180
211
await answerTest (answerDropdown, findsNothing);
181
212
await answerTest (answerEmoji, findsNothing);
182
213
await answerTest (answerNps, findsNothing);
183
214
await answerTest (answerTextArea, findsOneWidget);
184
215
await answerTest (answerForm, findsNothing);
216
+ await answerTest (answerMultipleChoices, findsNothing);
217
+ await answerTest (nextQuestionButton, findsOneWidget);
218
+ await answerTest (submitButton, findsNothing);
185
219
186
220
await nextQuestionTest (tester, '10/12' );
187
221
await answerTest (answerDropdown, findsOneWidget);
188
222
await answerTest (answerEmoji, findsNothing);
189
223
await answerTest (answerNps, findsNothing);
190
224
await answerTest (answerTextArea, findsNothing);
191
225
await answerTest (answerForm, findsNothing);
226
+ await answerTest (answerMultipleChoices, findsNothing);
227
+ await answerTest (nextQuestionButton, findsOneWidget);
228
+ await answerTest (submitButton, findsNothing);
192
229
193
230
await nextQuestionTest (tester, '11/12' );
194
231
await answerTest (answerDropdown, findsNothing);
195
232
await answerTest (answerEmoji, findsNothing);
196
233
await answerTest (answerNps, findsNothing);
197
234
await answerTest (answerTextArea, findsNothing);
198
235
await answerTest (answerForm, findsOneWidget);
236
+ await answerTest (answerMultipleChoices, findsNothing);
237
+ await answerTest (nextQuestionButton, findsOneWidget);
238
+ await answerTest (submitButton, findsNothing);
239
+
240
+ await nextQuestionTest (tester, '12/12' );
241
+ await answerTest (answerDropdown, findsNothing);
242
+ await answerTest (answerEmoji, findsNothing);
243
+ await answerTest (answerNps, findsNothing);
244
+ await answerTest (answerTextArea, findsNothing);
245
+ await answerTest (answerForm, findsNothing);
246
+ await answerTest (answerMultipleChoices, findsNothing);
247
+ await answerTest (nextQuestionButton, findsNothing);
248
+ await answerTest (submitButton, findsOneWidget);
249
+ });
250
+
251
+ testWidgets (
252
+ "When click on the close button, it displays the confirmation dialog correctly" ,
253
+ (WidgetTester tester) async {
254
+ await FakeData .initDefault ();
255
+ await tester
256
+ .pumpWidget (TestUtil .pumpWidgetWithRoutePath ('/home/questions/1' ));
257
+ await tester.pumpAndSettle ();
258
+
259
+ await tester.tap (closeSurveyButton);
260
+ await tester.pumpAndSettle ();
261
+
262
+ expect (quitSurveyConfirmationDialog, findsOneWidget);
199
263
});
200
264
});
201
265
}
0 commit comments