Skip to content

Modern Docker Management, Designed for Everyone

chore(tests): fix playwright e2e tests (#298)

Kyle Mendellf1324483cc75
diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml
index 95101d828..56e889471 100644
--- a/.github/workflows/e2e-tests.yml
+++ b/.github/workflows/e2e-tests.yml
@@ -3,8 +3,16 @@ name: Playwright E2E Tests
on:
push:
branches: [main]
+ paths-ignore:
+ - 'docs/**'
+ - '**.md'
+ - '.github/**'
pull_request:
branches: [main]
+ paths-ignore:
+ - 'docs/**'
+ - '**.md'
+ - '.github/**'
permissions:
contents: read
@@ -13,58 +21,117 @@ permissions:
pull-requests: write
jobs:
- e2e:
+ build:
+ timeout-minutes: 20
+ permissions:
+ contents: read
+ actions: write
runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Build and export Arcane image
+ uses: docker/build-push-action@v6
+ with:
+ push: false
+ load: false
+ tags: arcane:test
+ outputs: type=docker,dest=/tmp/arcane-image.tar
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Upload Docker image artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: arcane-image
+ path: /tmp/arcane-image.tar
+ retention-days: 1
+ test:
+ permissions:
+ contents: read
+ actions: write
+ runs-on: ubuntu-latest
+ needs: build
steps:
- - name: Checkout code
- uses: actions/checkout@v4
+ - uses: actions/checkout@v4
- - name: Set up Node.js
- uses: actions/setup-node@v4
+ - uses: actions/setup-node@v4
with:
node-version: 22
- name: Cache npm dependencies
uses: actions/cache@v4
with:
- path: ~/.npm
- key: npm-cache-universal
+ path: |
+ ~/.npm
+ tests/node_modules
+ key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
+ restore-keys: |
+ ${{ runner.os }}-node-
- name: Cache Playwright browsers
uses: actions/cache@v4
+ id: playwright-cache
with:
path: ~/.cache/ms-playwright
- key: playwright-browsers-universal
+ key: ${{ runner.os }}-playwright-${{ hashFiles('tests/package-lock.json') }}
+ restore-keys: |
+ ${{ runner.os }}-playwright-
- name: Create Docker volumes for tests
run: |
- docker volume create my-app-data
- docker volume create cache
+ docker volume create my-app-data || true
+ docker volume create cache || true
- - name: Install dependencies
- working-directory: frontend
- run: npm ci
+ - name: Download Arcane Docker image artifact
+ uses: actions/download-artifact@v4
+ with:
+ name: arcane-image
+ path: /tmp
- - name: Create .env
- run: echo PUBLIC_SESSION_SECRET=your-secure-random-string-here > .env
+ - name: Load Arcane Docker image
+ run: docker load -i /tmp/arcane-image.tar
+
+ - name: Cache test images
+ uses: actions/cache@v4
+ id: test-images-cache
+ with:
+ path: /tmp/test-images.tar
+ key: test-images-${{ runner.os }}-nginx-latest
+
+ - name: Pull and save test images
+ if: steps.test-images-cache.outputs.cache-hit != 'true'
+ run: |
+ docker pull ghcr.io/linuxserver/nginx:latest
+ docker pull ghcr.io/linuxserver/radarr:nightly
+ docker save ghcr.io/linuxserver/nginx:latest ghcr.io/linuxserver/radarr:nightly > /tmp/test-images.tar
+
+ - name: Load test images from cache
+ if: steps.test-images-cache.outputs.cache-hit == 'true'
+ run: docker load < /tmp/test-images.tar
+
+ - name: Install test dependencies
+ working-directory: tests
+ run: npm ci
- name: Install Playwright browsers
- working-directory: frontend
- run: npx playwright install --with-deps
+ working-directory: tests
+ if: steps.playwright-cache.outputs.cache-hit != 'true'
+ run: npx playwright install --with-deps chromium
- name: Run Playwright E2E tests
- working-directory: frontend
- run: npm run test:e2e
-
- - name: List Playwright report directory
- if: always()
- run: ls -lR tests/.report || echo "No report directory"
+ working-directory: tests
+ run: npx playwright test
- name: Upload Playwright HTML report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
- path: frontend/tests/.report
+ path: tests/.report
include-hidden-files: true
+ retention-days: 15
diff --git a/.gitignore b/.gitignore
index b46cef2e0..cd3601530 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,12 +29,8 @@ Thumbs.db
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
-.arcane/*
-.arcane/stacks/*
-.dev-data/*
-.dev-data/settings/*
-test-results/*
+#tests data
+tests/test-results/*
tests/.report/*
-.test-data/*
-data/*
\ No newline at end of file
+tests/.auth/
\ No newline at end of file
diff --git a/docker-compose.test.yml b/docker-compose.test.yml
new file mode 100644
index 000000000..9f070ab91
--- /dev/null
+++ b/docker-compose.test.yml
@@ -0,0 +1,19 @@
+services:
+ arcane:
+ image: arcane:test
+ ports:
+ - '3000:8080'
+ volumes:
+ - /var/run/docker.sock:/var/run/docker.sock
+ - arcane_data:/app/data
+ environment:
+ - PUID=1000
+ - PGID=1000
+ - DATABASE_URL=sqlite:///app/data/arcane.db
+ - ENCRYPTION_KEY=3JDIgolks2tJ9ymm1AdqzlYMWu0DUWyt
+ - JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
+ - APP_ENV=TEST
+ restart: unless-stopped
+
+volumes:
+ arcane_data:
diff --git a/frontend/.prettierrc b/frontend/.prettierrc
index 8bc6e8640..0edc4d041 100644
--- a/frontend/.prettierrc
+++ b/frontend/.prettierrc
@@ -1,8 +1,15 @@
{
- "useTabs": true,
- "singleQuote": true,
- "trailingComma": "none",
- "printWidth": 100,
- "plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
- "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
+ "useTabs": true,
+ "singleQuote": true,
+ "trailingComma": "none",
+ "printWidth": 450,
+ "plugins": ["prettier-plugin-svelte"],
+ "overrides": [
+ {
+ "files": "*.svelte",
+ "options": {
+ "parser": "svelte"
+ }
+ }
+ ]
}
diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte
index ded0db8b5..08f0b6a24 100644
--- a/frontend/src/routes/+layout.svelte
+++ b/frontend/src/routes/+layout.svelte
@@ -1,101 +1,105 @@
<script lang="ts">
- import '../app.css';
- import { ModeWatcher } from 'mode-watcher';
- import { Toaster } from '$lib/components/ui/sonner/index.js';
- import { navigating, page } from '$app/state';
- import ConfirmDialog from '$lib/components/confirm-dialog/confirm-dialog.svelte';
- import * as Sidebar from '$lib/components/ui/sidebar/index.js';
- import AppSidebar from '$lib/components/sidebar/sidebar.svelte';
- import { onMount } from 'svelte';
- import { goto } from '$app/navigation';
- import { initializeClientStores } from '$lib/stores/client-init';
+ import "../app.css";
+ import { ModeWatcher } from "mode-watcher";
+ import { Toaster } from "$lib/components/ui/sonner/index.js";
+ import { navigating, page } from "$app/state";
+ import ConfirmDialog from "$lib/components/confirm-dialog/confirm-dialog.svelte";
+ import * as Sidebar from "$lib/components/ui/sidebar/index.js";
+ import AppSidebar from "$lib/components/sidebar/sidebar.svelte";
+ import { onMount } from "svelte";
+ import { goto } from "$app/navigation";
+ import { initializeClientStores } from "$lib/stores/client-init";
- let { children, data } = $props();
+ let { children, data } = $props();
- const versionInformation = data.versionInformation;
- const user = $derived(data.user);
- const agents = $derived(data.agents);
- const isNavigating = $derived(navigating.type !== null);
- const isAuthenticated = $derived(!!user);
+ const versionInformation = data.versionInformation;
+ const user = $derived(data.user);
+ const agents = $derived(data.agents);
+ const isNavigating = $derived(navigating.type !== null);
+ const isAuthenticated = $derived(!!user);
- const isOnboardingPage = $derived(page.url.pathname.startsWith('/onboarding'));
- const isLoginPage = $derived(
- page.url.pathname === '/login' ||
- page.url.pathname.startsWith('/auth/login') ||
- page.url.pathname === '/auth' ||
- page.url.pathname.includes('/login')
- );
- const showSidebar = $derived(isAuthenticated && !isOnboardingPage && !isLoginPage);
+ const isOnboardingPage = $derived(
+ page.url.pathname.startsWith("/onboarding")
+ );
+ const isLoginPage = $derived(
+ page.url.pathname === "/login" ||
+ page.url.pathname.startsWith("/auth/login") ||
+ page.url.pathname === "/auth" ||
+ page.url.pathname.includes("/login")
+ );
+ const showSidebar = $derived(
+ isAuthenticated && !isOnboardingPage && !isLoginPage
+ );
- $effect(() => {
- const path = page.url.pathname;
+ $effect(() => {
+ const path = page.url.pathname;
- const publicPaths = [
- '/auth/login',
- '/auth/logout',
- '/auth/oidc/login',
- '/auth/oidc/callback',
- '/img',
- '/favicon.ico'
- ];
+ const publicPaths = [
+ "/auth/login",
+ "/auth/logout",
+ "/auth/oidc/login",
+ "/auth/oidc/callback",
+ "/img",
+ "/favicon.ico",
+ ];
- const isPublicPath = publicPaths.some((p) => path.startsWith(p));
+ const isPublicPath = publicPaths.some((p) => path.startsWith(p));
- if (!isPublicPath && !data.isAuthenticated) {
- fetch('/api/auth/me', {
- credentials: 'include'
- })
- .then((response) => {
- if (!response.ok) {
- goto(`/auth/login?redirect=${encodeURIComponent(path)}`);
- }
- })
- .catch(() => {
- goto(`/auth/login?redirect=${encodeURIComponent(path)}`);
- });
- }
- });
+ if (!isPublicPath && !data.isAuthenticated) {
+ fetch("/api/auth/me", {
+ credentials: "include",
+ })
+ .then((response) => {
+ if (!response.ok) {
+ goto(`/auth/login?redirect=${encodeURIComponent(path)}`);
+ }
+ })
+ .catch(() => {
+ goto(`/auth/login?redirect=${encodeURIComponent(path)}`);
+ });
+ }
+ });
- onMount(() => {
- const init = async () => {
- await initializeClientStores();
- };
+ onMount(() => {
+ const init = async () => {
+ await initializeClientStores();
+ };
- init();
- });
+ init();
+ });
</script>
<svelte:head><title>Arcane</title></svelte:head>
<ModeWatcher />
-<Toaster richColors />
+<Toaster />
<ConfirmDialog />
<!-- Loading Indicator -->
{#if isNavigating}
- <div class="fixed top-0 right-0 left-0 z-50 h-2">
- <div class="bg-primary h-full animate-pulse"></div>
- </div>
+ <div class="fixed top-0 right-0 left-0 z-50 h-2">
+ <div class="bg-primary h-full animate-pulse"></div>
+ </div>
{/if}
<div class="bg-background flex min-h-screen">
- {#if showSidebar}
- <Sidebar.Provider>
- <AppSidebar
- hasLocalDocker={data.hasLocalDocker || false}
- agents={agents || []}
- {versionInformation}
- {user}
- />
- <main class="flex-1">
- <section class="p-6">
- {@render children()}
- </section>
- </main>
- </Sidebar.Provider>
- {:else}
- <main class="flex-1">
- {@render children()}
- </main>
- {/if}
+ {#if showSidebar}
+ <Sidebar.Provider>
+ <AppSidebar
+ hasLocalDocker={data.hasLocalDocker || false}
+ agents={agents || []}
+ {versionInformation}
+ {user}
+ />
+ <main class="flex-1">
+ <section class="p-6">
+ {@render children()}
+ </section>
+ </main>
+ </Sidebar.Provider>
+ {:else}
+ <main class="flex-1">
+ {@render children()}
+ </main>
+ {/if}
</div>
diff --git a/tests/.auth/login.json b/tests/.auth/login.json
deleted file mode 100644
index 9ea6470cc..000000000
--- a/tests/.auth/login.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "cookies": [
- {
- "name": "kit.session",
- "value": "93beaccadd8a6498db9b84a10d853984df00b6bd7f14fc711b91a1d907d5e405636188adf7fce01505407b2de783e9801eb97c8ab009b1c24165268d0ad167264584b6431fad606eac5d49200f94a37cd16f9a8e5bdf0c697fdd03411b16e1daa84e7f524d49eb737188da7298447dc15d0c2e6790b0814cdf1e95b61fcfc2ddf4fda3f11f2822ae0376ca380e50abfbacc54d11d67e841d40353186b6c7a911b35a59f96e34261b22d2bd38f3c71d85f223e2f20c27df3e5d01bde260%26id%3D1",
- "domain": "localhost",
- "path": "/",
- "expires": 1783454073.37731,
- "httpOnly": true,
- "secure": false,
- "sameSite": "Lax"
- }
- ],
- "origins": [
- {
- "origin": "http://localhost:3000",
- "localStorage": [
- {
- "name": "mode-watcher-theme",
- "value": ""
- },
- {
- "name": "mode-watcher-mode",
- "value": "system"
- }
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/tests/auth.setup.ts b/tests/auth.setup.ts
deleted file mode 100644
index 3a4693249..000000000
--- a/tests/auth.setup.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { test as setup, expect } from '@playwright/test';
-
-const authFile = 'tests/.auth/login.json';
-
-setup('authenticate', async ({ page }) => {
- await page.goto('/auth/login');
- await page.getByLabel('Username').fill('arcane');
- await page.getByLabel('Password').fill('arcane-admin');
- await page.getByRole('button', { name: 'Sign in', exact: true }).click();
-
- await expect(page).toHaveURL('/');
-
- await page.context().storageState({ path: authFile });
- console.log(`Authentication state saved to ${authFile}`);
-});
diff --git a/tests/converter.spec.ts b/tests/converter.spec.ts
deleted file mode 100644
index d2c0ebb70..000000000
--- a/tests/converter.spec.ts
+++ /dev/null
@@ -1,194 +0,0 @@
-import { test, expect } from '@playwright/test';
-
-test.describe('Docker Run to Compose Converter', () => {
- test.beforeEach(async ({ page }) => {
- // Navigate to the new stack page
- await page.goto('/compose/new');
- await page.waitForLoadState('networkidle');
- });
-
- test('should display converter section', async ({ page }) => {
- // Check if the converter dropdown card is visible
- await expect(page.getByText('Docker Run to Compose Converter')).toBeVisible();
- await expect(page.getByText('Convert existing docker run commands to Docker Compose format')).toBeVisible();
- });
-
- test('should convert simple docker run command', async ({ page }) => {
- await page.waitForLoadState('networkidle');
- // Expand converter
- await page.getByText('Docker Run to Compose Converter').click();
- await page.waitForTimeout(300);
-
- // Enter a simple docker run command using the textarea
- const dockerCommand = 'docker run -d --name nginx -p 8080:80 nginx:alpine';
- await page.getByPlaceholder('docker run -d --name my-app -p 8080:80 nginx:alpine').fill(dockerCommand);
-
- // Mock the API response
- await page.route('/api/convert', async (route) => {
- await route.fulfill({
- status: 200,
- contentType: 'application/json',
- body: JSON.stringify({
- success: true,
- dockerCompose: `services:
- nginx:
- image: nginx:alpine
- container_name: nginx
- ports:
- - 8080:80`,
- envVars: '',
- serviceName: 'nginx'
- })
- });
- });
-
- // Click convert button
- await page.getByRole('button', { name: 'Convert to Compose' }).click();
-
- // Wait for success toast
- await expect(page.getByText('Docker run command converted successfully!')).toBeVisible();
-
- // Check if stack name was populated
- await expect(page.getByPlaceholder('e.g., my-web-app')).toHaveValue('nginx');
-
- // Check if docker run command was cleared
- await expect(page.getByPlaceholder('docker run -d --name my-app -p 8080:80 nginx:alpine')).toHaveValue('');
- });
-
- test('should convert docker run command with environment variables', async ({ page }) => {
- // Expand converter
- await page.getByText('Docker Run to Compose Converter').click();
- await page.waitForTimeout(300);
-
- // Enter docker run command with environment variables
- const dockerCommand = 'docker run -d --name postgres -e POSTGRES_DB=mydb -e POSTGRES_USER=user -e POSTGRES_PASSWORD=pass postgres:15';
- await page.getByPlaceholder('docker run -d --name my-app -p 8080:80 nginx:alpine').fill(dockerCommand);
-
- // Mock the API response
- await page.route('/api/convert', async (route) => {
- await route.fulfill({
- status: 200,
- contentType: 'application/json',
- body: JSON.stringify({
- success: true,
- dockerCompose: `services:
- postgres:
- image: postgres:15
- container_name: postgres
- environment:
- - POSTGRES_DB=mydb
- - POSTGRES_USER=user
- - POSTGRES_PASSWORD=pass`,
- envVars: 'POSTGRES_DB=mydb\nPOSTGRES_USER=user\nPOSTGRES_PASSWORD=pass',
- serviceName: 'postgres'
- })
- });
- });
-
- // Click convert button
- await page.getByRole('button', { name: 'Convert to Compose' }).click();
-
- // Wait for success toast
- await expect(page.getByText('Docker run command converted successfully!')).toBeVisible();
-
- // Check if stack name was populated
- await expect(page.getByPlaceholder('e.g., my-web-app')).toHaveValue('postgres');
- });
-
- test('should use example commands', async ({ page }) => {
- // Expand converter
- await page.getByText('Docker Run to Compose Converter').click();
- await page.waitForTimeout(300);
-
- // Click on the first example command (using a more specific selector)
- await page
- .getByRole('button', { name: /docker run -d --name nginx/ })
- .first()
- .click();
-
- // Check if the command was populated in the textarea
- const expectedCommand = 'docker run -d --name nginx -p 8080:80 -v nginx_data:/usr/share/nginx/html nginx:alpine';
- await expect(page.getByPlaceholder('docker run -d --name my-app -p 8080:80 nginx:alpine')).toHaveValue(expectedCommand);
- });
-
- test('should handle API error gracefully', async ({ page }) => {
- // Expand converter
- await page.getByText('Docker Run to Compose Converter').click();
- await page.waitForTimeout(300);
-
- // Enter a docker run command
- await page.getByPlaceholder('docker run -d --name my-app -p 8080:80 nginx:alpine').fill('docker run nginx:alpine');
-
- // Mock API error response
- await page.route('/api/convert', async (route) => {
- await route.fulfill({
- status: 400,
- contentType: 'application/json',
- body: JSON.stringify({
- success: false,
- error: 'Failed to parse docker run command. Please check the syntax.',
- code: 'BAD_REQUEST'
- })
- });
- });
-
- // Click convert button
- await page.getByRole('button', { name: 'Convert to Compose' }).click();
-
- // Check for error toast
- await expect(page.getByText('Failed to Convert Docker Run Command')).toBeVisible();
- });
-
- test('should disable convert button when no command is entered', async ({ page }) => {
- // Expand converter
- await page.getByText('Docker Run to Compose Converter').click();
- await page.waitForTimeout(300);
-
- // Check that convert button is disabled when textarea is empty
- await expect(page.getByRole('button', { name: 'Convert to Compose' })).toBeDisabled();
-
- // Enter some text
- await page.getByPlaceholder('docker run -d --name my-app -p 8080:80 nginx:alpine').fill('docker run nginx');
-
- // Check that convert button is now enabled
- await expect(page.getByRole('button', { name: 'Convert to Compose' })).toBeEnabled();
-
- // Clear the text
- await page.getByPlaceholder('docker run -d --name my-app -p 8080:80 nginx:alpine').clear();
-
- // Check that convert button is disabled again
- await expect(page.getByRole('button', { name: 'Convert to Compose' })).toBeDisabled();
- });
-
- test('should populate stack name only when empty', async ({ page }) => {
- // Expand converter
- await page.getByText('Docker Run to Compose Converter').click();
- await page.waitForTimeout(300);
-
- // Enter docker run command with name
- await page.getByPlaceholder('docker run -d --name my-app -p 8080:80 nginx:alpine').fill('docker run --name redis redis:alpine');
-
- // Mock the API response
- await page.route('/api/convert', async (route) => {
- await route.fulfill({
- status: 200,
- contentType: 'application/json',
- body: JSON.stringify({
- success: true,
- dockerCompose: 'services:\n redis:\n image: redis:alpine',
- envVars: '',
- serviceName: 'redis'
- })
- });
- });
-
- // Click convert button
- await page.getByRole('button', { name: 'Convert to Compose' }).click();
-
- // Wait for success
- await expect(page.getByText('Docker run command converted successfully!')).toBeVisible();
-
- // Check that stack name was populated from service name
- await expect(page.getByPlaceholder('e.g., my-web-app')).toHaveValue('redis');
- });
-});
diff --git a/tests/images.spec.ts b/tests/images.spec.ts
deleted file mode 100644
index 87bea0b2e..000000000
--- a/tests/images.spec.ts
+++ /dev/null
@@ -1,180 +0,0 @@
-import { test, expect, type Page } from '@playwright/test';
-
-async function fetchImagesWithRetry(page: Page, maxRetries = 3): Promise<any[]> {
- let retries = 0;
- while (retries < maxRetries) {
- try {
- const response = await page.request.get('/api/images');
- const images = await response.json();
- console.log(`Successfully fetched ${images.length} images on attempt ${retries + 1}`);
- return images;
- } catch (error) {
- retries++;
- console.log(`Attempt ${retries} failed, ${maxRetries - retries} retries left`);
- if (retries >= maxRetries) throw error;
- // Wait before retrying
- await new Promise((resolve) => setTimeout(resolve, 1000));
- }
- }
- return [];
-}
-
-let realImages: any[] = [];
-
-test.beforeEach(async ({ page }) => {
- await page.goto('/images');
- await page.waitForLoadState('networkidle');
-
- try {
- realImages = await fetchImagesWithRetry(page);
- } catch (error) {
- console.warn('Could not fetch images after multiple retries:', error);
- // Use default images if all retries fail
- realImages = [];
- }
-
- console.log(`Found ${realImages.length} real images for testing`);
-});
-
-test.describe('Images Page', () => {
- test('should display the images page title and description', async ({ page }) => {
- await page.goto('/images');
-
- await expect(page.getByRole('heading', { name: 'Container Images', level: 1 })).toBeVisible();
- await expect(page.getByText('View and Manage your Container images').first()).toBeVisible();
- });
-
- test('should display stats cards with correct counts and size', async ({ page }) => {
- await page.goto('/images');
-
- await expect(page.locator('p:has-text("Total Images") + p')).toHaveText(realImages.length.toString());
- await expect(page.locator('p:has-text("Total Size") + p')).not.toBeEmpty();
- });
-
- test('should display the image table when images exist', async ({ page }) => {
- await page.goto('/images');
-
- await page.waitForLoadState('networkidle');
-
- await expect(page.getByText('Image List')).toBeVisible();
- await expect(page.locator('table')).toBeVisible();
- });
-
- test('should open the Pull Image dialog', async ({ page }) => {
- await page.goto('/images');
- await page.waitForLoadState('networkidle');
- await page.locator('button:has-text("Pull Image")').first().click();
- await expect(page.locator('div[role="heading"][aria-level="2"][data-dialog-title]:has-text("Pull Docker Image")')).toBeVisible();
- });
-
- test('should open the Prune Unused Images dialog', async ({ page }) => {
- await page.goto('/images');
- await page.waitForLoadState('networkidle');
- await page.locator('button:has-text("Prune Unused")').click();
- await expect(page.locator('div[role="heading"][aria-level="2"][data-dialog-title]:has-text("Prune Unused Images")')).toBeVisible();
- });
-
- test('should navigate to image details on inspect click', async ({ page }) => {
- await page.goto('/images');
-
- await page.waitForLoadState('networkidle');
-
- const firstRow = page.locator('tbody tr').first();
- await firstRow.getByRole('button', { name: 'Open menu' }).click();
- await page.getByRole('menuitem', { name: 'Inspect' }).click();
-
- // await expect(page).toHaveURL(`/images/${realImages[0].id}`);
- });
-
- test('should call pull API on row action pull click', async ({ page }) => {
- test.skip(!realImages.length, 'No images available for pull API test');
- await page.goto('/images');
-
- await page.waitForLoadState('networkidle');
-
- // Find a real image in the table
- const firstRow = page.locator('tbody tr').first();
- await firstRow.getByRole('button', { name: 'Open menu' }).click();
-
- const pullPromise = page.waitForRequest((req) => req.url().includes('/api/images/pull') && req.method() === 'POST');
- await page.getByRole('menuitem', { name: 'Pull' }).click();
- const pullRequest = await pullPromise;
-
- await page.waitForLoadState('networkidle');
-
- // Extract image name from real images
- const realImageRef = realImages[0].repoTags?.[0]?.split(':')[0] || 'busybox';
- const realTag = realImages[0].repoTags?.[0]?.split(':')[1] || 'latest';
-
- expect(pullRequest).toBeTruthy();
- const postData = pullRequest.postDataJSON();
- expect(postData.tag).toBe(realTag);
-
- await expect(page.locator(`li[data-sonner-toast][data-type="success"] div[data-title]`)).toBeVisible();
- });
-
- test('should call remove API on row action remove click and confirmation', async ({ page }) => {
- test.skip(!realImages.length, 'No images available for remove API test');
- await page.goto('/images');
-
- await page.waitForLoadState('networkidle');
-
- const deleteableImage = realImages.find((img) => !img.inUse);
- test.skip(deleteableImage, 'No deletable images available');
-
- const imageRow = page.locator(`tr:has-text("${deleteableImage.repoTags?.[0] || deleteableImage.id.substring(7, 19)}")`);
- await imageRow.getByRole('button', { name: 'Open menu' }).click();
- await page.getByRole('menuitem', { name: 'Remove' }).click();
-
- await expect(page.locator('div[role="heading"][aria-level="2"][data-dialog-title]:has-text("Delete Image")')).toBeVisible();
-
- const removePromise = page.waitForRequest((req) => req.url().includes(`/api/images/${deleteableImage.id}`) && req.method() === 'DELETE');
-
- await page.locator('button:has-text("Delete")').click();
- const removeRequest = await removePromise;
-
- expect(removeRequest).toBeTruthy();
-
- await expect(page.locator('li[data-sonner-toast][data-type="success"] div[data-title]')).toBeVisible();
- });
- test('should call prune API on prune click and confirmation', async ({ page }) => {
- await page.goto('/images');
-
- await page.waitForLoadState('networkidle');
-
- await page.locator('button:has-text("Prune Unused")').click();
-
- await expect(page.locator('div[role="heading"][aria-level="2"][data-dialog-title]:has-text("Prune Unused Images")')).toBeVisible();
- const prunePromise = page.waitForRequest((req) => req.url().includes('/api/images/prune') && req.method() === 'POST');
- await page.locator('button:has-text("Prune Images")').click(); // Confirmation button
- const pruneRequest = await prunePromise;
-
- expect(pruneRequest).toBeTruthy();
- await expect(page.locator(`li[data-sonner-toast][data-type="success"] div[data-title]:has-text("pruned")`)).toBeVisible({
- timeout: 10000
- });
- });
-
- test('should pull image via dialog using EventSource', async ({ page }) => {
- await page.goto('/images');
-
- await page.waitForLoadState('networkidle');
-
- await page.locator('button:has-text("Pull Image")').first().click();
- await expect(page.locator('div[role="heading"][aria-level="2"][data-dialog-title]:has-text("Pull Docker Image")')).toBeVisible();
-
- const imageName = 'busybox';
- const imageTag = 'latest';
- await page.locator('input[id="image-ref"]').fill(imageName);
- await page.locator('input[id="image-tag"]').fill(imageTag);
-
- const eventSourcePromise = page.waitForRequest((req) => req.url().includes(`/api/images/pull-stream/${imageName}?tag=${imageTag}`) && req.method() === 'GET');
- await page.locator('button[type="submit"]:has-text("Pull Image")').click();
- const eventSourceRequest = await eventSourcePromise;
-
- expect(eventSourceRequest).toBeTruthy();
-
- await expect(page.locator(`li[data-sonner-toast][data-type="success"] div[data-title]:has-text("Image \\"${imageName}:${imageTag}\\" pulled successfully.")`)).toBeVisible();
- await expect(page.locator('div[role="heading"][aria-level="2"][data-dialog-title]:has-text("Pull Docker Image")')).not.toBeVisible();
- });
-});
diff --git a/tests/package-lock.json b/tests/package-lock.json
new file mode 100644
index 000000000..e1b499a47
--- /dev/null
+++ b/tests/package-lock.json
@@ -0,0 +1,93 @@
+{
+ "name": "tests",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "devDependencies": {
+ "@playwright/test": "^1.52.0",
+ "@types/node": "^22.15.21"
+ }
+ },
+ "node_modules/@playwright/test": {
+ "version": "1.53.0",
+ "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.53.0.tgz",
+ "integrity": "sha512-15hjKreZDcp7t6TL/7jkAo6Df5STZN09jGiv5dbP9A6vMVncXRqE7/B2SncsyOwrkZRBH2i6/TPOL8BVmm3c7w==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "playwright": "1.53.0"
+ },
+ "bin": {
+ "playwright": "cli.js"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@types/node": {
+ "version": "22.15.31",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.31.tgz",
+ "integrity": "sha512-jnVe5ULKl6tijxUhvQeNbQG/84fHfg+yMak02cT8QVhBx/F05rAVxCGBYYTh2EKz22D6JF5ktXuNwdx7b9iEGw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "undici-types": "~6.21.0"
+ }
+ },
+ "node_modules/fsevents": {
+ "version": "2.3.2",
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
+ "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
+ "dev": true,
+ "hasInstallScript": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
+ }
+ },
+ "node_modules/playwright": {
+ "version": "1.53.0",
+ "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.53.0.tgz",
+ "integrity": "sha512-ghGNnIEYZC4E+YtclRn4/p6oYbdPiASELBIYkBXfaTVKreQUYbMUYQDwS12a8F0/HtIjr/CkGjtwABeFPGcS4Q==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "playwright-core": "1.53.0"
+ },
+ "bin": {
+ "playwright": "cli.js"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "optionalDependencies": {
+ "fsevents": "2.3.2"
+ }
+ },
+ "node_modules/playwright-core": {
+ "version": "1.53.0",
+ "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.53.0.tgz",
+ "integrity": "sha512-mGLg8m0pm4+mmtB7M89Xw/GSqoNC+twivl8ITteqvAndachozYe2ZA7srU6uleV1vEdAHYqjq+SV8SNxRRFYBw==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "bin": {
+ "playwright-core": "cli.js"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/undici-types": {
+ "version": "6.21.0",
+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
+ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
+ "dev": true,
+ "license": "MIT"
+ }
+ }
+}
diff --git a/tests/package.json b/tests/package.json
new file mode 100644
index 000000000..221cc1c55
--- /dev/null
+++ b/tests/package.json
@@ -0,0 +1,7 @@
+{
+ "type": "module",
+ "devDependencies": {
+ "@playwright/test": "^1.52.0",
+ "@types/node": "^22.15.21"
+ }
+}
diff --git a/tests/playwright.config.ts b/tests/playwright.config.ts
index d0cb33dcd..0ba86f983 100644
--- a/tests/playwright.config.ts
+++ b/tests/playwright.config.ts
@@ -1,34 +1,38 @@
-import { defineConfig, devices } from '@playwright/test';
+import { defineConfig, devices } from "@playwright/test";
-const authFile = 'tests/.auth/login.json';
+const authFile = ".auth/login.json";
export default defineConfig({
- testDir: './tests',
- fullyParallel: true,
- forbidOnly: !!process.env.CI,
- retries: process.env.CI ? 2 : 0,
- workers: process.env.CI ? 1 : undefined,
- reporter: process.env.CI ? [['html', { outputFolder: 'tests/.report' }], ['github']] : [['line'], ['html', { open: 'never', outputFolder: 'tests/.report' }]],
- use: {
- baseURL: 'http://localhost:3000',
- trace: 'on-first-retry',
- video: 'retain-on-failure'
- },
- projects: [
- { name: 'setup', testMatch: /.*\.setup\.ts/ },
- {
- name: 'chromium',
- use: { ...devices['Desktop Chrome'], storageState: authFile },
- dependencies: ['setup']
- }
- ],
- webServer: {
- command: 'APP_ENV=TEST npm run dev',
- url: 'http://localhost:3000',
- reuseExistingServer: !process.env.CI,
- timeout: 120 * 1000,
- env: {
- APP_ENV: 'TEST'
- }
- }
+ testDir: ".",
+ fullyParallel: true,
+ forbidOnly: !!process.env.CI,
+ retries: process.env.CI ? 2 : 0,
+ workers: process.env.CI ? 1 : undefined,
+ reporter: process.env.CI
+ ? [["html", { outputFolder: ".report" }], ["github"]]
+ : [["line"], ["html", { open: "never", outputFolder: ".report" }]],
+ use: {
+ baseURL: "http://localhost:3000",
+ trace: "on-first-retry",
+ video: "retain-on-failure",
+ },
+ projects: [
+ {
+ name: "setup",
+ testMatch: /setup\/.*\.setup\.ts/,
+ },
+ {
+ name: "chromium",
+ use: { ...devices["Desktop Chrome"], storageState: authFile },
+ dependencies: ["setup"],
+ testMatch: /spec\/.*\.spec\.ts/,
+ },
+ ],
+ webServer: {
+ command:
+ "docker-compose -f ../docker-compose.test.yml up --build --abort-on-container-exit",
+ url: "http://localhost:3000",
+ reuseExistingServer: !process.env.CI,
+ timeout: 120 * 1000,
+ },
});
diff --git a/tests/setup/auth.setup.ts b/tests/setup/auth.setup.ts
new file mode 100644
index 000000000..bbfde412c
--- /dev/null
+++ b/tests/setup/auth.setup.ts
@@ -0,0 +1,15 @@
+import { test as setup, expect } from "@playwright/test";
+
+const authFile = ".auth/login.json";
+
+setup("authenticate", async ({ page }) => {
+ await page.goto("/auth/login");
+ await page.getByLabel("Username").fill("arcane");
+ await page.getByLabel("Password").fill("arcane-admin");
+ await page.getByRole("button", { name: "Sign in", exact: true }).click();
+
+ await expect(page).toHaveURL("/");
+
+ await page.context().storageState({ path: authFile });
+ console.log(`Authentication state saved to ${authFile}`);
+});
diff --git a/tests/spec/converter.spec.ts b/tests/spec/converter.spec.ts
new file mode 100644
index 000000000..b91d62aff
--- /dev/null
+++ b/tests/spec/converter.spec.ts
@@ -0,0 +1,166 @@
+import { test, expect } from '@playwright/test';
+
+test.describe('Docker Run to Compose Converter', () => {
+ test.beforeEach(async ({ page }) => {
+ // Navigate to the new stack page
+ await page.goto('/compose/new');
+ await page.waitForLoadState('networkidle');
+ });
+
+ test('should display converter section', async ({ page }) => {
+ // Check if the converter dropdown card is visible
+ await expect(page.getByText('Docker Run to Compose Converter')).toBeVisible();
+ await expect(page.getByText('Convert existing docker run commands to Docker Compose format')).toBeVisible();
+ });
+
+ test('should convert simple docker run command', async ({ page }) => {
+ await page.waitForLoadState('networkidle');
+ // Expand converter
+ await page.getByText('Docker Run to Compose Converter').click();
+ await page.waitForTimeout(300);
+
+ // Enter a simple docker run command using the textarea
+ const dockerCommand = 'docker run -d --name nginx -p 8080:80 nginx:alpine';
+ await page.getByPlaceholder('docker run -d --name my-app -p 8080:80 nginx:alpine').fill(dockerCommand);
+
+ // Mock the API response
+ await page.route('/api/convert', async (route) => {
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({
+ success: true,
+ dockerCompose: `services:
+ nginx:
+ image: nginx:alpine
+ container_name: nginx
+ ports:
+ - 8080:80`,
+ envVars: '',
+ serviceName: 'nginx',
+ }),
+ });
+ });
+
+ // Click convert button
+ await page.getByRole('button', { name: 'Convert to Compose' }).click();
+
+ // Wait for success toast
+ await expect(page.getByText('Docker run command converted successfully!')).toBeVisible();
+
+ // Check if stack name was populated
+ await expect(page.getByPlaceholder('e.g., my-web-app')).toHaveValue('nginx');
+
+ // Check if docker run command was cleared
+ await expect(page.getByPlaceholder('docker run -d --name my-app -p 8080:80 nginx:alpine')).toHaveValue('');
+ });
+
+ test('should convert docker run command with environment variables', async ({ page }) => {
+ // Expand converter
+ await page.getByText('Docker Run to Compose Converter').click();
+ await page.waitForTimeout(300);
+
+ // Enter docker run command with environment variables
+ const dockerCommand = 'docker run -d --name postgres -e POSTGRES_DB=mydb -e POSTGRES_USER=user -e POSTGRES_PASSWORD=pass postgres:15';
+ await page.getByPlaceholder('docker run -d --name my-app -p 8080:80 nginx:alpine').fill(dockerCommand);
+
+ // Mock the API response
+ await page.route('/api/convert', async (route) => {
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({
+ success: true,
+ dockerCompose: `services:
+ postgres:
+ image: postgres:15
+ container_name: postgres
+ environment:
+ - POSTGRES_DB=mydb
+ - POSTGRES_USER=user
+ - POSTGRES_PASSWORD=pass`,
+ envVars: 'POSTGRES_DB=mydb\nPOSTGRES_USER=user\nPOSTGRES_PASSWORD=pass',
+ serviceName: 'postgres',
+ }),
+ });
+ });
+
+ // Click convert button
+ await page.getByRole('button', { name: 'Convert to Compose' }).click();
+
+ // Wait for success toast
+ await expect(page.getByText('Docker run command converted successfully!')).toBeVisible();
+
+ // Check if stack name was populated
+ await expect(page.getByPlaceholder('e.g., my-web-app')).toHaveValue('postgres');
+ });
+
+ test('should use example commands', async ({ page }) => {
+ // Expand converter
+ await page.getByText('Docker Run to Compose Converter').click();
+ await page.waitForTimeout(300);
+
+ // Click on the first example command (using a more specific selector)
+ await page
+ .getByRole('button', { name: /docker run -d --name nginx/ })
+ .first()
+ .click();
+
+ // Check if the command was populated in the textarea
+ const expectedCommand = 'docker run -d --name nginx -p 8080:80 -v nginx_data:/usr/share/nginx/html nginx:alpine';
+ await expect(page.getByPlaceholder('docker run -d --name my-app -p 8080:80 nginx:alpine')).toHaveValue(expectedCommand);
+ });
+
+ test('should disable convert button when no command is entered', async ({ page }) => {
+ // Expand converter
+ await page.getByText('Docker Run to Compose Converter').click();
+ await page.waitForTimeout(300);
+
+ // Check that convert button is disabled when textarea is empty
+ await expect(page.getByRole('button', { name: 'Convert to Compose' })).toBeDisabled();
+
+ // Enter some text
+ await page.getByPlaceholder('docker run -d --name my-app -p 8080:80 nginx:alpine').fill('docker run nginx');
+
+ // Check that convert button is now enabled
+ await expect(page.getByRole('button', { name: 'Convert to Compose' })).toBeEnabled();
+
+ // Clear the text
+ await page.getByPlaceholder('docker run -d --name my-app -p 8080:80 nginx:alpine').clear();
+
+ // Check that convert button is disabled again
+ await expect(page.getByRole('button', { name: 'Convert to Compose' })).toBeDisabled();
+ });
+
+ test('should populate stack name only when empty', async ({ page }) => {
+ // Expand converter
+ await page.getByText('Docker Run to Compose Converter').click();
+ await page.waitForTimeout(300);
+
+ // Enter docker run command with name
+ await page.getByPlaceholder('docker run -d --name my-app -p 8080:80 nginx:alpine').fill('docker run --name redis redis:alpine');
+
+ // Mock the API response
+ await page.route('/api/convert', async (route) => {
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({
+ success: true,
+ dockerCompose: 'services:\n redis:\n image: redis:alpine',
+ envVars: '',
+ serviceName: 'redis',
+ }),
+ });
+ });
+
+ // Click convert button
+ await page.getByRole('button', { name: 'Convert to Compose' }).click();
+
+ // Wait for success
+ await expect(page.getByText('Docker run command converted successfully!')).toBeVisible();
+
+ // Check that stack name was populated from service name
+ await expect(page.getByPlaceholder('e.g., my-web-app')).toHaveValue('redis');
+ });
+});
diff --git a/tests/spec/images.spec.ts b/tests/spec/images.spec.ts
new file mode 100644
index 000000000..a4a169004
--- /dev/null
+++ b/tests/spec/images.spec.ts
@@ -0,0 +1,171 @@
+import { test, expect, type Page } from '@playwright/test';
+
+async function fetchImagesWithRetry(page: Page, maxRetries = 3): Promise<any[]> {
+ let retries = 0;
+ while (retries < maxRetries) {
+ try {
+ const response = await page.request.get('/api/images');
+ const images = await response.json();
+ return images.data;
+ } catch (error) {
+ retries++;
+ if (retries >= maxRetries) throw error;
+ await new Promise((resolve) => setTimeout(resolve, 1000));
+ }
+ }
+ return [];
+}
+
+let realImages: any[] = [];
+
+test.beforeEach(async ({ page }) => {
+ await page.goto('/images');
+ await page.waitForLoadState('networkidle');
+
+ try {
+ realImages = await fetchImagesWithRetry(page);
+ } catch (error) {
+ console.warn('Could not fetch images after multiple retries:', error);
+ realImages = [];
+ }
+
+ console.log(`Found ${realImages.length} real images for testing`);
+});
+
+test.describe('Images Page', () => {
+ test('should display the images page title and description', async ({ page }) => {
+ await page.goto('/images');
+
+ await expect(page.getByRole('heading', { name: 'Container Images', level: 1 })).toBeVisible();
+ await expect(page.getByText('View and Manage your Container images').first()).toBeVisible();
+ });
+
+ test('should display stats cards with correct counts and size', async ({ page }) => {
+ await page.goto('/images');
+
+ await expect(page.locator('p:has-text("Total Images") + p')).toHaveText(realImages.length.toString());
+ await expect(page.locator('p:has-text("Total Size") + p')).not.toBeEmpty();
+ });
+
+ test('should display the image table when images exist', async ({ page }) => {
+ await page.goto('/images');
+
+ await page.waitForLoadState('networkidle');
+
+ await expect(page.getByText('Image List')).toBeVisible();
+ await expect(page.locator('table')).toBeVisible();
+ });
+
+ test('should open the Pull Image dialog', async ({ page }) => {
+ await page.goto('/images');
+ await page.waitForLoadState('networkidle');
+ await page.locator('button:has-text("Pull Image")').first().click();
+ await expect(page.locator('div[role="heading"][aria-level="2"][data-dialog-title]:has-text("Pull Docker Image")')).toBeVisible();
+ });
+
+ test('should open the Prune Unused Images dialog', async ({ page }) => {
+ await page.goto('/images');
+ await page.waitForLoadState('networkidle');
+ await page.locator('button:has-text("Prune Unused")').click();
+ await expect(page.locator('div[role="heading"][aria-level="2"][data-dialog-title]:has-text("Prune Unused Images")')).toBeVisible();
+ });
+
+ test('should navigate to image details on inspect click', async ({ page }) => {
+ await page.goto('/images');
+
+ await page.waitForLoadState('networkidle');
+
+ const firstRow = page.locator('tbody tr').first();
+ await firstRow.getByRole('button', { name: 'Open menu' }).click();
+ await page.getByRole('menuitem', { name: 'Inspect' }).click();
+ });
+
+ test('should pull image from dropdown menu', async ({ page }) => {
+ test.skip(!realImages.length, 'No images available for pull API test');
+ await page.goto('/images');
+
+ await page.waitForLoadState('networkidle');
+
+ const firstRow = await page.getByRole('row', { name: 'ghcr.io/linuxserver/nginx' });
+ await firstRow.getByRole('button', { name: 'Open menu' }).click();
+
+ const pullPromise = page.waitForRequest((req) => req.url().includes('/api/images/pull') && req.method() === 'POST');
+ await page.getByRole('menuitem', { name: 'Pull' }).click();
+ const pullRequest = await pullPromise;
+
+ await page.waitForLoadState('networkidle');
+
+ expect(pullRequest).toBeTruthy();
+ const postData = pullRequest.postDataJSON();
+ expect(postData.imageName).toBe('ghcr.io/linuxserver/nginx:latest');
+
+ await expect(page.locator(`li[data-sonner-toast][data-type="success"] div[data-title]`)).toBeVisible();
+ });
+
+ test('should call remove API on row action remove click and confirmation', async ({ page }) => {
+ test.skip(!realImages.length, 'No images available for remove API test');
+ await page.goto('/images');
+
+ await page.waitForLoadState('networkidle');
+
+ const deleteableImage = realImages.find((img) => img.repoTags?.[0]?.includes('ghcr.io/linuxserver/radarr'));
+ test.skip(!deleteableImage, 'No deletable images available');
+
+ const firstRow = await page.getByRole('row', { name: 'ghcr.io/linuxserver/radarr' });
+ await firstRow.getByRole('button', { name: 'Open menu' }).click();
+ await page.getByRole('menuitem', { name: 'Remove' }).click();
+ console.log(firstRow);
+
+ await expect(page.locator('div[role="heading"][aria-level="2"][data-dialog-title]:has-text("Delete Image")')).toBeVisible();
+
+ const removePromise = page.waitForRequest((req) => req.url().includes(`/api/images/${deleteableImage.id}`) && req.method() === 'DELETE');
+
+ await page.locator('button:has-text("Delete")').click();
+ const removeRequest = await removePromise;
+
+ expect(removeRequest).toBeTruthy();
+
+ await expect(page.locator('li[data-sonner-toast][data-type="success"] div[data-title]')).toBeVisible();
+ });
+
+ test('should call prune API on prune click and confirmation', async ({ page }) => {
+ await page.goto('/images');
+
+ await page.waitForLoadState('networkidle');
+
+ await page.locator('button:has-text("Prune Unused")').click();
+
+ await expect(page.locator('div[role="heading"][aria-level="2"][data-dialog-title]:has-text("Prune Unused Images")')).toBeVisible();
+ const prunePromise = page.waitForRequest((req) => req.url().includes('/api/images/prune') && req.method() === 'POST');
+ await page.locator('button:has-text("Prune Images")').click();
+ const pruneRequest = await prunePromise;
+
+ expect(pruneRequest).toBeTruthy();
+ await expect(page.locator(`li[data-sonner-toast][data-type="success"] div[data-title]:has-text("pruned")`)).toBeVisible({
+ timeout: 10000,
+ });
+ });
+
+ test('should pull image via dialog', async ({ page }) => {
+ await page.goto('/images');
+
+ await page.waitForLoadState('networkidle');
+
+ await page.locator('button:has-text("Pull Image")').first().click();
+ await expect(page.locator('div[role="heading"][aria-level="2"][data-dialog-title]:has-text("Pull Docker Image")')).toBeVisible();
+
+ const imageNameFull = 'ghcr.io/linuxserver/nginx:latest';
+ const imageName = 'ghcr.io/linuxserver/nginx';
+ await page.locator('input[id="image-ref"]').fill(imageName);
+
+ const pullPromise = page.waitForRequest((req) => req.url().includes('/api/images/pull') && req.method() === 'POST');
+ await page.locator('button[type="submit"]:has-text("Pull Image")').click();
+ const pullRequest = await pullPromise;
+
+ expect(pullRequest).toBeTruthy();
+ const postData = pullRequest.postDataJSON();
+ expect(postData.imageName).toBe(imageNameFull);
+
+ await expect(page.locator('li[data-sonner-toast][data-type="success"] div[data-title]')).toContainText(`Image ${imageNameFull} pulled successfully.`);
+ });
+});
diff --git a/tests/networks.spec.ts b/tests/spec/networks.spec.ts
similarity index 100%
rename from tests/networks.spec.ts
rename to tests/spec/networks.spec.ts
diff --git a/tests/spec/volumes.spec.ts b/tests/spec/volumes.spec.ts
new file mode 100644
index 000000000..d45151437
--- /dev/null
+++ b/tests/spec/volumes.spec.ts
@@ -0,0 +1,214 @@
+import { test, expect, type Page } from '@playwright/test';
+
+async function fetchVolumesWithRetry(page: Page, maxRetries = 3): Promise<any[]> {
+ let retries = 0;
+ while (retries < maxRetries) {
+ try {
+ const response = await page.request.get('/api/volumes');
+ const volumes = await response.json();
+ return volumes.data;
+ } catch (error) {
+ retries++;
+ console.log(`Attempt ${retries} failed, ${maxRetries - retries} retries left`);
+ if (retries >= maxRetries) throw error;
+ // Wait before retrying
+ await new Promise((resolve) => setTimeout(resolve, 1000));
+ }
+ }
+ return [];
+}
+
+let realVolumes: any[] = [];
+
+test.beforeEach(async ({ page }) => {
+ await page.goto('/volumes');
+ await page.waitForLoadState('networkidle');
+
+ try {
+ realVolumes = await fetchVolumesWithRetry(page);
+ } catch (error) {
+ console.warn('Could not fetch volumes after multiple retries:', error);
+ realVolumes = [];
+ }
+});
+
+test.describe('Volumes Page', () => {
+ test('should display the volumes page title and description', async ({ page }) => {
+ await page.goto('/volumes');
+
+ await expect(page.getByRole('heading', { name: 'Volumes', level: 1 })).toBeVisible();
+ await expect(page.getByText('Manage persistent data storage for containers').first()).toBeVisible();
+ });
+
+ test('should display stats cards with correct counts', async ({ page }) => {
+ await page.goto('/volumes');
+
+ await expect(page.locator('p:has-text("Total Volumes") + p')).toHaveText(realVolumes.length.toString());
+ await expect(page.locator('p:has-text("Default Driver") + p')).toHaveText('local');
+ });
+
+ test('should display the volume table when volumes exist', async ({ page }) => {
+ await page.goto('/volumes');
+ await page.waitForLoadState('networkidle');
+
+ if (realVolumes.length > 0) {
+ await expect(page.getByText('Volume List')).toBeVisible();
+ await expect(page.locator('table')).toBeVisible();
+ } else {
+ await expect(page.getByText('No volumes found')).toBeVisible();
+ }
+ });
+
+ test('should open the Create Volume dialog', async ({ page }) => {
+ await page.goto('/volumes');
+ await page.waitForLoadState('networkidle');
+
+ await page.locator('button:has-text("Create Volume")').first().click();
+ await expect(page.getByRole('dialog')).toBeVisible();
+ await expect(page.getByText('Create New Volume')).toBeVisible();
+ });
+
+ test('should display filter dropdown and allow filtering', async ({ page }) => {
+ await page.goto('/volumes');
+ await page.waitForLoadState('networkidle');
+
+ await page.locator('button:has-text("Filter")').click();
+ await expect(page.getByText('Volume Usage')).toBeVisible();
+ await expect(page.getByText('Show Used Volumes')).toBeVisible();
+ await expect(page.getByText('Show Unused Volumes')).toBeVisible();
+ });
+
+ test('should navigate to volume details on inspect click', async ({ page }) => {
+ test.skip(!realVolumes.length, 'No volumes available for inspect test');
+
+ await page.goto('/volumes');
+ await page.waitForLoadState('networkidle');
+
+ const firstRow = page.locator('tbody tr').first();
+ await firstRow.getByRole('button', { name: 'Open menu' }).click();
+ await page.getByRole('menuitem', { name: 'Inspect' }).click();
+
+ await expect(page).toHaveURL(new RegExp(`/volumes/.+`));
+ });
+
+ test('should call remove API on row action delete click and confirmation', async ({ page }) => {
+ test.skip(!realVolumes.length, 'No volumes available for remove API test');
+
+ await page.goto('/volumes');
+ await page.waitForLoadState('networkidle');
+
+ const unusedVolume = 'my-app-data';
+ test.skip(!unusedVolume, 'No unused volumes available for deletion test');
+
+ const firstRow = await page.getByRole('row', { name: 'my-app-data' });
+ await firstRow.getByRole('button', { name: 'Open menu' }).click();
+
+ await page.getByRole('menuitem', { name: 'Delete' }).click();
+
+ await expect(page.getByRole('heading', { name: 'Delete Volume' })).toBeVisible();
+
+ const removePromise = page.waitForRequest((req) => req.url().includes(`/api/volumes/my-app-data`) && req.method() === 'DELETE');
+
+ await page.locator('button:has-text("Delete")').click();
+ const removeRequest = await removePromise;
+
+ expect(removeRequest).toBeTruthy();
+
+ await expect(page.locator('li[data-sonner-toast][data-type="success"] div[data-title]')).toBeVisible();
+ });
+
+ test('should create volume via dialog', async ({ page }) => {
+ await page.goto('/volumes');
+ await page.waitForLoadState('networkidle');
+
+ await page.locator('button:has-text("Create Volume")').first().click();
+ await expect(page.getByRole('dialog')).toBeVisible();
+
+ const volumeName = `test-volume-${Date.now()}`;
+ await page.locator('input[id="volume-name"]').fill(volumeName);
+
+ const createPromise = page.waitForRequest((req) => req.url().includes('/api/volumes') && req.method() === 'POST');
+
+ await page.getByRole('dialog').locator('button:has-text("Create Volume")').click();
+ const createRequest = await createPromise;
+
+ expect(createRequest).toBeTruthy();
+ const postData = createRequest.postDataJSON();
+ expect(postData.Name).toBe(volumeName);
+
+ await expect(page.locator(`li[data-sonner-toast][data-type="success"] div[data-title]:has-text("created successfully")`)).toBeVisible();
+ });
+
+ test('should disable delete action for volumes in use', async ({ page }) => {
+ test.skip(!realVolumes.length, 'No volumes available for in-use test');
+
+ const volumeInUse = realVolumes.find((vol) => vol.inUse);
+ test.skip(!volumeInUse, 'No volumes in use found for test');
+
+ await page.goto('/volumes');
+ await page.waitForLoadState('networkidle');
+
+ const volumeRow = page.locator(`tr:has-text("${volumeInUse.Name}")`);
+ await volumeRow.getByRole('button', { name: 'Open menu' }).click();
+
+ const deleteButton = page.getByRole('menuitem', { name: 'Delete' });
+ await expect(deleteButton).toBeDisabled();
+ });
+
+ test('should display correct status badges for volume usage', async ({ page }) => {
+ test.skip(!realVolumes.length, 'No volumes available for status badge test');
+
+ await page.goto('/volumes');
+ await page.waitForLoadState('networkidle');
+
+ // Check for "In Use" and "Unused" badges
+ const usedVolumes = realVolumes.filter((vol) => vol.inUse);
+ const unusedVolumes = realVolumes.filter((vol) => !vol.inUse);
+
+ if (usedVolumes.length > 0) {
+ await expect(page.locator('text="In Use"').first()).toBeVisible();
+ }
+
+ if (unusedVolumes.length > 0) {
+ await expect(page.locator('text="Unused"').first()).toBeVisible();
+ }
+ });
+
+ test('should filter volumes by usage status', async ({ page }) => {
+ test.skip(!realVolumes.length, 'No volumes available for filter test');
+
+ const usedVolumes = realVolumes.filter((vol) => vol.inUse);
+ const unusedVolumes = realVolumes.filter((vol) => !vol.inUse);
+
+ // Skip if we don't have both types
+ test.skip(usedVolumes.length === 0 || unusedVolumes.length === 0, 'Need both used and unused volumes for filter test');
+
+ await page.goto('/volumes');
+ await page.waitForLoadState('networkidle');
+
+ // Open filter dropdown
+ await page.locator('button:has-text("Filter")').click();
+
+ // Uncheck "Show Used Volumes"
+ await page.getByText('Show Used Volumes').click();
+
+ // Close dropdown
+ await page.locator('button:has-text("Filter")').click();
+
+ // Should only show unused volumes
+ await expect(page.locator('tbody tr')).toHaveCount(unusedVolumes.length);
+
+ // Open filter dropdown again
+ await page.locator('button:has-text("Filter")').click();
+
+ // Check "Show Used Volumes" and uncheck "Show Unused Volumes"
+ await page.getByText('Show Used Volumes').click();
+ await page.getByText('Show Unused Volumes').click();
+
+ // Close dropdown
+ await page.locator('button:has-text("Filter")').click();
+
+ // Should only show used volumes
+ await expect(page.locator('tbody tr')).toHaveCount(usedVolumes.length);
+ });
+});
diff --git a/tests/tsconfig.json b/tests/tsconfig.json
new file mode 100644
index 000000000..2adb063f0
--- /dev/null
+++ b/tests/tsconfig.json
@@ -0,0 +1,6 @@
+{
+ "compilerOptions": {
+ "baseUrl": ".",
+ "lib": ["ES2022"]
+ }
+}
diff --git a/tests/volumes.spec.ts b/tests/volumes.spec.ts
deleted file mode 100644
index 1cf3ba281..000000000
--- a/tests/volumes.spec.ts
+++ /dev/null
@@ -1,224 +0,0 @@
-import { test, expect, type Page } from '@playwright/test';
-
-async function fetchVolumesWithRetry(page: Page, maxRetries = 3): Promise<any[]> {
- let retries = 0;
- while (retries < maxRetries) {
- try {
- const response = await page.request.get('/api/volumes');
- const volumes = await response.json();
- console.log(`Successfully fetched ${volumes.length} volumes on attempt ${retries + 1}`);
- return volumes;
- } catch (error) {
- retries++;
- console.log(`Attempt ${retries} failed, ${maxRetries - retries} retries left`);
- if (retries >= maxRetries) throw error;
- // Wait before retrying
- await new Promise((resolve) => setTimeout(resolve, 1000));
- }
- }
- return [];
-}
-
-let realVolumes: any[] = [];
-
-test.beforeEach(async ({ page }) => {
- await page.goto('/volumes');
- await page.waitForLoadState('networkidle');
-
- try {
- realVolumes = await fetchVolumesWithRetry(page);
- } catch (error) {
- console.warn('Could not fetch volumes after multiple retries:', error);
- // Use default volumes if all retries fail
- realVolumes = [];
- }
-
- console.log(`Found ${realVolumes.length} real volumes for testing`);
-});
-
-test.describe('Volumes Page', () => {
- test('should display the volumes page title and description', async ({ page }) => {
- await page.goto('/volumes');
-
- await expect(page.getByRole('heading', { name: 'Volumes', level: 1 })).toBeVisible();
- await expect(page.getByText('Manage persistent data storage for containers').first()).toBeVisible();
- });
-
- test('should display stats cards with correct counts', async ({ page }) => {
- await page.goto('/volumes');
-
- await expect(page.locator('p:has-text("Total Volumes") + p')).toHaveText(realVolumes.length.toString());
- await expect(page.locator('p:has-text("Default Driver") + p')).toHaveText('local');
- });
-
- test('should display the volume table when volumes exist', async ({ page }) => {
- await page.goto('/volumes');
- await page.waitForLoadState('networkidle');
-
- if (realVolumes.length > 0) {
- await expect(page.getByText('Volume List')).toBeVisible();
- await expect(page.locator('table')).toBeVisible();
- } else {
- // Should show empty state instead
- await expect(page.getByText('No volumes found')).toBeVisible();
- }
- });
-
- test('should open the Create Volume dialog', async ({ page }) => {
- await page.goto('/volumes');
- await page.waitForLoadState('networkidle');
-
- await page.locator('button:has-text("Create Volume")').first().click();
- // Fix the dialog title selector - looking at the create-volume-dialog.svelte
- await expect(page.getByRole('dialog')).toBeVisible();
- await expect(page.getByText('Create New Volume')).toBeVisible();
- });
-
- test('should display filter dropdown and allow filtering', async ({ page }) => {
- await page.goto('/volumes');
- await page.waitForLoadState('networkidle');
-
- // Open filter dropdown
- await page.locator('button:has-text("Filter")').click();
- await expect(page.getByText('Volume Usage')).toBeVisible();
- await expect(page.getByText('Show Used Volumes')).toBeVisible();
- await expect(page.getByText('Show Unused Volumes')).toBeVisible();
- });
-
- test('should navigate to volume details on inspect click', async ({ page }) => {
- test.skip(!realVolumes.length, 'No volumes available for inspect test');
-
- await page.goto('/volumes');
- await page.waitForLoadState('networkidle');
-
- const firstRow = page.locator('tbody tr').first();
- await firstRow.getByRole('button', { name: 'Open menu' }).click();
- await page.getByRole('menuitem', { name: 'Inspect' }).click();
-
- // Check that we navigated to the volume details page
- await expect(page).toHaveURL(new RegExp(`/volumes/.+`));
- });
-
- test('should call remove API on row action delete click and confirmation', async ({ page }) => {
- test.skip(!realVolumes.length, 'No volumes available for remove API test');
-
- await page.goto('/volumes');
- await page.waitForLoadState('networkidle');
-
- // Find a volume that's not in use (if any)
- const unusedVolume = realVolumes.find((vol) => !vol.inUse);
- test.skip(!unusedVolume, 'No unused volumes available for deletion test');
-
- const volumeRow = page.locator(`tr:has-text("${unusedVolume.Name}")`);
- await volumeRow.getByRole('button', { name: 'Open menu' }).click();
- await page.getByRole('menuitem', { name: 'Delete' }).click();
-
- // Wait for confirmation dialog
- await expect(page.getByRole('heading', { name: 'Delete Volume' })).toBeVisible();
-
- const removePromise = page.waitForRequest((req) => req.url().includes(`/api/volumes/${unusedVolume.Name}`) && req.method() === 'DELETE');
-
- await page.locator('button:has-text("Delete")').click();
- const removeRequest = await removePromise;
-
- expect(removeRequest).toBeTruthy();
-
- await expect(page.locator('li[data-sonner-toast][data-type="success"] div[data-title]')).toBeVisible();
- });
-
- test('should create volume via dialog', async ({ page }) => {
- await page.goto('/volumes');
- await page.waitForLoadState('networkidle');
-
- await page.locator('button:has-text("Create Volume")').first().click();
- await expect(page.getByRole('dialog')).toBeVisible();
-
- const volumeName = `test-volume-${Date.now()}`;
- await page.locator('input[id="volume-name"]').fill(volumeName);
-
- const createPromise = page.waitForRequest((req) => req.url().includes('/api/volumes') && req.method() === 'POST');
-
- await page.getByRole('dialog').locator('button:has-text("Create Volume")').click();
- const createRequest = await createPromise;
-
- expect(createRequest).toBeTruthy();
- const postData = createRequest.postDataJSON();
- expect(postData.Name).toBe(volumeName);
-
- await expect(page.locator(`li[data-sonner-toast][data-type="success"] div[data-title]:has-text("created successfully")`)).toBeVisible();
- });
-
- test('should disable delete action for volumes in use', async ({ page }) => {
- test.skip(!realVolumes.length, 'No volumes available for in-use test');
-
- const volumeInUse = realVolumes.find((vol) => vol.inUse);
- test.skip(!volumeInUse, 'No volumes in use found for test');
-
- await page.goto('/volumes');
- await page.waitForLoadState('networkidle');
-
- const volumeRow = page.locator(`tr:has-text("${volumeInUse.Name}")`);
- await volumeRow.getByRole('button', { name: 'Open menu' }).click();
-
- // Check that delete button is disabled
- const deleteButton = page.getByRole('menuitem', { name: 'Delete' });
- await expect(deleteButton).toBeDisabled();
- });
-
- test('should display correct status badges for volume usage', async ({ page }) => {
- test.skip(!realVolumes.length, 'No volumes available for status badge test');
-
- await page.goto('/volumes');
- await page.waitForLoadState('networkidle');
-
- // Check for "In Use" and "Unused" badges
- const usedVolumes = realVolumes.filter((vol) => vol.inUse);
- const unusedVolumes = realVolumes.filter((vol) => !vol.inUse);
-
- if (usedVolumes.length > 0) {
- await expect(page.locator('text="In Use"').first()).toBeVisible();
- }
-
- if (unusedVolumes.length > 0) {
- await expect(page.locator('text="Unused"').first()).toBeVisible();
- }
- });
-
- test('should filter volumes by usage status', async ({ page }) => {
- test.skip(!realVolumes.length, 'No volumes available for filter test');
-
- const usedVolumes = realVolumes.filter((vol) => vol.inUse);
- const unusedVolumes = realVolumes.filter((vol) => !vol.inUse);
-
- // Skip if we don't have both types
- test.skip(usedVolumes.length === 0 || unusedVolumes.length === 0, 'Need both used and unused volumes for filter test');
-
- await page.goto('/volumes');
- await page.waitForLoadState('networkidle');
-
- // Open filter dropdown
- await page.locator('button:has-text("Filter")').click();
-
- // Uncheck "Show Used Volumes"
- await page.getByText('Show Used Volumes').click();
-
- // Close dropdown
- await page.locator('button:has-text("Filter")').click();
-
- // Should only show unused volumes
- await expect(page.locator('tbody tr')).toHaveCount(unusedVolumes.length);
-
- // Open filter dropdown again
- await page.locator('button:has-text("Filter")').click();
-
- // Check "Show Used Volumes" and uncheck "Show Unused Volumes"
- await page.getByText('Show Used Volumes').click();
- await page.getByText('Show Unused Volumes').click();
-
- // Close dropdown
- await page.locator('button:has-text("Filter")').click();
-
- // Should only show used volumes
- await expect(page.locator('tbody tr')).toHaveCount(usedVolumes.length);
- });
-});