Skip to content

Commit 728ac9a

Browse files
committed
Wait for hasMoreProducts/hasMoreVariations value
hasMoreVariations may not yet be loaded when products load since statistics are loaded separately
1 parent b832cd6 commit 728ac9a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Modules/Tests/YosemiteTests/PointOfSale/GRDBObservableDataSourceTests.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ struct GRDBObservableDataSourceTests {
9292
sut.loadProducts()
9393
}
9494

95+
// Wait for statistics to indicate more pages
96+
await waitForCondition {
97+
sut.hasMoreProducts == true
98+
} performAction: {}
99+
95100
// Then: First page loaded
96101
#expect(sut.productItems.count == 5)
97102
#expect(sut.hasMoreProducts == true)
@@ -101,6 +106,11 @@ struct GRDBObservableDataSourceTests {
101106
sut.loadMoreProducts()
102107
}
103108

109+
// Wait for statistics to indicate no more pages
110+
await waitForCondition {
111+
sut.hasMoreProducts == false
112+
} performAction: {}
113+
104114
// Then: Both pages loaded
105115
#expect(sut.productItems.count == 8)
106116
#expect(sut.hasMoreProducts == false)
@@ -301,6 +311,11 @@ struct GRDBObservableDataSourceTests {
301311
sut.loadVariations(for: posParent1)
302312
}
303313

314+
// Wait for statistics showing no more pages
315+
await waitForCondition {
316+
sut.hasMoreVariations == false
317+
} performAction: {}
318+
304319
// Then: Should show 3 variations for parent 1 (excluding downloadable)
305320
#expect(sut.variationItems.count == 3)
306321

@@ -312,6 +327,11 @@ struct GRDBObservableDataSourceTests {
312327
sut.loadVariations(for: posParent2)
313328
}
314329

330+
// Wait for statistics showing no more pages
331+
await waitForCondition {
332+
sut.hasMoreVariations == false
333+
} performAction: {}
334+
315335
// Then: Should show 5 variations for parent 2 (first page, excluding downloadable)
316336
#expect(sut.variationItems.count == 5)
317337

@@ -344,6 +364,11 @@ struct GRDBObservableDataSourceTests {
344364
sut.loadVariations(for: posParent1)
345365
}
346366

367+
// Wait for statistics showing no more pages
368+
await waitForCondition {
369+
sut.hasMoreVariations == false
370+
} performAction: {}
371+
347372
// Then: Should load 2 variations
348373
#expect(sut.variationItems.count == 2)
349374

@@ -354,6 +379,11 @@ struct GRDBObservableDataSourceTests {
354379
sut.loadVariations(for: posParent2)
355380
}
356381

382+
// Wait for statistics showing more pages available
383+
await waitForCondition {
384+
sut.hasMoreVariations == true
385+
} performAction: {}
386+
357387
// Then: Should load first page (5 variations)
358388
#expect(sut.variationItems.count == 5)
359389

@@ -365,6 +395,11 @@ struct GRDBObservableDataSourceTests {
365395
sut.loadMoreVariations()
366396
}
367397

398+
// Wait for statistics showing no more pages
399+
await waitForCondition {
400+
sut.hasMoreVariations == false
401+
} performAction: {}
402+
368403
// Then: Should load all 8 variations
369404
#expect(sut.variationItems.count == 8)
370405

@@ -617,6 +652,8 @@ struct GRDBObservableDataSourceTests {
617652
_ = sut.variationItems
618653
_ = sut.isLoadingProducts
619654
_ = sut.isLoadingVariations
655+
_ = sut.hasMoreProducts
656+
_ = sut.hasMoreVariations
620657

621658
return condition()
622659
} onChange: {

0 commit comments

Comments
 (0)