From aa84692df3f0de19021153ada69572335cff8547 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sun, 27 Sep 2026 09:50:52 +0200 Subject: [PATCH] Make `USE_NEW_DESIGN` deterministic by cache-busting `config.json` in design switcher (#858) * Initial plan * Fix design switch config caching for USE_NEW_DESIGN Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com> --- design-switch.js | 3 ++- tests/e2e/design-switch.spec.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/design-switch.js b/design-switch.js index 0a23475..4ea78c6 100644 --- a/design-switch.js +++ b/design-switch.js @@ -37,7 +37,8 @@ try { const xhr = new XMLHttpRequest(); // Use a synchronous request to prevent a flash of the old design before redirecting - xhr.open('GET', 'config.json', false); + // Bypass stale browser caches so Docker env changes are reflected immediately + xhr.open('GET', 'config.json?_=' + Date.now(), false); xhr.send(null); // Check for a successful response, but not 304 Not Modified, which can have an empty response body diff --git a/tests/e2e/design-switch.spec.js b/tests/e2e/design-switch.spec.js index c676215..8cb1ac8 100644 --- a/tests/e2e/design-switch.spec.js +++ b/tests/e2e/design-switch.spec.js @@ -26,4 +26,21 @@ test.describe('Design switch behavior', () => { await expect(page).toHaveURL(/index-classic\.html\?design=old/); await expect(classicStartButton(page)).toBeVisible(); }); + + test('config fetch bypasses browser cache', async ({ page }) => { + let configRequestUrl = ''; + + await page.route('**/config.json*', async (route) => { + configRequestUrl = route.request().url(); + await route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify({ useNewDesign: true }), + }); + }); + + await page.goto(`${baseUrls.standalone}/index.html`); + await expect(page).toHaveURL(/index-modern\.html/); + expect(configRequestUrl).toMatch(/config\.json\?_=\d+/); + }); });