From db8010f7c6c6cbbd020ce8ec74b9fe31d47a533b Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Tue, 18 Feb 2025 13:03:57 +0530 Subject: [PATCH] Fix site tests --- .../Services/Sites/SitesCustomServerTest.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 3fde0ba175..eefa0ddcbb 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -11,6 +11,7 @@ use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; use Utopia\Database\Validator\Datetime as DatetimeValidator; +use Utopia\System\System; class SitesCustomServerTest extends Scope { @@ -1307,7 +1308,7 @@ class SitesCustomServerTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertStringNotContainsString("This domain is not connected to any Appwrite resource yet", $response['body']); - $site = $this->createSite([ + $site2 = $this->createSite([ 'siteId' => ID::unique(), 'name' => 'Startup 2 site', 'framework' => 'other', @@ -1319,10 +1320,19 @@ class SitesCustomServerTest extends Scope 'fallbackFile' => '', ]); - $domain = $this->setupSiteDomain($site['body']['$id'], $subdomain); + $siteId2 = $site2['body']['$id']; - $this->assertEquals(409, $domain['headers']['status-code']); - $this->assertStringContainsString("Domain already assigned to another resource.", $domain['body']['message']); + $rule = $this->client->call(Client::METHOD_POST, '/proxy/rules', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'domain' => $subdomain . '.' . System::getEnv('_APP_DOMAIN_SITES', ''), + 'resourceType' => 'site', + 'resourceId' => $siteId2, + ]); + + $this->assertEquals(409, $rule['headers']['status-code']); + $this->assertStringContainsString("Document with the requested ID already exists. Try again with a different ID or use ID.unique() to generate a unique ID.", $rule['body']['message']); $this->cleanupSite($siteId);