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

Code before:
            'name' => 'Duplicate deployment Site',
            'adapter' => 'static',
            'fallbackFile' => 'index.html',
        ]);
        $this->assertEquals(200, $site['headers']['status-code']);
        $this->assertEquals('index.html', $site['body']['fallbackFile']);

        $deployment = $this->client->call(Client::METHOD_POST, '/sites/' . $siteId . '/deployments/duplicate', array_merge([
            'content-type' => 'multipart/form-data',
            'x-appwrite-project' => $this->getProject()['$id'],
            'x-sdk-language' => 'cli'
        ], $this->getHeaders()), [
            'deploymentId' => $deploymentId1,
        ]);

        $this->assertEquals(202, $deployment['headers']['status-code']);

        $deploymentId2 = $deployment['body']['$id'];
        $this->assertNotEmpty($deploymentId2);

        $deployment = $this->getDeployment($siteId, $deploymentId2);
        $this->assertEquals(200, $deployment['headers']['status-code']);
        $this->assertGreaterThan(0, $deployment['body']['sourceSize']);
        $this->assertEquals(0, $deployment['body']['buildSize']);
        $this->assertEquals($deployment['body']['sourceSize'], $deployment['body']['totalSize']);
        $this->assertEquals('cli', $deployment['body']['type']);

        $this->assertEventually(function () use ($siteId, $deploymentId2) {
            $site = $this->getSite($siteId);
            $this->assertEquals($deploymentId2, $site['body']['deploymentId']);
        }, 50000, 500);

        $response = $proxyClient->call(Client::METHOD_GET, '/not-found');
        $this->assertStringContainsString("Index page", $response['body']);

        $deployment = $this->getDeployment($siteId, $deploymentId2);
        $this->assertEquals(200, $deployment['headers']['status-code']);
        $this->assertGreaterThan(0, $deployment['body']['sourceSize']);
        $this->assertGreaterThan(0, $deployment['body']['buildSize']);
        $totalSize = $deployment['body']['sourceSize'] + $deployment['body']['buildSize'];
        $this->assertEquals($totalSize, $deployment['body']['totalSize']);

        $this->cleanupSite($siteId);
    }

    public function testUpdateDeploymentStatus(): void
    {
        $siteId = $this->setupSite([
            'buildRuntime' => 'node-22',
            'framework' => 'other',
            'name' => 'Activate test Site',

Review comment (refactor):
Let's find any place where we do createDuplicateDeployment again (another place), and there let's use helper, and ensure type is manual.

If we dont have such a scenario, let's create it somewhere around here

Code after:
            'name' => 'Duplicate deployment Site',
            'adapter' => 'static',
            'fallbackFile' => 'index.html',
        ]);
        $this->assertEquals(200, $site['headers']['status-code']);
        $this->assertEquals('index.html', $site['body']['fallbackFile']);

        $deployment = $this->client->call(Client::METHOD_POST, '/sites/' . $siteId . '/deployments/duplicate', array_merge([
            'content-type' => 'multipart/form-data',
            'x-appwrite-project' => $this->getProject()['$id'],
            'x-sdk-language' => 'cli'
        ], $this->getHeaders()), [
            'deploymentId' => $deploymentId1,
        ]);

        $this->assertEquals(202, $deployment['headers']['status-code']);

        $deploymentId2 = $deployment['body']['$id'];
        $this->assertNotEmpty($deploymentId2);

        $deployment = $this->getDeployment($siteId, $deploymentId2);
        $this->assertEquals(200, $deployment['headers']['status-code']);
        $this->assertGreaterThan(0, $deployment['body']['sourceSize']);
        $this->assertEquals(0, $deployment['body']['buildSize']);
        $this->assertEquals($deployment['body']['sourceSize'], $deployment['body']['totalSize']);
        $this->assertEquals('cli', $deployment['body']['type']);

        // create another duplicate deployment with manual trigger
        $deployment = $this->client->call(Client::METHOD_POST, '/sites/' . $siteId . '/deployments/duplicate', array_merge([
            'content-type' => 'multipart/form-data',
            'x-appwrite-project' => $this->getProject()['$id'],
        ], $this->getHeaders()), [
            'deploymentId' => $deploymentId1,
        ]);

        $this->assertEquals(202, $deployment['headers']['status-code']);

        $deploymentId2 = $deployment['body']['$id'];
        $this->assertNotEmpty($deploymentId2);

        $deployment = $this->getDeployment($siteId, $deploymentId2);
        $this->assertEquals(200, $deployment['headers']['status-code']);
        $this->assertGreaterThan(0, $deployment['body']['sourceSize']);
        $this->assertEquals(0, $deployment['body']['buildSize']);
        $this->assertEquals($deployment['body']['sourceSize'], $deployment['body']['totalSize']);
        $this->assertEquals('manual', $deployment['body']['type']);

        $this->assertEventually(function () use ($siteId, $deploymentId2) {
            $site = $this->getSite($siteId);
            $this->assertEquals($deploymentId2, $site['body']['deploymentId']);
        }, 50000, 500);