From 4cf44ad6ac0618a201d5e2f14a9f30cbfcdab8cb Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Oct 2026 07:36:01 +0200 Subject: [PATCH] Point classic UI at mounted /servers.json in Docker entrypoint (#870) * Initial plan * Apply remaining changes Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com> * Apply remaining changes Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com> * Reuse SERVER_LIST_URL sed block for mounted servers.json Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com> * Strengthen classic mounted server list E2E assertions --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com> Co-authored-by: Stefan Stidl --- docker/entrypoint.sh | 2 ++ tests/e2e/classic-server-list.spec.js | 29 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/e2e/classic-server-list.spec.js diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 8fe1987..36e8eae 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -91,6 +91,8 @@ if [[ "$MODE" == "frontend" || "$MODE" == "dual" || "$MODE" == "standalone" ]]; if [ -f /servers.json ]; then echo "using mounted /servers.json for server-list.json" cp /servers.json /var/www/html/server-list.json + # default the frontend list to the mounted file so the classic design uses it too + SERVER_LIST_URL="${SERVER_LIST_URL:-server-list.json}" elif [ -n "$SERVER_LIST_URL" ]; then echo "no /servers.json found, relying on SERVER_LIST_URL" elif [ "$MODE" == "frontend" ]; then diff --git a/tests/e2e/classic-server-list.spec.js b/tests/e2e/classic-server-list.spec.js new file mode 100644 index 0000000..17a097b --- /dev/null +++ b/tests/e2e/classic-server-list.spec.js @@ -0,0 +1,29 @@ +const { test, expect } = require("@playwright/test"); +const { baseUrls } = require("./helpers/env"); + +test.describe("Classic design with mounted server list", () => { + test("frontend classic page loads the mounted server-list.json", async ({ page, request }) => { + const html = await (await request.get(`${baseUrls.frontend}/index-classic.html`)).text(); + expect(html).toMatch(/var SPEEDTEST_SERVERS = "server-list\.json";/); + + const pageErrors = []; + page.on("pageerror", error => pageErrors.push(error.message)); + + // This fixture hostname only resolves inside Docker. Keep server selection + // deterministic without mocking the mounted server-list.json response. + await page.route("http://backend-testpoint:8080/empty.php*", route => + route.fulfill({ status: 200, headers: { "Access-Control-Allow-Origin": "*" }, body: "" }) + ); + + const listResponse = page.waitForResponse(response => response.url().endsWith("/server-list.json")); + await page.goto(`${baseUrls.frontend}/index-classic.html`); + + const response = await listResponse; + expect(response.ok()).toBeTruthy(); + + // Verify the fetched config was applied to the classic server selector. + await expect(page.locator("#server option")).toHaveText(["Backend testpoint"], { timeout: 10_000 }); + await expect(page.locator("#startStopBtn")).toBeVisible(); + expect(pageErrors).toEqual([]); + }); +});