| 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:flutter_test/flutter_test.dart'; |
| 3 | import 'package:hugeicons/hugeicons.dart'; |
| 4 | import 'package:localmind/core/components/server_logo.dart'; |
| 5 | import 'package:localmind/core/models/enums.dart'; |
| 6 | |
| 7 | void main() { |
| 8 | group('ServerTypeLogoExtension', () { |
| 9 | test('provides correct asset paths for brand logos', () { |
| 10 | expect(ServerType.lmStudio.logoAsset, 'assets/images/lmstudio.webp'); |
| 11 | expect(ServerType.lmStudio.hasLogo, isTrue); |
| 12 | |
| 13 | expect(ServerType.ollama.logoAsset, 'assets/images/ollama.webp'); |
| 14 | expect(ServerType.ollama.hasLogo, isTrue); |
| 15 | |
| 16 | expect(ServerType.ollamaCloud.logoAsset, 'assets/images/ollama.webp'); |
| 17 | expect(ServerType.ollamaCloud.hasLogo, isTrue); |
| 18 | |
| 19 | expect(ServerType.openRouter.logoAsset, 'assets/images/openrouter.webp'); |
| 20 | expect(ServerType.openRouter.hasLogo, isTrue); |
| 21 | |
| 22 | expect(ServerType.requesty.logoAsset, 'assets/images/requesty.webp'); |
| 23 | expect(ServerType.requesty.hasLogo, isTrue); |
| 24 | |
| 25 | expect(ServerType.openAICompatible.logoAsset, isNull); |
| 26 | expect(ServerType.openAICompatible.hasLogo, isFalse); |
| 27 | |
| 28 | expect(ServerType.onDevice.logoAsset, isNull); |
| 29 | expect(ServerType.onDevice.hasLogo, isFalse); |
| 30 | }); |
| 31 | }); |
| 32 | |
| 33 | group('ServerLogo widget', () { |
| 34 | testWidgets('renders Image for server types with brand logos', ( |
| 35 | tester, |
| 36 | ) async { |
| 37 | await tester.pumpWidget( |
| 38 | const MaterialApp( |
| 39 | home: Scaffold(body: ServerLogo(type: ServerType.lmStudio, size: 24)), |
| 40 | ), |
| 41 | ); |
| 42 | |
| 43 | expect(find.byType(Image), findsOneWidget); |
| 44 | expect(find.byType(HugeIcon), findsNothing); |
| 45 | }); |
| 46 | |
| 47 | testWidgets('renders HugeIcon for server types without brand logos', ( |
| 48 | tester, |
| 49 | ) async { |
| 50 | await tester.pumpWidget( |
| 51 | const MaterialApp( |
| 52 | home: Scaffold( |
| 53 | body: ServerLogo(type: ServerType.openAICompatible, size: 24), |
| 54 | ), |
| 55 | ), |
| 56 | ); |
| 57 | |
| 58 | expect(find.byType(HugeIcon), findsOneWidget); |
| 59 | expect(find.byType(Image), findsNothing); |
| 60 | }); |
| 61 | |
| 62 | testWidgets( |
| 63 | 'renders custom HugeIcon when customIcon is explicitly provided', |
| 64 | (tester) async { |
| 65 | await tester.pumpWidget( |
| 66 | const MaterialApp( |
| 67 | home: Scaffold( |
| 68 | body: ServerLogo( |
| 69 | type: ServerType.lmStudio, |
| 70 | customIcon: HugeIcons.strokeRoundedStar, |
| 71 | size: 24, |
| 72 | ), |
| 73 | ), |
| 74 | ), |
| 75 | ); |
| 76 | |
| 77 | expect(find.byType(HugeIcon), findsOneWidget); |
| 78 | expect(find.byType(Image), findsNothing); |
| 79 | }, |
| 80 | ); |
| 81 | }); |
| 82 | } |