修复离线路径误弹位置上报超时窗,并优化提醒设置与定位 Loading 展示。
离线或倒计时未进入提醒窗口时不再弹出超时提醒;全局 Loading 支持按需展示定位文案,提前提醒选项抽成共用组件。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -331,19 +331,54 @@ final class HomeLocationViewModelTests: XCTestCase {
|
||||
XCTAssertEqual(viewModel.reminderMinutes, 10)
|
||||
}
|
||||
|
||||
/// 测试 detail 接口触发超时对话框。
|
||||
func testCheckLocationTimeoutShowsDialogWhenNearExpiry() async {
|
||||
let api = MockLocationReportService()
|
||||
/// 测试在线且倒计时进入提醒窗口时弹出超时对话框。
|
||||
func testCheckLocationTimeoutShowsDialogWhenOnlineAndWithinReminderWindow() async {
|
||||
let store = makeIsolatedStore()
|
||||
let expireTime = Int(Date().timeIntervalSince1970) + 120
|
||||
api.detailResponse = LocationDetailResponse(status: 1, needReport: true, expireTime: expireTime)
|
||||
let viewModel = HomeLocationViewModel(api: api, store: makeIsolatedStore())
|
||||
viewModel.updateReminderMinutes(5)
|
||||
store.saveOnlineStatus(true)
|
||||
store.saveExpireTime(expireTime)
|
||||
store.saveReminderMinutes(5)
|
||||
|
||||
let viewModel = HomeLocationViewModel(api: MockLocationReportService(), store: store)
|
||||
viewModel.restoreState()
|
||||
|
||||
await viewModel.checkLocationTimeout(staffId: 77)
|
||||
|
||||
XCTAssertTrue(viewModel.isOnline)
|
||||
XCTAssertTrue(viewModel.showTimeoutDialog)
|
||||
}
|
||||
|
||||
/// 测试离线状态不弹出超时对话框。
|
||||
func testCheckLocationTimeoutDoesNotShowDialogWhenOffline() async {
|
||||
let store = makeIsolatedStore()
|
||||
store.saveOnlineStatus(false)
|
||||
store.saveReminderMinutes(5)
|
||||
|
||||
let viewModel = HomeLocationViewModel(api: MockLocationReportService(), store: store)
|
||||
viewModel.restoreState()
|
||||
|
||||
await viewModel.checkLocationTimeout(staffId: 77)
|
||||
|
||||
XCTAssertFalse(viewModel.showTimeoutDialog)
|
||||
}
|
||||
|
||||
/// 测试在线但倒计时未进入提醒窗口时不弹窗。
|
||||
func testCheckLocationTimeoutDoesNotShowDialogWhenOutsideReminderWindow() async {
|
||||
let store = makeIsolatedStore()
|
||||
let expireTime = Int(Date().timeIntervalSince1970) + 3_600
|
||||
store.saveOnlineStatus(true)
|
||||
store.saveExpireTime(expireTime)
|
||||
store.saveReminderMinutes(5)
|
||||
|
||||
let viewModel = HomeLocationViewModel(api: MockLocationReportService(), store: store)
|
||||
viewModel.restoreState()
|
||||
|
||||
await viewModel.checkLocationTimeout(staffId: 77)
|
||||
|
||||
XCTAssertTrue(viewModel.isOnline)
|
||||
XCTAssertFalse(viewModel.showTimeoutDialog)
|
||||
}
|
||||
|
||||
private func makeIsolatedStore() -> LocationStateStore {
|
||||
let suiteName = "HomeLocationViewModelTests.\(UUID().uuidString)"
|
||||
let defaults = UserDefaults(suiteName: suiteName)!
|
||||
|
||||
Reference in New Issue
Block a user