Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 9f0e5b6

Browse files
author
Jens Schulze
committed
test(ProductSearch): fix flaky test for channel availability
1 parent b3606b6 commit 9f0e5b6

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

tests/integration/Inventory/InventoryUpdateRequestTest.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,24 @@ public function testQueryChannels()
202202
->limit(1);
203203
$response = $request->executeWithClient($this->getClient());
204204
$result = $request->mapResponse($response);
205-
} while ($result->count() > 0 && $retries <= 9);
205+
} while ($result->count() == 0 && $retries <= 20);
206206

207-
$request = ProductProjectionSearchRequest::of()
208-
->addFilterQuery(
209-
Filter::ofName('variants.availability.isOnStockInChannels')->setValue([$channel->getId()])
210-
)
211-
->limit(1);
212-
$response = $request->executeWithClient($this->getClient());
213-
$result = $request->mapResponse($response);
207+
if ($result->count() == 0) {
208+
$this->markTestSkipped('Product availability not updated in time');
209+
}
210+
211+
$retries = 0;
212+
do {
213+
$retries++;
214+
sleep(1);
215+
$request = ProductProjectionSearchRequest::of()
216+
->addFilterQuery(
217+
Filter::ofName('variants.availability.isOnStockInChannels')->setValue([$channel->getId()])
218+
)
219+
->limit(1);
220+
$response = $request->executeWithClient($this->getClient());
221+
$result = $request->mapResponse($response);
222+
} while ($result->count() == 0 && $retries <= 9);
214223

215224
$this->assertSame(
216225
$product->getId(),

0 commit comments

Comments
 (0)