feat: Add logger service and improve expense dialog with enhanced receipt management and calculation logic.

This commit is contained in:
Van Leemput Dayron
2025-11-28 12:54:54 +01:00
parent cad9d42128
commit fd710b8cb8
35 changed files with 2148 additions and 1296 deletions

View File

@@ -1,10 +1,11 @@
// ignore_for_file: avoid_print
import 'package:flutter_test/flutter_test.dart';
import 'package:travel_mate/services/place_image_service.dart';
void main() {
group('PlaceImageService Tests', () {
late PlaceImageService placeImageService;
setUp(() {
placeImageService = PlaceImageService();
});
@@ -12,9 +13,9 @@ void main() {
test('should generate search terms correctly for Paris', () {
// Cette fonction n'est pas publique, mais nous pouvons tester indirectement
// en vérifiant que différentes villes génèrent des termes appropriés
final cities = ['Paris', 'London', 'Rome', 'New York', 'Tokyo'];
for (String city in cities) {
print('Testing search terms generation for: $city');
// Le test indirect sera fait lors de l'appel réel à l'API
@@ -23,14 +24,8 @@ void main() {
});
test('should prioritize tourist attractions in search terms', () {
const testCases = [
'Paris',
'London',
'Rome',
'New York',
'Tokyo'
];
const testCases = ['Paris', 'London', 'Rome', 'New York', 'Tokyo'];
for (String city in testCases) {
print('City: $city should have tourist attraction terms');
expect(city.length, greaterThan(0));
@@ -41,7 +36,7 @@ void main() {
test('should handle API key missing gracefully', () async {
// Test avec une clé API vide
final result = await placeImageService.getPlaceImageUrl('Paris');
// Devrait retourner null si pas de clé API
expect(result, isNull);
});
@@ -57,12 +52,12 @@ void main() {
'Louvre Paris',
'Champs-Élysées Paris',
];
for (String term in parisTerms) {
expect(term.contains('Paris'), true);
print('Generated term: $term');
}
// Test des termes spécifiques pour Londres
const londonTerms = [
'Big Ben London',
@@ -71,7 +66,7 @@ void main() {
'Buckingham Palace London',
'Tower of London',
];
for (String term in londonTerms) {
expect(term.contains('London') || term.contains('Eye'), true);
print('Generated term: $term');
@@ -88,7 +83,7 @@ void main() {
'centre ville',
'skyline',
];
for (String term in genericTerms) {
expect(term.isNotEmpty, true);
print('Generic term: $term');
@@ -105,32 +100,34 @@ void main() {
{'width': 300, 'height': 300}, // Carré
{'width': 1200, 'height': 800}, // Horizontal haute résolution
];
// Le tri devrait favoriser les photos horizontales
photos.sort((a, b) {
final aRatio = a['width']! / a['height']!;
final bRatio = b['width']! / b['height']!;
// Favoriser les ratios > 1 (horizontal)
if (aRatio > 1 && bRatio <= 1) return -1;
if (bRatio > 1 && aRatio <= 1) return 1;
// Si les deux sont horizontaux, favoriser la plus haute résolution
final aResolution = a['width']! * a['height']!;
final bResolution = b['width']! * b['height']!;
return bResolution.compareTo(aResolution);
});
// La première photo devrait être celle avec la plus haute résolution horizontale
expect(photos.first['width'], 1200);
expect(photos.first['height'], 800);
print('Photos triées par qualité:');
for (var photo in photos) {
final ratio = photo['width']! / photo['height']!;
print('${photo['width']}x${photo['height']} (ratio: ${ratio.toStringAsFixed(2)})');
print(
'${photo['width']}x${photo['height']} (ratio: ${ratio.toStringAsFixed(2)})',
);
}
});
});
}
}