@@ -18,13 +18,16 @@ void surveyQuestionsScreenTest() {
1818 late Finder questionIndicator;
1919 late Finder questionText;
2020 late Finder nextQuestionButton;
21+ late Finder submitButton;
2122 late Finder answerDropdown;
2223 late Finder answerRating;
2324 late Finder answerEmoji;
2425 late Finder answerSmiley;
2526 late Finder answerNps;
2627 late Finder answerTextArea;
2728 late Finder answerForm;
29+ late Finder answerMultipleChoices;
30+ late Finder quitSurveyConfirmationDialog;
2831
2932 setUpAll (() async {
3033 await TestUtil .setupTestEnvironment ();
@@ -38,13 +41,18 @@ void surveyQuestionsScreenTest() {
3841 questionText = find.byKey (SurveyQuestionsWidgetId .questionText);
3942 nextQuestionButton =
4043 find.byKey (SurveyQuestionsWidgetId .nextQuestionButton);
44+ submitButton = find.byKey (SurveyQuestionsWidgetId .submitButton);
4145 answerDropdown = find.byKey (SurveyQuestionsWidgetId .answersDropdown);
4246 answerRating = find.byKey (SurveyQuestionsWidgetId .answersRating);
4347 answerEmoji = find.byKey (SurveyQuestionsWidgetId .answersEmoji);
4448 answerSmiley = find.byKey (SurveyQuestionsWidgetId .answersSmiley);
4549 answerNps = find.byKey (SurveyQuestionsWidgetId .answersNps);
4650 answerTextArea = find.byKey (SurveyQuestionsWidgetId .answersTextArea);
4751 answerForm = find.byKey (SurveyQuestionsWidgetId .answersForm);
52+ answerMultipleChoices =
53+ find.byKey (SurveyQuestionsWidgetId .answersMultipleChoices);
54+ quitSurveyConfirmationDialog =
55+ find.byKey (SurveyQuestionsWidgetId .quitSurveyConfirmationDialog);
4856 });
4957
5058 Future nextQuestionTest (
@@ -86,6 +94,8 @@ void surveyQuestionsScreenTest() {
8694 expect (answerNps, findsNothing);
8795 expect (answerTextArea, findsNothing);
8896 expect (answerForm, findsNothing);
97+ expect (answerMultipleChoices, findsNothing);
98+ expect (quitSurveyConfirmationDialog, findsNothing);
8999 });
90100
91101 testWidgets (
@@ -133,69 +143,123 @@ void surveyQuestionsScreenTest() {
133143 await answerTest (answerNps, findsNothing);
134144 await answerTest (answerTextArea, findsNothing);
135145 await answerTest (answerForm, findsNothing);
146+ await answerTest (answerMultipleChoices, findsOneWidget);
147+ await answerTest (nextQuestionButton, findsOneWidget);
148+ await answerTest (submitButton, findsNothing);
136149
137150 await nextQuestionTest (tester, '3/12' );
138151 await answerTest (answerDropdown, findsNothing);
139152 await answerTest (answerEmoji, findsNothing);
140153 await answerTest (answerNps, findsNothing);
141154 await answerTest (answerTextArea, findsNothing);
142155 await answerTest (answerForm, findsNothing);
156+ await answerTest (answerMultipleChoices, findsOneWidget);
157+ await answerTest (nextQuestionButton, findsOneWidget);
158+ await answerTest (submitButton, findsNothing);
143159
144160 await nextQuestionTest (tester, '4/12' );
145161 await answerTest (answerDropdown, findsNothing);
146162 await answerTest (answerEmoji, findsNothing);
147163 await answerTest (answerNps, findsOneWidget);
148164 await answerTest (answerTextArea, findsNothing);
149165 await answerTest (answerForm, findsNothing);
166+ await answerTest (answerMultipleChoices, findsNothing);
167+ await answerTest (nextQuestionButton, findsOneWidget);
168+ await answerTest (submitButton, findsNothing);
150169
151170 await nextQuestionTest (tester, '5/12' );
152171 await answerTest (answerDropdown, findsNothing);
153172 await answerTest (answerEmoji, findsOneWidget);
154173 await answerTest (answerNps, findsNothing);
155174 await answerTest (answerTextArea, findsNothing);
156175 await answerTest (answerForm, findsNothing);
176+ await answerTest (answerMultipleChoices, findsNothing);
177+ await answerTest (nextQuestionButton, findsOneWidget);
178+ await answerTest (submitButton, findsNothing);
157179
158180 await nextQuestionTest (tester, '6/12' );
159181 await answerTest (answerDropdown, findsNothing);
160182 await answerTest (answerEmoji, findsOneWidget);
161183 await answerTest (answerNps, findsNothing);
162184 await answerTest (answerTextArea, findsNothing);
163185 await answerTest (answerForm, findsNothing);
186+ await answerTest (answerMultipleChoices, findsNothing);
187+ await answerTest (nextQuestionButton, findsOneWidget);
188+ await answerTest (submitButton, findsNothing);
164189
165190 await nextQuestionTest (tester, '7/12' );
166191 await answerTest (answerDropdown, findsNothing);
167192 await answerTest (answerEmoji, findsOneWidget);
168193 await answerTest (answerNps, findsNothing);
169194 await answerTest (answerTextArea, findsNothing);
170195 await answerTest (answerForm, findsNothing);
196+ await answerTest (answerMultipleChoices, findsNothing);
197+ await answerTest (nextQuestionButton, findsOneWidget);
198+ await answerTest (submitButton, findsNothing);
171199
172200 await nextQuestionTest (tester, '8/12' );
173201 await answerTest (answerDropdown, findsNothing);
174202 await answerTest (answerEmoji, findsOneWidget);
175203 await answerTest (answerNps, findsNothing);
176204 await answerTest (answerTextArea, findsNothing);
177205 await answerTest (answerForm, findsNothing);
206+ await answerTest (answerMultipleChoices, findsNothing);
207+ await answerTest (nextQuestionButton, findsOneWidget);
208+ await answerTest (submitButton, findsNothing);
178209
179210 await nextQuestionTest (tester, '9/12' );
180211 await answerTest (answerDropdown, findsNothing);
181212 await answerTest (answerEmoji, findsNothing);
182213 await answerTest (answerNps, findsNothing);
183214 await answerTest (answerTextArea, findsOneWidget);
184215 await answerTest (answerForm, findsNothing);
216+ await answerTest (answerMultipleChoices, findsNothing);
217+ await answerTest (nextQuestionButton, findsOneWidget);
218+ await answerTest (submitButton, findsNothing);
185219
186220 await nextQuestionTest (tester, '10/12' );
187221 await answerTest (answerDropdown, findsOneWidget);
188222 await answerTest (answerEmoji, findsNothing);
189223 await answerTest (answerNps, findsNothing);
190224 await answerTest (answerTextArea, findsNothing);
191225 await answerTest (answerForm, findsNothing);
226+ await answerTest (answerMultipleChoices, findsNothing);
227+ await answerTest (nextQuestionButton, findsOneWidget);
228+ await answerTest (submitButton, findsNothing);
192229
193230 await nextQuestionTest (tester, '11/12' );
194231 await answerTest (answerDropdown, findsNothing);
195232 await answerTest (answerEmoji, findsNothing);
196233 await answerTest (answerNps, findsNothing);
197234 await answerTest (answerTextArea, findsNothing);
198235 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);
199263 });
200264 });
201265}
0 commit comments