1
0

classic-server-list.spec.js 1.4 KB

1234567891011121314151617181920212223242526272829
  1. const { test, expect } = require("@playwright/test");
  2. const { baseUrls } = require("./helpers/env");
  3. test.describe("Classic design with mounted server list", () => {
  4. test("frontend classic page loads the mounted server-list.json", async ({ page, request }) => {
  5. const html = await (await request.get(`${baseUrls.frontend}/index-classic.html`)).text();
  6. expect(html).toMatch(/var SPEEDTEST_SERVERS = "server-list\.json";/);
  7. const pageErrors = [];
  8. page.on("pageerror", error => pageErrors.push(error.message));
  9. // This fixture hostname only resolves inside Docker. Keep server selection
  10. // deterministic without mocking the mounted server-list.json response.
  11. await page.route("http://backend-testpoint:8080/empty.php*", route =>
  12. route.fulfill({ status: 200, headers: { "Access-Control-Allow-Origin": "*" }, body: "" })
  13. );
  14. const listResponse = page.waitForResponse(response => response.url().endsWith("/server-list.json"));
  15. await page.goto(`${baseUrls.frontend}/index-classic.html`);
  16. const response = await listResponse;
  17. expect(response.ok()).toBeTruthy();
  18. // Verify the fetched config was applied to the classic server selector.
  19. await expect(page.locator("#server option")).toHaveText(["Backend testpoint"], { timeout: 10_000 });
  20. await expect(page.locator("#startStopBtn")).toBeVisible();
  21. expect(pageErrors).toEqual([]);
  22. });
  23. });