[iOS & Android] iOS 1.2.4 & Android 1.7.3

This commit is contained in:
2025-10-06 11:54:36 -06:00
parent acf487db93
commit c10fa48bf5
10 changed files with 245 additions and 54 deletions

View File

@@ -252,4 +252,78 @@ final class OpenClimbTests: XCTestCase {
XCTAssertNotNil(parsedDate)
XCTAssertEqual(date.timeIntervalSince1970, parsedDate!.timeIntervalSince1970, accuracy: 1.0)
}
// MARK: - Active Session Preservation Tests
func testActiveSessionPreservationDuringImport() throws {
// Test that active sessions are preserved during import operations
// This tests the fix for the bug where active sessions disappear after sync
// Simulate an active session that exists locally but not in import data
let activeSessionId = UUID()
let gymId = UUID()
// Test data structure representing local active session
let localActiveSession: [String: Any] = [
"id": activeSessionId.uuidString,
"gymId": gymId.uuidString,
"status": "active",
"date": "2024-01-01",
"startTime": "2024-01-01T10:00:00Z",
]
// Test data structure representing server sessions (without the active one)
let serverSessions: [[String: Any]] = [
[
"id": UUID().uuidString,
"gymId": gymId.uuidString,
"status": "completed",
"date": "2023-12-31",
"startTime": "2023-12-31T15:00:00Z",
"endTime": "2023-12-31T17:00:00Z",
]
]
// Verify test setup
XCTAssertEqual(localActiveSession["status"] as? String, "active")
XCTAssertEqual(serverSessions.count, 1)
XCTAssertEqual(serverSessions[0]["status"] as? String, "completed")
// Verify that the active session ID is not in the server sessions
let serverSessionIds = serverSessions.compactMap { $0["id"] as? String }
XCTAssertFalse(serverSessionIds.contains(activeSessionId.uuidString))
// Test that we can identify an active session
if let status = localActiveSession["status"] as? String {
XCTAssertTrue(status == "active")
} else {
XCTFail("Failed to extract session status")
}
// Test session ID validation
if let sessionIdString = localActiveSession["id"] as? String,
let sessionId = UUID(uuidString: sessionIdString)
{
XCTAssertEqual(sessionId, activeSessionId)
} else {
XCTFail("Failed to parse session ID")
}
// Test that combining sessions preserves both local active and server completed
var combinedSessions = serverSessions
combinedSessions.append(localActiveSession)
XCTAssertEqual(combinedSessions.count, 2)
// Verify both session types are present
let hasActiveSession = combinedSessions.contains { session in
(session["status"] as? String) == "active"
}
let hasCompletedSession = combinedSessions.contains { session in
(session["status"] as? String) == "completed"
}
XCTAssertTrue(hasActiveSession, "Combined sessions should contain active session")
XCTAssertTrue(hasCompletedSession, "Combined sessions should contain completed session")
}
}