From a49bf8118ab83805a954870f89593bf72c29fbcc Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Fri, 12 Mar 2021 13:50:03 -0300 Subject: [PATCH] Attempt to fix a flaky integration test This commit attempts to fix the integration test SubscriberListingRepositoryTest::testReturnsCorrectCountForSubscribersInDynamicSegment() that was failing sometimes on CircleCI. My theory is that the test was failing because we were using created_at to order the subscribers in the query that is used to get subscribers in a given dynamic segment, but there is a chance the the value of this field is the same for all the three subscribers that are created in this test. As this could lead to a situation where the order of the returned subscribers changes, causing the test to fail. To work around that, I changed the test to order the results by ID. This way we should always get the subscribers in the same order. [MAILPOET-3451] --- .../integration/Subscribers/SubscriberListingRepositoryTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integration/Subscribers/SubscriberListingRepositoryTest.php b/tests/integration/Subscribers/SubscriberListingRepositoryTest.php index 7c54372c20..5c5f41f22d 100644 --- a/tests/integration/Subscribers/SubscriberListingRepositoryTest.php +++ b/tests/integration/Subscribers/SubscriberListingRepositoryTest.php @@ -212,6 +212,7 @@ class SubscriberListingRepositoryTest extends \MailPoetTest { $this->listingData['filter'] = ['segment' => $list->getId()]; $this->listingData['limit'] = 2; $this->listingData['offset'] = 2; + $this->listingData['sort_by'] = 'id'; $data = $this->repository->getData($this->getListingDefinition()); expect(count($data))->equals(1); expect($data[0]->getEmail())->equals($wpUserEmail3);