feat: Add logger service and improve expense dialog with enhanced receipt management and calculation logic.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// ignore_for_file: avoid_print
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
@@ -13,7 +14,7 @@ void main() {
|
||||
print('✓ Téléchargement d\'une nouvelle image depuis Google Places');
|
||||
existingImage = 'https://storage.googleapis.com/image1.jpg';
|
||||
print('✓ Image sauvée: $existingImage');
|
||||
|
||||
|
||||
expect(existingImage, isNotNull);
|
||||
|
||||
// Scénario 2: Rechargement (image existante)
|
||||
@@ -34,7 +35,7 @@ void main() {
|
||||
print('✓ Nouvelle destination, aucune image existante');
|
||||
print('✓ Téléchargement autorisé pour cette nouvelle destination');
|
||||
differentLocationImage = 'https://storage.googleapis.com/image2.jpg';
|
||||
|
||||
|
||||
expect(differentLocationImage, isNotNull);
|
||||
expect(differentLocationImage, isNot(equals(existingImage)));
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// ignore_for_file: avoid_print
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -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)})',
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user