Preserve courses with pending rooms and report precise graduate import errors

This commit is contained in:
david1465833828
2026-10-28 19:56:02 +08:00
parent 8713bce0ee
commit 21b0df9e33
17 changed files with 340 additions and 53 deletions
@@ -16,6 +16,31 @@ String fixture() {
void main() {
final url = Uri.parse('https://yjsjy.uestc.edu.cn/pyxx/pygl/xskbcx/index/1');
test('graduate course identifiers need not be numeric and missing rooms remain explicit', () {
final body = fixture()
.replaceAll('101/示例', 'G101/示例')
.replaceAll('/示例楼B212', '/');
final draft = SchoolPageAdapter().extract(body, url);
expect(draft.courses, hasLength(4));
final pending = draft.courses.where((c) => c.name.contains('集成电路'));
expect(pending.every((c) => c.room == '教室待定'), isTrue);
expect(pending.every((c) => c.notes.contains('学校未提供教室')), isTrue);
});
test('graduate malformed record provides a safe specific reason', () {
expect(
() => SchoolPageAdapter().extract(
fixture().replaceFirst('1-3周', '未知周'),
url,
),
throwsA(
isA<UnsupportedSchoolLayout>().having(
(e) => e.toString(),
'reason',
contains('上课周次'),
),
),
);
});
test('school DOM merges week segments without losing full metadata or evening periods', () {
final draft = SchoolPageAdapter().extract(fixture(), url);
expect(draft.courses.length, 4);