feat(training): 新增已结束筛选并精简课程展示
新增已结束任务筛选与只读回顾资格,保留搜索和游标分页。移除任务小节数量及课程附件文件名、切换入口,并更新接口和界面回归测试。
This commit is contained in:
@@ -8,6 +8,14 @@ struct TrainingRemoteListTests {
|
||||
@Test("首页只请求概览与三条任务摘要")
|
||||
func homeUsesSmallResources() async {
|
||||
let source = TrainingDataStub()
|
||||
await source.configure {
|
||||
$0.tasksHandler = { status, _, cursor, limit in
|
||||
#expect(status == .pendingExam)
|
||||
#expect(cursor == nil)
|
||||
#expect(limit == 3)
|
||||
return TrainingCursorPage(items: [TrainingRemoteFixtures.task()], nextCursor: nil, hasMore: false, serverTime: nil)
|
||||
}
|
||||
}
|
||||
let model = TrainingRemoteCenterViewModel()
|
||||
await model.load(service: source)
|
||||
let calls = await source.calls
|
||||
@@ -17,25 +25,26 @@ struct TrainingRemoteListTests {
|
||||
#expect(model.latestScore == "—")
|
||||
}
|
||||
|
||||
@Test("任务筛选传给服务端,用户翻页才消费游标")
|
||||
func serverFilteringAndPagination() async {
|
||||
@Test("任务筛选传给服务端,用户翻页才消费游标", arguments: [TrainingLearnerStatus.completed, .ended])
|
||||
func serverFilteringAndPagination(status expectedStatus: TrainingLearnerStatus) async {
|
||||
let source = TrainingDataStub()
|
||||
await source.configure {
|
||||
$0.tasksHandler = { status, keyword, cursor, _ in
|
||||
#expect(status == .completed)
|
||||
#expect(status == expectedStatus)
|
||||
#expect(keyword == "服务")
|
||||
return TrainingCursorPage(items: [TrainingRemoteFixtures.task(id: cursor == nil ? "first" : "second")], nextCursor: cursor == nil ? "next" : nil, hasMore: cursor == nil, serverTime: nil)
|
||||
return TrainingCursorPage(items: [TrainingRemoteFixtures.task(id: cursor == nil ? "first" : "second", learnerStatus: expectedStatus)], nextCursor: cursor == nil ? "next" : nil, hasMore: cursor == nil, serverTime: nil)
|
||||
}
|
||||
}
|
||||
let model = TrainingRemoteCenterViewModel()
|
||||
model.selectTab(.tasks)
|
||||
model.filter = .completed
|
||||
model.filter = expectedStatus
|
||||
model.keyword = " 服务 "
|
||||
await model.load(service: source)
|
||||
#expect(model.tasks.map(\.id) == ["first"])
|
||||
#expect(model.hasMore)
|
||||
await model.loadMore(service: source)
|
||||
#expect(model.tasks.map(\.id) == ["first", "second"])
|
||||
#expect(model.tasks.allSatisfy { $0.learnerStatus == expectedStatus })
|
||||
#expect(!model.hasMore)
|
||||
#expect(await source.calls.count == 3)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user