From 901ed1c09857cc50ceb0f5e6fad913902277f5df Mon Sep 17 00:00:00 2001 From: surtic86 Date: Thu, 15 Oct 2026 10:18:45 +0200 Subject: [PATCH] fix: e2e size helper keeps the user's other appearance choices It sent the size alone, which replaced the admin's saved mode, contrast and color. Co-Authored-By: Claude Opus 5.5 --- e2e/size.mjs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/e2e/size.mjs b/e2e/size.mjs index f7d5880..b1281d1 100644 --- a/e2e/size.mjs +++ b/e2e/size.mjs @@ -1,10 +1,16 @@ -// Saves a size mode on the logged-in user's account (needs the redmine_tonalmine plugin). -// No size resets the account to the default appearance. +// Saves a size mode on the logged-in user's account (needs the redmine_tonalmine plugin). The user's +// other choices (mode, contrast, color) are kept. No size removes the size choice again. +// The page must be loaded after the last change, since the saved choice is read from it. export async function setSize(page, size) { - const status = await page.evaluate(async (body) => { + const status = await page.evaluate(async (size) => { + // The plugin hands the saved choice to theme.js in : Tonalmine.configure({..., user: {...}}) + const script = [...document.scripts].find((s) => s.text.includes('Tonalmine.configure(')); + const prefs = JSON.parse(script.text.match(/Tonalmine\.configure\((.*)\);/s)[1]).user; + if (size) prefs.size = size; + else delete prefs.size; const headers = { 'Content-Type': 'application/json', 'X-Requested-With': 'XMLHttpRequest', 'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content }; - return (await fetch('/tonalmine/appearance', { method: 'PUT', headers, body: JSON.stringify(body) })).status; - }, size ? { size } : {}); + return (await fetch('/tonalmine/appearance', { method: 'PUT', headers, body: JSON.stringify(prefs) })).status; + }, size); if (status !== 204) throw new Error(`could not save size ${size ?? 'default'} (HTTP ${status})`); }