diff --git a/tests/e2e/Scopes/ProjectCustom.php b/tests/e2e/Scopes/ProjectCustom.php index b75f46cfb8..fa317a2b48 100644 --- a/tests/e2e/Scopes/ProjectCustom.php +++ b/tests/e2e/Scopes/ProjectCustom.php @@ -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.*' diff --git a/tests/e2e/Scopes/Scope.php b/tests/e2e/Scopes/Scope.php index 85214ad4f8..3d16db1b1b 100644 --- a/tests/e2e/Scopes/Scope.php +++ b/tests/e2e/Scopes/Scope.php @@ -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'); diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index d6dadf61fe..e449bd4867 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -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']); diff --git a/tests/e2e/Services/Webhooks/WebhooksBase.php b/tests/e2e/Services/Webhooks/WebhooksBase.php index 6b57dc980f..84748f98a5 100644 --- a/tests/e2e/Services/Webhooks/WebhooksBase.php +++ b/tests/e2e/Services/Webhooks/WebhooksBase.php @@ -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'] ?? '';