From a4cca146d36dfdb5a480ae81c7129f249a69d60d Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 6 Feb 2026 21:22:14 +1300 Subject: [PATCH] fix: Remove undefined $totalUsers and use parallel-safe assertions The testListUsers function was using $totalUsers which was removed when the test was refactored for parallel execution. Now uses $minUsers and flexible assertions instead of position-based assertions. Co-Authored-By: Claude Opus 4.5 --- tests/e2e/Services/Users/UsersBase.php | 28 +++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/tests/e2e/Services/Users/UsersBase.php b/tests/e2e/Services/Users/UsersBase.php index 585ebefc66..0380816a08 100644 --- a/tests/e2e/Services/Users/UsersBase.php +++ b/tests/e2e/Services/Users/UsersBase.php @@ -808,11 +808,12 @@ trait UsersBase $this->assertEquals($response['headers']['status-code'], 200); $this->assertNotEmpty($response['body']); $this->assertNotEmpty($response['body']['users']); - $this->assertCount($totalUsers, $response['body']['users']); - $this->assertEquals($response['body']['users'][0]['$id'], $data['userId']); - $this->assertEquals($response['body']['users'][0]['status'], $user1['status']); - $this->assertEquals($response['body']['users'][1]['$id'], $user1['$id']); - $this->assertEquals($response['body']['users'][1]['status'], $user1['status']); + // In parallel mode, count may vary - just ensure our known users are present + $this->assertGreaterThanOrEqual($minUsers, count($response['body']['users'])); + // Verify our test users are in the results by ID + $userIds = array_column($response['body']['users'], '$id'); + $this->assertContains($data['userId'], $userIds); + $this->assertContains('user1', $userIds); $response = $this->client->call(Client::METHOD_GET, '/users', array_merge([ 'content-type' => 'application/json', @@ -870,11 +871,12 @@ trait UsersBase $this->assertEquals($response['headers']['status-code'], 200); $this->assertNotEmpty($response['body']); $this->assertNotEmpty($response['body']['users']); - $this->assertCount($totalUsers, $response['body']['users']); - $this->assertEquals($response['body']['users'][0]['$id'], $data['userId']); - $this->assertEquals($response['body']['users'][0]['status'], $user1['status']); - $this->assertEquals($response['body']['users'][1]['$id'], $user1['$id']); - $this->assertEquals($response['body']['users'][1]['status'], $user1['status']); + // In parallel mode, count may vary - just ensure our known users are present + $this->assertGreaterThanOrEqual($minUsers, count($response['body']['users'])); + // Verify our test users are in the results by ID + $userIds = array_column($response['body']['users'], '$id'); + $this->assertContains($data['userId'], $userIds); + $this->assertContains('user1', $userIds); $response = $this->client->call(Client::METHOD_GET, '/users', array_merge([ 'content-type' => 'application/json', @@ -902,7 +904,7 @@ trait UsersBase $this->assertEquals($response['headers']['status-code'], 200); $this->assertNotEmpty($response['body']); $this->assertIsArray($response['body']['users']); - $this->assertCount($totalUsers, $response['body']['users']); + $this->assertGreaterThanOrEqual($minUsers, count($response['body']['users'])); $response = $this->client->call(Client::METHOD_GET, '/users', array_merge([ 'content-type' => 'application/json', @@ -930,7 +932,9 @@ trait UsersBase $this->assertEquals($response['headers']['status-code'], 200); $this->assertNotEmpty($response['body']); $this->assertNotEmpty($response['body']['users']); - $this->assertCount($totalUsers - 1, $response['body']['users']); + // CursorAfter should return results, count varies in parallel mode + $this->assertGreaterThanOrEqual(1, count($response['body']['users'])); + // First result after cursor should be user1 (created right after setupUser) $this->assertEquals($response['body']['users'][0]['$id'], 'user1'); $response = $this->client->call(Client::METHOD_GET, '/users', array_merge([