mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
fix: improve E2E test probes and enable function webhook events
- Fix testPasswordRecoveryUrlParams: use URL-based probes instead of userId-based probes to distinguish between test cases that share the same user - Enable functions.* webhook events in ProjectCustom for function webhook tests that were silently passing by matching stale events - Fix setupTeamMembership: add email address probe to getLastEmail to prevent picking up wrong invitation email - Fix getLastEmail multi-email race: assert count inside assertEventually when requesting multiple emails Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -188,7 +188,7 @@ trait ProjectCustom
|
||||
'name' => 'Webhook Test',
|
||||
'events' => [
|
||||
'databases.*',
|
||||
// 'functions.*', TODO @christyjacob4 : enable test once we allow functions.* events
|
||||
'functions.*',
|
||||
'buckets.*',
|
||||
'teams.*',
|
||||
'users.*'
|
||||
|
||||
@@ -167,6 +167,7 @@ abstract class Scope extends TestCase
|
||||
$result = end($emails);
|
||||
} else {
|
||||
$result = array_slice($emails, -1 * $limit);
|
||||
$this->assertCount($limit, $result, "Expected {$limit} emails but only got " . count($result));
|
||||
}
|
||||
|
||||
$this->assertNotEmpty($result, 'Expected email result to be non-empty');
|
||||
|
||||
@@ -6441,8 +6441,8 @@ class ProjectsConsoleClientTest extends Scope
|
||||
|
||||
$userId = $response['body']['userId'];
|
||||
|
||||
$lastEmail = $this->getLastEmail(1, function ($email) use ($userId) {
|
||||
$this->assertStringContainsString($userId, $email['html'] ?? '');
|
||||
$lastEmail = $this->getLastEmail(1, function ($email) use ($url) {
|
||||
$this->assertStringContainsString($url, $email['html'] ?? '');
|
||||
});
|
||||
|
||||
$this->assertEquals($this->getUser()['email'], $lastEmail['to'][0]['address']);
|
||||
@@ -6474,8 +6474,8 @@ class ProjectsConsoleClientTest extends Scope
|
||||
|
||||
$userId = $response['body']['userId'];
|
||||
|
||||
$lastEmail = $this->getLastEmail(1, function ($email) use ($userId) {
|
||||
$this->assertStringContainsString($userId, $email['html'] ?? '');
|
||||
$lastEmail = $this->getLastEmail(1, function ($email) use ($url) {
|
||||
$this->assertStringContainsString($url, $email['html'] ?? '');
|
||||
});
|
||||
|
||||
$this->assertEquals($this->getUser()['email'], $lastEmail['to'][0]['address']);
|
||||
@@ -6507,8 +6507,8 @@ class ProjectsConsoleClientTest extends Scope
|
||||
|
||||
$userId = $response['body']['userId'];
|
||||
|
||||
$lastEmail = $this->getLastEmail(1, function ($email) use ($userId) {
|
||||
$this->assertStringContainsString($userId, $email['html'] ?? '');
|
||||
$lastEmail = $this->getLastEmail(1, function ($email) use ($url, $userId) {
|
||||
$this->assertStringContainsString($url . '?userId=' . $userId, $email['html'] ?? '');
|
||||
});
|
||||
|
||||
$this->assertEquals($this->getUser()['email'], $lastEmail['to'][0]['address']);
|
||||
@@ -6540,8 +6540,8 @@ class ProjectsConsoleClientTest extends Scope
|
||||
|
||||
$userId = $response['body']['userId'];
|
||||
|
||||
$lastEmail = $this->getLastEmail(1, function ($email) use ($userId) {
|
||||
$this->assertStringContainsString($userId, $email['html'] ?? '');
|
||||
$lastEmail = $this->getLastEmail(1, function ($email) use ($url, $userId) {
|
||||
$this->assertStringContainsString($url . '?userId=' . $userId, $email['html'] ?? '');
|
||||
});
|
||||
|
||||
$this->assertEquals($this->getUser()['email'], $lastEmail['to'][0]['address']);
|
||||
@@ -6573,8 +6573,8 @@ class ProjectsConsoleClientTest extends Scope
|
||||
|
||||
$userId = $response['body']['userId'];
|
||||
|
||||
$lastEmail = $this->getLastEmail(1, function ($email) use ($userId) {
|
||||
$this->assertStringContainsString($userId, $email['html'] ?? '');
|
||||
$lastEmail = $this->getLastEmail(1, function ($email) {
|
||||
$this->assertStringContainsString('INJECTED', $email['html'] ?? '');
|
||||
});
|
||||
|
||||
$this->assertEquals($this->getUser()['email'], $lastEmail['to'][0]['address']);
|
||||
|
||||
@@ -277,8 +277,10 @@ trait WebhooksBase
|
||||
$membershipId = $team['body']['$id'];
|
||||
$userId = $team['body']['userId'];
|
||||
|
||||
// Get the secret from email
|
||||
$lastEmail = $this->getLastEmail();
|
||||
// Get the secret from email (use probe to match correct email by recipient address)
|
||||
$lastEmail = $this->getLastEmail(1, function ($msg) use ($email) {
|
||||
$this->assertEquals($email, $msg['to'][0]['address'] ?? '');
|
||||
});
|
||||
$tokens = $this->extractQueryParamsFromEmailLink($lastEmail['html'] ?? '');
|
||||
$secret = $tokens['secret'] ?? '';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user