LifeMate — Personal, Family & Learning Companion
test: cover phase 4 Flutter guide flow
davoodmehraban89 committed
Oct 5, 2026 at 16:15 UTC
4f5021feb2508c8e129ed4d2845cb67cf0a2b674
1 file changed
+108
apps/lifemate/test/app_test.dart
+108
@@ -237,6 +237,114 @@ class FakeApi implements IdentityApi {
237
.map((m) => {'id': m['id'], 'status': 'accepted'})
238
.toList(),
239
};
240
+
241
+ @override
242
+ Future<Map<String, dynamic>> createLearningGoal({
243
+ required String title,
244
+ String? target,
245
+ String? subjectId,
246
+ }) async =>
247
+ {'id': 'goal-1', 'title': title, 'target': target};
248
+
249
+ @override
250
+ Future<List<Map<String, dynamic>>> listLearningGoals() async => [
251
+ {'id': 'goal-1', 'title': 'مرور ریاضی', 'target': 'فصل اول'}
252
+ ];
253
+
254
+ @override
255
+ Future<Map<String, dynamic>> createLearningCheckin({
256
+ String? learningGoalId,
257
+ required int confidence,
258
+ required int difficulty,
259
+ String? note,
260
+ }) async =>
261
+ {
262
+ 'id': 'checkin-1',
263
+ 'confidence': confidence,
264
+ 'difficulty': difficulty,
265
+ };
266
+
267
+ @override
268
+ Future<Map<String, dynamic>> createWellbeingCheckin({
269
+ required int mood,
270
+ required int energy,
271
+ required int stress,
272
+ String? note,
273
+ String visibility = 'private',
274
+ }) async =>
275
+ {
276
+ 'id': 'wellbeing-1',
277
+ 'mood': mood,
278
+ 'energy': energy,
279
+ 'stress': stress,
280
+ 'visibility': visibility,
281
+ };
282
+
283
+ @override
284
+ Future<List<Map<String, dynamic>>> listWellbeingCheckins() async => [];
285
+
286
+ @override
287
+ Future<Map<String, dynamic>> createAiSession(String kind) async =>
288
+ {'id': 'session-1', 'guide_kind': kind};
289
+
290
+ @override
291
+ Future<Map<String, dynamic>> sendAiMessage(
292
+ String sessionId,
293
+ String message,
294
+ ) async =>
295
+ {
296
+ 'id': 'message-1',
297
+ 'body': 'پاسخ آزمایشی همراه هوشمند',
298
+ 'safety_class': 'ordinary',
299
+ 'advisory': true,
300
+ };
301
+
302
+ @override
303
+ Future<Map<String, dynamic>> getGuardianWellbeingSummary(
304
+ String familyId,
305
+ String minorUserId,
306
+ ) async =>
307
+ {
308
+ 'summary': {
309
+ 'checkin_count': 3,
310
+ 'mood_average': 4,
311
+ 'energy_average': 3,
312
+ 'stress_average': 2,
313
+ },
314
+ 'safety': {'open_urgent_count': 0},
315
+ 'rawNotesIncluded': false,
316
+ 'rawConversationIncluded': false,
317
+ };
318
+ testWidgets('phase 4 guide opens and returns advisory reply', (tester) async {
319
+ await tester.pumpWidget(
320
+ LifeMateApp(
321
+ api: FakeApi(role: 'parent_guardian', themePreference: 'adult_blue'),
322
+ ),
323
+ );
324
+ await tester.enterText(
325
+ find.widgetWithText(TextField, 'ایمیل'),
326
+ 'parent@example.test',
327
+ );
328
+ await tester.enterText(
329
+ find.widgetWithText(TextField, 'رمز عبور'),
330
+ 'StrongPass!123',
331
+ );
332
+ await tester.tap(find.text('ورود'));
333
+ await tester.pumpAndSettle();
334
+ await tester.tap(find.text('راهنما'));
335
+ await tester.pumpAndSettle();
336
+
337
+ expect(find.text('راهنمای هوشمند'), findsOneWidget);
338
+ expect(find.text('همراه حال خوب'), findsOneWidget);
339
+
340
+ await tester.tap(find.text('راهنمای مطالعه'));
341
+ await tester.pumpAndSettle();
342
+ await tester.enterText(find.byType(TextField).last, 'برای امتحان ریاضی چه کنم؟');
343
+ await tester.tap(find.byIcon(Icons.send_rounded));
344
+ await tester.pumpAndSettle();
345
+
346
+ expect(find.text('پاسخ آزمایشی همراه هوشمند'), findsOneWidget);
347
+ });
348
}
349
350
void main() {