diff --git a/test/widget_tests/widgets/event_card_test.dart b/test/widget_tests/widgets/event_card_test.dart index 51fab396b..47248da9d 100644 --- a/test/widget_tests/widgets/event_card_test.dart +++ b/test/widget_tests/widgets/event_card_test.dart @@ -65,6 +65,10 @@ void main() { testSetupLocator(); }); + tearDown(() { + userConfig.currentUser.id = null; + }); + group("Test for EventCard widget", () { testWidgets('Check if Event Card shows up', (tester) async { mockNetworkImages(() async { @@ -195,5 +199,37 @@ void main() { expect(find.text("1"), findsOneWidget); }); }); + + testWidgets('Check for Created Row visibility', (tester) async { + mockNetworkImages(() async { + final event = getEvent(); + userConfig.currentUser.id = event.creator!.id; + await tester.pumpWidget(createCustomEventCard(event)); + await tester.pump(); + final BuildContext ctx = tester.element(find.byType(EventCard)); + expect(find.byIcon(Icons.verified), findsOneWidget); + expect( + find.text(AppLocalizations.of(ctx)!.strictTranslate('Created')), + findsOneWidget, + ); + }); + }); + + testWidgets( + 'should not show Created row and verified icon when current user is not the event creator', + (tester) async { + mockNetworkImages(() async { + final event = getEvent(); + userConfig.currentUser.id = "nonCreatorId"; + await tester.pumpWidget(createCustomEventCard(event)); + await tester.pump(); + final BuildContext ctx = tester.element(find.byType(EventCard)); + expect(find.byIcon(Icons.verified), findsNothing); + expect( + find.text(AppLocalizations.of(ctx)!.strictTranslate('Created')), + findsNothing, + ); + }); + }); }); }