Skip to content

Commit

Permalink
test(datastore): fix broken datastore observeQuery integ tests (#3752)
Browse files Browse the repository at this point in the history
  • Loading branch information
5d authored Jun 19, 2024
1 parent 11302ca commit 9ed6c1c
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase {
try await clearDataStore()
var snapshots = [DataStoreQuerySnapshot<Post>]()
let snapshotWithIsSynced = expectation(description: "query snapshot with isSynced true")
snapshotWithIsSynced.assertForOverFulfill = false
Amplify.Publisher.create(Amplify.DataStore.observeQuery(for: Post.self)).sink { completed in
switch completed {
case .finished:
Expand Down Expand Up @@ -130,6 +131,7 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase {
var isObserveQueryReadyForTest = false
let observeQueryReadyForTest = expectation(description: "received query snapshot with .isSynced true")
let snapshotWithPost = expectation(description: "received first snapshot")
snapshotWithPost.assertForOverFulfill = false
let post = Post(title: "title", content: "content", createdAt: .now())
Amplify.Publisher.create(Amplify.DataStore.observeQuery(for: Post.self)).sink { completed in
switch completed {
Expand Down Expand Up @@ -339,6 +341,7 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase {
try await clearDataStore()

let snapshotWithIsSynced = expectation(description: "query snapshot with isSynced true")
snapshotWithIsSynced.assertForOverFulfill = false
var snapshots = [DataStoreQuerySnapshot<Post>]()

Amplify.Publisher.create(Amplify.DataStore.observeQuery(for: Post.self)).sink { completed in
Expand All @@ -363,7 +366,6 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase {
await fulfillment(of: [snapshotWithIsSynced], timeout: 30)
XCTAssertTrue(snapshots.count >= 2)
XCTAssertFalse(snapshots[0].isSynced)
XCTAssertEqual(1, snapshots.filter({ $0.isSynced }).count)

let theSyncedSnapshot = snapshots.first(where: { $0.isSynced })
XCTAssertNotNil(theSyncedSnapshot)
Expand Down

0 comments on commit 9ed6c1c

Please sign in to comment.