Fix location report parsing and center map on user location immediately.
Decode numeric staff_id from the report API and auto-center the map when the first user location update arrives. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -26,6 +26,26 @@ final class LocationReportServiceTests: XCTestCase {
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
func testReportLocationDecodesNumericStaffId() async throws {
|
||||
let reportJSON = """
|
||||
{"code":100000,"msg":"success","data":{"staff_id":732,"expired":1783403917,"status":1,"store_user_id":732}}
|
||||
""".data(using: .utf8)!
|
||||
let api = HomeAPI(client: APIClient(environment: .testing, session: MockURLSession(responses: [reportJSON])))
|
||||
let stateStore = HomeLocationStateStore(store: appStore)
|
||||
let service = LocationReportService(appStore: appStore, locationStateStore: stateStore)
|
||||
|
||||
let result = try await service.reportWithCoordinates(
|
||||
api: api,
|
||||
latitude: 32.429921061197916,
|
||||
longitude: 119.44032958984376,
|
||||
address: "测试地址",
|
||||
type: 1
|
||||
)
|
||||
|
||||
XCTAssertTrue(result.shouldShowSuccessDialog)
|
||||
XCTAssertTrue(stateStore.isOnline)
|
||||
}
|
||||
|
||||
func testReportWithCoordinatesType2UsesProvidedLocation() async throws {
|
||||
let reportJSON = """
|
||||
{"code":100000,"msg":"success","data":{"staff_id":"staff-1","expired":0,"status":1}}
|
||||
|
||||
Reference in New Issue
Block a user