forked from eatvio/eatvio_app
1036 lines
33 KiB
Dart
1036 lines
33 KiB
Dart
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
|
import 'package:eatvio_app/features/notifications/models/notification_model.dart';
|
|
import 'package:eatvio_app/features/notifications/presentation/widgets/notification_widget.dart';
|
|
import 'package:eatvio_app/generated/l10n.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
|
|
void main() {
|
|
group('NotificationWidget', () {
|
|
final testDate = DateTime(2024, 1, 15, 10, 30);
|
|
|
|
Widget createTestWidget(BaseNotificationModel notification) {
|
|
return MaterialApp(
|
|
localizationsDelegates: const [
|
|
S.delegate,
|
|
GlobalMaterialLocalizations.delegate,
|
|
GlobalWidgetsLocalizations.delegate,
|
|
GlobalCupertinoLocalizations.delegate,
|
|
],
|
|
supportedLocales: const [Locale('ru'), Locale('en')],
|
|
locale: const Locale('ru'),
|
|
theme: ThemeHelper().themeData(),
|
|
home: Scaffold(
|
|
body: NotificationWidget(notification: notification),
|
|
),
|
|
);
|
|
}
|
|
|
|
testWidgets('displays PlanSubscriptionStartedToAuthorNotification', (tester) async {
|
|
final notification = PlanSubscriptionStartedToAuthorNotification(
|
|
type: NotificationType.planSubscriptionStartedToAuthor,
|
|
planName: 'Test Plan',
|
|
customerName: 'Test Customer',
|
|
chatId: 'chat123',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays PlanSubscriptionCanceledToAuthorNotification', (tester) async {
|
|
final notification = PlanSubscriptionCanceledToAuthorNotification(
|
|
type: NotificationType.planSubscriptionCanceledToAuthor,
|
|
planName: 'Test Plan',
|
|
customerName: 'Test Customer',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ChosenPlanStartedToClientNotification', (tester) async {
|
|
final notification = ChosenPlanStartedToClientNotification(
|
|
type: NotificationType.chosenPlanStartedToClient,
|
|
planName: 'Test Plan',
|
|
planId: 1,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ChosenPlanTomorrowReminderToClientNotification', (tester) async {
|
|
final notification = ChosenPlanTomorrowReminderToClientNotification(
|
|
type: NotificationType.chosenPlanTomorrowReminderToClient,
|
|
planName: 'Test Plan',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays DiaryReminderNotification', (tester) async {
|
|
final notification = DiaryReminderNotification(
|
|
type: NotificationType.diaryReminderNotification,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ConsultantLeftCommentNotification', (tester) async {
|
|
final notification = ConsultantLeftCommentNotification(
|
|
type: NotificationType.consultantLeftComment,
|
|
date: testDate,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays PersonalizedDietIsDefinedNotification', (tester) async {
|
|
final notification = PersonalizedDietIsDefinedNotification(
|
|
type: NotificationType.personalizedDietIsDefined,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ChosenPlanFinishedToClientNotification', (tester) async {
|
|
final notification = ChosenPlanFinishedToClientNotification(
|
|
type: NotificationType.chosenPlanFinishedToClient,
|
|
planName: 'Test Plan',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays PlanSubscriptionCanceledToCustomerNotification', (tester) async {
|
|
final notification = PlanSubscriptionCanceledToCustomerNotification(
|
|
type: NotificationType.planSubscriptionCanceledToCustomer,
|
|
planName: 'Test Plan',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ChosenPlanStartedToConsultantNotification', (tester) async {
|
|
final notification = ChosenPlanStartedToConsultantNotification(
|
|
type: NotificationType.chosenPlanStartedToConsultant,
|
|
planName: 'Test Plan',
|
|
customerName: 'Test Customer',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ChosenPlanTomorrowReminderToConsultantNotification', (tester) async {
|
|
final notification = ChosenPlanTomorrowReminderToConsultantNotification(
|
|
type: NotificationType.chosenPlanTomorrowReminderToConsultant,
|
|
planName: 'Test Plan',
|
|
customerName: 'Test Customer',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays PlanSubscriptionPaidToAuthorNotification', (tester) async {
|
|
final notification = PlanSubscriptionPaidToAuthorNotification(
|
|
type: NotificationType.planSubscriptionPaidToAuthor,
|
|
planName: 'Test Plan',
|
|
customerName: 'Test Customer',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ChosenPlanFinishedToConsultantNotification with button', (tester) async {
|
|
final notification = ChosenPlanFinishedToConsultantNotification(
|
|
type: NotificationType.chosenPlanFinishedToConsultant,
|
|
planName: 'Test Plan',
|
|
customerName: 'Test Customer',
|
|
planId: 1,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ChosenPlanLastDayFinishedForUser', (tester) async {
|
|
final notification = ChosenPlanLastDayFinishedForUser(
|
|
type: NotificationType.chosenPlanLastDayFinishedForUser,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ChosenPlanConsultantLastDayStarted', (tester) async {
|
|
final notification = ChosenPlanConsultantLastDayStarted(
|
|
type: NotificationType.chosenPlanConsultantLastDayStarted,
|
|
planName: 'Test Plan',
|
|
planId: 1,
|
|
chatId: 'chat123',
|
|
chatUrl: 'chat_url',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ComplaintToModerationForUser', (tester) async {
|
|
final notification = ComplaintToModerationForUser(
|
|
type: NotificationType.complaintToModerationForUser,
|
|
message: 'Test message',
|
|
entityId: 1,
|
|
entityType: 'test',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays CommentReplied', (tester) async {
|
|
final notification = CommentReplied(
|
|
type: NotificationType.commentReplied,
|
|
entityName: 'Test Entity',
|
|
commentedEntityId: 1,
|
|
commentedEntityType: 'test',
|
|
author: 'Test Author',
|
|
authorId: 1,
|
|
parentCommentId: 1,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ScoreAdded', (tester) async {
|
|
final notification = ScoreAdded(
|
|
type: NotificationType.scoreAdded,
|
|
scoreKey: 'test_key',
|
|
scorableId: 1,
|
|
scorableType: 'test',
|
|
scorableName: 'Test Name',
|
|
scorableSlug: 'test-slug',
|
|
scoreValue: 10,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays EntityCommented', (tester) async {
|
|
final notification = EntityCommented(
|
|
type: NotificationType.entityCommented,
|
|
entityName: 'Test Entity',
|
|
entityId: 1,
|
|
entityType: 'test',
|
|
entityTranslatedType: 'Test Type',
|
|
entityUrl: 'test_url',
|
|
authorName: 'Test Author',
|
|
authorId: 1,
|
|
authorSlug: 'test-author',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays PlanSubscriptionExpiredNotification', (tester) async {
|
|
final notification = PlanSubscriptionExpiredNotification(
|
|
type: NotificationType.planSubscriptionExpired,
|
|
planName: 'Test Plan',
|
|
customerName: 'Test Customer',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays PlanSubscriptionRenewedNotification', (tester) async {
|
|
final notification = PlanSubscriptionRenewedNotification(
|
|
type: NotificationType.planSubscriptionRenewed,
|
|
planName: 'Test Plan',
|
|
customerName: 'Test Customer',
|
|
renewalDate: '2024-02-01',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ConsultantAssignedNotification', (tester) async {
|
|
final notification = ConsultantAssignedNotification(
|
|
type: NotificationType.consultantAssigned,
|
|
consultantName: 'Test Consultant',
|
|
planName: 'Test Plan',
|
|
planId: 1,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ConsultantUnassignedNotification', (tester) async {
|
|
final notification = ConsultantUnassignedNotification(
|
|
type: NotificationType.consultantUnassigned,
|
|
consultantName: 'Test Consultant',
|
|
planName: 'Test Plan',
|
|
planId: 1,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays PaymentFailedNotification', (tester) async {
|
|
final notification = PaymentFailedNotification(
|
|
type: NotificationType.paymentFailed,
|
|
planName: 'Test Plan',
|
|
errorMessage: 'Test error',
|
|
paymentMethod: 'card',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays PaymentSuccessfulNotification', (tester) async {
|
|
final notification = PaymentSuccessfulNotification(
|
|
type: NotificationType.paymentSuccessful,
|
|
planName: 'Test Plan',
|
|
amount: 100.0,
|
|
currency: 'USD',
|
|
transactionId: 'trans123',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays GoalAchievedNotification', (tester) async {
|
|
final notification = GoalAchievedNotification(
|
|
type: NotificationType.goalAchieved,
|
|
goalName: 'Test Goal',
|
|
goalType: 'weight',
|
|
achievedValue: 50.0,
|
|
targetValue: 100.0,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays WorkoutReminderNotification', (tester) async {
|
|
final notification = WorkoutReminderNotification(
|
|
type: NotificationType.workoutReminder,
|
|
workoutName: 'Test Workout',
|
|
workoutType: 'cardio',
|
|
duration: 30,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays MealReminderNotification', (tester) async {
|
|
final notification = MealReminderNotification(
|
|
type: NotificationType.mealReminder,
|
|
mealName: 'Test Meal',
|
|
mealType: 'breakfast',
|
|
calories: 500,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays DietCancelledNotification', (tester) async {
|
|
final notification = DietCancelledNotification(
|
|
type: NotificationType.dietCancelled,
|
|
dietName: 'Test Diet',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays DietStartedNotification', (tester) async {
|
|
final notification = DietStartedNotification(
|
|
type: NotificationType.dietStarted,
|
|
dietName: 'Test Diet',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays DietExpiredNotification', (tester) async {
|
|
final notification = DietExpiredNotification(
|
|
type: NotificationType.dietExpired,
|
|
dietName: 'Test Diet',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays DietWillStartedInNotification', (tester) async {
|
|
final notification = DietWillStartedInNotification(
|
|
type: NotificationType.dietWillStartedIn,
|
|
dietName: 'Test Diet',
|
|
startDate: '2024-02-01',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays DietCanNotBeStartedNotification', (tester) async {
|
|
final notification = DietCanNotBeStartedNotification(
|
|
type: NotificationType.dietCanNotBeStarted,
|
|
dietName: 'Test Diet',
|
|
reason: 'Test reason',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays PersonalDietCreationNeededNotification', (tester) async {
|
|
final notification = PersonalDietCreationNeededNotification(
|
|
type: NotificationType.personalDietCreationNeeded,
|
|
planName: 'Test Plan',
|
|
clientName: 'Test Client',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ChosenPlanClientLastDayFinishedNotification', (tester) async {
|
|
final notification = ChosenPlanClientLastDayFinishedNotification(
|
|
type: NotificationType.chosenPlanClientLastDayFinished,
|
|
planName: 'Test Plan',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ChosenPlanClientLastDayStartedNotification', (tester) async {
|
|
final notification = ChosenPlanClientLastDayStartedNotification(
|
|
type: NotificationType.chosenPlanClientLastDayStarted,
|
|
planName: 'Test Plan',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays StayOnTrackToAuthorNotification', (tester) async {
|
|
final notification = StayOnTrackToAuthorNotification(
|
|
type: NotificationType.stayOnTrackToAuthor,
|
|
planName: 'Test Plan',
|
|
clientName: 'Test Client',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ClientStartPlanSubscriptionToSubscriberNotification', (tester) async {
|
|
final notification = ClientStartPlanSubscriptionToSubscriberNotification(
|
|
type: NotificationType.clientStartPlanSubscriptionToSubscriber,
|
|
planName: 'Test Plan',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ConsultantConfirmPlanSubscriptionToSubscriberNotification', (tester) async {
|
|
final notification = ConsultantConfirmPlanSubscriptionToSubscriberNotification(
|
|
type: NotificationType.consultantConfirmPlanSubscriptionToSubscriber,
|
|
planName: 'Test Plan',
|
|
consultantName: 'Test Consultant',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ClientPaidPlanSubscriptionToAuthorNotification', (tester) async {
|
|
final notification = ClientPaidPlanSubscriptionToAuthorNotification(
|
|
type: NotificationType.clientPaidPlanSubscriptionToAuthor,
|
|
planName: 'Test Plan',
|
|
clientName: 'Test Client',
|
|
amount: 100.0,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ConsultantLeftDiaryCommentNotification', (tester) async {
|
|
final notification = ConsultantLeftDiaryCommentNotification(
|
|
type: NotificationType.consultantLeftDiaryComment,
|
|
planName: 'Test Plan',
|
|
consultantName: 'Test Consultant',
|
|
diaryDate: testDate,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ConsultantConfirmPlanSubscriptionToAuthorNotification', (tester) async {
|
|
final notification = ConsultantConfirmPlanSubscriptionToAuthorNotification(
|
|
type: NotificationType.consultantConfirmPlanSubscriptionToAuthor,
|
|
planName: 'Test Plan',
|
|
consultantName: 'Test Consultant',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ClientPaidPlanSubscriptionToSubscriberNotification', (tester) async {
|
|
final notification = ClientPaidPlanSubscriptionToSubscriberNotification(
|
|
type: NotificationType.clientPaidPlanSubscriptionToSubscriber,
|
|
planName: 'Test Plan',
|
|
amount: 100.0,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ClientStartPlanSubscriptionToAuthorNotification', (tester) async {
|
|
final notification = ClientStartPlanSubscriptionToAuthorNotification(
|
|
type: NotificationType.clientStartPlanSubscriptionToAuthor,
|
|
planName: 'Test Plan',
|
|
clientName: 'Test Client',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ClientCancelPlanSubscriptionToAuthorNotification', (tester) async {
|
|
final notification = ClientCancelPlanSubscriptionToAuthorNotification(
|
|
type: NotificationType.clientCancelPlanSubscriptionToAuthor,
|
|
planName: 'Test Plan',
|
|
clientName: 'Test Client',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ClientCancelPlanSubscriptionToSubscriberNotification', (tester) async {
|
|
final notification = ClientCancelPlanSubscriptionToSubscriberNotification(
|
|
type: NotificationType.clientCancelPlanSubscriptionToSubscriber,
|
|
planName: 'Test Plan',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays UserDailyReportCompletedNotification', (tester) async {
|
|
final notification = UserDailyReportCompletedNotification(
|
|
type: NotificationType.userDailyReportCompleted,
|
|
planName: 'Test Plan',
|
|
clientName: 'Test Client',
|
|
reportDate: testDate,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays StayOnTrackToCustomerNotification', (tester) async {
|
|
final notification = StayOnTrackToCustomerNotification(
|
|
type: NotificationType.stayOnTrackToCustomer,
|
|
planName: 'Test Plan',
|
|
consultantName: 'Test Consultant',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays PhoneChangedNotification', (tester) async {
|
|
final notification = PhoneChangedNotification(
|
|
type: NotificationType.phoneChanged,
|
|
oldPhone: '+1234567890',
|
|
newPhone: '+0987654321',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays SubscriptionNotification', (tester) async {
|
|
final notification = SubscriptionNotification(
|
|
type: NotificationType.subscription,
|
|
subscriptionType: 'monthly',
|
|
planName: 'Test Plan',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays BadgeAwardedNotification', (tester) async {
|
|
final notification = BadgeAwardedNotification(
|
|
type: NotificationType.badgeAwarded,
|
|
badgeName: 'Test Badge',
|
|
badgeDescription: 'Test Description',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays BadgeRevokedNotification', (tester) async {
|
|
final notification = BadgeRevokedNotification(
|
|
type: NotificationType.badgeRevoked,
|
|
badgeName: 'Test Badge',
|
|
reason: 'Test reason',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ConsultantRequestStartedNotification', (tester) async {
|
|
final notification = ConsultantRequestStartedNotification(
|
|
type: NotificationType.consultantRequestStarted,
|
|
consultantName: 'Test Consultant',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ClientCloseComplaintSuccessNotification', (tester) async {
|
|
final notification = ClientCloseComplaintSuccessNotification(
|
|
type: NotificationType.clientCloseComplaintSuccess,
|
|
complaintType: 'test',
|
|
entityName: 'Test Entity',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ClientRefundSuccessNotification', (tester) async {
|
|
final notification = ClientRefundSuccessNotification(
|
|
type: NotificationType.clientRefundSuccess,
|
|
planName: 'Test Plan',
|
|
amount: 100.0,
|
|
reason: 'Test reason',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ConsultantRefundSuccessNotification', (tester) async {
|
|
final notification = ConsultantRefundSuccessNotification(
|
|
type: NotificationType.consultantRefundSuccess,
|
|
planName: 'Test Plan',
|
|
clientName: 'Test Client',
|
|
amount: 100.0,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ClientRejectSuccessNotification', (tester) async {
|
|
final notification = ClientRejectSuccessNotification(
|
|
type: NotificationType.clientRejectSuccess,
|
|
planName: 'Test Plan',
|
|
reason: 'Test reason',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ConsultantRejectSuccessNotification', (tester) async {
|
|
final notification = ConsultantRejectSuccessNotification(
|
|
type: NotificationType.consultantRejectSuccess,
|
|
planName: 'Test Plan',
|
|
clientName: 'Test Client',
|
|
reason: 'Test reason',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ScoreSubstractedNotification', (tester) async {
|
|
final notification = ScoreSubstractedNotification(
|
|
type: NotificationType.scoreSubstracted,
|
|
scoreKey: 'test_key',
|
|
scorableId: 1,
|
|
scorableType: 'test',
|
|
scorableName: 'Test Name',
|
|
scorableSlug: 'test-slug',
|
|
scoreValue: 10,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays ProductStatusUpdatedForAuthorNotification', (tester) async {
|
|
final notification = ProductStatusUpdatedForAuthorNotification(
|
|
type: NotificationType.productStatusUpdatedForAuthor,
|
|
productName: 'Test Product',
|
|
oldStatus: 'pending',
|
|
newStatus: 'approved',
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays DiaryReminderForUsersNotification', (tester) async {
|
|
final notification = DiaryReminderForUsersNotification(
|
|
type: NotificationType.diaryReminderForUsers,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays PersonalDietIsDefinedToCustomerNotification', (tester) async {
|
|
final notification = PersonalDietIsDefinedToCustomerNotification(
|
|
type: NotificationType.personalDietIsDefinedToCustomer,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
dietName: 'Test Diet',
|
|
dietId: 1,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('displays UnknownNotification', (tester) async {
|
|
final notification = UnknownNotification(
|
|
type: NotificationType.unknown,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('shows unread indicator when isRead is false', (tester) async {
|
|
final notification = DiaryReminderNotification(
|
|
type: NotificationType.diaryReminderNotification,
|
|
isRead: false,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
// Check for unread indicator (blue circle)
|
|
expect(find.byType(Container), findsWidgets);
|
|
});
|
|
|
|
testWidgets('hides unread indicator when isRead is true', (tester) async {
|
|
final notification = DiaryReminderNotification(
|
|
type: NotificationType.diaryReminderNotification,
|
|
isRead: true,
|
|
createdAt: testDate,
|
|
);
|
|
|
|
await tester.pumpWidget(createTestWidget(notification));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(NotificationWidget), findsOneWidget);
|
|
});
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|