1
0
Fork 0
mirror of synced 2024-09-29 17:01:37 +13:00

Fix users tests

This commit is contained in:
Jake Barnby 2024-01-09 16:43:39 +13:00
parent 460ace2d0a
commit 5044c0cafa
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C

View file

@ -5,7 +5,9 @@ namespace Tests\E2E\Services\Users;
use Appwrite\Tests\Retry; use Appwrite\Tests\Retry;
use Appwrite\Utopia\Response; use Appwrite\Utopia\Response;
use Tests\E2E\Client; use Tests\E2E\Client;
use Utopia\Database\Document;
use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\ID;
use Utopia\Database\Query;
trait UsersBase trait UsersBase
{ {
@ -350,7 +352,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['equal("name", "' . $user1['name'] . '")'] 'queries' => [
Query::equal('name', [$user1['name']])->toString()
]
]); ]);
$this->assertEquals($response['headers']['status-code'], 200); $this->assertEquals($response['headers']['status-code'], 200);
@ -359,11 +363,14 @@ trait UsersBase
$this->assertCount(1, $response['body']['users']); $this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['name'], $user1['name']); $this->assertEquals($response['body']['users'][0]['name'], $user1['name']);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([ $response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['equal("email", "' . $user1['email'] . '")'] 'queries' => [
Query::equal('name', [$user1['name']])->toString()
]
]); ]);
$this->assertEquals($response['headers']['status-code'], 200); $this->assertEquals($response['headers']['status-code'], 200);
@ -376,7 +383,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['equal("status", true)'] 'queries' => [
Query::equal('status', [true])->toString()
]
]); ]);
$this->assertEquals($response['headers']['status-code'], 200); $this->assertEquals($response['headers']['status-code'], 200);
@ -392,7 +401,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['equal("status", false)'] 'queries' => [
Query::equal('status', [false])->toString()
]
]); ]);
$this->assertEquals($response['headers']['status-code'], 200); $this->assertEquals($response['headers']['status-code'], 200);
@ -404,7 +415,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['equal("passwordUpdate", "' . $user1['passwordUpdate'] . '")'] 'queries' => [
Query::equal('passwordUpdate', [$user1['passwordUpdate']])->toString()
]
]); ]);
$this->assertEquals($response['headers']['status-code'], 200); $this->assertEquals($response['headers']['status-code'], 200);
@ -417,7 +430,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['equal("registration", "' . $user1['registration'] . '")'] 'queries' => [
Query::equal('registration', [$user1['registration']])->toString()
]
]); ]);
$this->assertEquals($response['headers']['status-code'], 200); $this->assertEquals($response['headers']['status-code'], 200);
@ -430,7 +445,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['equal("emailVerification", false)'] 'queries' => [
Query::equal('emailVerification', [false])->toString()
]
]); ]);
$this->assertEquals($response['headers']['status-code'], 200); $this->assertEquals($response['headers']['status-code'], 200);
@ -446,7 +463,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['equal("emailVerification", true)'] 'queries' => [
Query::equal('emailVerification', [true])->toString()
]
]); ]);
$this->assertEquals($response['headers']['status-code'], 200); $this->assertEquals($response['headers']['status-code'], 200);
@ -458,7 +477,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['equal("phoneVerification", false)'] 'queries' => [
Query::equal('phoneVerification', [false])->toString()
]
]); ]);
$this->assertEquals($response['headers']['status-code'], 200); $this->assertEquals($response['headers']['status-code'], 200);
@ -470,7 +491,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['equal("phoneVerification", true)'] 'queries' => [
Query::equal('phoneVerification', [true])->toString()
]
]); ]);
$this->assertEquals($response['headers']['status-code'], 200); $this->assertEquals($response['headers']['status-code'], 200);
@ -482,7 +505,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['cursorAfter("' . $data['userId'] . '")'] 'queries' => [
Query::cursorAfter(new Document(['$id' => $data['userId']]))->toString()
]
]); ]);
$this->assertEquals($response['headers']['status-code'], 200); $this->assertEquals($response['headers']['status-code'], 200);
@ -495,7 +520,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['cursorBefore("user1")'] 'queries' => [
Query::cursorBefore(new Document(['$id' => 'user1']))->toString()
]
]); ]);
$this->assertEquals($response['headers']['status-code'], 200); $this->assertEquals($response['headers']['status-code'], 200);
@ -615,7 +642,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['cursorAfter("unknown")'] 'queries' => [
Query::cursorAfter(new Document(['$id' => 'unknown']))->toString()
]
]); ]);
$this->assertEquals(400, $response['headers']['status-code']); $this->assertEquals(400, $response['headers']['status-code']);
@ -1144,7 +1173,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['limit(1)'], 'queries' => [
Query::limit(1)->toString()
],
]); ]);
$this->assertEquals($logs['headers']['status-code'], 200); $this->assertEquals($logs['headers']['status-code'], 200);
@ -1156,7 +1187,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['offset(1)'], 'queries' => [
Query::offset(1)->toString()
],
]); ]);
$this->assertEquals($logs['headers']['status-code'], 200); $this->assertEquals($logs['headers']['status-code'], 200);
@ -1167,7 +1200,10 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['limit(1)', 'offset(1)'], 'queries' => [
Query::limit(1)->toString(),
Query::offset(1)->toString(),
],
]); ]);
$this->assertEquals($logs['headers']['status-code'], 200); $this->assertEquals($logs['headers']['status-code'], 200);
@ -1182,7 +1218,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['limit(-1)'] 'queries' => [
Query::limit(-1)->toString()
]
]); ]);
$this->assertEquals($response['headers']['status-code'], 400); $this->assertEquals($response['headers']['status-code'], 400);
@ -1191,7 +1229,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['offset(-1)'] 'queries' => [
Query::offset(-1)->toString()
]
]); ]);
$this->assertEquals($response['headers']['status-code'], 400); $this->assertEquals($response['headers']['status-code'], 400);
@ -1200,7 +1240,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['equal("$id", "asdf")'] 'queries' => [
Query::equal('$id', ['asdf'])->toString()
]
]); ]);
$this->assertEquals($response['headers']['status-code'], 400); $this->assertEquals($response['headers']['status-code'], 400);
@ -1209,7 +1251,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['orderAsc("$id")'] 'queries' => [
Query::orderAsc('$id')->toString()
]
]); ]);
$this->assertEquals($response['headers']['status-code'], 400); $this->assertEquals($response['headers']['status-code'], 400);
@ -1218,7 +1262,9 @@ trait UsersBase
'content-type' => 'application/json', 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ ], $this->getHeaders()), [
'queries' => ['cursorAsc("$id")'] 'queries' => [
'{ "method": "cursorAsc", "attribute": "$id" }'
]
]); ]);
$this->assertEquals($response['headers']['status-code'], 400); $this->assertEquals($response['headers']['status-code'], 400);