From e3bed0c6369d1c9bc280d4d36a304eb8f2c4c330 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 18 Jul 2022 21:38:13 +1200 Subject: [PATCH] Test fixes --- app/config/variables.php | 4 ++-- app/controllers/api/teams.php | 2 +- src/Appwrite/GraphQL/Resolvers.php | 2 +- tests/e2e/Services/GraphQL/GraphQLAccountTest.php | 3 ++- tests/e2e/Services/GraphQL/GraphQLAuthTest.php | 1 + tests/e2e/Services/GraphQL/GraphQLBase.php | 4 ++-- tests/e2e/Services/GraphQL/GraphQLDatabaseClientTest.php | 1 + tests/e2e/Services/GraphQL/GraphQLDatabaseServerTest.php | 4 ++++ tests/e2e/Services/GraphQL/GraphQLFunctionsServerTest.php | 2 ++ tests/e2e/Services/GraphQL/GraphQLStorageClientTest.php | 4 ++-- tests/e2e/Services/GraphQL/GraphQLStorageServerTest.php | 4 +++- tests/e2e/Services/GraphQL/GraphQLTeamsClientTest.php | 3 ++- tests/e2e/Services/GraphQL/GraphQLTeamsServerTest.php | 6 ++++-- tests/e2e/Services/GraphQL/GraphQLUsersTest.php | 3 +++ 14 files changed, 30 insertions(+), 13 deletions(-) diff --git a/app/config/variables.php b/app/config/variables.php index 0116c8d335..ce13dec21b 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -838,7 +838,7 @@ return [ 'variables' => [ [ 'name' => '_APP_GRAPHQL_MAX_BATCH_SIZE', - 'description' => 'Maximum number of batched queries per request. The default value is 50.', + 'description' => 'Maximum number of batched queries per request. The default value is 10.', 'introduction' => '0.17.0', 'default' => '10', 'required' => false, @@ -847,7 +847,7 @@ return [ ], [ 'name' => '_APP_GRAPHQL_MAX_COMPLEXITY', - 'description' => 'Maximum complexity of a GraphQL query. The default value is 200.', + 'description' => 'Maximum complexity of a GraphQL query. The default value is 50.', 'introduction' => '0.17.0', 'default' => '50', 'required' => false, diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 40388a8520..f0778802cb 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -70,7 +70,7 @@ App::post('/v1/teams') if (!\in_array('owner', $roles)) { $roles[] = 'owner'; } - + $membershipId = $dbForProject->getId(); $membership = new Document([ '$id' => $membershipId, diff --git a/src/Appwrite/GraphQL/Resolvers.php b/src/Appwrite/GraphQL/Resolvers.php index 04f903290b..053e6a2b07 100644 --- a/src/Appwrite/GraphQL/Resolvers.php +++ b/src/Appwrite/GraphQL/Resolvers.php @@ -32,7 +32,7 @@ class Resolvers $path = $route->getPath(); foreach ($args as $key => $value) { - if (\str_contains($path, $key)) { + if (\str_contains($path, '/:' . $key)) { $path = \str_replace(':' . $key, $value, $path); } } diff --git a/tests/e2e/Services/GraphQL/GraphQLAccountTest.php b/tests/e2e/Services/GraphQL/GraphQLAccountTest.php index 573ad839d8..1e998bf6a5 100644 --- a/tests/e2e/Services/GraphQL/GraphQLAccountTest.php +++ b/tests/e2e/Services/GraphQL/GraphQLAccountTest.php @@ -444,8 +444,8 @@ class GraphQLAccountTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); + $this->assertIsNotArray($account['body']); $this->assertEquals(204, $account['headers']['status-code']); - $this->assertEmpty($account['body']); unset(self::$user[$this->getProject()['$id']]); $this->getUser(); @@ -469,6 +469,7 @@ class GraphQLAccountTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); + $this->assertIsNotArray($account['body']); $this->assertEquals(204, $account['headers']['status-code']); unset(self::$user[$this->getProject()['$id']]); diff --git a/tests/e2e/Services/GraphQL/GraphQLAuthTest.php b/tests/e2e/Services/GraphQL/GraphQLAuthTest.php index edc6f0c67c..8ca72e61ca 100644 --- a/tests/e2e/Services/GraphQL/GraphQLAuthTest.php +++ b/tests/e2e/Services/GraphQL/GraphQLAuthTest.php @@ -235,6 +235,7 @@ class GraphQLAuthTest extends Scope 'cookie' => 'a_session_' . $projectId . '=' . $this->token1, ], $gqlPayload); + $this->assertIsNotArray($document['body']); $this->assertEquals(204, $document['headers']['status-code']); } } diff --git a/tests/e2e/Services/GraphQL/GraphQLBase.php b/tests/e2e/Services/GraphQL/GraphQLBase.php index 22fe55274b..a36577ed66 100644 --- a/tests/e2e/Services/GraphQL/GraphQLBase.php +++ b/tests/e2e/Services/GraphQL/GraphQLBase.php @@ -1057,8 +1057,8 @@ trait GraphQLBase } }'; case self::$DELETE_TEAM_MEMBERSHIP: - return 'mutation deleteTeamMembership($teamId: String!, $userId: String!){ - teamsDeleteMembership(teamId: $teamId, userId: $userId) + return 'mutation deleteTeamMembership($teamId: String!, $membershipId: String!){ + teamsDeleteMembership(teamId: $teamId, membershipId: $membershipId) }'; case self::$GET_FUNCTION: return 'query getFunction($functionId: String!) { diff --git a/tests/e2e/Services/GraphQL/GraphQLDatabaseClientTest.php b/tests/e2e/Services/GraphQL/GraphQLDatabaseClientTest.php index b8f97c4d31..83605771e8 100644 --- a/tests/e2e/Services/GraphQL/GraphQLDatabaseClientTest.php +++ b/tests/e2e/Services/GraphQL/GraphQLDatabaseClientTest.php @@ -288,6 +288,7 @@ class GraphQLDatabaseClientTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $gqlPayload); + $this->assertIsNotArray($document['body']); $this->assertEquals(204, $document['headers']['status-code']); } } diff --git a/tests/e2e/Services/GraphQL/GraphQLDatabaseServerTest.php b/tests/e2e/Services/GraphQL/GraphQLDatabaseServerTest.php index 0ddba9541e..14edc1d6ca 100644 --- a/tests/e2e/Services/GraphQL/GraphQLDatabaseServerTest.php +++ b/tests/e2e/Services/GraphQL/GraphQLDatabaseServerTest.php @@ -843,6 +843,7 @@ class GraphQLDatabaseServerTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $gqlPayload); + $this->assertIsNotArray($document['body']); $this->assertEquals(204, $document['headers']['status-code']); } @@ -871,6 +872,7 @@ class GraphQLDatabaseServerTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $gqlPayload); + $this->assertIsNotArray($attribute['body']); $this->assertEquals(204, $attribute['headers']['status-code']); } @@ -895,6 +897,7 @@ class GraphQLDatabaseServerTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $gqlPayload); + $this->assertIsNotArray($collection['body']); $this->assertEquals(204, $collection['headers']['status-code']); } @@ -918,6 +921,7 @@ class GraphQLDatabaseServerTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $gqlPayload); + $this->assertIsNotArray($database['body']); $this->assertEquals(204, $database['headers']['status-code']); } } diff --git a/tests/e2e/Services/GraphQL/GraphQLFunctionsServerTest.php b/tests/e2e/Services/GraphQL/GraphQLFunctionsServerTest.php index ac45aaa954..d53b73923a 100644 --- a/tests/e2e/Services/GraphQL/GraphQLFunctionsServerTest.php +++ b/tests/e2e/Services/GraphQL/GraphQLFunctionsServerTest.php @@ -400,6 +400,7 @@ class GraphQLFunctionsServerTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $gqlPayload); + $this->assertIsNotArray($response['body']); $this->assertEquals(204, $response['headers']['status-code']); } @@ -425,6 +426,7 @@ class GraphQLFunctionsServerTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $gqlPayload); + $this->assertIsNotArray($response['body']); $this->assertEquals(204, $response['headers']['status-code']); } } diff --git a/tests/e2e/Services/GraphQL/GraphQLStorageClientTest.php b/tests/e2e/Services/GraphQL/GraphQLStorageClientTest.php index 4f0e92a1f7..3e74ada14b 100644 --- a/tests/e2e/Services/GraphQL/GraphQLStorageClientTest.php +++ b/tests/e2e/Services/GraphQL/GraphQLStorageClientTest.php @@ -258,7 +258,6 @@ class GraphQLStorageClientTest extends Scope /** * @depends testCreateFile * @param $file - * @return array * @throws \Exception */ public function testDeleteFile($file): void @@ -278,6 +277,7 @@ class GraphQLStorageClientTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $gqlPayload); - $this->assertEquals(200, $file['headers']['status-code']); + $this->assertIsNotArray($file['body']); + $this->assertEquals(204, $file['headers']['status-code']); } } diff --git a/tests/e2e/Services/GraphQL/GraphQLStorageServerTest.php b/tests/e2e/Services/GraphQL/GraphQLStorageServerTest.php index 0be400cd90..beb0ac3b6b 100644 --- a/tests/e2e/Services/GraphQL/GraphQLStorageServerTest.php +++ b/tests/e2e/Services/GraphQL/GraphQLStorageServerTest.php @@ -358,7 +358,8 @@ class GraphQLStorageServerTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $gqlPayload); - $this->assertEquals(200, $file['headers']['status-code']); + $this->assertIsNotArray($file['body']); + $this->assertEquals(204, $file['headers']['status-code']); } /** @@ -383,6 +384,7 @@ class GraphQLStorageServerTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $gqlPayload); + $this->assertIsNotArray($bucket['body']); $this->assertEquals(204, $bucket['headers']['status-code']); } } diff --git a/tests/e2e/Services/GraphQL/GraphQLTeamsClientTest.php b/tests/e2e/Services/GraphQL/GraphQLTeamsClientTest.php index a663bb039e..228855c72e 100644 --- a/tests/e2e/Services/GraphQL/GraphQLTeamsClientTest.php +++ b/tests/e2e/Services/GraphQL/GraphQLTeamsClientTest.php @@ -183,6 +183,7 @@ class GraphQLTeamsClientTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); - $this->assertEquals(200, $team['headers']['status-code']); + $this->assertIsNotArray($team['body']); + $this->assertEquals(204, $team['headers']['status-code']); } } diff --git a/tests/e2e/Services/GraphQL/GraphQLTeamsServerTest.php b/tests/e2e/Services/GraphQL/GraphQLTeamsServerTest.php index 225a4b9689..a348c0b7ec 100644 --- a/tests/e2e/Services/GraphQL/GraphQLTeamsServerTest.php +++ b/tests/e2e/Services/GraphQL/GraphQLTeamsServerTest.php @@ -236,7 +236,8 @@ class GraphQLTeamsServerTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); - $this->assertEquals(200, $team['headers']['status-code']); + $this->assertIsNotArray($team['body']); + $this->assertEquals(204, $team['headers']['status-code']); } public function testDeleteTeam() @@ -257,6 +258,7 @@ class GraphQLTeamsServerTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); - $this->assertEquals(200, $team['headers']['status-code']); + $this->assertIsNotArray($team['body']); + $this->assertEquals(204, $team['headers']['status-code']); } } diff --git a/tests/e2e/Services/GraphQL/GraphQLUsersTest.php b/tests/e2e/Services/GraphQL/GraphQLUsersTest.php index da5fab5ad6..90a086eabd 100644 --- a/tests/e2e/Services/GraphQL/GraphQLUsersTest.php +++ b/tests/e2e/Services/GraphQL/GraphQLUsersTest.php @@ -372,6 +372,7 @@ class GraphQLUsersTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); + $this->assertIsNotArray($user['body']); $this->assertEquals(204, $user['headers']['status-code']); unset(self::$user[$this->getProject()['$id']]); @@ -395,6 +396,7 @@ class GraphQLUsersTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); + $this->assertIsNotArray($user['body']); $this->assertEquals(204, $user['headers']['status-code']); unset(self::$user[$this->getProject()['$id']]); @@ -417,6 +419,7 @@ class GraphQLUsersTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); + $this->assertIsNotArray($user['body']); $this->assertEquals(204, $user['headers']['status-code']); } }