Files
Client/lib/api/demo/demo_marianumconnect.dart
T
MineTecandClaude Opus 5.5 c5592f117b added automated App Store screenshots via iOS simulators and fastlane deliver
tool/screenshots_ios.sh runs the existing demo-login integration test on
iPhone 6.5" (iPhone 14 Plus) and iPad 13" simulators, stores the canonical PNGs
under materials/screenshots and mirrors alpha-free JPEGs to
ios/fastlane/screenshots for `fastlane upload_screenshots`.

Fixed the demo router answering timetable/custom-events with a week, which
crashed the inline iOS widget refresh after a demo login. The screenshot test
now skips the one-time Talk notification dialog and waits longer for the app
shell on cold simulators.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-29 16:58:29 +02:00

67 lines
2.6 KiB
Dart

import 'data/demo_absence.dart';
import 'data/demo_breaker.dart';
import 'data/demo_holidays.dart';
import 'data/demo_timetable.dart';
import 'data/demo_users.dart';
/// Single source of truth for the MarianumConnect demo responses. The demo
/// interceptor asks this for the body of any MC request. Read endpoints reuse
/// the typed fixtures and serialize them to the exact shape the matching query
/// parses (a bare list vs. an object); write/side-effect endpoints (telemetry,
/// client-errors, auth, push, feedback) have no consumed body and resolve to an
/// empty success.
class DemoMarianumConnect {
const DemoMarianumConnect._();
/// Body for [path] (relative to `/api/mobile/v1/`), using [query] for the
/// timetable date window.
static Object responseBody(String path, Map<String, dynamic> query) {
switch (path) {
case 'timetable/me':
return DemoTimetable.week(
_date(query['from']),
_date(query['until']),
).toJson();
case 'timetable/schoolyear':
return DemoTimetable.schoolyear().toJson();
case 'timetable/rooms':
return DemoTimetable.rooms().result.map((e) => e.toJson()).toList();
case 'timetable/subjects':
return DemoTimetable.subjects().result.map((e) => e.toJson()).toList();
case 'timetable/timegrid':
return DemoTimetable.timegrid().result.map((e) => e.toJson()).toList();
case 'timetable/holidays':
return DemoTimetable.holidays().result.map((e) => e.toJson()).toList();
case 'timetable/custom-events':
return DemoTimetable.customEvents().toJson();
case 'holidays':
return DemoHolidays.upcoming().map((e) => e.toJson()).toList();
case 'users/search':
return DemoUsers.search(query['q']?.toString() ?? '')
.map((e) => e.toJson())
.toList();
case 'breaker':
return DemoBreaker.none().toJson();
case 'absence/classes':
return DemoAbsence.classes();
case 'absence/prefill':
return DemoAbsence.prefill().toJson();
case 'timetable/elements/teachers':
case 'timetable/elements/students':
case 'timetable/elements/classes':
return const <dynamic>[];
}
// A foreign element's week (timetable/<type>/<id>) shows the same demo week.
if (path.startsWith('timetable/')) {
return DemoTimetable.week(
_date(query['from']),
_date(query['until']),
).toJson();
}
return const <String, dynamic>{};
}
static DateTime _date(Object? raw) =>
DateTime.tryParse(raw?.toString() ?? '') ?? DateTime.now();
}