-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for image analysis list tile
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
test/features/ai/ui/image_analysis/ai_image_analysis_list_tile_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:lotti/classes/journal_entities.dart'; | ||
import 'package:lotti/features/ai/state/ollama_image_analysis.dart'; | ||
import 'package:lotti/features/ai/ui/image_analysis/ai_image_analysis_list_tile.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
|
||
import '../../../../test_helper.dart'; | ||
|
||
class MockAiImageAnalysisController extends Mock | ||
implements AiImageAnalysisController {} | ||
|
||
void main() { | ||
late JournalImage mockJournalImage; | ||
|
||
setUp(() { | ||
mockJournalImage = JournalImage( | ||
meta: Metadata( | ||
id: 'test-id', | ||
createdAt: DateTime.now(), | ||
updatedAt: DateTime.now(), | ||
dateFrom: DateTime.now(), | ||
dateTo: DateTime.now(), | ||
), | ||
data: ImageData( | ||
capturedAt: DateTime.now(), | ||
imageId: 'test-id', | ||
imageFile: 'test-file', | ||
imageDirectory: 'test/dir', | ||
), | ||
); | ||
}); | ||
|
||
testWidgets('renders correctly with expected elements', | ||
(WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
createTestApp( | ||
ProviderScope( | ||
child: AiImageAnalysisListTile( | ||
journalImage: mockJournalImage, | ||
), | ||
), | ||
), | ||
); | ||
|
||
expect(find.byType(ListTile), findsOneWidget); | ||
expect(find.byType(Icon), findsOneWidget); | ||
expect(find.byIcon(Icons.assistant), findsOneWidget); | ||
}); | ||
|
||
testWidgets('linkedFromId is optional', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
createTestApp( | ||
ProviderScope( | ||
child: AiImageAnalysisListTile( | ||
journalImage: mockJournalImage, | ||
linkedFromId: 'linked-id', | ||
), | ||
), | ||
), | ||
); | ||
|
||
expect(find.byType(ListTile), findsOneWidget); | ||
}); | ||
} |