Add E2E test for secret env var

This commit is contained in:
Khushboo Verma
2025-02-10 18:43:31 +05:30
parent f96291af88
commit 3a766bf970
6 changed files with 4937 additions and 0 deletions
@@ -212,6 +212,55 @@ class SitesCustomServerTest extends Scope
$this->cleanupSite($siteId);
}
public function testVariablesE2E(): void
{
$siteId = $this->setupSite([
'siteId' => ID::unique(),
'name' => 'Astro site',
'framework' => 'astro',
'adapter' => 'ssr',
'buildRuntime' => 'ssr-22',
'outputDirectory' => './dist',
'buildCommand' => 'npm run build',
'installCommand' => 'npm install',
'fallbackFile' => '',
]);
$this->assertNotEmpty($siteId);
$secretVariable = $this->createVariable($siteId, [
'key' => 'name',
'value' => 'Appwrite',
]);
$this->assertEquals(201, $secretVariable['headers']['status-code']);
$this->assertNotEmpty($secretVariable['body']['$id']);
$this->assertEquals('name', $secretVariable['body']['key']);
$this->assertEquals('', $secretVariable['body']['value']);
$this->assertEquals(true, $secretVariable['body']['secret']);
$deploymentId = $this->setupDeployment($siteId, [
'code' => $this->packageSite('astro'),
'activate' => 'true'
]);
$this->assertNotEmpty($deploymentId);
$domain = $this->getSiteDomain($siteId);
$proxyClient = new Client();
$proxyClient->setEndpoint('http://' . $domain);
$response = $proxyClient->call(Client::METHOD_GET, '/', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]));
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertStringContainsString("Message from ENV: Appwrite", $response['body']);
$this->cleanupSite($siteId);
}
public function testListSites(): void
{
/**
@@ -0,0 +1,10 @@
import { defineConfig } from 'astro/config';
import node from '@astrojs/node';
import 'dotenv/config';
export default defineConfig({
output: 'server',
adapter: node({
mode: 'standalone'
}),
});
File diff suppressed because it is too large Load Diff
+16
View File
@@ -0,0 +1,16 @@
{
"name": "my-astro-app",
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"@astrojs/node": "^9.0.2",
"astro": "^5.2.5",
"dotenv": "^16.4.7"
}
}
@@ -0,0 +1,15 @@
---
const message = import.meta.env.name || 'Default message';
---
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Astro SSR</title>
</head>
<body>
<p>Message from ENV: {message}</p>
</body>
</html>
@@ -0,0 +1,5 @@
{
"extends": "astro/tsconfigs/strict",
"include": [".astro/types.d.ts", "**/*"],
"exclude": ["dist"]
}