From 1580bac1fc68157eefa9c66371bc39dcd95a141e Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Mon, 24 Mar 2025 13:30:21 +0530 Subject: [PATCH 1/4] Add tests for empty output directory --- .../Services/Sites/SitesCustomServerTest.php | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index a95568c7ce..861eeb7dc9 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -2331,4 +2331,82 @@ class SitesCustomServerTest extends Scope $this->cleanupSite($siteId); } + + public function testEmptyOutputDirectoryExists(): void + { + $siteId = $this->setupSite([ + 'siteId' => ID::unique(), + 'name' => 'Astro empty output directory', + 'framework' => 'astro', + 'buildRuntime' => 'node-22', + 'outputDirectory' => './random', + 'buildCommand' => 'mkdir random && npm run build', + 'installCommand' => 'npm install', + ]); + $this->assertNotEmpty($siteId); + + $site = $this->getSite($siteId); + $this->assertEquals('200', $site['headers']['status-code']); + $this->assertArrayHasKey('adapter', $site['body']); + $this->assertEmpty($site['body']['adapter']); + + $domain = $this->setupSiteDomain($siteId); + $this->assertNotEmpty($domain); + + $deployment = $this->createDeployment($siteId, [ + 'code' => $this->packageSite('astro'), + 'activate' => true + ]); + $this->assertEquals(202, $deployment['headers']['status-code']); + + $deploymentId = $deployment['body']['$id']; + $this->assertNotEmpty($deploymentId); + + $this->assertEventually(function () use ($siteId, $deploymentId) { + $deployment = $this->getDeployment($siteId, $deploymentId); + $this->assertEquals('failed', $deployment['body']['status'], 'Deployment status is failed, deployment: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); + $this->assertStringContainsString('Error: Build output directory is empty.', $deployment['body']['buildLogs']); + }, 100000, 500); + + $this->cleanupSite($siteId); + } + + public function testEmptyOutputDirectoryDoesNotExist(): void + { + $siteId = $this->setupSite([ + 'siteId' => ID::unique(), + 'name' => 'Astro empty output directory', + 'framework' => 'astro', + 'buildRuntime' => 'node-22', + 'outputDirectory' => './random', + 'buildCommand' => 'npm run build', + 'installCommand' => 'npm install', + ]); + $this->assertNotEmpty($siteId); + + $site = $this->getSite($siteId); + $this->assertEquals('200', $site['headers']['status-code']); + $this->assertArrayHasKey('adapter', $site['body']); + $this->assertEmpty($site['body']['adapter']); + + $domain = $this->setupSiteDomain($siteId); + $this->assertNotEmpty($domain); + + $deployment = $this->createDeployment($siteId, [ + 'code' => $this->packageSite('astro'), + 'activate' => true + ]); + $this->assertEquals(202, $deployment['headers']['status-code']); + + $deploymentId = $deployment['body']['$id']; + $this->assertNotEmpty($deploymentId); + + $this->assertEventually(function () use ($siteId, $deploymentId) { + $deployment = $this->getDeployment($siteId, $deploymentId); + $this->assertEquals('failed', $deployment['body']['status'], 'Deployment status is failed, deployment: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); + $this->assertStringContainsString('Error: Output directory is either not set or does not exist.', $deployment['body']['buildLogs']); + }, 100000, 500); + + $this->cleanupSite($siteId); + } } From 5582c6956de156a633c3e910060a2d77bf8a3af0 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Tue, 25 Mar 2025 17:03:19 +0530 Subject: [PATCH 2/4] Remove specific checks --- tests/e2e/Services/Sites/SitesCustomServerTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 35dfaa0e81..86fc20c234 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -2294,7 +2294,6 @@ class SitesCustomServerTest extends Scope $this->assertEventually(function () use ($siteId, $deploymentId) { $deployment = $this->getDeployment($siteId, $deploymentId); $this->assertEquals('failed', $deployment['body']['status'], 'Deployment status is failed, deployment: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); - $this->assertStringContainsString('Error: Build output directory is empty.', $deployment['body']['buildLogs']); }, 100000, 500); $this->cleanupSite($siteId); @@ -2333,7 +2332,6 @@ class SitesCustomServerTest extends Scope $this->assertEventually(function () use ($siteId, $deploymentId) { $deployment = $this->getDeployment($siteId, $deploymentId); $this->assertEquals('failed', $deployment['body']['status'], 'Deployment status is failed, deployment: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); - $this->assertStringContainsString('Error: Output directory is either not set or does not exist.', $deployment['body']['buildLogs']); }, 100000, 500); $this->cleanupSite($siteId); From ed95ac764380efcac4e55b5357a2ae2b342b45ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 14 Apr 2025 12:54:56 +0200 Subject: [PATCH 3/4] Re-add test, simplify --- .../Services/Sites/SitesCustomServerTest.php | 61 ++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index ba0242bb20..160b2a018d 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -2535,7 +2535,66 @@ class SitesCustomServerTest extends Scope $this->assertEventually(function () use ($siteId, $deploymentId) { $deployment = $this->getDeployment($siteId, $deploymentId); $this->assertEquals('failed', $deployment['body']['status'], 'Deployment status does not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); - $this->assertStringContainsString('Error', $deployment['body']['buildLogs'], 'Deployment logs do not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); + $this->assertStringContainsString('Error:', $deployment['body']['buildLogs'], 'Deployment logs do not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); + }, 100000, 500); + + $this->cleanupSite($siteId); + } + + public function testOutputDirectoryEmpty(): void + { + $siteId = $this->setupSite([ + 'siteId' => ID::unique(), + 'name' => 'Empty output directory', + 'framework' => 'other', + 'buildRuntime' => 'node-22', + 'outputDirectory' => './empty-directory', + 'buildCommand' => 'mkdir -p ./empty-directory' + ]); + $this->assertNotEmpty($siteId); + + $deployment = $this->createDeployment($siteId, [ + 'code' => $this->packageSite('static'), + 'activate' => true + ]); + $this->assertEquals(202, $deployment['headers']['status-code']); + + $deploymentId = $deployment['body']['$id']; + $this->assertNotEmpty($deploymentId); + + $this->assertEventually(function () use ($siteId, $deploymentId) { + $deployment = $this->getDeployment($siteId, $deploymentId); + $this->assertEquals('failed', $deployment['body']['status'], 'Deployment status does not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); + $this->assertStringContainsString('Error:', $deployment['body']['buildLogs'], 'Deployment logs do not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); + }, 100000, 500); + + $this->cleanupSite($siteId); + } + + public function testOutputDirectoryMissing(): void + { + $siteId = $this->setupSite([ + 'siteId' => ID::unique(), + 'name' => 'Empty output directory', + 'framework' => 'other', + 'buildRuntime' => 'node-22', + 'outputDirectory' => './non-existing-directory', + ]); + $this->assertNotEmpty($siteId); + + $deployment = $this->createDeployment($siteId, [ + 'code' => $this->packageSite('static'), + 'activate' => true + ]); + $this->assertEquals(202, $deployment['headers']['status-code']); + + $deploymentId = $deployment['body']['$id']; + $this->assertNotEmpty($deploymentId); + + $this->assertEventually(function () use ($siteId, $deploymentId) { + $deployment = $this->getDeployment($siteId, $deploymentId); + $this->assertEquals('failed', $deployment['body']['status'], 'Deployment status does not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); + $this->assertStringContainsString('Error:', $deployment['body']['buildLogs'], 'Deployment logs do not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); }, 100000, 500); $this->cleanupSite($siteId); From 0b6a8ec2cac42feaded0d25d4e5ae5fd9ca95729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 14 Apr 2025 13:39:23 +0200 Subject: [PATCH 4/4] Update tests/e2e/Services/Sites/SitesCustomServerTest.php --- tests/e2e/Services/Sites/SitesCustomServerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 160b2a018d..0b3b1710c1 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -2575,7 +2575,7 @@ class SitesCustomServerTest extends Scope { $siteId = $this->setupSite([ 'siteId' => ID::unique(), - 'name' => 'Empty output directory', + 'name' => 'Missing output directory', 'framework' => 'other', 'buildRuntime' => 'node-22', 'outputDirectory' => './non-existing-directory',