|
|
|
|
@ -22,6 +22,8 @@ struct SynchronizationTests { |
|
|
|
|
self.secondStoreCenter.configureURLs(secureScheme: false, domain: "127.0.0.1:8000", webSockets: false) |
|
|
|
|
self.secondStoreCenter.tokenKeychain = MockKeychainStore(fileName: "storage-2/token.json") |
|
|
|
|
self.secondStoreCenter.deviceKeychain = MockKeychainStore(fileName: "storage-2/device.json") |
|
|
|
|
try self.secondStoreCenter.deviceKeychain.add(value: UUID().uuidString) |
|
|
|
|
|
|
|
|
|
self.secondStoreCenter.classProject = "PadelClubData" |
|
|
|
|
|
|
|
|
|
let token2 = try? self.secondStoreCenter.rawTokenShouldNotBeUsed() |
|
|
|
|
@ -32,6 +34,7 @@ struct SynchronizationTests { |
|
|
|
|
StoreCenter.main.configureURLs(secureScheme: false, domain: "127.0.0.1:8000", webSockets: false) |
|
|
|
|
StoreCenter.main.tokenKeychain = MockKeychainStore(fileName: "storage/token.json") |
|
|
|
|
StoreCenter.main.deviceKeychain = MockKeychainStore(fileName: "storage/device.json") |
|
|
|
|
try StoreCenter.main.deviceKeychain.add(value: UUID().uuidString) |
|
|
|
|
StoreCenter.main.classProject = "PadelClubData" |
|
|
|
|
|
|
|
|
|
let token = try? StoreCenter.main.rawTokenShouldNotBeUsed() |
|
|
|
|
@ -44,6 +47,11 @@ struct SynchronizationTests { |
|
|
|
|
let _: CustomUser = try await storeCenter.service().login(username: self.username, password: self.password) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test("device id tests") |
|
|
|
|
func testDeviceIds() async throws { |
|
|
|
|
#expect(StoreCenter.main.deviceId() != self.secondStoreCenter.deviceId()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test func testAuthentication() { |
|
|
|
|
#expect(StoreCenter.main.isAuthenticated) |
|
|
|
|
#expect(self.secondStoreCenter.isAuthenticated) |
|
|
|
|
@ -56,10 +64,13 @@ struct SynchronizationTests { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Cleanup |
|
|
|
|
let eventCollection1: SyncedCollection<Event> = StoreCenter.main.mainStore.registerSynchronizedCollection(synchronousLoading: true) |
|
|
|
|
let eventCollection1: SyncedCollection<Event> = await StoreCenter.main.mainStore.synchronizedCollectionWithFileLoading() |
|
|
|
|
#expect(eventCollection1.hasLoaded == true) |
|
|
|
|
|
|
|
|
|
await eventCollection1.deleteAsync(contentOfs: Array(eventCollection1)) |
|
|
|
|
|
|
|
|
|
let eventCollection2: SyncedCollection<Event> = self.secondStoreCenter.mainStore.registerSynchronizedCollection(synchronousLoading: true) |
|
|
|
|
let eventCollection2: SyncedCollection<Event> = await self.secondStoreCenter.mainStore.synchronizedCollectionWithFileLoading() |
|
|
|
|
#expect(eventCollection2.hasLoaded == true) |
|
|
|
|
eventCollection2.clear() |
|
|
|
|
|
|
|
|
|
// Create |
|
|
|
|
@ -72,7 +83,7 @@ struct SynchronizationTests { |
|
|
|
|
try await eventCollection1.loadDataFromServerIfAllowed(clear: true) |
|
|
|
|
#expect(eventCollection1.count == 1) |
|
|
|
|
|
|
|
|
|
try await eventCollection2.loadDataFromServerIfAllowed(clear: true) |
|
|
|
|
try await self.secondStoreCenter.testSynchronizeOnceAsync() |
|
|
|
|
#expect(eventCollection2.count == 1) |
|
|
|
|
|
|
|
|
|
try await self.secondStoreCenter.testSynchronizeOnceAsync() |
|
|
|
|
|