feat: Add services for managing trip-related data

- Implement EmergencyService for handling emergency contacts per trip.
- Create GuestFlagService to manage guest mode flags for trips.
- Introduce NotificationService with local notification capabilities.
- Add OfflineFlagService for managing offline caching flags.
- Develop PackingService for shared packing lists per trip.
- Implement ReminderService for managing reminders/to-dos per trip.
- Create SosService for dispatching SOS events to a backend.
- Add StorageService with album image upload functionality.
- Implement TransportService for managing transport segments per trip.
- Create TripChecklistService for storing and retrieving trip checklists.
- Add TripDocumentService for persisting trip documents metadata.

test: Add unit tests for new services

- Implement tests for AlbumService, BudgetService, EmergencyService, GuestFlagService, PackingService, ReminderService, SosService, TransportService, TripChecklistService, and TripDocumentService.
- Ensure tests cover adding, loading, deleting, and handling corrupted payloads for each service.
This commit is contained in:
Van Leemput Dayron
2026-03-13 15:02:23 +01:00
parent 3215a990d1
commit 9b08b2896c
36 changed files with 4731 additions and 2 deletions

View File

@@ -0,0 +1,45 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:travel_mate/models/reminder_item.dart';
import 'package:travel_mate/services/reminder_service.dart';
void main() {
const tripId = 'trip-reminders-1';
late ReminderService service;
setUp(() {
SharedPreferences.setMockInitialValues({});
service = ReminderService();
});
test('adds and toggles reminders', () async {
final r = ReminderItem.newItem(
id: 'r1',
title: 'Check-in en ligne',
dueAt: DateTime.utc(2026, 4, 10, 7),
);
await service.addReminder(tripId, r);
var list = await service.loadReminders(tripId);
expect(list.single.isDone, isFalse);
list = await service.toggleReminder(tripId, 'r1');
expect(list.single.isDone, isTrue);
});
test('deletes and clears corrupted payload', () async {
final r = ReminderItem.newItem(
id: 'r1',
title: 'Acheter métro pass',
dueAt: DateTime.utc(2026, 4, 1),
);
await service.addReminder(tripId, r);
var list = await service.deleteReminder(tripId, 'r1');
expect(list, isEmpty);
final prefs = await SharedPreferences.getInstance();
await prefs.setString('reminders_$tripId', 'oops');
list = await service.loadReminders(tripId);
expect(list, isEmpty);
expect(prefs.getString('reminders_$tripId'), isNull);
});
}