Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(datastore): fix broken datastore observeQuery integ tests #3752

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading