Make USE_NEW_DESIGN deterministic by cache-busting config.json in design switcher (#858)
Some checks failed
Docker / e2e (push) Has been cancelled
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Has been cancelled
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Has been cancelled

* 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>
This commit is contained in:
Copilot 2026-09-27 09:50:52 +02:00 • committed by GitHub
parent be1e0a0daa
commit aa84692df3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View file

@ -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

View file

@ -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+/);
});
});