mirror of
https://github.com/librespeed/speedtest.git
synced 2026-11-22 16:14:56 +00:00
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 <sti-github@stidl.com>
This commit is contained in:
parent
a820d7cdf1
commit
4cf44ad6ac
2 changed files with 31 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
29
tests/e2e/classic-server-list.spec.js
Normal file
29
tests/e2e/classic-server-list.spec.js
Normal file
|
|
@ -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([]);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue