mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
fix: test phone verification flakiness
This commit is contained in:
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace Tests\E2E\Services\Account;
|
||||
|
||||
use Appwrite\Tests\Async;
|
||||
use Tests\E2E\Client;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Validator\Datetime as DatetimeValidator;
|
||||
|
||||
trait AccountBase
|
||||
{
|
||||
use Async;
|
||||
|
||||
public function testCreateAccount(): array
|
||||
{
|
||||
$email = uniqid() . 'user@localhost.test';
|
||||
|
||||
@@ -2339,7 +2339,6 @@ class AccountCustomClientTest extends Scope
|
||||
/**
|
||||
* @depends testUpdatePhone
|
||||
*/
|
||||
#[Retry(count: 3)]
|
||||
public function testPhoneVerification(array $data): array
|
||||
{
|
||||
$session = $data['session'] ?? '';
|
||||
@@ -2359,13 +2358,21 @@ class AccountCustomClientTest extends Scope
|
||||
$this->assertEmpty($response['body']['secret']);
|
||||
$this->assertTrue((new DatetimeValidator())->isValid($response['body']['expire']));
|
||||
|
||||
$smsRequest = $this->getLastRequest();
|
||||
$token = null;
|
||||
|
||||
$this->assertEventually(function () use (&$token) {
|
||||
$request = json_decode(file_get_contents('http://request-catcher:5000/__last_request__'), true);
|
||||
|
||||
$body = json_decode($request['data'], true);
|
||||
$this->assertArrayHasKey('message', $body);
|
||||
|
||||
$token = substr($body['message'], 0, 6);
|
||||
$this->assertNotEmpty($token);
|
||||
}, 10000, 500);
|
||||
|
||||
$message = $smsRequest['data']['message'];
|
||||
$token = substr($message, 0, 6);
|
||||
|
||||
return \array_merge($data, [
|
||||
'token' => \substr($smsRequest['data']['message'], 0, 6)
|
||||
'token' => $token
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user