Skip to content

Modern Docker Management, Designed for Everyone

chore: use env interpolation in project tests

Kyle Mendell7ba22ceaef0b
diff --git a/backend/internal/services/project_service.go b/backend/internal/services/project_service.go
index 7d0db533e..95354552e 100644
--- a/backend/internal/services/project_service.go
+++ b/backend/internal/services/project_service.go
@@ -42,12 +42,13 @@ func NewProjectService(db *database.DB, settingsService *SettingsService, eventS
// Helpers
type ProjectServiceInfo struct {
- Name string `json:"name"`
- Image string `json:"image"`
- Status string `json:"status"`
- ContainerID string `json:"container_id"`
- Ports []string `json:"ports"`
- Health *string `json:"health,omitempty"`
+ Name string `json:"name"`
+ Image string `json:"image"`
+ Status string `json:"status"`
+ ContainerID string `json:"container_id"`
+ ContainerName string `json:"container_name"`
+ Ports []string `json:"ports"`
+ Health *string `json:"health,omitempty"`
}
func (s *ProjectService) GetProjectFromDatabaseByID(ctx context.Context, id string) (*models.Project, error) {
@@ -150,12 +151,13 @@ func (s *ProjectService) GetProjectServices(ctx context.Context, projectID strin
}
services = append(services, ProjectServiceInfo{
- Name: c.Service,
- Image: c.Image,
- Status: c.State,
- ContainerID: c.ID,
- Ports: formatPorts(c.Publishers),
- Health: health,
+ Name: c.Service,
+ Image: c.Image,
+ Status: c.State,
+ ContainerID: c.ID,
+ ContainerName: c.Name,
+ Ports: formatPorts(c.Publishers),
+ Health: health,
})
have[c.Service] = true
}
diff --git a/frontend/src/routes/projects/components/ServicesGrid.svelte b/frontend/src/routes/projects/components/ServicesGrid.svelte
index 539fe9f5f..a31cd92fa 100644
--- a/frontend/src/routes/projects/components/ServicesGrid.svelte
+++ b/frontend/src/routes/projects/components/ServicesGrid.svelte
@@ -6,9 +6,11 @@
import { getStatusVariant } from '$lib/utils/status.utils';
import { capitalizeFirstLetter } from '$lib/utils/string.utils';
import { m } from '$lib/paraglide/messages';
+ import { Badge } from '$lib/components/ui/badge';
type Service = {
container_id?: string;
+ container_name?: string;
name: string;
status?: string;
health?: string;
@@ -16,12 +18,12 @@
let { services, projectId }: { services?: Service[]; projectId?: string } = $props();
- function getHealthVariant(health: string | undefined): 'green' | 'red' | 'amber' {
- if (!health) return 'amber';
+ function getHealthColor(health: string | undefined): string {
+ if (!health) return 'text-amber-500';
const normalized = health.toLowerCase();
- if (normalized === 'healthy') return 'green';
- if (normalized === 'unhealthy') return 'red';
- return 'amber'; // starting, none, etc.
+ if (normalized === 'healthy') return 'text-green-500';
+ if (normalized === 'unhealthy') return 'text-red-500';
+ return 'text-amber-500';
}
</script>
@@ -58,19 +60,18 @@
<LayersIcon class="size-5 text-blue-500" />
</div>
<div class="min-w-0 flex-1">
- <h3 class="text-foreground mb-2 text-base font-semibold transition-colors">
- {service.name}
- </h3>
+ <div class="mb-2 flex items-center gap-2">
+ <h3 class="text-foreground text-base font-semibold transition-colors">
+ {service.container_name || service.name}
+ </h3>
+ <Badge variant="outline" class="text-xs">
+ {service.name}
+ </Badge>
+ </div>
<div class="flex flex-wrap items-center gap-3">
<StatusBadge {variant} text={capitalizeFirstLetter(status)} />
{#if service.health}
- {@const healthVariant = getHealthVariant(service.health)}
- {@const healthColor =
- healthVariant === 'green'
- ? 'text-green-500'
- : healthVariant === 'red'
- ? 'text-red-500'
- : 'text-amber-500'}
+ {@const healthColor = getHealthColor(service.health)}
<div class="flex items-center gap-1.5">
<HeartPulseIcon class="{healthColor} size-4" />
<span class="text-muted-foreground text-xs">{capitalizeFirstLetter(service.health)}</span>
diff --git a/tests/setup/project.data.ts b/tests/setup/project.data.ts
new file mode 100644
index 000000000..f2ce31e5c
--- /dev/null
+++ b/tests/setup/project.data.ts
@@ -0,0 +1,19 @@
+export const TEST_COMPOSE_YAML = `services:
+ redis:
+ image: redis:latest
+ container_name: \${CONTAINER_NAME}
+ ports:
+ - "8081:81"
+ - "6379:6379"
+ - "6378:6378"
+ volumes:
+ - redis_data:/data
+ restart: unless-stopped
+
+volumes:
+ redis_data:
+ driver: local
+`;
+
+export const TEST_ENV_FILE = `CONTAINER_NAME=test-redis-container
+`;
diff --git a/tests/spec/project.spec.ts b/tests/spec/project.spec.ts
index 9f1f24a58..4a23de922 100644
--- a/tests/spec/project.spec.ts
+++ b/tests/spec/project.spec.ts
@@ -1,6 +1,7 @@
import { test, expect, type Page } from '@playwright/test';
import { fetchProjectCountsWithRetry, fetchProjectsWithRetry } from '../utils/fetch.util';
import { Project, ProjectStatusCounts } from 'types/project.type';
+import { TEST_COMPOSE_YAML, TEST_ENV_FILE } from '../setup/project.data';
const ROUTES = {
page: '/projects',
@@ -138,6 +139,22 @@ test.describe('New Compose Project Page', () => {
const composeEditor = page.locator('.cm-editor').first();
await expect(composeEditor).toBeVisible();
+ const composeContent = composeEditor.locator('.cm-content[contenteditable]');
+ await composeContent.focus();
+ await page.keyboard.press('ControlOrMeta+A');
+ await page.context().grantPermissions(['clipboard-read', 'clipboard-write']);
+ await page.evaluate((text) => navigator.clipboard.writeText(text), TEST_COMPOSE_YAML);
+ await page.keyboard.press('ControlOrMeta+V');
+
+ const envEditor = page.locator('.cm-editor').nth(1);
+ await expect(envEditor).toBeVisible();
+
+ const envContent = envEditor.locator('.cm-content[contenteditable]');
+ await envContent.focus();
+ await page.keyboard.press('ControlOrMeta+A');
+ await page.evaluate((text) => navigator.clipboard.writeText(text), TEST_ENV_FILE);
+ await page.keyboard.press('ControlOrMeta+V');
+
await page.route('/api/environments/*/projects', async (route) => {
if (route.request().method() === 'POST') {
const response = await route.fetch();
@@ -172,6 +189,27 @@ test.describe('New Compose Project Page', () => {
}
await expect(page.getByRole('button', { name: projectName })).toBeVisible();
+
+ await page.getByRole('tab', { name: /Services/i }).click();
+ await page.waitForLoadState('networkidle');
+
+ const serviceNameWhenStopped = page.getByRole('heading', { name: 'redis', exact: true });
+ await expect(serviceNameWhenStopped).toBeVisible();
+
+ const containerNameWhenStopped = page.getByRole('link', { name: 'test-redis-container redis' });
+ await expect(containerNameWhenStopped).not.toBeVisible();
+
+ const deployButton = page.getByRole('button', { name: 'Up', exact: true }).filter({ hasText: 'Up' }).last();
+ await deployButton.click();
+
+ await page.waitForTimeout(5000);
+ await page.waitForLoadState('networkidle');
+
+ const containerNameElement = page.getByRole('link', { name: 'test-redis-container redis' });
+ await expect(containerNameElement).toBeVisible({ timeout: 15000 });
+
+ const serviceBadge = page.locator('text=redis').first();
+ await expect(serviceBadge).toBeVisible();
});
});