Repository: appwrite/appwrite
File: tests/e2e/Services/Sites/SitesCustomServerTest.php (PHP)

Code before:
            $this->assertEquals('failed', $deployment['body']['status'], 'Deployment status is failed, deployment: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT));
        }, 100000, 500);

        $this->cleanupSite($siteId);
    }

    public function testPermanentRedirect(): void
    {
        $siteId = $this->setupSite([
            'siteId' => ID::unique(),
            'name' => 'Sub project site',
            'framework' => 'other',
            'buildRuntime' => 'node-22',
            'outputDirectory' => './'
        ]);
        $this->assertNotEmpty($siteId);

        $site = $this->getSite($siteId);
        $this->assertEquals('200', $site['headers']['status-code']);
        $this->assertArrayHasKey('adapter', $site['body']);

        $domain = $this->setupSiteDomain($siteId);
        $this->assertNotEmpty($domain);

        $deploymentId = $this->setupDeployment($siteId, [
            'code' => $this->packageSite('subProjects'),
            'activate' => 'true'
        ]);
        $this->assertNotEmpty($deploymentId);

        $site = $this->getSite($siteId);

        $proxyClient = new Client();
        $proxyClient->setEndpoint('http://' . $domain);
        $response = $proxyClient->call(Client::METHOD_GET, '/');
        $this->assertEquals(200, $response['headers']['status-code']);
        $response1 = $proxyClient->call(Client::METHOD_GET, '/project1');
        $this->assertEquals(200, $response1['headers']['status-code']);
        $response2 = $proxyClient->call(Client::METHOD_GET, '/project1/');
        $this->assertEquals(200, $response2['headers']['status-code']);
        $this->cleanupSite($siteId);
    }
}


Review comment (suggestion):
Let's rename to sub-directories, it better describes what we are testing.

Also `sub-directories` not `subDirectories` for folder name

Code after:
            $this->assertEquals('failed', $deployment['body']['status'], 'Deployment status is failed, deployment: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT));
        }, 100000, 500);

        $this->cleanupSite($siteId);
    }

    public function testDomainForFailedDeloyment(): void
    {
        $siteId = $this->setupSite([
            'siteId' => ID::unique(),
            'name' => 'Test Site',
            'framework' => 'astro',
            'buildRuntime' => 'node-22',
            'buildCommand' => 'cd random'
        ]);

        $this->assertNotEmpty($siteId);

        $domain = $this->setupSiteDomain($siteId);
        $this->assertNotEmpty($domain);
        $proxyClient = new Client();
        $proxyClient->setEndpoint('http://' . $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'], json_encode($deployment['body'], JSON_PRETTY_PRINT));
        }, 100000, 500);

        $response = $proxyClient->call(Client::METHOD_GET, '/');
        $this->assertStringContainsString('build_failed', $response['body']);

        $this->cleanupSite($siteId);
    }

    public function testPermanentRedirect(): void
    {
        $siteId = $this->setupSite([
            'siteId' => ID::unique(),
            'name' => 'Sub project site',
            'framework' => 'other',
            'buildRuntime' => 'node-22',
            'outputDirectory' => './'