mirror of
https://github.com/librespeed/speedtest.git
synced 2026-10-25 01:31:32 +00:00
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>
This commit is contained in:
parent
be1e0a0daa
commit
aa84692df3
2 changed files with 19 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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+/);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue