feat: select school terms and smooth refractive Dock motion

This commit is contained in:
Codex
2026-10-13 19:08:36 +08:00
parent 3e2d8864af
commit 50fcc70e8e
33 changed files with 1245 additions and 94 deletions
@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter_test/flutter_test.dart';
import 'package:webview_flutter_platform_interface/webview_flutter_platform_interface.dart';
import 'package:hepan_everyday/features/school/school_session.dart';
import 'package:hepan_everyday/domain/school_term.dart';
import 'package:hepan_everyday/features/school/school_exam_adapter.dart';
import '../support/fake_school_web.dart';
@@ -26,7 +27,7 @@ void main() {
}
test('graduate logout function automatically opens timetable without an exit anchor', () async {
await session.open();
await session.openTimetable(term: SchoolTerm(73));
platform.web.javascript = (script) async =>
script.contains("typeof window.logout")
? schoolPageEvidence(topUrl: platform.web.url!, authenticated: true)
@@ -37,7 +38,7 @@ void main() {
});
test('manual graduate page reads recognized embedded timetable instead of restarting login', () async {
await session.open();
await session.openTimetable(term: SchoolTerm(73));
const home = 'https://yjsjy.uestc.edu.cn/pyxx/home/index';
platform.web.url = home;
platform.web.javascript = (_) async => schoolPageEvidence(
@@ -53,7 +54,7 @@ void main() {
test(
'closed authentication screen ignores later page-finished callbacks',
() async {
await session.open();
await session.openTimetable(term: SchoolTerm(73));
session.setReadingActive(true);
session.setReadingActive(false);
platform.web.javascript = (_) async =>
@@ -68,7 +69,7 @@ void main() {
test(
'asynchronous timetable DOM is imported without another navigation',
() async {
await session.open();
await session.openTimetable(term: SchoolTerm(73));
session.setReadingActive(true);
var ready = false;
platform.web.javascript = (_) async => schoolPageEvidence(
@@ -88,7 +89,7 @@ void main() {
);
test('stale script response cannot cancel polling on a newer page', () async {
await session.open();
await session.openTimetable(term: SchoolTerm(73));
session.setReadingActive(true);
final old = Completer<Object>();
platform.web.javascript = (_) => old.future;
@@ -116,7 +117,7 @@ void main() {
});
test('external document evidence cannot become a school import', () async {
await session.open();
await session.openTimetable(term: SchoolTerm(73));
platform.web.url = SchoolSession.timetableUrl.toString();
for (final url in [
'https://evil.test/pyxx/pygl/xskbcx/index/1',
@@ -135,7 +136,7 @@ void main() {
});
test('read-current recovery imports a frame and never reloads SSO', () async {
await session.open();
await session.openTimetable(term: SchoolTerm(73));
const home = 'http://yjsjy.uestc.edu.cn/pyxx/home/index';
platform.web.url = home;
platform.web.javascript = (_) async => schoolPageEvidence(
@@ -152,7 +153,7 @@ void main() {
test(
'authenticated graduate root dashboard automatically opens timetable',
() async {
await session.open();
await session.openTimetable(term: SchoolTerm(73));
const home = 'http://yjsjy.uestc.edu.cn/pyxx?targetUrl=-1';
final decision = await platform.delegate.navigation(
const NavigationRequest(url: home, isMainFrame: true),
@@ -169,7 +170,7 @@ void main() {
test(
'obsolete automatic request failure preserves a newer pending import',
() async {
await session.open();
await session.openTimetable(term: SchoolTerm(73));
final oldRequest = Completer<void>();
platform.web.request = (_) => oldRequest.future;
platform.web.javascript = (_) async =>
@@ -190,7 +191,7 @@ void main() {
);
test('actual session follows service login then reads exam HTML', () async {
await session.openExams();
await session.openExams(term: SchoolTerm(73));
expect(platform.web.loads.single, SchoolSession.authUrl.toString());
navigate('https://idas.uestc.edu.cn/authserver/login?service=graduate');
await flushSchoolEvents();
@@ -216,7 +217,7 @@ void main() {
test(
'obsolete main-frame error cannot interrupt a newer exam read',
() async {
await session.openExams();
await session.openExams(term: SchoolTerm(73));
platform.web.javascript = (_) async => schoolPageEvidence(
topUrl: platform.web.url!,
html: examHtml(),
@@ -240,11 +241,11 @@ void main() {
test(
'open waits for logout so old clearing cannot blank the new login',
() async {
await session.open();
await session.openTimetable(term: SchoolTerm(73));
platform.cookies.clearing = Completer<bool>();
final closing = session.logout();
await flushSchoolEvents();
final reopening = session.openExams();
final reopening = session.openExams(term: SchoolTerm(73));
await flushSchoolEvents();
platform.cookies.clearing!.complete(true);
await closing;
@@ -257,11 +258,11 @@ void main() {
test(
'acknowledging an old saved draft preserves a newer pending import',
() async {
await session.openExams();
await session.openExams(term: SchoolTerm(73));
final old = SchoolExamAdapter.extract(examHtml());
session.pendingExams = old;
final generation = session.pageGeneration;
await session.openExams();
await session.openExams(term: SchoolTerm(73));
final newer = SchoolExamAdapter.extract(examHtml(room: '品学楼A101'));
session.pendingExams = newer;
expect(
@@ -283,7 +284,7 @@ void main() {
test(
'native logout failure is reported and subsequent login can recover',
() async {
await session.open();
await session.openTimetable(term: SchoolTerm(73));
session.connectionState = SchoolConnectionState.connected;
platform.cookies.clearing = Completer<bool>();
final closing = session.logout();
@@ -294,12 +295,12 @@ void main() {
expect(await result, isTrue);
expect(session.connectionState, isNot(SchoolConnectionState.connected));
expect(session.message, contains('退出未完成'));
await session.openExams();
await session.openExams(term: SchoolTerm(73));
expect(platform.web.loads.last, SchoolSession.authUrl.toString());
},
);
test('university HTTP identity redirect upgrades to HTTPS with service preserved', () async {
await session.open();
await session.openTimetable(term: SchoolTerm(73));
const redirect =
'http://idas.uestc.edu.cn/authserver/login?service=http%3A%2F%2Fyjsjy.uestc.edu.cn%2Fpyxx%2Fjzsso%2Flogin';
final decision = await platform.delegate.navigation(