From 646bbdf4891d74b06d52823341d5d3a3b8eb8348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 1 Sep 2022 09:09:28 +0000 Subject: [PATCH] Join tests to resolve race condition --- .../Services/Teams/TeamsConsoleClientTest.php | 56 +++---------------- 1 file changed, 9 insertions(+), 47 deletions(-) diff --git a/tests/e2e/Services/Teams/TeamsConsoleClientTest.php b/tests/e2e/Services/Teams/TeamsConsoleClientTest.php index d91c0abdc4..a55b28a436 100644 --- a/tests/e2e/Services/Teams/TeamsConsoleClientTest.php +++ b/tests/e2e/Services/Teams/TeamsConsoleClientTest.php @@ -67,7 +67,7 @@ class TeamsConsoleClientTest extends Scope /** * @depends testCreateTeam */ - public function testCreateConsoleAccount($data): array + public function testTeamMembershipPerms($data): array { $teamUid = $data['teamUid'] ?? ''; $teamName = $data['teamName'] ?? ''; @@ -81,70 +81,34 @@ class TeamsConsoleClientTest extends Scope 'x-appwrite-project' => 'console'], [ 'userId' => 'unique()', 'email' => $email, - 'password' => 'password', + 'password' => $password, 'name' => $name, - ], false); + ], false); $this->assertEquals(201, $user['headers']['status-code']); - return [ - 'teamUid' => $teamUid, - 'teamName' => $teamName, - 'email' => $email, - 'name' => $name, - 'password' => $password - ]; - } - - // Create membership - /** - * @depends testCreateConsoleAccount - */ - public function testCreateTeamMembershipPerms(array $data): array - { - $teamUid = $data['teamUid'] ?? ''; - $teamName = $data['teamName'] ?? ''; - /** * Test for SUCCESS */ - $response = $this->client->call(Client::METHOD_POST, '/teams/' . $data['teamUid'] . '/memberships', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/teams/' . $teamUid . '/memberships', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'email' => $data['email'], - 'name' => $data['name'], + 'email' => $email, + 'name' => $name, 'roles' => ['admin', 'editor'], 'url' => 'http://localhost:5000/join-us#title' ]); $this->assertEquals(201, $response['headers']['status-code']); - return $data; - } - /** - * @depends testCreateTeamMembership - */ - public function testInvalidPermissionsPerms(array $data): array - { - /** - * Test for FAILURE - */ $response = $this->client->call(Client::METHOD_GET, '/users', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); $this->assertEquals(401, $response['headers']['status-code']); - return $data; - } - // Delete membership and cleanup after permission test - /** - * @depends testInvalidPermissionsPermFix - */ - public function testDeleteTeamMembershipPerms(array $data): array - { - $response = $this->client->call(Client::METHOD_GET, '/teams/' . $data['teamUid'] . '/memberships', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid . '/memberships', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); @@ -153,15 +117,13 @@ class TeamsConsoleClientTest extends Scope $ownerMembershipUid = $response['body']['memberships'][1]['$id']; - /** - * Test for SUCCESS - */ - $response = $this->client->call(Client::METHOD_DELETE, '/teams/' . $data['teamUid'] . '/memberships/' . $ownerMembershipUid, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/teams/' . $teamUid . '/memberships/' . $ownerMembershipUid, array_merge([ 'origin' => 'http://localhost', 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); $this->assertEquals(204, $response['headers']['status-code']); + return $data; } }