import 'package:flutter_test/flutter_test.dart';
import 'package:meinweimar_city_guide/models/localized_content.dart';
import 'package:meinweimar_city_guide/models/poi.dart';
import 'package:meinweimar_city_guide/models/transport_mode.dart';
import 'package:meinweimar_city_guide/services/tour_planner_service.dart';
Poi poi({
required String id,
required String title,
required double lat,
required double lng,
String category = 'Kultur',
List<String> topics = const [],
List<String> eras = const [],
bool highlight = false,
}) {
return Poi(
id: id,
title: LocalizedContent({'de': title}),
shortDescription: const LocalizedContent({'de': ''}),
guideText: LocalizedContent({'de': 'Guide $title'}),
latitude: lat,
longitude: lng,
category: category,
topicNames: topics,
eraNames: eras,
highlight: highlight,
);
}
void main() {
const planner = TourPlannerService();
test('filters unusable 0/0 coordinates', () {
final tour = planner.buildTour(
availableMinutes: 60,
interests: const {'Highlights'},
familyFriendly: false,
pois: [
poi(
id: 'bad',
title: 'Ungültig',
lat: 0,
lng: 0,
highlight: true,
),
poi(
id: 'good',
title: 'Gültig',
lat: 50.979,
lng: 11.329,
highlight: true,
),
],
transportMode: TransportMode.walking,
);
expect(tour.stops.map((e) => e.poiId), isNot(contains('bad')));
expect(tour.stops.map((e) => e.poiId), contains('good'));
});
test('matches interests against topic and era names', () {
final tour = planner.buildTour(
availableMinutes: 90,
interests: const {'Bauhaus'},
familyFriendly: false,
pois: [
poi(
id: 'bauhaus',
title: 'Bauhaus',
lat: 50.979,
lng: 11.329,
topics: const ['Bauhaus'],
),
poi(
id: 'other',
title: 'Anderes',
lat: 50.980,
lng: 11.330,
category: 'Natur',
),
],
transportMode: TransportMode.walking,
);
expect(tour.stops.first.poiId, 'bauhaus');
});
test('required POI survives interest scoring', () {
final tour = planner.buildTour(
availableMinutes: 60,
interests: const {'Goethe'},
familyFriendly: false,
requiredPoiIds: const {'must'},
pois: [
poi(
id: 'must',
title: 'Muss mit',
lat: 50.979,
lng: 11.329,
category: 'Natur',
),
poi(
id: 'goethe',
title: 'Goethe',
lat: 50.980,
lng: 11.330,
topics: const ['Goethe'],
),
],
transportMode: TransportMode.walking,
);
expect(tour.stops.map((e) => e.poiId), contains('must'));
});
}

