修复离线路径误弹位置上报超时窗,并优化提醒设置与定位 Loading 展示。

离线或倒计时未进入提醒窗口时不再弹出超时提醒;全局 Loading 支持按需展示定位文案,提前提醒选项抽成共用组件。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-29 16:22:55 +08:00
parent 560b52fcc8
commit 63fb0462d6
11 changed files with 188 additions and 108 deletions

View File

@ -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)!