From bd8ec153cd810d6f621239ec6ce637aabbee458a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 9 Sep 2026 07:30:34 +0000 Subject: [PATCH] Fix SERVER_LIST_URL frontend startup Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com> --- docker/entrypoint.sh | 7 ++++++- tests/docker-compose-playwright.yml | 13 +++++++++++++ .../e2e/fixtures/servers-frontend-remote.json | 11 +++++++++++ tests/e2e/global-setup.js | 1 + tests/e2e/helpers/env.js | 1 + tests/e2e/modes.spec.js | 18 ++++++++++++++++++ 6 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 tests/e2e/fixtures/servers-frontend-remote.json diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index e82b75a..cdc8e80 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -56,7 +56,7 @@ fi # Copy servers.json for stability page (frontend/dual modes) -if [[ "$MODE" == "frontend" || "$MODE" == "dual" ]]; then +if [[ "$MODE" == "frontend" || "$MODE" == "dual" ]] && [ -f /servers.json ]; then cp /servers.json /var/www/html/servers.json fi @@ -91,6 +91,11 @@ 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 + elif [ -n "$SERVER_LIST_URL" ]; then + echo "no /servers.json found, relying on SERVER_LIST_URL" + elif [ "$MODE" == "frontend" ]; then + echo "ERROR: /servers.json not found and SERVER_LIST_URL is not set" >&2 + exit 1 else echo "no /servers.json found, create one for local host" # generate config for just the local server diff --git a/tests/docker-compose-playwright.yml b/tests/docker-compose-playwright.yml index 7ea3296..e63a466 100644 --- a/tests/docker-compose-playwright.yml +++ b/tests/docker-compose-playwright.yml @@ -78,6 +78,19 @@ services: ports: - "18182:8080" + frontend-remote: + build: + context: .. + dockerfile: Dockerfile + depends_on: + - backend-testpoint + environment: + - MODE=frontend + - WEBPORT=8080 + - SERVER_LIST_URL=http://127.0.0.1:18184/tests/e2e/fixtures/servers-frontend-remote.json + ports: + - "18188:8080" + dual: build: context: .. diff --git a/tests/e2e/fixtures/servers-frontend-remote.json b/tests/e2e/fixtures/servers-frontend-remote.json new file mode 100644 index 0000000..bdd7e61 --- /dev/null +++ b/tests/e2e/fixtures/servers-frontend-remote.json @@ -0,0 +1,11 @@ +[ + { + "name": "Remote frontend backend", + "server": "http://127.0.0.1:18181/", + "dlURL": "garbage.php", + "ulURL": "empty.php", + "pingURL": "empty.php", + "getIpURL": "getIP.php", + "id": 1 + } +] diff --git a/tests/e2e/global-setup.js b/tests/e2e/global-setup.js index a861e0a..b95b178 100644 --- a/tests/e2e/global-setup.js +++ b/tests/e2e/global-setup.js @@ -71,5 +71,6 @@ module.exports = async () => { await waitForReady('standalone-alpine', 'http://127.0.0.1:18187/index.html', timeoutMs); await waitForReady('backend', 'http://127.0.0.1:18181/empty.php', timeoutMs); await waitForReady('frontend', 'http://127.0.0.1:18182/index-modern.html', timeoutMs); + await waitForReady('frontend-remote', 'http://127.0.0.1:18188/index-modern.html', timeoutMs); await waitForReady('dual', 'http://127.0.0.1:18183/index-modern.html', timeoutMs); }; diff --git a/tests/e2e/helpers/env.js b/tests/e2e/helpers/env.js index e935680..b76d317 100644 --- a/tests/e2e/helpers/env.js +++ b/tests/e2e/helpers/env.js @@ -3,6 +3,7 @@ const baseUrls = { backend: 'http://127.0.0.1:18181', frontend: 'http://127.0.0.1:18182', dual: 'http://127.0.0.1:18183', + frontendRemote: 'http://127.0.0.1:18188', standaloneNew: 'http://127.0.0.1:18185', standaloneApostrophe: 'http://127.0.0.1:18186', standaloneAlpine: 'http://127.0.0.1:18187', diff --git a/tests/e2e/modes.spec.js b/tests/e2e/modes.spec.js index ea37a51..c714832 100644 --- a/tests/e2e/modes.spec.js +++ b/tests/e2e/modes.spec.js @@ -3,6 +3,7 @@ const { baseUrls } = require('./helpers/env'); const { modernStartButton } = require('./helpers/ui'); const defaultTagline = 'No Flash, No Java, No Websockets, No Bullsh*t'; +const frontendRemoteServerListUrl = 'http://127.0.0.1:18184/tests/e2e/fixtures/servers-frontend-remote.json'; test.describe('Runtime mode smoke coverage', () => { test('standalone exposes UI and local backend endpoints', async ({ page, request }) => { @@ -52,6 +53,23 @@ test.describe('Runtime mode smoke coverage', () => { await expect(page.locator('#selected-server')).not.toHaveText(/searching nearest server/i); }); + test('frontend starts with SERVER_LIST_URL without requiring /servers.json', async ({ page, request }) => { + const index = await request.get(`${baseUrls.frontendRemote}/index-modern.html`); + expect(index.ok()).toBeTruthy(); + await expect(await index.text()).toContain(frontendRemoteServerListUrl); + + const stability = await request.get(`${baseUrls.frontendRemote}/stability.html`); + expect(stability.ok()).toBeTruthy(); + await expect(await stability.text()).toContain(frontendRemoteServerListUrl); + + const localBackendEndpoint = await request.get(`${baseUrls.frontendRemote}/backend/empty.php`); + expect(localBackendEndpoint.status()).toBe(404); + + await page.goto(`${baseUrls.frontendRemote}/index-modern.html`); + await expect(modernStartButton(page)).toBeVisible(); + await expect(page.locator('#selected-server')).toContainText('Remote frontend backend', { timeout: 10_000 }); + }); + test('dual combines frontend and local backend availability', async ({ page, request }) => { const serverList = await request.get(`${baseUrls.dual}/server-list.json`); expect(serverList.ok()).toBeTruthy();