Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: forward and validate origin header in websocket tunnel (#2003)
Kyle Mendellfb7790a17cf5
diff --git a/backend/pkg/libarcane/edge/client.go b/backend/pkg/libarcane/edge/client.goindex 4a6c03c0f..a1aa38939 100644--- a/backend/pkg/libarcane/edge/client.go+++ b/backend/pkg/libarcane/edge/client.go@@ -404,7 +404,18 @@ func (c *TunnelClient) handleWebSocketStart(ctx context.Context, msg *TunnelMessdefer func() { _ = resp.Body.Close() }()}if err != nil {- slog.ErrorContext(ctx, "Failed to dial local WebSocket", "error", err, "url", localURL)+ attrs := []any{"error", err, "url", localURL}+ if resp != nil {+ attrs = append(attrs, "status", resp.StatusCode)+ if resp.Body != nil {+ buf := make([]byte, 512)+ n, _ := resp.Body.Read(buf)+ if n > 0 {+ attrs = append(attrs, "response_body", string(buf[:n]))+ }+ }+ }+ slog.ErrorContext(ctx, "Failed to dial local WebSocket", attrs...)c.sendWebSocketClose(streamID)return}@@ -450,18 +461,42 @@ func (c *TunnelClient) localWebSocketHostInternal() string {}}+// localDialSkipHeaders lists headers that must not be forwarded when the+// agent dials its own local HTTP server for a proxied WebSocket stream.+// This includes:+// - Standard WebSocket handshake headers (gorilla/websocket sets its own)+// - Browser-specific headers that were forwarded through the tunnel from+// the manager. These cause handshake failures because the agent's+// WebSocket upgrader validates the Origin against localhost, not the+// browser's remote origin.+var localDialSkipHeaders = map[string]bool{+ // WebSocket handshake (gorilla/websocket adds its own)+ "Sec-Websocket-Key": true,+ "Sec-Websocket-Version": true,+ "Sec-Websocket-Extensions": true,+ "Upgrade": true,+ "Connection": true,++ // Browser headers forwarded through the tunnel that are invalid+ // for a server-to-server local dial.+ "Origin": true,+ "Cookie": true,+ "Authorization": true,+ "Referer": true,+ "Sec-Fetch-Dest": true,+ "Sec-Fetch-Mode": true,+ "Sec-Fetch-Site": true,+ "Sec-Fetch-User": true,+ "Sec-Ch-Ua": true,+ "Sec-Ch-Ua-Mobile": true,+ "Sec-Ch-Ua-Platform": true,+}+func (c *TunnelClient) buildLocalWebSocketHeadersInternal(msg *TunnelMessage) http.Header {headers := http.Header{}- wsHandshakeHeaders := map[string]bool{- "Sec-Websocket-Key": true,- "Sec-Websocket-Version": true,- "Sec-Websocket-Extensions": true,- "Upgrade": true,- "Connection": true,- }for k, v := range msg.Headers {canonicalKey := http.CanonicalHeaderKey(k)- if !wsHandshakeHeaders[canonicalKey] {+ if !localDialSkipHeaders[canonicalKey] {headers.Set(canonicalKey, v)}}diff --git a/backend/pkg/libarcane/edge/client_test.go b/backend/pkg/libarcane/edge/client_test.goindex cacb182db..87cc29f61 100644--- a/backend/pkg/libarcane/edge/client_test.go+++ b/backend/pkg/libarcane/edge/client_test.go@@ -7,12 +7,14 @@ import ("maps""net/http""net/http/httptest"+ "net/url""strings""sync""testing""time""github.com/getarcaneapp/arcane/backend/internal/config"+ httputil "github.com/getarcaneapp/arcane/backend/internal/utils/http""github.com/gorilla/websocket""github.com/stretchr/testify/assert""github.com/stretchr/testify/require"@@ -360,6 +362,126 @@ func TestTunnelClient_buildLocalWebSocketHeadersInternal(t *testing.T) {assert.Equal(t, "agent-token", headers.Get("X-Arcane-Agent-Token"))}+func TestTunnelClient_buildLocalWebSocketHeadersInternal_FiltersBrowserHeaders(t *testing.T) {+ client := NewTunnelClient(&config.Config{+ AgentToken: "agent-token",+ }, http.NotFoundHandler())++ headers := client.buildLocalWebSocketHeadersInternal(&TunnelMessage{+ Headers: map[string]string{+ // Browser headers that should be stripped+ "Origin": "https://docker.example.com",+ "Cookie": "session=abc123",+ "Authorization": "Bearer browser-jwt",+ "Referer": "https://docker.example.com/environments/123",+ "Sec-Fetch-Dest": "websocket",+ "Sec-Fetch-Mode": "websocket",+ "Sec-Fetch-Site": "same-origin",+ "Sec-Fetch-User": "?1",+ "Sec-Ch-Ua": "\"Chromium\";v=\"130\"",+ "Sec-Ch-Ua-Mobile": "?0",+ "Sec-Ch-Ua-Platform": "\"Linux\"",+ // Headers that should be preserved+ "X-Custom": "value",+ "Sec-WebSocket-Protocol": "binary",+ "Accept-Language": "en-US",+ },+ })++ // Browser headers must be stripped+ assert.Empty(t, headers.Get("Origin"), "Origin should be stripped")+ assert.Empty(t, headers.Get("Cookie"), "Cookie should be stripped")+ assert.Empty(t, headers.Get("Authorization"), "Authorization should be stripped")+ assert.Empty(t, headers.Get("Referer"), "Referer should be stripped")+ assert.Empty(t, headers.Get("Sec-Fetch-Dest"), "Sec-Fetch-Dest should be stripped")+ assert.Empty(t, headers.Get("Sec-Fetch-Mode"), "Sec-Fetch-Mode should be stripped")+ assert.Empty(t, headers.Get("Sec-Fetch-Site"), "Sec-Fetch-Site should be stripped")+ assert.Empty(t, headers.Get("Sec-Fetch-User"), "Sec-Fetch-User should be stripped")+ assert.Empty(t, headers.Get("Sec-Ch-Ua"), "Sec-Ch-Ua should be stripped")+ assert.Empty(t, headers.Get("Sec-Ch-Ua-Mobile"), "Sec-Ch-Ua-Mobile should be stripped")+ assert.Empty(t, headers.Get("Sec-Ch-Ua-Platform"), "Sec-Ch-Ua-Platform should be stripped")++ // Non-browser headers must be preserved+ assert.Equal(t, "value", headers.Get("X-Custom"))+ assert.Equal(t, "binary", headers.Get("Sec-Websocket-Protocol"))+ assert.Equal(t, "en-US", headers.Get("Accept-Language"))++ // Agent token must override any manager-forwarded auth+ assert.Equal(t, "agent-token", headers.Get("X-API-Key"))+ assert.Equal(t, "agent-token", headers.Get("X-Arcane-Agent-Token"))+}++func TestTunnelClient_DialLocalWebSocket_StripsForwardedBrowserHeaders(t *testing.T) {+ managerURL := "https://manager.internal.example.com"++ localServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ if r.Header.Get("X-API-Key") != "agent-token" {+ http.Error(w, "missing agent auth", http.StatusForbidden)+ return+ }++ if origin := r.Header.Get("Origin"); origin != "" {+ http.Error(w, "unexpected forwarded origin: "+origin, http.StatusForbidden)+ return+ }++ if cookie := r.Header.Get("Cookie"); cookie != "" {+ http.Error(w, "unexpected forwarded cookie", http.StatusForbidden)+ return+ }++ upgrader := websocket.Upgrader{+ CheckOrigin: httputil.ValidateWebSocketOrigin(managerURL),+ }+ conn, err := upgrader.Upgrade(w, r, nil)+ if err != nil {+ return+ }+ defer func() { _ = conn.Close() }()++ require.NoError(t, conn.WriteMessage(websocket.TextMessage, []byte("ok")))+ }))+ defer localServer.Close()++ parsedURL, err := url.Parse(localServer.URL)+ require.NoError(t, err)++ client := NewTunnelClient(&config.Config{+ AgentToken: "agent-token",+ Listen: parsedURL.Hostname(),+ Port: parsedURL.Port(),+ }, http.NotFoundHandler())++ msg := &TunnelMessage{+ Path: "/",+ Headers: map[string]string{+ "Origin": "https://public.browser.example.com",+ "Cookie": "session=browser-cookie",+ "Authorization": "Bearer browser-token",+ "Sec-Fetch-Mode": "websocket",+ "Sec-Fetch-Site": "same-origin",+ "Sec-Websocket-Key": "forwarded-handshake-key",+ },+ }++ headers := client.buildLocalWebSocketHeadersInternal(msg)+ assert.Empty(t, headers.Get("Origin"))+ assert.Empty(t, headers.Get("Cookie"))+ assert.Empty(t, headers.Get("Authorization"))++ ws, resp, err := client.dialLocalWebSocket(t.Context(), client.buildLocalWebSocketURLInternal(msg), headers)+ require.NoError(t, err)+ if resp != nil {+ defer func() { _ = resp.Body.Close() }()+ }+ defer func() { _ = ws.Close() }()++ msgType, body, err := ws.ReadMessage()+ require.NoError(t, err)+ assert.Equal(t, websocket.TextMessage, msgType)+ assert.Equal(t, "ok", string(body))+}+func TestTunnelClient_IsGRPCConnectionInternal(t *testing.T) {t.Run("nil connection", func(t *testing.T) {client := &TunnelClient{}diff --git a/go.work.sum b/go.work.sumindex 376fcde1c..0bb348217 100644--- a/go.work.sum+++ b/go.work.sum@@ -418,8 +418,6 @@ github.com/golang/glog v1.2.5/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmgithub.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=-github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=-github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=@@ -456,12 +454,8 @@ github.com/google/go-dap v0.12.0 h1:rVcjv3SyMIrpaOoTAdFDyHs99CwVOItIJGKLQFQhNeM=github.com/google/go-dap v0.12.0/go.mod h1:tNjCASCm5cqePi/RVXXWEVqtnNLV1KTWtYOqu6rZNzc=github.com/google/go-dap v0.12.1-0.20250904181021-d7a2259b058b h1:m+yLjBIoXaMKk6pwd1IJYYgM76+mwcy7J9+cuY7LqmQ=github.com/google/go-dap v0.12.1-0.20250904181021-d7a2259b058b/go.mod h1:tNjCASCm5cqePi/RVXXWEVqtnNLV1KTWtYOqu6rZNzc=-github.com/google/go-github/v39 v39.2.0 h1:rNNM311XtPOz5rDdsJXAp2o8F67X9FnROXTvto3aSnQ=-github.com/google/go-github/v39 v39.2.0/go.mod h1:C1s8C5aCC9L+JXIYpJM5GYytdX52vC1bLvHEF1IhBrE=github.com/google/go-intervals v0.0.2 h1:FGrVEiUnTRKR8yE04qzXYaJMtnIYqobR5QbblK3ixcM=github.com/google/go-intervals v0.0.2/go.mod h1:MkaR3LNRfeKLPmqgJYs4E66z5InYjmCjbbr4TQlcT6Y=-github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=-github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg=@@ -864,8 +858,10 @@ github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E=github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=+github.com/xdg-go/scram v1.2.0/go.mod h1:3dlrS0iBaWKYVt2ZfA4cj48umJZ+cAEbR6/SjLA88I8=github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs=github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=+github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=@@ -878,6 +874,7 @@ github.com/yashtewari/glob-intersection v0.2.0 h1:8iuHdN88yYuCzCdjt0gDe+6bAhUwBegithub.com/yashtewari/glob-intersection v0.2.0/go.mod h1:LK7pIC3piUjovexikBbJ26Yml7g8xa5bsjfx2v1fwok=github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=+github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI=github.com/ysmood/fetchup v0.2.3 h1:ulX+SonA0Vma5zUFXtv52Kzip/xe7aj4vqT5AJwQ+ZQ=github.com/ysmood/fetchup v0.2.3/go.mod h1:xhibcRKziSvol0H1/pj33dnKrYyI2ebIvz5cOOkYGns=github.com/ysmood/goob v0.4.0 h1:HsxXhyLBeGzWXnqVKtmT9qM7EuVs/XOgkX7T6r1o1AQ=@@ -984,7 +981,6 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtngolang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=-golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=@@ -1004,7 +1000,6 @@ golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=-golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=golang.org/x/oauth2 v0.33.0 h1:4Q+qn+E5z8gPRJfmRy7C2gGG3T4jIprK6aSYgTXGRpo=golang.org/x/oauth2 v0.33.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=diff --git a/tests/spec/dashboard-system-stats.spec.ts b/tests/spec/dashboard-system-stats.spec.tsnew file mode 100644index 000000000..c81a6ddc0--- /dev/null+++ b/tests/spec/dashboard-system-stats.spec.ts@@ -0,0 +1,110 @@+import { test, expect, type Page } from '@playwright/test';++const mockedStats = {+ cpuUsage: 12.3,+ memoryUsage: 512 * 1024 * 1024,+ memoryTotal: 1024 * 1024 * 1024,+ diskUsage: 256 * 1024 * 1024,+ diskTotal: 1024 * 1024 * 1024,+ cpuCount: 7,+ architecture: 'amd64',+ platform: 'linux',+ hostname: 'edge-client',+ gpuCount: 0,+ gpus: [],+};++async function mockDashboardStatsWebSocket(page: Page) {+ await page.addInitScript((statsPayload) => {+ const browserWindow = globalThis as typeof globalThis & {+ WebSocket: any;+ EventTarget: any;+ Event: any;+ MessageEvent: any;+ CloseEvent: any;+ };+ const NativeWebSocket = browserWindow.WebSocket;+ const statsPathPattern = /\/api\/environments\/[^/]+\/ws\/system\/stats(?:\?.*)?$/;++ class MockStatsWebSocket extends browserWindow.EventTarget {+ static CONNECTING = 0;+ static OPEN = 1;+ static CLOSING = 2;+ static CLOSED = 3;++ url: string;+ readyState = MockStatsWebSocket.CONNECTING;+ bufferedAmount = 0;+ extensions = '';+ protocol = '';+ binaryType = 'blob';+ onopen: ((event: unknown) => void) | null = null;+ onmessage: ((event: unknown) => void) | null = null;+ onerror: ((event: unknown) => void) | null = null;+ onclose: ((event: unknown) => void) | null = null;++ constructor(url: string | URL) {+ super();+ this.url = String(url);++ queueMicrotask(() => {+ if (this.readyState !== MockStatsWebSocket.CONNECTING) return;+ this.readyState = MockStatsWebSocket.OPEN;+ const openEvent = new browserWindow.Event('open');+ this.dispatchEvent(openEvent);+ this.onopen?.(openEvent);++ const messageEvent = new browserWindow.MessageEvent('message', {+ data: JSON.stringify(statsPayload),+ });+ this.dispatchEvent(messageEvent);+ this.onmessage?.(messageEvent);+ });+ }++ send(_data?: string | ArrayBufferLike | Blob | ArrayBufferView) {}++ close(code = 1000, reason = '') {+ if (this.readyState === MockStatsWebSocket.CLOSED) return;+ this.readyState = MockStatsWebSocket.CLOSED;+ const closeEvent = new browserWindow.CloseEvent('close', { code, reason, wasClean: true });+ this.dispatchEvent(closeEvent);+ this.onclose?.(closeEvent);+ }+ }++ const PatchedWebSocket = function (this: unknown, url: string | URL, protocols?: string | string[]) {+ const urlString = String(url);+ if (statsPathPattern.test(urlString)) {+ return new MockStatsWebSocket(urlString);+ }+ return protocols === undefined ? new NativeWebSocket(url) : new NativeWebSocket(url, protocols);+ } as unknown as typeof WebSocket;++ Object.defineProperties(PatchedWebSocket, {+ CONNECTING: { value: NativeWebSocket.CONNECTING },+ OPEN: { value: NativeWebSocket.OPEN },+ CLOSING: { value: NativeWebSocket.CLOSING },+ CLOSED: { value: NativeWebSocket.CLOSED },+ });+ PatchedWebSocket.prototype = NativeWebSocket.prototype;++ browserWindow.WebSocket = PatchedWebSocket;+ }, mockedStats);+}++test.describe('Dashboard system stats websocket', () => {+ test('renders metrics from the system stats websocket stream', async ({ page }) => {+ await mockDashboardStatsWebSocket(page);++ await page.goto('/dashboard');+ await page.waitForLoadState('networkidle');++ await expect(page.getByText('12.3%', { exact: true })).toBeVisible();+ await expect(page.getByText('50.0%', { exact: true })).toBeVisible();+ await expect(page.getByText('25.0%', { exact: true })).toBeVisible();+ await expect(page.getByText('7 CPUs', { exact: true })).toBeVisible();+ await expect(page.getByText('512 MB / 1 GB', { exact: true })).toBeVisible();+ await expect(page.getByText('256 MB / 1 GB', { exact: true })).toBeVisible();+ });+});diff --git a/tests/spec/environment-settings.spec.ts b/tests/spec/environment-settings.spec.tsindex 560507f78..aa1e8fd25 100644--- a/tests/spec/environment-settings.spec.ts+++ b/tests/spec/environment-settings.spec.ts@@ -1,61 +1,46 @@-import { test, expect, type Locator, type Page } from "@playwright/test";+import { test, expect, type Locator, type Page } from '@playwright/test';-const LOCAL_ENV_ID = "0";+const LOCAL_ENV_ID = '0';async function openEnvironment(page: Page, environmentId: string) {await page.goto(`/environments/${environmentId}`);- await page.waitForLoadState("networkidle");- await expect(page.locator("#env-name")).toBeVisible();- await expect(- page.getByRole("button", { name: "Save", exact: true }).first(),- ).toBeVisible();+ await page.waitForLoadState('networkidle');+ await expect(page.locator('#env-name')).toBeVisible();+ await expect(page.getByRole('button', { name: 'Save', exact: true }).first()).toBeVisible();}-async function createDirectEnvironmentViaUI(- page: Page,- environmentName: string,-) {- await page.goto("/environments");- await page.waitForLoadState("networkidle");-- await page- .getByRole("button", { name: "Add Environment", exact: true })- .click();- await expect(page.getByText("Create New Agent Environment")).toBeVisible();-- await page.locator("input#name:visible").first().fill(environmentName);- await page.locator("#new-agent-api-url").fill("localhost:3552");- await page- .getByRole("button", { name: "Generate Agent Configuration", exact: true })- .click();-- await expect(page.locator('[data-slot="sheet-title"]')).toContainText(- /Environment Created/i,- );- await page.getByRole("button", { name: "Done", exact: true }).click();- await expect(- page.getByRole("button", { name: environmentName, exact: true }),- ).toBeVisible();+async function createDirectEnvironmentViaUI(page: Page, environmentName: string) {+ await page.goto('/environments');+ await page.waitForLoadState('networkidle');++ await page.getByRole('button', { name: 'Add Environment', exact: true }).click();+ await expect(page.getByText('Create New Agent Environment')).toBeVisible();++ await page.locator('input#name:visible').first().fill(environmentName);+ await page.locator('#new-agent-api-url').fill('localhost:3552');+ await page.getByRole('button', { name: 'Generate Agent Configuration', exact: true }).click();++ await expect(page.locator('[data-slot="sheet-title"]')).toContainText(/Environment Created/i);+ await page.getByRole('button', { name: 'Done', exact: true }).click();+ await expect(page.getByRole('button', { name: environmentName, exact: true })).toBeVisible();}async function deleteEnvironmentViaUI(page: Page, environmentName: string) {- await page.goto("/environments");- await page.waitForLoadState("networkidle");+ await page.goto('/environments');+ await page.waitForLoadState('networkidle');- const envRow = page.locator("tr").filter({- has: page.getByRole("button", { name: environmentName, exact: true }),+ const envRow = page.locator('tr').filter({+ has: page.getByRole('button', { name: environmentName, exact: true }),});if ((await envRow.count()) === 0) {return;}- await envRow.getByRole("button", { name: /open menu/i }).click();- await page.getByRole("menuitem", { name: "Delete", exact: true }).click();- await page.getByRole("button", { name: "Remove", exact: true }).click();- await expect(- page.getByRole("button", { name: environmentName, exact: true }),- ).toHaveCount(0);+ await envRow.getByRole('button', { name: /open menu/i }).click();+ await page.getByRole('menuitem', { name: 'Delete', exact: true }).click();+ await page.getByRole('button', { name: 'Remove', exact: true }).click();+ await expect(page.getByRole('button', { name: environmentName, exact: true })).toHaveCount(0);}async function openLocalEnvironment(page: Page) {@@ -63,115 +48,97 @@ async function openLocalEnvironment(page: Page) {}async function saveAndWaitForPut(page: Page, expectedPath: string) {- const saveButton = page- .getByRole("button", { name: "Save", exact: true })- .first();+ const saveButton = page.getByRole('button', { name: 'Save', exact: true }).first();await expect(saveButton).toBeEnabled();- const requestPromise = page.waitForRequest((request) => {- if (request.method() !== "PUT") return false;- const url = new URL(request.url());+ const responsePromise = page.waitForResponse((response) => {+ const request = response.request();+ if (request.method() !== 'PUT') return false;+ const url = new URL(response.url());return url.pathname === expectedPath;});await saveButton.click();- await requestPromise;- await expect(saveButton).toBeDisabled();+ const response = await responsePromise;+ expect(response.ok(), `Expected successful PUT to ${expectedPath}`).toBeTruthy();+ await expect(saveButton).toBeDisabled({ timeout: 10000 });}-async function selectSettingOption(- page: Page,- trigger: Locator,- optionText: string,-) {+async function selectSettingOption(page: Page, trigger: Locator, optionText: string) {await expect(trigger).toBeVisible();await trigger.click();- await page- .locator('[data-slot="select-item"]')- .filter({ hasText: optionText })- .first()- .click();+ const option = page.locator('[data-slot="select-item"]').filter({ hasText: optionText }).first();+ await expect(option).toBeVisible();+ await option.click();}-test.describe("Environment Settings UI", () => {- test("should update and save environment details", async ({ page }) => {+test.describe('Environment Settings UI', () => {+ test.describe.configure({ mode: 'serial' });++ test('should update and save environment details', async ({ page }) => {const envName = `settings-ui-${Date.now().toString().slice(-5)}`;const updatedName = `${envName}-updated`;try {await createDirectEnvironmentViaUI(page, envName);- await page.getByRole("button", { name: envName, exact: true }).click();+ await page.getByRole('button', { name: envName, exact: true }).click();await expect(page).toHaveURL(/\/environments\/[^/]+$/);- const environmentId = new URL(page.url()).pathname.split("/").pop()!;- const nameInput = page.locator("#env-name");+ const environmentId = new URL(page.url()).pathname.split('/').pop()!;+ const nameInput = page.locator('#env-name');await nameInput.fill(updatedName);await saveAndWaitForPut(page, `/api/environments/${environmentId}`);await page.reload();- await expect(page.locator("#env-name")).toHaveValue(updatedName);+ await expect(page.locator('#env-name')).toHaveValue(updatedName);} finally {await deleteEnvironmentViaUI(page, updatedName);await deleteEnvironmentViaUI(page, envName);}});- test("should update and save general environment settings", async ({- page,- }) => {+ test('should update and save general environment settings', async ({ page }) => {await openLocalEnvironment(page);+ await page.getByRole('tab', { name: 'General', exact: true }).click();- await page.getByRole("tab", { name: "General", exact: true }).click();- const projectsDirectoryInput = page.locator("#projects-directory");- await expect(projectsDirectoryInput).toBeVisible();+ const baseServerUrlInput = page.locator('#base-server-url');+ await expect(baseServerUrlInput).toBeVisible();- const originalProjectsDirectory = await projectsDirectoryInput.inputValue();- const updatedProjectsDirectory = originalProjectsDirectory.endsWith("-e2e")- ? `${originalProjectsDirectory}-x`- : `${originalProjectsDirectory}-e2e`;+ const originalBaseServerUrl = await baseServerUrlInput.inputValue();+ const updatedBaseServerUrl =+ originalBaseServerUrl.endsWith('/e2e') ? `${originalBaseServerUrl}-2` : `${originalBaseServerUrl}/e2e`;try {- await projectsDirectoryInput.fill(updatedProjectsDirectory);- await saveAndWaitForPut(- page,- `/api/environments/${LOCAL_ENV_ID}/settings`,- );+ await baseServerUrlInput.fill(updatedBaseServerUrl);+ await expect(baseServerUrlInput).toHaveValue(updatedBaseServerUrl);+ await saveAndWaitForPut(page, `/api/environments/${LOCAL_ENV_ID}/settings`);await page.reload();- await page.getByRole("tab", { name: "General", exact: true }).click();- await expect(page.locator("#projects-directory")).toHaveValue(- updatedProjectsDirectory,- );+ await page.getByRole('tab', { name: 'General', exact: true }).click();+ await expect(page.locator('#base-server-url')).toHaveValue(updatedBaseServerUrl, {+ timeout: 15000,+ });} finally {- await page.getByRole("tab", { name: "General", exact: true }).click();- const currentProjectsDirectory = await page- .locator("#projects-directory")- .inputValue();- if (currentProjectsDirectory !== originalProjectsDirectory) {- await page- .locator("#projects-directory")- .fill(originalProjectsDirectory);- await saveAndWaitForPut(- page,- `/api/environments/${LOCAL_ENV_ID}/settings`,- );+ if (!page.isClosed()) {+ await page.getByRole('tab', { name: 'General', exact: true }).click();+ const currentValue = await page.locator('#base-server-url').inputValue();+ if (currentValue !== originalBaseServerUrl) {+ await page.locator('#base-server-url').fill(originalBaseServerUrl);+ await saveAndWaitForPut(page, `/api/environments/${LOCAL_ENV_ID}/settings`);+ }}}});- test("should reset unsaved environment detail changes", async ({ page }) => {+ test('should reset unsaved environment detail changes', async ({ page }) => {await openLocalEnvironment(page);- const nameInput = page.locator("#env-name");+ const nameInput = page.locator('#env-name');const originalName = await nameInput.inputValue();await nameInput.fill(`${originalName}-pending`);- const saveButton = page- .getByRole("button", { name: "Save", exact: true })- .first();- const resetButton = page- .getByRole("button", { name: "Reset", exact: true })- .first();+ const saveButton = page.getByRole('button', { name: 'Save', exact: true }).first();+ const resetButton = page.getByRole('button', { name: 'Reset', exact: true }).first();await expect(saveButton).toBeEnabled();await expect(resetButton).toBeVisible();@@ -181,53 +148,41 @@ test.describe("Environment Settings UI", () => {await expect(saveButton).toBeDisabled();});- test("should update and save the default deploy pull policy in Docker settings", async ({- page,- }) => {+ test('should update and save the default deploy pull policy in Docker settings', async ({ page }) => {await openLocalEnvironment(page);- const dockerTab = page.getByRole("tab", { name: /Docker/i }).first();+ const dockerTab = page.getByRole('tab', { name: /Docker/i }).first();await dockerTab.click();- const pullPolicyTrigger = page.locator("#defaultDeployPullPolicy");+ const pullPolicyTrigger = page.locator('#defaultDeployPullPolicy');await expect(pullPolicyTrigger).toBeVisible();- const originalValue =- (await pullPolicyTrigger.textContent())?.trim() || "Missing";- const updatedValue = originalValue.includes("Always") ? "Never" : "Always";+ const originalValue = (await pullPolicyTrigger.textContent())?.trim() || 'Missing';+ const updatedValue = originalValue.includes('Always') ? 'Never' : 'Always';try {await selectSettingOption(page, pullPolicyTrigger, updatedValue);- await saveAndWaitForPut(- page,- `/api/environments/${LOCAL_ENV_ID}/settings`,- );+ await expect(pullPolicyTrigger).toContainText(updatedValue);+ await saveAndWaitForPut(page, `/api/environments/${LOCAL_ENV_ID}/settings`);await page.reload();await page- .getByRole("tab", { name: /Docker/i })+ .getByRole('tab', { name: /Docker/i }).first().click();- await expect(page.locator("#defaultDeployPullPolicy")).toContainText(- updatedValue,- );+ await expect(page.locator('#defaultDeployPullPolicy')).toContainText(updatedValue, {+ timeout: 15000,+ });} finally {- await page- .getByRole("tab", { name: /Docker/i })- .first()- .click();- const currentValue = (- (await page.locator("#defaultDeployPullPolicy").textContent()) || ""- ).trim();- if (!currentValue.includes(originalValue)) {- await selectSettingOption(- page,- page.locator("#defaultDeployPullPolicy"),- originalValue,- );- await saveAndWaitForPut(- page,- `/api/environments/${LOCAL_ENV_ID}/settings`,- );+ if (!page.isClosed()) {+ await page+ .getByRole('tab', { name: /Docker/i })+ .first()+ .click();+ const currentValue = ((await page.locator('#defaultDeployPullPolicy').textContent()) || '').trim();+ if (!currentValue.includes(originalValue)) {+ await selectSettingOption(page, page.locator('#defaultDeployPullPolicy'), originalValue);+ await saveAndWaitForPut(page, `/api/environments/${LOCAL_ENV_ID}/settings`);+ }}}});diff --git a/tests/spec/project.spec.ts b/tests/spec/project.spec.tsindex 9572daed7..ab9295591 100644--- a/tests/spec/project.spec.ts+++ b/tests/spec/project.spec.ts@@ -1,81 +1,108 @@-import { test, expect, type Locator, 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";+import { test, expect, type Locator, 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",- apiProjects: "/api/environments/0/projects",- newProject: "/projects/new",+ page: '/projects',+ apiProjects: '/api/environments/0/projects',+ newProject: '/projects/new',};-const DEPLOY_STREAM_SUCCESS =- '{"type":"deploy","phase":"begin"}\n' +- '{"type":"deploy","phase":"complete"}\n';+const DEPLOY_STREAM_SUCCESS = '{"type":"deploy","phase":"begin"}\n' + '{"type":"deploy","phase":"complete"}\n';async function navigateToProjects(page: Page) {await page.goto(ROUTES.page);- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');}async function setCodeMirrorValue(page: Page, editor: Locator, text: string) {- const content = editor.locator(".cm-content").first();+ const content = editor.locator('.cm-content').first();await expect(content).toBeVisible();await content.click({ position: { x: 10, y: 10 } });- await content.press("ControlOrMeta+A");+ await content.press('ControlOrMeta+A');await page.keyboard.type(text, { delay: 0 });}async function createProjectViaUI(page: Page, projectName: string) {const containerName = `test-redis-container-${Date.now()}`;- const envFile = TEST_ENV_FILE.replace(- /CONTAINER_NAME=.*/m,- `CONTAINER_NAME=${containerName}`,- );+ const envFile = TEST_ENV_FILE.replace(/CONTAINER_NAME=.*/m, `CONTAINER_NAME=${containerName}`);await page.goto(ROUTES.newProject);- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');- await page.getByRole("button", { name: "My New Project" }).click();- await page.getByRole("textbox", { name: "My New Project" }).fill(projectName);- await page.getByRole("textbox", { name: "My New Project" }).press("Enter");+ await page.getByRole('button', { name: 'My New Project' }).click();+ await page.getByRole('textbox', { name: 'My New Project' }).fill(projectName);+ await page.getByRole('textbox', { name: 'My New Project' }).press('Enter');- const composeEditor = page.locator(".cm-editor").first();- const envEditor = page.locator(".cm-editor").nth(1);+ const composeEditor = page.locator('.cm-editor').first();+ const envEditor = page.locator('.cm-editor').nth(1);await expect(composeEditor).toBeVisible();await expect(envEditor).toBeVisible();await setCodeMirrorValue(page, composeEditor, TEST_COMPOSE_YAML);await setCodeMirrorValue(page, envEditor, envFile);- const createButton = page- .getByRole("button", { name: "Create Project" })- .locator('[data-slot="arcane-button"]');+ const createButton = page.getByRole('button', { name: 'Create Project' }).locator('[data-slot="arcane-button"]');await createButton.click();await page.waitForURL(/\/projects\/.+/, { timeout: 10000 });- await expect(page.getByRole("button", { name: projectName })).toBeVisible();+ await expect(page.getByRole('button', { name: projectName })).toBeVisible();++ return new URL(page.url()).pathname.split('/').pop()!;}async function destroyCurrentProjectViaUI(page: Page) {- const destroyButton = page.getByRole("button", {- name: "Destroy",+ if (page.isClosed()) {+ return;+ }++ const destroyButton = page.getByRole('button', {+ name: 'Destroy',exact: true,});await expect(destroyButton).toBeVisible();await destroyButton.click();- const dialog = page.getByRole("dialog");+ const dialog = page.getByRole('dialog');await expect(dialog).toBeVisible();await dialog.getByLabel(/Remove project files/i).check();- await dialog.getByRole("button", { name: "Destroy", exact: true }).click();+ await dialog.getByRole('button', { name: 'Destroy', exact: true }).click();await page.waitForURL(ROUTES.page, { timeout: 10000 });}+async function destroyProjectByNameViaUI(page: Page, projectName: string) {+ if (page.isClosed()) {+ return;+ }++ await page.goto(ROUTES.page);+ await page.waitForLoadState('networkidle');++ const searchInput = page.getByPlaceholder('Search…');+ if (await searchInput.isVisible().catch(() => false)) {+ await searchInput.fill(projectName);+ }++ const row = page.locator('tbody tr').filter({ hasText: projectName }).first();+ if (!(await row.isVisible().catch(() => false))) {+ return;+ }++ await row.getByRole('button', { name: 'Open menu' }).click();+ await page.getByRole('menuitem', { name: 'Destroy', exact: true }).click();++ const dialog = page.getByRole('dialog');+ await expect(dialog).toBeVisible();+ await dialog.getByLabel(/Remove project files/i).check();+ await dialog.getByRole('button', { name: 'Destroy', exact: true }).click();++ await expect(page.locator('tbody tr').filter({ hasText: projectName })).toHaveCount(0, {+ timeout: 15000,+ });+}+let realProjects: Project[] = [];let projectCounts: ProjectStatusCounts = {runningProjects: 0,@@ -94,17 +121,13 @@ test.beforeEach(async ({ page }) => {}});-test.describe("Projects Page", () => {- test("should display the main heading and description", async ({ page }) => {- await expect(- page.getByRole("heading", { name: "Projects", level: 1 }),- ).toBeVisible();- await expect(- page.getByText("View and Manage Compose Projects"),- ).toBeVisible();+test.describe('Projects Page', () => {+ test('should display the main heading and description', async ({ page }) => {+ await expect(page.getByRole('heading', { name: 'Projects', level: 1 })).toBeVisible();+ await expect(page.getByText('View and Manage Compose Projects')).toBeVisible();});- test("should display summary cards with correct counts", async ({ page }) => {+ test('should display summary cards with correct counts', async ({ page }) => {await expect(page.getByText(`${projectCounts.totalProjects} Total Projects`, {exact: true,@@ -122,92 +145,72 @@ test.describe("Projects Page", () => {).toBeVisible();});- test("should display projects list", async ({ page }) => {- await expect(page.locator("table")).toBeVisible();+ test('should display projects list', async ({ page }) => {+ await expect(page.locator('table')).toBeVisible();});- test("should show project actions menu", async ({ page }) => {- test.skip(- !realProjects.length,- "No projects available for actions menu test",- );+ test('should show project actions menu', async ({ page }) => {+ test.skip(!realProjects.length, 'No projects available for actions menu test');- await page.waitForLoadState("networkidle");- const firstRow = page.locator("tbody tr").first();- const menuButton = firstRow.getByRole("button", { name: "Open menu" });+ await page.waitForLoadState('networkidle');+ const firstRow = page.locator('tbody tr').first();+ const menuButton = firstRow.getByRole('button', { name: 'Open menu' });await expect(menuButton).toBeVisible();await menuButton.click();- await expect(page.getByRole("menuitem", { name: "Edit" })).toBeVisible();+ await expect(page.getByRole('menuitem', { name: 'Edit' })).toBeVisible();// Check for at least one of the state action buttons (Up/Down/Restart)- const upItem = page.getByRole("menuitem", { name: "Up", exact: true });- const downItem = page.getByRole("menuitem", { name: "Down", exact: true });- const restartItem = page.getByRole("menuitem", {- name: "Restart",+ const upItem = page.getByRole('menuitem', { name: 'Up', exact: true });+ const downItem = page.getByRole('menuitem', { name: 'Down', exact: true });+ const restartItem = page.getByRole('menuitem', {+ name: 'Restart',exact: true,});- const hasStateAction =- (await upItem.count()) > 0 ||- (await downItem.count()) > 0 ||- (await restartItem.count()) > 0;+ const hasStateAction = (await upItem.count()) > 0 || (await downItem.count()) > 0 || (await restartItem.count()) > 0;expect(hasStateAction).toBe(true);- await expect(- page.getByRole("menuitem", { name: "Pull & Redeploy" }),- ).toBeVisible();- await expect(page.getByRole("menuitem", { name: "Destroy" })).toBeVisible();+ await expect(page.getByRole('menuitem', { name: 'Pull & Redeploy' })).toBeVisible();+ await expect(page.getByRole('menuitem', { name: 'Destroy' })).toBeVisible();});- test("should navigate to project details when project name is clicked", async ({- page,- }) => {- test.skip(- !realProjects.length,- "No projects available for navigation test",- );+ test('should navigate to project details when project name is clicked', async ({ page }) => {+ test.skip(!realProjects.length, 'No projects available for navigation test');- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');// Get the first project link that points to /projects/ (not the "Git" indicator link)const firstProjectLink = page- .locator("tbody tr")+ .locator('tbody tr').first()- .getByRole("link")+ .getByRole('link').filter({ hasText: /^(?!Git$)/ }).first();const projectName = await firstProjectLink.textContent();await firstProjectLink.click();await expect(page).toHaveURL(/\/projects\/.+/);- await expect(- page.getByRole("button", { name: new RegExp(`${projectName}`) }),- ).toBeVisible();+ await expect(page.getByRole('button', { name: new RegExp(`${projectName}`) })).toBeVisible();});- test("should allow searching/filtering projects", async ({ page }) => {- test.skip(!realProjects.length, "No projects available for search test");+ test('should allow searching/filtering projects', async ({ page }) => {+ test.skip(!realProjects.length, 'No projects available for search test');- const searchInput = page.getByPlaceholder("Search…");+ const searchInput = page.getByPlaceholder('Search…');await expect(searchInput).toBeVisible();const firstProject = realProjects[0];if (firstProject?.name) {await searchInput.fill(firstProject.name);- await expect(- page.getByRole("link", { name: firstProject.name }),- ).toBeVisible();+ await expect(page.getByRole('link', { name: firstProject.name })).toBeVisible();await searchInput.clear();}});- test("should display project status badges", async ({ page }) => {- test.skip(- !realProjects.length,- "No projects available for status badge test",- );+ test('should display project status badges', async ({ page }) => {+ test.skip(!realProjects.length, 'No projects available for status badge test');- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');- const runningProjects = realProjects.filter((p) => p.status === "running");- const stoppedProjects = realProjects.filter((p) => p.status === "stopped");+ const runningProjects = realProjects.filter((p) => p.status === 'running');+ const stoppedProjects = realProjects.filter((p) => p.status === 'stopped');if (runningProjects.length > 0) {await expect(page.locator('text="Running"').first()).toBeVisible();@@ -219,162 +222,110 @@ test.describe("Projects Page", () => {});});-test.describe("New Compose Project Page", () => {+test.describe('New Compose Project Page', () => {test.beforeEach(async ({ page }) => {await page.goto(ROUTES.newProject);- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');});- test("should display the create project form", async ({ page }) => {- await expect(- page.getByRole("button", { name: "My New Project" }),- ).toBeVisible();- await expect(- page.getByRole("heading", { name: "Docker Compose File" }),- ).toBeVisible();- await expect(- page.getByRole("heading", { name: "Environment (.env)" }),- ).toBeVisible();+ test('should display the create project form', async ({ page }) => {+ await expect(page.getByRole('button', { name: 'My New Project' })).toBeVisible();+ await expect(page.getByRole('heading', { name: 'Docker Compose File' })).toBeVisible();+ await expect(page.getByRole('heading', { name: 'Environment (.env)' })).toBeVisible();});- test("should validate required fields", async ({ page }) => {- const createButton = page- .getByRole("button", { name: "Create Project" })- .locator('[data-slot="arcane-button"]');+ test('should validate required fields', async ({ page }) => {+ const createButton = page.getByRole('button', { name: 'Create Project' }).locator('[data-slot="arcane-button"]');await expect(createButton).toBeDisabled();- await page.getByRole("button", { name: "My New Project" }).click();- await page- .getByRole("textbox", { name: "My New Project" })- .fill("test-project");- await page.getByRole("textbox", { name: "My New Project" }).press("Enter");+ await page.getByRole('button', { name: 'My New Project' }).click();+ await page.getByRole('textbox', { name: 'My New Project' }).fill('test-project');+ await page.getByRole('textbox', { name: 'My New Project' }).press('Enter');});- test("should enable Create Project after entering a valid name", async ({- page,- }) => {+ test('should enable Create Project after entering a valid name', async ({ page }) => {const observedErrors: string[] = [];- page.on("pageerror", (err) =>- observedErrors.push(String(err?.message ?? err)),- );- page.on("console", (msg) => {- if (msg.type() === "error") observedErrors.push(msg.text());+ page.on('pageerror', (err) => observedErrors.push(String(err?.message ?? err)));+ page.on('console', (msg) => {+ if (msg.type() === 'error') observedErrors.push(msg.text());});- const createButton = page- .getByRole("button", { name: "Create Project" })- .locator('[data-slot="arcane-button"]');+ const createButton = page.getByRole('button', { name: 'Create Project' }).locator('[data-slot="arcane-button"]');await expect(createButton).toBeVisible();// Open the inline name editor and set a valid name.- await page.getByRole("button", { name: "My New Project" }).click();- await page- .getByRole("textbox", { name: "My New Project" })- .fill("test-project");- await page.getByRole("textbox", { name: "My New Project" }).press("Enter");+ await page.getByRole('button', { name: 'My New Project' }).click();+ await page.getByRole('textbox', { name: 'My New Project' }).fill('test-project');+ await page.getByRole('textbox', { name: 'My New Project' }).press('Enter');// The button should become enabled once name + compose content are present.await expect(createButton).toBeEnabled();- const stateUnsafe = observedErrors.filter((e) =>- e.includes("state_unsafe_mutation"),- );- expect(- stateUnsafe,- `Unexpected state_unsafe_mutation errors: ${stateUnsafe.join("\n")}`,- ).toHaveLength(0);+ const stateUnsafe = observedErrors.filter((e) => e.includes('state_unsafe_mutation'));+ expect(stateUnsafe, `Unexpected state_unsafe_mutation errors: ${stateUnsafe.join('\n')}`).toHaveLength(0);});- test("should hide Create Project when compose syntax is invalid and show it when fixed", async ({- page,- }) => {- await page.getByRole("button", { name: "My New Project" }).click();- await page- .getByRole("textbox", { name: "My New Project" })- .fill("syntax-check-project");- await page.getByRole("textbox", { name: "My New Project" }).press("Enter");+ test('should hide Create Project when compose syntax is invalid and show it when fixed', async ({ page }) => {+ await page.getByRole('button', { name: 'My New Project' }).click();+ await page.getByRole('textbox', { name: 'My New Project' }).fill('syntax-check-project');+ await page.getByRole('textbox', { name: 'My New Project' }).press('Enter');- const composeEditor = page.locator(".cm-editor").first();+ const composeEditor = page.locator('.cm-editor').first();await expect(composeEditor).toBeVisible();- await setCodeMirrorValue(- page,- composeEditor,- "services:\n\tredis:\n\t\timage: redis:latest\n",- );- await expect(- page- .locator('button[data-slot="arcane-button"]')- .filter({ hasText: "Create Project" }),- ).toHaveCount(0);+ await setCodeMirrorValue(page, composeEditor, 'services:\n\tredis:\n\t\timage: redis:latest\n');+ await expect(page.locator('button[data-slot="arcane-button"]').filter({ hasText: 'Create Project' })).toHaveCount(0);await setCodeMirrorValue(page, composeEditor, TEST_COMPOSE_YAML);- const createButton = page- .locator('button[data-slot="arcane-button"]')- .filter({ hasText: "Create Project" });+ const createButton = page.locator('button[data-slot="arcane-button"]').filter({ hasText: 'Create Project' });await expect(createButton).toBeVisible();await expect(createButton).toBeEnabled();});- test("should hide Create Project when env syntax is invalid and show it when fixed", async ({- page,- }) => {- await page.getByRole("button", { name: "My New Project" }).click();- await page- .getByRole("textbox", { name: "My New Project" })- .fill("env-check-project");- await page.getByRole("textbox", { name: "My New Project" }).press("Enter");-- const composeEditor = page.locator(".cm-editor").first();- const envEditor = page.locator(".cm-editor").nth(1);+ test('should hide Create Project when env syntax is invalid and show it when fixed', async ({ page }) => {+ await page.getByRole('button', { name: 'My New Project' }).click();+ await page.getByRole('textbox', { name: 'My New Project' }).fill('env-check-project');+ await page.getByRole('textbox', { name: 'My New Project' }).press('Enter');++ const composeEditor = page.locator('.cm-editor').first();+ const envEditor = page.locator('.cm-editor').nth(1);await expect(composeEditor).toBeVisible();await expect(envEditor).toBeVisible();await setCodeMirrorValue(page, composeEditor, TEST_COMPOSE_YAML);- await setCodeMirrorValue(page, envEditor, "NOT VALID LINE");- await expect(- page- .locator('button[data-slot="arcane-button"]')- .filter({ hasText: "Create Project" }),- ).toHaveCount(0);+ await setCodeMirrorValue(page, envEditor, 'NOT VALID LINE');+ await expect(page.locator('button[data-slot="arcane-button"]').filter({ hasText: 'Create Project' })).toHaveCount(0);await setCodeMirrorValue(page, envEditor, TEST_ENV_FILE);- const createButton = page- .locator('button[data-slot="arcane-button"]')- .filter({ hasText: "Create Project" });+ const createButton = page.locator('button[data-slot="arcane-button"]').filter({ hasText: 'Create Project' });await expect(createButton).toBeVisible();await expect(createButton).toBeEnabled();});- test("should create a new project successfully", async ({ page }) => {+ test('should create a new project successfully', async ({ page }) => {const projectName = `test-project-${Date.now()}`;const containerName = `test-redis-container-${Date.now()}`;- const envFile = TEST_ENV_FILE.replace(- /CONTAINER_NAME=.*/m,- `CONTAINER_NAME=${containerName}`,- );+ const envFile = TEST_ENV_FILE.replace(/CONTAINER_NAME=.*/m, `CONTAINER_NAME=${containerName}`);let createdProjectId: string | null = null;let projectPullRequestCount = 0;- await page.getByRole("button", { name: "My New Project" }).click();- await page- .getByRole("textbox", { name: "My New Project" })- .fill(projectName);- await page.getByRole("textbox", { name: "My New Project" }).press("Enter");+ await page.getByRole('button', { name: 'My New Project' }).click();+ await page.getByRole('textbox', { name: 'My New Project' }).fill(projectName);+ await page.getByRole('textbox', { name: 'My New Project' }).press('Enter');- const composeEditor = page.locator(".cm-editor").first();+ const composeEditor = page.locator('.cm-editor').first();await expect(composeEditor).toBeVisible();await setCodeMirrorValue(page, composeEditor, TEST_COMPOSE_YAML);await expect(composeEditor).toContainText(/redis/i);- const envEditor = page.locator(".cm-editor").nth(1);+ const envEditor = page.locator('.cm-editor').nth(1);await expect(envEditor).toBeVisible();await setCodeMirrorValue(page, envEditor, envFile);await expect(envEditor).toContainText(/redis/i);- await page.route("/api/environments/*/projects", async (route) => {- if (route.request().method() === "POST") {+ await page.route('/api/environments/*/projects', async (route) => {+ if (route.request().method() === 'POST') {const response = await route.fetch();const responseBody = await response.text();@@ -395,9 +346,7 @@ test.describe("New Compose Project Page", () => {}});- const createButton = page- .getByRole("button", { name: "Create Project" })- .locator('[data-slot="arcane-button"]');+ const createButton = page.getByRole('button', { name: 'Create Project' }).locator('[data-slot="arcane-button"]');await createButton.click();await page.waitForURL(/\/projects\/.+/, { timeout: 10000 });@@ -408,18 +357,16 @@ test.describe("New Compose Project Page", () => {await expect(page).toHaveURL(new RegExp(`/projects/[a-f0-9\\-]{36}`));}- await expect(page.getByRole("button", { name: projectName })).toBeVisible();+ await expect(page.getByRole('button', { name: projectName })).toBeVisible();- await page.getByRole("tab", { name: "Services" }).click();- await page.waitForLoadState("networkidle");+ await page.getByRole('tab', { name: 'Services' }).click();+ await page.waitForLoadState('networkidle');- const serviceTable = page.getByRole("table");- const serviceNameWhenStopped = serviceTable.getByText("redis", {+ const serviceTable = page.getByRole('table');+ const serviceNameWhenStopped = serviceTable.getByText('redis', {exact: true,});- const emptyServicesState = page.getByText(- /No services found for this project/i,- );+ const emptyServicesState = page.getByText(/No services found for this project/i);if ((await serviceNameWhenStopped.count()) > 0) {await expect(serviceNameWhenStopped.first()).toBeVisible();@@ -427,127 +374,111 @@ test.describe("New Compose Project Page", () => {await expect(emptyServicesState).toBeVisible();}- await page.route("**/api/environments/*/projects/*/pull", async (route) => {+ await page.route('**/api/environments/*/projects/*/pull', async (route) => {projectPullRequestCount += 1;await route.continue();});- const deployButton = page- .getByRole("button", { name: "Up", exact: true })- .filter({ hasText: "Up" })- .last();+ const deployButton = page.getByRole('button', { name: 'Up', exact: true }).filter({ hasText: 'Up' }).last();await deployButton.click();await page.waitForTimeout(5000);- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');expect(projectPullRequestCount).toBe(0);- await expect(page.getByText("Running", { exact: true })).toBeVisible({+ await expect(page.getByText('Running', { exact: true })).toBeVisible({timeout: 20000,});- await expect(- page.getByRole("button", { name: "Down", exact: true }),- ).toBeVisible();+ await expect(page.getByRole('button', { name: 'Down', exact: true })).toBeVisible();});- test("should send selected deploy split-button options in the up request", async ({- page,- }) => {+ test('should send selected deploy split-button options in the up request', async ({ page }) => {const projectName = `test-deploy-options-${Date.now()}`;- let deployRequestBody: Record<string, unknown> | null = null;try {await createProjectViaUI(page, projectName);- await page.route("**/api/environments/*/projects/*/up", async (route) => {- const postData = route.request().postDataJSON() as Record<- string,- unknown- > | null;- deployRequestBody = postData;-+ await page.route('**/api/environments/*/projects/*/up', async (route) => {await route.fulfill({status: 200,- contentType: "application/x-json-stream",+ contentType: 'application/x-json-stream',body: DEPLOY_STREAM_SUCCESS,});});+ const deployRequestPromise = page.waitForRequest((request) => {+ if (request.method() !== 'POST') return false;+ return /\/api\/environments\/[^/]+\/projects\/[^/]+\/up$/.test(new URL(request.url()).pathname);+ });+const deployButtonGroup = page.locator('[data-slot="button-group"]')- .filter({ has: page.getByRole("button", { name: "Up", exact: true }) })+ .filter({ has: page.getByRole('button', { name: 'Up', exact: true }) }).first();- const deployMenuTrigger = deployButtonGroup.getByRole("button", {- name: "Open menu",+ const deployMenuTrigger = deployButtonGroup.getByRole('button', {+ name: 'Open menu',});await expect(deployMenuTrigger).toBeVisible();await deployMenuTrigger.click();- await page- .locator('[data-slot="dropdown-menu-radio-item"]')- .filter({ hasText: "Always" })- .first()- .click();+ await page.getByRole('menuitemradio', { name: /Always/i }).click();await deployMenuTrigger.click();- await page- .getByRole("menuitemcheckbox", { name: /Force recreate containers/i })- .click();+ await page.getByRole('menuitemcheckbox', { name: /Force recreate containers/i }).click();- await page.getByRole("button", { name: "Up", exact: true }).click();+ await page.getByRole('button', { name: 'Up', exact: true }).click();++ const deployRequest = await deployRequestPromise;+ const deployRequestBody = deployRequest.postDataJSON() as Record<string, unknown> | null;await expect.poll(() => deployRequestBody, {- message: "Expected the deploy request body to be captured",+ message: 'Expected the deploy request body to be captured',}).not.toBeNull();expect(deployRequestBody).toEqual({- pullPolicy: "always",+ pullPolicy: 'always',forceRecreate: true,});} finally {- if (/\/projects\/.+/.test(new URL(page.url()).pathname)) {+ if (!page.isClosed() && /\/projects\/.+/.test(new URL(page.url()).pathname)) {await destroyCurrentProjectViaUI(page);+ } else {+ await destroyProjectByNameViaUI(page, projectName);}}});- test("should destroy the project and remove files from disk", async ({- page,- }) => {+ test('should destroy the project and remove files from disk', async ({ page }) => {const projectName = `test-destroy-${Date.now()}`;// 1. Create the project first- await page.getByRole("button", { name: "My New Project" }).click();- await page- .getByRole("textbox", { name: "My New Project" })- .fill(projectName);- await page.getByRole("textbox", { name: "My New Project" }).press("Enter");+ await page.getByRole('button', { name: 'My New Project' }).click();+ await page.getByRole('textbox', { name: 'My New Project' }).fill(projectName);+ await page.getByRole('textbox', { name: 'My New Project' }).press('Enter');- const composeEditor = page.locator(".cm-editor").first();+ const composeEditor = page.locator('.cm-editor').first();await expect(composeEditor).toBeVisible();await setCodeMirrorValue(page, composeEditor, TEST_COMPOSE_YAML);- const createButton = page- .locator('button[data-slot="arcane-button"]')- .filter({ hasText: "Create Project" });+ const createButton = page.locator('button[data-slot="arcane-button"]').filter({ hasText: 'Create Project' });await createButton.click();await page.waitForURL(/\/projects\/.+/, { timeout: 10000 });- await expect(page.getByRole("button", { name: projectName })).toBeVisible();+ await expect(page.getByRole('button', { name: projectName })).toBeVisible();// 2. Destroy the project- const destroyButton = page.getByRole("button", {- name: "Destroy",+ const destroyButton = page.getByRole('button', {+ name: 'Destroy',exact: true,});await expect(destroyButton).toBeVisible();await destroyButton.click();// 3. Handle the confirmation dialog- const dialog = page.getByRole("dialog");+ const dialog = page.getByRole('dialog');await expect(dialog).toBeVisible();// Check "Remove project files"@@ -555,241 +486,189 @@ test.describe("New Compose Project Page", () => {await removeFilesCheckbox.check();// Click "Destroy" in the dialog- const confirmDestroyButton = dialog.getByRole("button", {- name: "Destroy",+ const confirmDestroyButton = dialog.getByRole('button', {+ name: 'Destroy',exact: true,});await confirmDestroyButton.click();// 4. Verify redirection and project removalawait page.waitForURL(ROUTES.page, { timeout: 10000 });- await expect(- page.getByRole("link", { name: projectName }),- ).not.toBeVisible();+ await expect(page.getByRole('link', { name: projectName })).not.toBeVisible();});});-test.describe("GitOps Managed Project", () => {- test("should show read-only alert when project is GitOps managed", async ({- page,- }) => {+test.describe('GitOps Managed Project', () => {+ test('should show read-only alert when project is GitOps managed', async ({ page }) => {const gitOpsProject = realProjects.find((p) => p.gitOpsManagedBy);- test.skip(!gitOpsProject, "No GitOps-managed projects found");+ test.skip(!gitOpsProject, 'No GitOps-managed projects found');await page.goto(`/projects/${gitOpsProject!.id}`);- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');// Navigate to Configuration tab- const configTab = page.getByRole("tab", { name: /Configuration|Config/i });+ const configTab = page.getByRole('tab', { name: /Configuration|Config/i });await configTab.click();- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');// Verify the GitOps read-only alert is visible (title contains "Git" and "Read-only")- await expect(page.getByText("Git Read-only")).toBeVisible();+ await expect(page.getByText('Git Read-only')).toBeVisible();await expect(page.getByText(/managed by Git/i)).toBeVisible();});- test("should display Sync from Git button when GitOps managed", async ({- page,- }) => {+ test('should display Sync from Git button when GitOps managed', async ({ page }) => {const gitOpsProject = realProjects.find((p) => p.gitOpsManagedBy);- test.skip(!gitOpsProject, "No GitOps-managed projects found");+ test.skip(!gitOpsProject, 'No GitOps-managed projects found');await page.goto(`/projects/${gitOpsProject!.id}`);- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');- const configTab = page.getByRole("tab", { name: /Configuration|Config/i });+ const configTab = page.getByRole('tab', { name: /Configuration|Config/i });await configTab.click();- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');// Verify the Sync from Git button is present- await expect(- page.getByRole("button", { name: "Sync from Git" }),- ).toBeVisible();+ await expect(page.getByRole('button', { name: 'Sync from Git' })).toBeVisible();});- test("should show last sync commit when GitOps managed", async ({ page }) => {- const gitOpsProject = realProjects.find(- (p) => p.gitOpsManagedBy && p.lastSyncCommit,- );- test.skip(- !gitOpsProject,- "No GitOps-managed projects with sync commit found",- );+ test('should show last sync commit when GitOps managed', async ({ page }) => {+ const gitOpsProject = realProjects.find((p) => p.gitOpsManagedBy && p.lastSyncCommit);+ test.skip(!gitOpsProject, 'No GitOps-managed projects with sync commit found');await page.goto(`/projects/${gitOpsProject!.id}`);- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');// The commit hash should be visible somewhere on the pageconst commitHash = gitOpsProject!.lastSyncCommit!.substring(0, 7);await expect(page.getByText(new RegExp(commitHash))).toBeVisible();});- test("should disable name editing when GitOps managed", async ({ page }) => {+ test('should disable name editing when GitOps managed', async ({ page }) => {const gitOpsProject = realProjects.find((p) => p.gitOpsManagedBy);- test.skip(!gitOpsProject, "No GitOps-managed projects found");+ test.skip(!gitOpsProject, 'No GitOps-managed projects found');await page.goto(`/projects/${gitOpsProject!.id}`);- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');// The name button should be disabled for GitOps-managed projects- const nameButton = page.getByRole("button", { name: gitOpsProject!.name });+ const nameButton = page.getByRole('button', { name: gitOpsProject!.name });await expect(nameButton).toBeDisabled();});- test("should have compose editor in read-only mode when GitOps managed", async ({- page,- }) => {+ test('should have compose editor in read-only mode when GitOps managed', async ({ page }) => {const gitOpsProject = realProjects.find((p) => p.gitOpsManagedBy);- test.skip(!gitOpsProject, "No GitOps-managed projects found");+ test.skip(!gitOpsProject, 'No GitOps-managed projects found');await page.goto(`/projects/${gitOpsProject!.id}`);- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');- const configTab = page.getByRole("tab", { name: /Configuration|Config/i });+ const configTab = page.getByRole('tab', { name: /Configuration|Config/i });await configTab.click();- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');await page.waitForTimeout(800);- const composeContent = page- .locator(".cm-editor")- .first()- .locator(".cm-content");- await expect(composeContent).toHaveAttribute("aria-readonly", "true");+ const composeContent = page.locator('.cm-editor').first().locator('.cm-content');+ await expect(composeContent).toHaveAttribute('aria-readonly', 'true');});- test("should have env editor in read-only mode when GitOps managed", async ({- page,- }) => {+ test('should have env editor in read-only mode when GitOps managed', async ({ page }) => {const gitOpsProject = realProjects.find((p) => p.gitOpsManagedBy);- test.skip(!gitOpsProject, "No GitOps-managed projects found");+ test.skip(!gitOpsProject, 'No GitOps-managed projects found');await page.goto(`/projects/${gitOpsProject!.id}`);- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');- const configTab = page.getByRole("tab", { name: /Configuration|Config/i });+ const configTab = page.getByRole('tab', { name: /Configuration|Config/i });await configTab.click();- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');await page.waitForTimeout(800);- const envContent = page.locator(".cm-editor").nth(1).locator(".cm-content");- await expect(envContent).toHaveAttribute("aria-readonly", "true");+ const envContent = page.locator('.cm-editor').nth(1).locator('.cm-content');+ await expect(envContent).toHaveAttribute('aria-readonly', 'true');});- test("should allow editing for non-GitOps managed projects", async ({- page,- }) => {- const regularProject = realProjects.find(- (p) => !p.gitOpsManagedBy && p.status === "stopped",- );- test.skip(- !regularProject,- "No regular (non-GitOps) stopped projects found",- );+ test('should allow editing for non-GitOps managed projects', async ({ page }) => {+ const regularProject = realProjects.find((p) => !p.gitOpsManagedBy && p.status === 'stopped');+ test.skip(!regularProject, 'No regular (non-GitOps) stopped projects found');await page.goto(`/projects/${regularProject!.id}`);- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');// The name button should be enabled for regular projects that are stopped- const nameButton = page.getByRole("button", { name: regularProject!.name });+ const nameButton = page.getByRole('button', { name: regularProject!.name });await expect(nameButton).toBeEnabled();// Navigate to Configuration tab- const configTab = page.getByRole("tab", { name: /Configuration|Config/i });+ const configTab = page.getByRole('tab', { name: /Configuration|Config/i });await configTab.click();- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');// GitOps alert should NOT be visible- await expect(page.getByText("Git Read-only")).not.toBeVisible();+ await expect(page.getByText('Git Read-only')).not.toBeVisible();// Sync from Git button should NOT be visible- await expect(- page.getByRole("button", { name: "Sync from Git" }),- ).not.toBeVisible();+ await expect(page.getByRole('button', { name: 'Sync from Git' })).not.toBeVisible();});- test("should not show GitOps alert on Configuration tab for regular projects", async ({- page,- }) => {+ test('should not show GitOps alert on Configuration tab for regular projects', async ({ page }) => {const regularProject = realProjects.find((p) => !p.gitOpsManagedBy);- test.skip(!regularProject, "No regular (non-GitOps) projects found");+ test.skip(!regularProject, 'No regular (non-GitOps) projects found');await page.goto(`/projects/${regularProject!.id}`);- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');- const configTab = page.getByRole("tab", { name: /Configuration|Config/i });+ const configTab = page.getByRole('tab', { name: /Configuration|Config/i });await configTab.click();- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');// Verify no GitOps-related UI elementsawait expect(page.getByText(/managed by Git\./i)).not.toBeVisible();- await expect(- page.getByRole("button", { name: "Sync from Git" }),- ).not.toBeVisible();+ await expect(page.getByRole('button', { name: 'Sync from Git' })).not.toBeVisible();});});-test.describe("Project Detail Page", () => {- test("should display project details for existing project", async ({- page,- }) => {- test.skip(- !realProjects.length,- "No projects available for detail page test",- );+test.describe('Project Detail Page', () => {+ test('should display project details for existing project', async ({ page }) => {+ test.skip(!realProjects.length, 'No projects available for detail page test');const firstProject = realProjects[0];await page.goto(`/projects/${firstProject.id || firstProject.name}`);- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');- await expect(- page.getByRole("button", { name: firstProject.name, exact: false }),- ).toBeVisible();+ await expect(page.getByRole('button', { name: firstProject.name, exact: false })).toBeVisible();- await expect(page.getByRole("tab", { name: /Services/i })).toBeVisible();- await expect(- page.getByRole("tab", { name: /Configuration|Config/i }),- ).toBeVisible();- await expect(page.getByRole("tab", { name: /Logs/i })).toBeVisible();+ await expect(page.getByRole('tab', { name: /Services/i })).toBeVisible();+ await expect(page.getByRole('tab', { name: /Configuration|Config/i })).toBeVisible();+ await expect(page.getByRole('tab', { name: /Logs/i })).toBeVisible();});- test("should display tabs navigation", async ({ page }) => {- test.skip(- !realProjects.length,- "No projects available for navigation test",- );+ test('should display tabs navigation', async ({ page }) => {+ test.skip(!realProjects.length, 'No projects available for navigation test');const firstProject = realProjects[0];await page.goto(`/projects/${firstProject.id || firstProject.name}`);- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');- await expect(page.getByRole("tab", { name: /Services/i })).toBeVisible();- await expect(- page.getByRole("tab", { name: /Configuration|Config/i }),- ).toBeVisible();- await expect(page.getByRole("tab", { name: /Logs/i })).toBeVisible();+ await expect(page.getByRole('tab', { name: /Services/i })).toBeVisible();+ await expect(page.getByRole('tab', { name: /Configuration|Config/i })).toBeVisible();+ await expect(page.getByRole('tab', { name: /Logs/i })).toBeVisible();});- test("should display services tab content", async ({ page }) => {- test.skip(!realProjects.length, "No projects available for services test");+ test('should display services tab content', async ({ page }) => {+ test.skip(!realProjects.length, 'No projects available for services test');- const projectWithServices =- realProjects.find((p) => p.serviceCount > 0) || realProjects[0];- await page.goto(- `/projects/${projectWithServices.id || projectWithServices.name}`,- );- await page.waitForLoadState("networkidle");+ const projectWithServices = realProjects.find((p) => p.serviceCount > 0) || realProjects[0];+ await page.goto(`/projects/${projectWithServices.id || projectWithServices.name}`);+ await page.waitForLoadState('networkidle');- await page.getByRole("tab", { name: /Services/i }).click();+ await page.getByRole('tab', { name: /Services/i }).click();- const nginxService = page.getByRole("heading", { name: /nginx/i });+ const nginxService = page.getByRole('heading', { name: /nginx/i });const emptyState = page.getByText(/No services found/i);if ((await nginxService.count()) > 0) {await expect(nginxService.first()).toBeVisible();} else {- const anyServiceBadge = page- .locator("text=/running|stopped|unknown/i")- .first();+ const anyServiceBadge = page.locator('text=/running|stopped|unknown/i').first();if ((await anyServiceBadge.count()) > 0) {await expect(anyServiceBadge).toBeVisible();} else {@@ -798,106 +677,89 @@ test.describe("Project Detail Page", () => {}});- test("should display configuration editors", async ({ page }) => {- test.skip(- !realProjects.length,- "No projects available for configuration test",- );+ test('should display configuration editors', async ({ page }) => {+ test.skip(!realProjects.length, 'No projects available for configuration test');const firstProject = realProjects[0];await page.goto(`/projects/${firstProject.id || firstProject.name}`);- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');- const configTab = page.getByRole("tab", { name: /Configuration|Config/i });+ const configTab = page.getByRole('tab', { name: /Configuration|Config/i });await configTab.click();// The project config editor supports two layouts:// - classic (default): side-by-side compose.yaml + .env panels// - tree view: file list on the left and a single code panel on the right- await expect(- page.getByRole("heading", { name: "compose.yaml" }),- ).toBeVisible();+ await expect(page.getByRole('heading', { name: 'compose.yaml' })).toBeVisible();- const projectFilesHeading = page.getByRole("heading", {+ const projectFilesHeading = page.getByRole('heading', {name: /Project Files/i,});const isTreeView = await projectFilesHeading.isVisible();if (isTreeView) {- const composeFileButton = page- .getByRole("button", { name: "compose.yaml" })- .first();- const envFileButton = page.getByRole("button", { name: ".env" }).first();+ const composeFileButton = page.getByRole('button', { name: 'compose.yaml' }).first();+ const envFileButton = page.getByRole('button', { name: '.env' }).first();await expect(composeFileButton).toBeVisible();await expect(envFileButton).toBeVisible();// Switching files should update the visible code panel titleawait envFileButton.click();- await expect(page.getByRole("heading", { name: ".env" })).toBeVisible();+ await expect(page.getByRole('heading', { name: '.env' })).toBeVisible();await composeFileButton.click();- await expect(- page.getByRole("heading", { name: "compose.yaml" }),- ).toBeVisible();+ await expect(page.getByRole('heading', { name: 'compose.yaml' })).toBeVisible();- const includesFolder = page.getByRole("button", { name: "Includes" });+ const includesFolder = page.getByRole('button', { name: 'Includes' });if (await includesFolder.count()) {await expect(includesFolder.first()).toBeVisible();}} else {// Classic layout renders both editors at the same time.- await expect(page.getByRole("heading", { name: ".env" })).toBeVisible();+ await expect(page.getByRole('heading', { name: '.env' })).toBeVisible();// Also validate that we can switch to tree view and see the file list.- const layoutSwitch = page.getByRole("switch", {+ const layoutSwitch = page.getByRole('switch', {name: /Classic|Tree View/i,});if (await layoutSwitch.count()) {await layoutSwitch.click();await expect(projectFilesHeading).toBeVisible();- const composeFileButton = page- .getByRole("button", { name: "compose.yaml" })- .first();- const envFileButton = page- .getByRole("button", { name: ".env" })- .first();+ const composeFileButton = page.getByRole('button', { name: 'compose.yaml' }).first();+ const envFileButton = page.getByRole('button', { name: '.env' }).first();await expect(composeFileButton).toBeVisible();await expect(envFileButton).toBeVisible();await envFileButton.click();- await expect(page.getByRole("heading", { name: ".env" })).toBeVisible();+ await expect(page.getByRole('heading', { name: '.env' })).toBeVisible();}}});- test("should show logs tab for running projects", async ({ page }) => {- test.skip(!realProjects.length, "No projects available for logs test");+ test('should show logs tab for running projects', async ({ page }) => {+ test.skip(!realProjects.length, 'No projects available for logs test');- const runningProject = realProjects.find((p) => p.status === "running");- test.skip(!runningProject, "No running projects found for logs test");+ const runningProject = realProjects.find((p) => p.status === 'running');+ test.skip(!runningProject, 'No running projects found for logs test');await page.goto(`/projects/${runningProject.id || runningProject.name}`);- await page.waitForLoadState("networkidle");+ await page.waitForLoadState('networkidle');- const logsTab = page.getByRole("tab", { name: /Logs/i });+ const logsTab = page.getByRole('tab', { name: /Logs/i });await expect(logsTab).toBeEnabled();await logsTab.click();- const logsSelected = await logsTab.getAttribute("aria-selected");- if (logsSelected === "true") {+ const logsSelected = await logsTab.getAttribute('aria-selected');+ if (logsSelected === 'true') {await expect(page.getByText(/Real-time project logs/i)).toBeVisible();- await expect(- page.getByRole("button", { name: /^(Start|Stop)$/i }),- ).toBeVisible();- await expect(- page.getByRole("button", { name: "Clear", exact: true }),- ).toBeVisible();-- const startButton = page.getByRole("button", {- name: "Start",+ await expect(page.getByRole('button', { name: /^(Start|Stop)$/i })).toBeVisible();+ await expect(page.getByRole('button', { name: 'Clear', exact: true })).toBeVisible();++ const startButton = page.getByRole('button', {+ name: 'Start',exact: true,});if ((await startButton.count()) > 0) {diff --git a/tests/spec/settings-notifications.spec.ts b/tests/spec/settings-notifications.spec.tsindex 9ef2ad643..65b224cff 100644--- a/tests/spec/settings-notifications.spec.ts+++ b/tests/spec/settings-notifications.spec.ts@@ -6,6 +6,20 @@ test.describe('Notification settings', () => {await tab.scrollIntoViewIfNeeded();await expect(tab).toBeVisible();await tab.click();+ await expect(page.locator('h3').filter({ hasText: name }).first()).toBeVisible();+ };++ const enableCurrentProvider = async (page: Page) => {+ const toggle = page.getByRole('switch').first();+ await expect(toggle).toBeVisible();+ await toggle.click();+ await expect(page.locator('[data-dropdown-menu-trigger]').last()).toBeVisible({ timeout: 10000 });+ };++ const openTestMenu = async (page: Page) => {+ const trigger = page.locator('[data-dropdown-menu-trigger]').last();+ await expect(trigger).toBeVisible({ timeout: 10000 });+ await trigger.click();};// Shared setup for all notification tests@@ -25,9 +39,17 @@ test.describe('Notification settings', () => {let saveEndpointCalled = false;let testEndpointCalled = false;- // Stub "save settings"await page.route('**/api/environments/*/notifications/settings', async (route) => {const req = route.request();+ if (req.method() === 'GET') {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify([]),+ });+ return;+ }+if (req.method() === 'POST') {saveEndpointCalled = true;await route.fulfill({@@ -37,6 +59,20 @@ test.describe('Notification settings', () => {});return;}++ await route.continue();+ });++ await page.route('**/api/environments/*/notifications/apprise', async (route) => {+ if (route.request().method() === 'GET') {+ await route.fulfill({+ status: 404,+ contentType: 'application/json',+ body: JSON.stringify({ error: 'not configured' }),+ });+ return;+ }+await route.continue();});@@ -52,6 +88,8 @@ test.describe('Notification settings', () => {await page.goto('/settings/notifications');await page.waitForLoadState('networkidle');+ await expect(page.getByRole('tab', { name: 'Built-in' })).toBeVisible();+ await expect(page.getByRole('tab', { name: 'Email' })).toBeVisible();return {getErrorCheck: () => {@@ -66,8 +104,8 @@ test.describe('Notification settings', () => {test('should allow testing email notifications without state_unsafe_mutation errors', async ({ page }) => {const { getErrorCheck, wasTestEndpointCalled } = await setupNotificationTest(page, 'email');- // Enable email notifications- await page.locator('#email-enabled').click();+ await openProviderTab(page, 'Email');+ await enableCurrentProvider(page);// Fill fieldsawait page.getByPlaceholder('smtp.example.com').fill('smtp.example.com');@@ -75,7 +113,7 @@ test.describe('Notification settings', () => {// Trigger test- await page.locator('[data-dropdown-menu-trigger]').filter({ hasText: 'Test' }).click();+ await openTestMenu(page);await page.getByRole('menuitem', { name: 'Simple Test Notification', exact: true }).click();// Handle Save & Test if needed@@ -92,13 +130,13 @@ test.describe('Notification settings', () => {const { getErrorCheck, wasTestEndpointCalled } = await setupNotificationTest(page, 'discord');await openProviderTab(page, 'Discord');- await page.locator('#discord-enabled').click();+ await enableCurrentProvider(page);// Discord split fieldsawait page.getByPlaceholder('Enter webhook ID').fill('123456789');await page.getByPlaceholder('Enter webhook token').fill('abc-def-ghi');- await page.locator('[data-dropdown-menu-trigger]').filter({ hasText: 'Test Provider' }).click();+ await openTestMenu(page);await page.getByRole('menuitem', { name: 'Simple Test Notification', exact: true }).click();const saveAndTestButton = page.getByRole('button', { name: 'Save & Test', exact: true });@@ -114,12 +152,12 @@ test.describe('Notification settings', () => {const { getErrorCheck, wasTestEndpointCalled } = await setupNotificationTest(page, 'slack');await openProviderTab(page, 'Slack');- await page.locator('#slack-enabled').click();+ await enableCurrentProvider(page);// Slack OAuth token (xoxb- or xoxp- format)await page.getByPlaceholder('xoxb-... or xoxp-...').fill('xoxb-123456789012-1234567890123-abcdefghijklmnopqrstuvwx');- await page.locator('[data-dropdown-menu-trigger]').filter({ hasText: 'Test Provider' }).click();+ await openTestMenu(page);await page.getByRole('menuitem', { name: 'Simple Test Notification', exact: true }).click();const saveAndTestButton = page.getByRole('button', { name: 'Save & Test', exact: true });@@ -135,13 +173,13 @@ test.describe('Notification settings', () => {const { getErrorCheck, wasTestEndpointCalled } = await setupNotificationTest(page, 'telegram');await openProviderTab(page, 'Telegram');- await page.locator('#telegram-enabled').click();+ await enableCurrentProvider(page);// Telegram fields (placeholders are hardcoded in component)await page.getByPlaceholder('123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11').fill('123456:TEST-TOKEN');await page.getByPlaceholder('@channel, 123456789, @another_channel').fill('123456789');- await page.locator('[data-dropdown-menu-trigger]').filter({ hasText: 'Test Provider' }).click();+ await openTestMenu(page);await page.getByRole('menuitem', { name: 'Simple Test Notification', exact: true }).click();const saveAndTestButton = page.getByRole('button', { name: 'Save & Test', exact: true });@@ -157,11 +195,11 @@ test.describe('Notification settings', () => {const { getErrorCheck, wasTestEndpointCalled } = await setupNotificationTest(page, 'generic');await openProviderTab(page, 'Generic');- await page.locator('#generic-enabled').click();+ await enableCurrentProvider(page);await page.getByPlaceholder('https://example.com/webhook').fill('https://example.com/webhook');- await page.locator('[data-dropdown-menu-trigger]').filter({ hasText: 'Test Provider' }).click();+ await openTestMenu(page);await page.getByRole('menuitem', { name: 'Simple Test Notification', exact: true }).click();const saveAndTestButton = page.getByRole('button', { name: 'Save & Test', exact: true });@@ -177,14 +215,14 @@ test.describe('Notification settings', () => {const { getErrorCheck, wasTestEndpointCalled } = await setupNotificationTest(page, 'signal');await openProviderTab(page, 'Signal');- await page.locator('#signal-enabled').click();+ await enableCurrentProvider(page);await page.getByPlaceholder('localhost').fill('signal-api.example.com');await page.getByPlaceholder('8080').fill('8080');await page.locator('#signal-source').fill('+1234567890');await page.locator('#signal-recipients').fill('+1987654321');- await page.locator('[data-dropdown-menu-trigger]').filter({ hasText: 'Test Provider' }).click();+ await openTestMenu(page);await page.getByRole('menuitem', { name: 'Simple Test Notification', exact: true }).click();const saveAndTestButton = page.getByRole('button', { name: 'Save & Test', exact: true });@@ -200,12 +238,12 @@ test.describe('Notification settings', () => {const { getErrorCheck, wasTestEndpointCalled } = await setupNotificationTest(page, 'ntfy');await openProviderTab(page, 'Ntfy');- await page.locator('#ntfy-enabled').click();+ await enableCurrentProvider(page);await page.getByPlaceholder('ntfy.sh').fill('ntfy.sh');await page.getByPlaceholder('my-updates').fill('arcane-updates');- await page.locator('[data-dropdown-menu-trigger]').filter({ hasText: 'Test Provider' }).click();+ await openTestMenu(page);await page.getByRole('menuitem', { name: 'Simple Test Notification', exact: true }).click();const saveAndTestButton = page.getByRole('button', { name: 'Save & Test', exact: true });diff --git a/tests/spec/volumes.spec.ts b/tests/spec/volumes.spec.tsindex 8bf75ea0c..0cefbffdb 100644--- a/tests/spec/volumes.spec.ts+++ b/tests/spec/volumes.spec.ts@@ -36,11 +36,15 @@ async function findVolumeRow(page: Page, volumeName: string, maxRetries = 10) {}async function removeVolumeViaUI(page: Page, volumeName: string) {+ if (page.isClosed()) {+ return;+ }+await page.goto('/volumes');await page.waitForLoadState('networkidle');const row = await findVolumeRow(page, volumeName, 4);- if ((await row.count()) === 0) return;+ if (!(await row.isVisible().catch(() => false))) return;await row.locator('a[href*="/volumes/"]').first().click();await expect(page).toHaveURL(/\/volumes\/.+/);