feat: study home with daily plan card and quick actions
This commit is contained in:
1 parent
277ead9fe7
commit
0423027e97
4 files changed
+452
-6
No files matched your search
@@ -0,0 +1,57 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mobile/models/study_plan.dart';
|
||||
|
||||
void main() {
|
||||
test('预计用时按条目数与平均耗时向上取整', () {
|
||||
// 18 + 35 = 53 条 × 13 秒 = 689 秒 → 12 分钟
|
||||
expect(StudyPlan.sample.itemCount, 53);
|
||||
expect(StudyPlan.sample.estimatedMinutes, 12);
|
||||
expect(StudyPlan.sample.estimatedLabel, '预计用时 12 分钟');
|
||||
});
|
||||
|
||||
test('没有任务时不给时长承诺,也不算空转', () {
|
||||
const StudyPlan plan = StudyPlan(
|
||||
deckName: '空单元集',
|
||||
algorithm: 'SM-2',
|
||||
totalItems: 10,
|
||||
activatedItems: 0,
|
||||
dueItems: 0,
|
||||
newItems: 0,
|
||||
secondsPerItem: 13,
|
||||
);
|
||||
|
||||
expect(plan.isEmpty, isTrue);
|
||||
expect(plan.estimatedMinutes, 0);
|
||||
expect(plan.estimatedLabel, '今天没有到期的内容');
|
||||
});
|
||||
|
||||
test('完成度保留一位小数', () {
|
||||
const StudyPlan plan = StudyPlan(
|
||||
deckName: '高考必背古诗文',
|
||||
algorithm: 'NSP-0',
|
||||
totalItems: 950,
|
||||
activatedItems: 295,
|
||||
dueItems: 0,
|
||||
newItems: 0,
|
||||
secondsPerItem: 0,
|
||||
);
|
||||
|
||||
expect(plan.progress, closeTo(0.3105, 0.0001));
|
||||
expect(plan.progressPercent, '31.1%');
|
||||
});
|
||||
|
||||
test('条目总数为 0 时不除零', () {
|
||||
const StudyPlan plan = StudyPlan(
|
||||
deckName: '空集',
|
||||
algorithm: 'SM-2',
|
||||
totalItems: 0,
|
||||
activatedItems: 0,
|
||||
dueItems: 0,
|
||||
newItems: 0,
|
||||
secondsPerItem: 13,
|
||||
);
|
||||
|
||||
expect(plan.progress, 0);
|
||||
expect(plan.progressPercent, '0.0%');
|
||||
});
|
||||
}
|
||||
@@ -41,4 +41,20 @@ void main() {
|
||||
bar = tester.widget<NavigationBar>(find.byType(NavigationBar));
|
||||
expect(bar.selectedIndex, 3);
|
||||
});
|
||||
|
||||
testWidgets('学习首页展示今日任务与唯一主行动', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const KiriMemoApp());
|
||||
|
||||
expect(find.text('今日计划'), findsOneWidget);
|
||||
expect(find.text('待复习'), findsOneWidget);
|
||||
expect(find.text('待新识'), findsOneWidget);
|
||||
expect(find.text('开始学习'), findsOneWidget);
|
||||
|
||||
// 未接入内核的入口点击后要有反馈,不能静默无响应。
|
||||
await tester.tap(find.text('开始学习'));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
|
||||
expect(find.text('学习会话 尚未接入内核'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user