From 353069bc1fcbbda8b40b6c0848afad51ab337205 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 21 Feb 2024 18:50:28 +1300 Subject: [PATCH] Fix GraphQL test relying on creating session when one exists --- tests/e2e/Services/GraphQL/BatchTest.php | 27 +++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/e2e/Services/GraphQL/BatchTest.php b/tests/e2e/Services/GraphQL/BatchTest.php index 55bce6eae3..7d154de802 100644 --- a/tests/e2e/Services/GraphQL/BatchTest.php +++ b/tests/e2e/Services/GraphQL/BatchTest.php @@ -281,19 +281,22 @@ class BatchTest extends Scope public function testQueryBatchedMutations() { $projectId = $this->getProject()['$id']; - $email = 'tester' . \uniqid() . '@example.com'; + $email1 = 'tester' . \uniqid() . '@example.com'; + $email2 = 'tester' . \uniqid() . '@example.com'; $graphQLPayload = [ - 'query' => 'mutation CreateAndLogin($userId: String!, $email: String!, $password: String!, $name: String) { - accountCreate(userId: $userId, email: $email, password: $password, name: $name) { - name + 'query' => 'mutation CreateAndLogin($user1Id: String!, $user2Id: String!, $email1: String!, $email2: String!, $password: String!, $name: String) { + account1: accountCreate(userId: $user1Id, email: $email1, password: $password, name: $name) { + email } - accountCreateEmailPasswordSession(email: $email, password: $password) { - expire + account2: accountCreate(userId: $user2Id, email: $email2, password: $password, name: $name) { + email } }', 'variables' => [ - 'userId' => ID::unique(), - 'email' => $email, + 'user1Id' => ID::unique(), + 'user2Id' => ID::unique(), + 'email1' => $email1, + 'email2' => $email2, 'password' => 'password', 'name' => 'Tester', ], @@ -304,12 +307,12 @@ class BatchTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); - $this->assertIsArray($response['body']['data']); $this->assertArrayNotHasKey('errors', $response['body']); - $this->assertArrayHasKey('accountCreate', $response['body']['data']); - $this->assertArrayHasKey('accountCreateEmailPasswordSession', $response['body']['data']); - $this->assertEquals('Tester', $response['body']['data']['accountCreate']['name']); + $this->assertArrayHasKey('account1', $response['body']['data']); + $this->assertArrayHasKey('account2', $response['body']['data']); + $this->assertEquals($email1, $response['body']['data']['account1']['email']); + $this->assertEquals($email2, $response['body']['data']['account2']['email']); } public function testQueryBatchedMutationsOfSameType()