mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Add SSR tests
This commit is contained in:
@@ -82,6 +82,8 @@ trait ProjectCustom
|
||||
'sites.write',
|
||||
'execution.read',
|
||||
'execution.write',
|
||||
'log.read',
|
||||
'log.write',
|
||||
'locale.read',
|
||||
'avatars.read',
|
||||
'health.read',
|
||||
|
||||
@@ -208,12 +208,14 @@ trait SitesBase
|
||||
return $deployments;
|
||||
}
|
||||
|
||||
protected function listLogs(string $siteId, mixed $params = []): mixed
|
||||
protected function listLogs(string $siteId, array $queries = []): mixed
|
||||
{
|
||||
$logs = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId . '/logs', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), $params);
|
||||
], $this->getHeaders()), [
|
||||
'queries' => $queries
|
||||
]);
|
||||
|
||||
return $logs;
|
||||
}
|
||||
|
||||
@@ -1675,4 +1675,74 @@ class SitesCustomServerTest extends Scope
|
||||
|
||||
$this->cleanupSite($siteId);
|
||||
}
|
||||
|
||||
public function testSSRLogs(): void
|
||||
{
|
||||
$siteId = $this->setupSite([
|
||||
'siteId' => ID::unique(),
|
||||
'name' => 'SSR site',
|
||||
'framework' => 'astro',
|
||||
'adapter' => 'ssr',
|
||||
'buildRuntime' => 'ssr-22',
|
||||
'outputDirectory' => './dist',
|
||||
'buildCommand' => 'npm run build',
|
||||
'installCommand' => 'npm install',
|
||||
'fallbackFile' => '',
|
||||
]);
|
||||
|
||||
$this->assertNotEmpty($siteId);
|
||||
|
||||
$domain = $this->setupSiteDomain($siteId);
|
||||
|
||||
$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, '/logs-inline');
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertStringContainsString("Inline logs printed.", $response['body']);
|
||||
|
||||
$logs = $this->listLogs($siteId, [
|
||||
Query::orderDesc('$createdAt')->toString(),
|
||||
Query::limit(1)->toString(),
|
||||
]);
|
||||
$this->assertEquals(200, $logs['headers']['status-code']);
|
||||
$this->assertStringContainsString("GET", $logs['body']['executions'][0]['requestMethod']);
|
||||
$this->assertStringContainsString("/logs-inline", $logs['body']['executions'][0]['requestPath']);
|
||||
$this->assertStringContainsString("Log1", $logs['body']['executions'][0]['logs']);
|
||||
$this->assertStringContainsString("Log2", $logs['body']['executions'][0]['logs']);
|
||||
$this->assertStringContainsString("Error1", $logs['body']['executions'][0]['errors']);
|
||||
$this->assertStringContainsString("Error2", $logs['body']['executions'][0]['errors']);
|
||||
$log1Id = $logs['body']['executions'][0]['$id'];
|
||||
$this->assertNotEmpty($log1Id);
|
||||
|
||||
$response = $proxyClient->call(Client::METHOD_GET, '/logs-action');
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertStringContainsString("Action logs printed.", $response['body']);
|
||||
|
||||
$logs = $this->listLogs($siteId, [
|
||||
Query::orderDesc('$createdAt')->toString(),
|
||||
Query::limit(1)->toString(),
|
||||
]);
|
||||
$this->assertEquals(200, $logs['headers']['status-code']);
|
||||
$this->assertStringContainsString("GET", $logs['body']['executions'][0]['requestMethod']);
|
||||
$this->assertStringContainsString("/logs-action", $logs['body']['executions'][0]['requestPath']);
|
||||
$this->assertStringContainsString("Log1", $logs['body']['executions'][0]['logs']);
|
||||
$this->assertStringContainsString("Log2", $logs['body']['executions'][0]['logs']);
|
||||
$this->assertStringContainsString("Error1", $logs['body']['executions'][0]['errors']);
|
||||
$this->assertStringContainsString("Error2", $logs['body']['executions'][0]['errors']);
|
||||
$log2Id = $logs['body']['executions'][0]['$id'];
|
||||
$this->assertNotEmpty($log2Id);
|
||||
|
||||
$this->assertNotEquals($log1Id, $log2Id);
|
||||
|
||||
$this->cleanupSite($siteId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { defineConfig } from 'astro/config';
|
||||
import node from '@astrojs/node';
|
||||
import 'dotenv/config';
|
||||
|
||||
export default defineConfig({
|
||||
output: 'server',
|
||||
output: 'server',
|
||||
adapter: node({
|
||||
mode: 'standalone'
|
||||
}),
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/node": "^9.0.2",
|
||||
"astro": "^5.2.5",
|
||||
"dotenv": "^16.4.7"
|
||||
"astro": "^5.2.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
export async function GET(context) {
|
||||
console.log("Log1");
|
||||
console.error("Error1");
|
||||
console.log("Log2");
|
||||
console.error("Error2");
|
||||
return new Response('Action logs printed.');
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
console.log("Log1");
|
||||
console.error("Error1");
|
||||
console.log("Log2");
|
||||
console.error("Error2");
|
||||
---
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Astro Logs</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Inline logs printed.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"extends": "astro/tsconfigs/strict",
|
||||
"include": [".astro/types.d.ts", "**/*"],
|
||||
"exclude": ["dist"]
|
||||
}
|
||||
Reference in New Issue
Block a user