From 51ffc47dc6c140388ab5dee0ccc63599d595f8d2 Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Mon, 10 Nov 2025 19:50:32 +0100 Subject: [PATCH] Added tracing to debug failure --- .github/workflows/tests.yml | 36 ++++++++++++++++++++--- playwright-tests/backupRestore.spec.ts | 40 ++++++++++++++++++++++++++ playwright.config.ts | 8 +++++- 3 files changed, 79 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 58c01a593..d19f72fb4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -78,17 +78,45 @@ jobs: run: dotnet publish -c Debug -o published Duplicati.sln - name: Start server run: | - ./published/Duplicati.Server --disable-database-encryption --webservice-password=easy1234 & + ./published/Duplicati.Server --disable-database-encryption --webservice-password=easy1234 > server.log 2>&1 & + SERVER_PID=$! + echo "SERVER_PID=$SERVER_PID" >> $GITHUB_ENV timeout 30 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/127.0.0.1/8200; do sleep 1; echo waiting; done' + echo "Server started with PID: $SERVER_PID" - name: Load web UI - run: curl -f http://localhost:8200/ngclient/index.html + run: | + curl -f http://localhost:8200/ngclient/index.html + echo "Web UI loaded successfully" + - name: Check server status + run: | + echo "Server process status:" + ps aux | grep Duplicati.Server || true + echo "Server log (last 50 lines):" + tail -n 50 server.log || true - name: Run Playwright tests - run: npx playwright test + run: npx playwright test --reporter=list,html,github + + - name: Capture server logs on failure + if: failure() + run: | + echo "=== Full Server Log ===" + cat server.log || echo "No server log found" - name: Upload Playwright test results on failure if: failure() uses: actions/upload-artifact@v4 with: name: playwright-test-results - path: test-results/ + path: | + test-results/ + playwright-report/ + server.log + retention-days: 7 + + - name: Upload Playwright HTML report + if: always() + uses: actions/upload-artifact@v4 + with: + name: playwright-html-report + path: playwright-report/ retention-days: 7 diff --git a/playwright-tests/backupRestore.spec.ts b/playwright-tests/backupRestore.spec.ts index 5a57cb283..e27d7245c 100644 --- a/playwright-tests/backupRestore.spec.ts +++ b/playwright-tests/backupRestore.spec.ts @@ -144,6 +144,22 @@ async function createBackup(page: Page) { async function deleteBackupIfExists(page: Page) { await page.goto(HOME_URL); await page.waitForLoadState("networkidle"); + + // Take a screenshot before waiting for backup elements + await page.screenshot({ + path: path.join("test-results", "before-backup-wait.png"), + fullPage: true, + }); + + // Log page content for debugging + const pageContent = await page.content(); + console.log("Page HTML length:", pageContent.length); + console.log("Page title:", await page.title()); + + // Check if any backup elements exist + const backupCount = await page.locator("div.backup").count(); + console.log("Number of backup elements found:", backupCount); + await page.locator("div.backup").first().waitFor(); // Cleanup existing backup with the same name @@ -303,6 +319,10 @@ async function restoreFromConfigFile(page: Page) { } test("backup and restore flow", async ({ page }) => { + // Enable console logging from the browser + page.on("console", (msg) => console.log("Browser console:", msg.text())); + page.on("pageerror", (err) => console.error("Browser error:", err.message)); + await page .context() .addCookies([ @@ -314,13 +334,33 @@ test("backup and restore flow", async ({ page }) => { console.log("Navigating to login page..."); await page.goto(LOGIN_URL); await page.waitForLoadState("networkidle"); + + // Take screenshot after login page loads + await page.screenshot({ + path: path.join("test-results", "01-login-page.png"), + fullPage: true, + }); + await page.fill("[formcontrolname='pass']", WEBSERVICE_PASSWORD); await page.locator("button").filter({ hasText: "Login" }).click(); console.log("Waiting for page to load..."); + + // Take screenshot after login + await page.screenshot({ + path: path.join("test-results", "02-after-login.png"), + fullPage: true, + }); + await page.locator("text=Add backup").waitFor(); + // Take screenshot when home page is ready + await page.screenshot({ + path: path.join("test-results", "03-home-page-ready.png"), + fullPage: true, + }); + // Ensure no existing backup console.log("Deleting existing backup if it exists..."); await deleteBackupIfExists(page); diff --git a/playwright.config.ts b/playwright.config.ts index 20a06dc1f..a863636fe 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -4,10 +4,16 @@ export default defineConfig({ use: { baseURL: "http://localhost:8200", headless: true, + // Capture screenshots on failure + screenshot: "only-on-failure", + // Capture video on failure + video: "retain-on-failure", + // Capture trace on failure for detailed debugging + trace: "retain-on-failure", }, testDir: "playwright-tests", timeout: 120000, workers: 1, - reporter: process.env.CI ? "html" : "list", + reporter: process.env.CI ? [["html"], ["list"], ["github"]] : "list", outputDir: "test-results/", });