Files
TPSchedule/mobile/test/widgets/timetable_test.dart
T

52 lines
1.6 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:timezone/data/latest.dart' as tzdata;
import 'package:hepan_everyday/features/timetable/week_grid.dart';
import 'package:hepan_everyday/domain/schedule_engine.dart';
import 'package:hepan_everyday/domain/app_settings.dart';
void main() {
setUpAll(tzdata.initializeTimeZones);
testWidgets('transitive lesson conflicts never cover another course card', (
tester,
) async {
final term = Semester(startDate: DateTime(2026, 9, 7), totalWeeks: 1);
Course c(String name, int first, int last) => Course(
id: name,
name: name,
teacher: 'T',
room: 'R',
weekday: 1,
startPeriod: first,
endPeriod: last,
weeks: {1},
source: CourseSource.file,
);
final events = ScheduleEngine.occurrences([
c('A', 1, 2),
c('B', 2, 3),
c('C', 3, 4),
], term);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: SingleChildScrollView(
child: WeekGrid(
events: events,
monday: term.firstMonday,
today: term.startDate,
settings: const AppSettings(),
),
),
),
),
);
await tester.pumpAndSettle();
final a = tester.getRect(find.bySemanticsLabel('A,T,R'));
final b = tester.getRect(find.bySemanticsLabel('B,T,R'));
final cRect = tester.getRect(find.bySemanticsLabel('C,T,R'));
expect(a.right, lessThanOrEqualTo(b.left));
expect(b.right, lessThanOrEqualTo(cRect.left));
});
}