From 515cbd64daf051db01a17b8f470b0a25484e4ca8 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 12:43:22 +0800 Subject: [PATCH 01/13] ci: an Unraid-alone pass checks every Unraid hook FV3 relies on, and FV3's pages keep Unraid's layout in every Dashboard layout --- .coderabbit.yaml | 8 + .github/unraid-compat/browser_test.js | 211 ++++++++++++++++++-------- .github/unraid-compat/browser_test.sh | 15 +- .github/unraid-compat/hooks.js | 94 ++++++++++++ .github/unraid-compat/layout.js | 58 +++++++ 5 files changed, 315 insertions(+), 71 deletions(-) create mode 100644 .github/unraid-compat/hooks.js create mode 100644 .github/unraid-compat/layout.js diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 4d3ef96d..42e6488d 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -239,6 +239,14 @@ reviews: fake_logs.php holds the log checks both tests run. package.json pins playwright-core to the image's version, which browser_test.sh checks. + - browser_test.sh runs an Unraid-alone pass first, FV3's three + page hooks moved out of its plugin folder. It checks hooks.js, a + hand-written list of Unraid's DOM hooks, functions and endpoints + FV3 relies on, each naming the FV3 file that still mentions it and + what the user loses; any/since only where FV3 itself branches. + layout.js holds the layout rules FV3's pass checks against that + pass and a loose container on the same page, each from a fix FV3 + has shipped. - matrix_check.py keeps ci.yml's Unraid rows at one per minor from the .plg's min to the newest release; Renovate only moves rows. - Each step asserts what the user is left with (live files, the diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index 42c4ec52..ce2ada0d 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -1,10 +1,16 @@ // FV3's pages in Chromium and Firefox on the fake Unraid browser_test.sh started, 4 themes at 3 widths, screenshots kept. -// Usage: node browser_test.js +// Usage: node browser_test.js [unraid-alone] 'use strict'; const fs = require('fs'); +const path = require('path'); const { chromium, firefox } = require('playwright-core'); +const { HOOKS, names, describe, applies, missingHooks } = require('./hooks'); +const { widths, layoutState } = require('./layout'); -const [version, shots, fakeToken] = process.argv.slice(2); +const [version, shots, fakeToken, tree, mode = 'fv3'] = process.argv.slice(2); +// The Unraid-alone pass runs with FV3's page hooks moved away: it checks Unraid's hooks and measures what FV3's pass compares with +const ALONE = mode === 'unraid-alone'; +const MEASURED = `${shots}/unraid-alone.json`; const base = 'http://127.0.0.1'; const failures = []; let checks = 0; @@ -53,11 +59,11 @@ const READ = { return { rows: window.fv3Test.tableRows('kvm_list', 'vm-name'), details: `${paired} of ${details.length} detail rows after their VM` }; }, Dashboard: () => { - const { seen, name } = window.fv3Test; - const tiles = (view) => [...document.querySelectorAll(`tbody#${view} > tr.updated > td > *`)].filter(seen).map((tile) => { + const { seen, name, members } = window.fv3Test; + const tiles = (view) => [...document.querySelectorAll(`tbody#${view} > tr.updated > td > :not(.fv3-fullwidth-panel)`)].filter(seen).map((tile) => { if (!tile.classList.contains('folder-showcase-outer')) return name(tile); - const members = [...tile.querySelectorAll('.folder-storage > span.outer, .folder-showcase > span.outer')]; - return `${tile.querySelector('.fv3-folder-appname').innerText.trim()} [${members.map(name).join(', ')}] shows [${members.filter(seen).map(name).join(', ')}]`; + const mine = members(tile); + return `${tile.querySelector('.fv3-folder-appname').innerText.trim()} [${mine.map(name).join(', ')}] shows [${mine.filter(seen).map(name).join(', ')}]`; }); return { docker: tiles('docker_view'), vms: tiles('vm_view') }; }, @@ -90,9 +96,13 @@ const OPEN = { await press(p.locator('ul.dropdown-context:visible li > a', { hasText: await p.evaluate(() => $.i18n('expand')) }), "its menu's Expand"); }], }; -// The first member of Media, and where a click opens its advanced preview once Media is open +// FV3's Dashboard layouts for the Docker and VM cards in each theme, so every layout is drawn at every width +const LAYOUTS = [['classic', 'embossed'], ['fullwidth', 'classic'], ['accordion', 'fullwidth'], ['inset', 'accordion']]; +// Unraid's own list on each page once its rows load: a loading placeholder row is not one +const LISTED = { Docker: '#docker_list > tr.sortable', VMs: '#kvm_list > tr.sortable', Dashboard: 'tbody#docker_view > tr.updated' }; +// The first member of Media, and where a click opens its advanced preview once Media is open (fullwidth: in the panel after its row) const PREVIEWED = 'app-a'; -const PREVIEW = { Docker: `tr.folder-id-${MEDIA} .folder-preview span.hand[id^="folder-preview-"]`, Dashboard: `.folder-showcase-${MEDIA} > span.outer > span.hand` }; +const PREVIEW = { Docker: `tr.folder-id-${MEDIA} .folder-preview span.hand[id^="folder-preview-"]`, Dashboard: `.folder-showcase-${MEDIA} > span.outer > span.hand, .fv3-fullwidth-panel[data-folder-name="Media"] > span.outer > span.hand` }; // Before the page's scripts: records FV3's draw and expansion events as they fire, and the readers' helpers. A display: contents // element (FV3's Dashboard folders) is seen when a child is; a name is .inner's text before its first line break, drawn or not @@ -125,10 +135,16 @@ function testHelpers() { for (const node of outer.querySelector('.inner').childNodes) { if (node.nodeName === 'BR') break; before.push(node.textContent); } return before.join('').trim(); }; + // A Dashboard folder's member tiles wherever its layout puts them: in the folder, or the fullwidth layout's panel in its row + const members = (folder) => { + const named = folder.querySelector('.folder-showcase')?.dataset.folderName; + const panel = [...folder.parentElement.querySelectorAll(':scope > .fv3-fullwidth-panel')].find((p) => p.dataset.folderName === named); + return [...folder.querySelectorAll('.folder-storage > span.outer, .folder-showcase > span.outer'), ...(panel?.querySelectorAll(':scope > span.outer') || [])]; + }; const tableRows = (list, nameCell) => [...document.querySelectorAll(`#${list} > tr`)].filter(seen).map((row) => row.classList.contains('folder') ? `${row.querySelector('.folder-appname').innerText.trim()} [${[...row.querySelectorAll('.folder-preview span.outer')].filter(seen).map(name).join(', ')}]` : name(row.querySelector(`td.${nameCell} span.outer`))); - window.fv3Test = { events, seen, name, tableRows, banners }; + window.fv3Test = { events, seen, name, members, tableRows, banners }; } // The page's reading once two in a row agree: FV3 animates an opening and Unraid may reload a list after the first draw @@ -202,12 +218,12 @@ function popupState(name) { // A page whose script never yields stalls page.evaluate, which has no timeout: past this the view fails, not the step's time limit const VIEW_LIMIT = 90000; -// One page in one browser, theme and width; false when it ended before FV3 drew -async function view(browser, kind, theme, [width, height], page) { - const where = `${kind} ${theme} ${width}px ${page}`; - const file = `${shots}/${kind}/${theme}-${width}-${page}`; +// One page in one browser, theme and width, through one pass's steps; false when it ended before the page drew +async function view(browser, kind, theme, [width, height], page, steps) { + const v = { where: `${kind} ${theme} ${width}px ${page}`, file: `${shots}/${kind}/${theme}-${width}-${page}`, theme, width, page, drew: false }; + const { where, file } = v; const errors = []; - let context, tab, timer, drew = false; + let context, tab, timer; try { context = await browser.newContext({ viewport: { width, height } }); await context.addInitScript(testHelpers); @@ -216,59 +232,117 @@ async function view(browser, kind, theme, [width, height], page) { tab.on('console', (m) => { if (m.type() === 'error' && !excused(m, page)) errors.push(`console error: ${m.text()} (${m.location()?.url || 'no source'})`); }); tab.on('response', (r) => { if (r.status() >= 400 && !absent(r.url())) errors.push(`${r.status()} for ${r.url()}`); }); tab.on('requestfailed', (r) => { if (!absent(r.url())) errors.push(`request failed: ${r.url()} ${r.failure()?.errorText}`); }); - await Promise.race([steps(), new Promise((_, reject) => { timer = setTimeout(() => reject(new Error(`the view took over ${VIEW_LIMIT / 1000} s`)), VIEW_LIMIT); })]); + await Promise.race([steps(tab, v), new Promise((_, reject) => { timer = setTimeout(() => reject(new Error(`the view took over ${VIEW_LIMIT / 1000} s`)), VIEW_LIMIT); })]); } catch (e) { check(false, `${where}: ${e.message.split('\n')[0]}`); await tab?.screenshot({ path: `${file}-failed.png`, fullPage: true, timeout: 10000 }).catch(() => {}); } finally { clearTimeout(timer); } - check(!errors.length, `${where}:\n ${[...new Set(errors)].join('\n ')}`); + // Unraid alone's own errors are not FV3's + if (!ALONE) check(!errors.length, `${where}:\n ${[...new Set(errors)].join('\n ')}`); await context?.close().catch(() => {}); - return drew; + return v.drew; +} - async function steps() { - const loaded = await tab.goto(`${base}/${page}`); - if (loaded?.status() !== 200) throw new Error(`/${page} answered ${loaded?.status()}`); - check(await tab.evaluate((t) => [...document.querySelectorAll('link[rel=stylesheet]')] - .some((l) => new RegExp(`/webGui/styles/(?:themes/|default-)${t}\\.css`).test(l.getAttribute('href'))), theme), `${where}: the ${theme} theme's stylesheet is not on the page`); - await waitEvents(tab, DRAWN[page]).catch(() => { throw new Error(`FV3 did not finish drawing within 20 s (${DRAWN[page].join(', ')})`); }); - drew = true; - let got = await settled(tab, READ[page]); - check(same(got, WANT[page].shut), `${where}: drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].shut)}`); - const [folder, opened, open] = OPEN[page]; - await open(tab); - await waitEvents(tab, [opened]).catch(() => { throw new Error(`${folder} did not open within 20 s (${opened})`); }); - got = await settled(tab, READ[page]); - check(same(got, WANT[page].open), `${where}: with ${folder} open, drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].open)}`); - await tab.screenshot({ path: `${file}.png`, fullPage: true }); - if (PREVIEW[page]) { - await press(tab.locator(PREVIEW[page]).first(), `${PREVIEWED}'s preview icon`); - await tab.waitForSelector('.tooltipster-base .preview-outbox', { state: 'visible', timeout: 10000 }) - .catch(() => { throw new Error('the advanced preview did not open within 10 s'); }); - // The popup fades in and draws its graph after it opens - const popup = await settled(tab, popupState, PREVIEWED); - if (popup.error) throw new Error(popup.error); - // Playwright's visible ignores opacity: a popup tooltipster leaves transparent opens to nothing - if (!popup.seen) throw new Error('the advanced preview opened but cannot be seen'); - check(popup.named, `${where}: the advanced preview is not ${PREVIEWED}'s`); - check(!popup.moved, `${where}: the advanced preview draws its markup's line breaks: ${popup.moved} moved when ${popup.blanks} blank text nodes became one space`); - check(!popup.inside, `${where}: the advanced preview is out of reach: ${popup.inside}`); - await tab.screenshot({ path: `${file}-preview.png` }); - } - const banners = await tab.evaluate(() => window.fv3Test.banners); - check(!banners.length, `${where}: FV3 showed a banner: ${banners.join(' | ')}`); +// The page as the theme's stylesheet draws it, or the view fails +async function load(tab, { where, page, theme }) { + const loaded = await tab.goto(`${base}/${page}`); + if (loaded?.status() !== 200) throw new Error(`/${page} answered ${loaded?.status()}`); + check(await tab.evaluate((t) => [...document.querySelectorAll('link[rel=stylesheet]')] + .some((l) => new RegExp(`/webGui/styles/(?:themes/|default-)${t}\\.css`).test(l.getAttribute('href'))), theme), `${where}: the ${theme} theme's stylesheet is not on the page`); +} + +// Unraid alone: its list drawn, the widths FV3's pass compares with, and which of FV3's hooks it lacks +const measured = {}, lacking = new Map(); +async function aloneSteps(tab, v) { + await load(tab, v); + v.drew = await tab.waitForSelector(LISTED[v.page], { timeout: 20000 }).then(() => true, () => false); + check(v.drew, `${v.where}: Unraid alone drew no ${LISTED[v.page]} within 20 s`); + measured[v.where] = await settled(tab, widths); + const hooks = HOOKS.filter((h) => !h.url && [v.page, 'any page'].includes(h.page) && applies(h, version)); + for (const i of await settled(tab, missingHooks, hooks)) lacking.set(hooks[i], [...(lacking.get(hooks[i]) || []), v.where]); +} + +// FV3's pass: drawn in the saved order, a folder opened as a user opens it, the layout rules, the advanced preview, no banners +async function fv3Steps(tab, v) { + const { where, file, page, width } = v; + await load(tab, v); + await waitEvents(tab, DRAWN[page]).catch(() => { throw new Error(`FV3 did not finish drawing within 20 s (${DRAWN[page].join(', ')})`); }); + v.drew = true; + if (page === 'Dashboard') { + const want = LAYOUTS[THEMES.indexOf(v.theme)]; + const drawn = await tab.evaluate(() => ['docker_view', 'vm_view'].map((t) => [...(document.querySelector(`tbody#${t} > tr.updated > td`)?.classList || [])] + .find((c) => c.startsWith('fv3-layout-'))?.slice('fv3-layout-'.length) || 'no layout')); + check(same(drawn, want), `${where}: the Docker and VM cards are drawn in ${drawn.join(' and ')}, not ${want.join(' and ')}`); + } + let got = await settled(tab, READ[page]); + check(same(got, WANT[page].shut), `${where}: drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].shut)}`); + const [folder, opened, open] = OPEN[page]; + await open(tab); + await waitEvents(tab, [opened]).catch(() => { throw new Error(`${folder} did not open within 20 s (${opened})`); }); + got = await settled(tab, READ[page]); + check(same(got, WANT[page].open), `${where}: with ${folder} open, drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].open)}`); + const layout = await settled(tab, layoutState, { page, desktop: width === SIZES[0][0] }); + if (layout.error) throw new Error(layout.error); + for (const problem of Object.values(layout.rules)) check(!problem, `${where}: ${problem}`); + // Where Unraid alone already scrolls sideways (both tables at tablet and phone widths), FV3 may be wider + const now = await tab.evaluate(widths), was = measured[where]; + check(was && (!was.page || now.page) && (was.table !== true || now.table), + `${where}: FV3 adds sideways scrolling Unraid alone does not have: ${now.sizes} (Unraid alone ${was?.sizes ?? 'not measured'})`); + await tab.screenshot({ path: `${file}.png`, fullPage: true }); + if (PREVIEW[page]) { + await press(tab.locator(PREVIEW[page]).first(), `${PREVIEWED}'s preview icon`); + await tab.waitForSelector('.tooltipster-base .preview-outbox', { state: 'visible', timeout: 10000 }) + .catch(() => { throw new Error('the advanced preview did not open within 10 s'); }); + // The popup fades in and draws its graph after it opens + const popup = await settled(tab, popupState, PREVIEWED); + if (popup.error) throw new Error(popup.error); + // Playwright's visible ignores opacity: a popup tooltipster leaves transparent opens to nothing + if (!popup.seen) throw new Error('the advanced preview opened but cannot be seen'); + check(popup.named, `${where}: the advanced preview is not ${PREVIEWED}'s`); + check(!popup.moved, `${where}: the advanced preview draws its markup's line breaks: ${popup.moved} moved when ${popup.blanks} blank text nodes became one space`); + check(!popup.inside, `${where}: the advanced preview is out of reach: ${popup.inside}`); + await tab.screenshot({ path: `${file}-preview.png` }); } + const banners = await tab.evaluate(() => window.fv3Test.banners); + check(!banners.length, `${where}: FV3 showed a banner: ${banners.join(' | ')}`); } // A save as the page posts it; anything but a 200, or an FV3 answer without FV3's header, stops the run -async function post(request, path, form, what) { - const r = await request.post(`${base}${path}`, { form }); - if (r.status() !== 200 || (path.includes('folder.view3') && !r.headers()['x-fv3-answer'])) throw new Error(`${what}: status ${r.status()}, ${(await r.text()).slice(0, 200)}`); +async function post(request, route, form, what) { + const r = await request.post(`${base}${route}`, { form }); + if (r.status() !== 200 || (route.includes('folder.view3') && !r.headers()['x-fv3-answer'])) throw new Error(`${what}: status ${r.status()}, ${(await r.text()).slice(0, 200)}`); +} + +// FV3's pass starts from: Media and the Dashboard with the advanced preview on, and an empty folder +async function fv3Setup(request, token) { + // Media as fake_unraid.sh saved it + const saved = await request.get(`${base}/plugins/folder.view3/server/read.php?type=docker`); + const media = saved.ok() ? (await saved.json())[MEDIA] : undefined; + if (!media) throw new Error(`no Media folder to turn the advanced preview on: status ${saved.status()}`); + await post(request, '/plugins/folder.view3/server/update.php', { type: 'docker', id: MEDIA, csrf_token: token, + content: JSON.stringify({ ...media, settings: { ...media.settings, context: 2 } }) }, "Media's advanced preview"); + await post(request, '/plugins/folder.view3/server/update_settings.php', { key: 'dashboard_context', value: '2', csrf_token: token }, "the Dashboard's advanced preview"); + // Named in characters a page must escape + await post(request, '/plugins/folder.view3/server/create.php', { type: 'docker', csrf_token: token, + content: JSON.stringify({ name: SPARE, icon: '', regex: '', containers: [], settings: { preview: 1 }, actions: [] }) }, 'the empty folder'); +} + +// Each hook's FV3 file still mentions it; each missing hook once, with the views it was missing from. An endpoint is a webGUI file +function hookChecks(webgui) { + for (const h of HOOKS) { + const text = fs.existsSync(`${plugin}/${h.file}`) ? fs.readFileSync(`${plugin}/${h.file}`, 'utf8') : null; + const gone = text === null ? [h.file] : names(h).filter((n) => !text.includes(n)); + check(!gone.length, `hooks.js names ${h.file} for ${describe(h)}, but FV3 no longer has ${gone.join(', ')} there`); + } + for (const [h, where] of lacking) check(false, `Unraid ${version} lacks ${describe(h)} on ${h.page} (${where.length} views, first ${where[0]}), which ${h.file} needs: ${h.loses}`); + for (const h of HOOKS.filter((x) => x.url)) check(fs.existsSync(path.join(webgui, 'emhttp', h.url)), `Unraid ${version} lacks ${h.url}, which ${h.file} needs: ${h.loses}`); } (async () => { - if (!fs.existsSync('/.dockerenv') || !fakeToken) { console.error('Run browser_test.sh: this needs the fake Unraid it starts'); process.exit(2); } + const webgui = path.resolve(__dirname, '../..', tree || ''); + if (!fs.existsSync('/.dockerenv') || !fakeToken || !fs.existsSync(`${webgui}/emhttp`)) { console.error('Run browser_test.sh: this needs the fake Unraid it starts and its webGUI tree'); process.exit(2); } check(!fv3Unload.length, `FV3 adds an unload handler, which Chromium never runs: ${fv3Unload.join(', ')}`); const browsers = { chromium: await chromium.launch(), firefox: await firefox.launch() }; const setup = await browsers.chromium.newContext(); @@ -278,35 +352,38 @@ async function post(request, path, form, what) { // lib.sh gives every fake this token and a real Unraid never has it, so no real server on this loopback is written to const token = await tab.evaluate(() => typeof csrf_token === 'string' ? csrf_token : ''); if (token !== fakeToken) { console.error(`127.0.0.1 is not the fake Unraid browser_test.sh started (token "${token}")`); process.exit(2); } - // Media as fake_unraid.sh saved it, with the advanced preview on - const saved = await setup.request.get(`${base}/plugins/folder.view3/server/read.php?type=docker`); - const media = saved.ok() ? (await saved.json())[MEDIA] : undefined; - if (!media) throw new Error(`no Media folder to turn the advanced preview on: status ${saved.status()}`); - await post(setup.request, '/plugins/folder.view3/server/update.php', { type: 'docker', id: MEDIA, csrf_token: token, - content: JSON.stringify({ ...media, settings: { ...media.settings, context: 2 } }) }, "Media's advanced preview"); - await post(setup.request, '/plugins/folder.view3/server/update_settings.php', { key: 'dashboard_context', value: '2', csrf_token: token }, "the Dashboard's advanced preview"); - // A folder with no members, named in characters a page must escape - await post(setup.request, '/plugins/folder.view3/server/create.php', { type: 'docker', csrf_token: token, - content: JSON.stringify({ name: SPARE, icon: '', regex: '', containers: [], settings: { preview: 1 }, actions: [] }) }, 'the empty folder'); + if (!ALONE) { + try { Object.assign(measured, JSON.parse(fs.readFileSync(MEASURED, 'utf8'))); } catch (e) { throw new Error(`the Unraid-alone pass left no measurements: ${e.message}`); } + await fv3Setup(setup.request, token); + } let undrawn = 0; - for (const theme of THEMES) { + for (const [i, theme] of THEMES.entries()) { // As Unraid's Display Settings saves it await post(setup.request, '/update.php', { '#file': 'dynamix/dynamix.cfg', '#section': 'display', theme, csrf_token: token }, `the ${theme} theme`); + if (!ALONE) for (const [card, layout] of [['docker', LAYOUTS[i][0]], ['vm', LAYOUTS[i][1]]]) { + await post(setup.request, '/plugins/folder.view3/server/update_settings.php', { key: `dashboard_${card}_layout`, value: layout, csrf_token: token }, `the Dashboard's ${layout} ${card} card`); + } for (const [kind, browser] of Object.entries(browsers)) { fs.mkdirSync(`${shots}/${kind}`, { recursive: true }); for (const size of SIZES) for (const page of ['Docker', 'VMs', 'Dashboard']) { - undrawn = (await view(browser, kind, theme, size, page)) ? 0 : undrawn + 1; - if (undrawn === 3) throw new Error('3 views in a row ended before FV3 drew, so the rest were not run'); + undrawn = (await view(browser, kind, theme, size, page, ALONE ? aloneSteps : fv3Steps)) ? 0 : undrawn + 1; + if (undrawn === 3) throw new Error(`3 views in a row ended before ${ALONE ? 'Unraid' : 'FV3'} drew, so the rest were not run`); } } } await setup.close(); for (const browser of Object.values(browsers)) await browser.close(); + if (ALONE) { + hookChecks(webgui); + fs.writeFileSync(MEASURED, JSON.stringify(measured)); + } + const what = ALONE ? `Unraid alone has the ${HOOKS.length} hooks FV3 relies on, ${THEMES.length} themes at ${SIZES.length} widths in Chromium and Firefox` + : `FV3's pages in Chromium and Firefox, ${THEMES.length} themes at ${SIZES.length} widths`; if (failures.length) { - console.log(`FAILED [Unraid ${version}]: ${failures.length} of ${checks} browser checks, each listed above`); + console.log(`FAILED [Unraid ${version}]: ${failures.length} of ${checks} checks (${ALONE ? 'Unraid alone' : "FV3's pages"}), each listed above`); process.exit(1); } - console.log(`Unraid ${version}: FV3's pages in Chromium and Firefox, ${THEMES.length} themes at ${SIZES.length} widths, passed (${checks} checks)`); + console.log(`Unraid ${version}: ${what}, passed (${checks} checks)`); })().catch((e) => { console.log(`FAILED [Unraid ${version}]: ${e.message.split('\n')[0]}${failures.length ? ` (after ${failures.length} failed checks, listed above)` : ''}`); process.exit(1); diff --git a/.github/unraid-compat/browser_test.sh b/.github/unraid-compat/browser_test.sh index 7b41b87b..27783073 100644 --- a/.github/unraid-compat/browser_test.sh +++ b/.github/unraid-compat/browser_test.sh @@ -1,6 +1,6 @@ #!/bin/bash # FV3's pages in Chromium and Firefox: the fake Unraid in a container with no network, the browsers in one that joins its network. -# From the repo root, after npm ci here: browser_test.sh +# From the repo root, after npm ci here: browser_test.sh set -u image=$1; tree=$2; version=$3; shots=$4 # Renovate moves this with playwright-core in package.json: the driver only runs the browsers built for its own version @@ -26,9 +26,16 @@ token=$(docker exec "$fake" php -d auto_prepend_file= -r 'echo parse_ini_file("/ [ -n "$token" ] || fail "no csrf_token in the fake's var.ini" mkdir -p "$shots" || fail "cannot make $shots" -docker run --rm --network container:"$fake" --shm-size=1g --user "$(id -u):$(id -g)" -e HOME=/tmp \ - -v "$PWD:/repo:ro" -v "$(cd "$shots" && pwd):/shots" -w /repo/.github/unraid-compat "$browsers" node browser_test.js "$version" /shots "$token" -status=$? +browse() { docker run --rm --network container:"$fake" --shm-size=1g --user "$(id -u):$(id -g)" -e HOME=/tmp -v "$PWD:/repo:ro" \ + -v "$(cd "$shots" && pwd):/shots" -w /repo/.github/unraid-compat "$browsers" node browser_test.js "$version" /shots "$token" "$tree" "$@"; } +# Unraid alone first, with FV3's page hooks out of its plugin folder; FV3's pass then compares with what it measured +pages='folder.view3.Docker.page folder.view3.VMs.page folder.view3.Dashboard.page' +docker exec "$fake" bash -c "mkdir -p /run/fv3-off && cd /usr/local/emhttp/plugins/folder.view3 && mv $pages /run/fv3-off/" || fail "FV3's pages could not be moved aside" +# FV3's pass must never compare with an earlier run's measurements +rm -f "$shots/unraid-alone.json" +browse unraid-alone; status=$? +docker exec "$fake" bash -c 'mv /run/fv3-off/* /usr/local/emhttp/plugins/folder.view3/' || fail "FV3's pages could not be put back" +browse || status=1 # The logs hold what the pages asked of Unraid's PHP and the fakes, for every run above docker exec "$fake" php -d auto_prepend_file= -d display_errors=stderr .github/unraid-compat/fake_logs.php "$version" || status=1 exit $status diff --git a/.github/unraid-compat/hooks.js b/.github/unraid-compat/hooks.js new file mode 100644 index 00000000..b6445d80 --- /dev/null +++ b/.github/unraid-compat/hooks.js @@ -0,0 +1,94 @@ +// Unraid's own parts FV3 relies on: each names the FV3 file that uses it and what the user loses without it. browser_test.js +// checks each on Unraid alone, and that the file still mentions it. any: FV3 takes whichever exists; since: FV3 needs it only from there +'use strict'; +const D = 'Docker', V = 'VMs', B = 'Dashboard', ALL = 'any page'; +const HOOKS = [ + // Docker's list and its rows + { page: D, dom: '#docker_list > tr.sortable', file: 'scripts/docker.js', loses: 'folders never draw' }, + { page: D, dom: '#docker_containers > thead > tr > th', file: 'scripts/docker.js', loses: 'folder rows lose their column spans and widths' }, + { page: D, dom: '#docker_list td.ct-name > span.outer > span.hand > img.img', file: 'scripts/docker.js', loses: "folder previews show no containers' icons" }, + { page: D, dom: '#docker_list td.ct-name span.inner > span.appname > a.exec', file: 'scripts/docker.js', loses: 'containers are not read into their folders' }, + { page: D, dom: '#docker_list td.ct-name span.outer i[id^="load-"]', file: 'scripts/docker.js', loses: "folder icons stop showing their containers' state" }, + { page: D, dom: '#docker_list td.updatecolumn', file: 'scripts/shared.js', loses: 'incognito leaves version text showing' }, + { page: D, dom: '#docker_list td.advanced', file: 'scripts/docker.js', loses: "the folder autostart switch cannot find its containers' switches" }, + { page: D, dom: '#docker_list input.autostart', file: 'scripts/docker.js', loses: 'the folder autostart switch does nothing' }, + { page: D, dom: '.switch-button-background', file: 'scripts/docker.js', loses: 'the folder autostart switch is unstyled' }, + { page: D, dom: '#docker_containers th.nine', file: 'scripts/shared.js', loses: 'the autostart column is sized wrong' }, + { page: D, dom: '.advancedview', file: 'scripts/docker.js', loses: 'folders are not redrawn on the basic/advanced toggle' }, + { page: D, any: ['.js-actions', 'input[value="Add Container"]'], file: 'folder.view3.Docker.page', loses: 'no Add Folder button' }, + { page: D, dom: 'div.spinner.fixed', file: 'scripts/docker.js', loses: 'no spinner during folder actions' }, + // VMs' list and its rows + { page: V, dom: '#kvm_list > tr.sortable', file: 'scripts/vm.js', loses: 'folders never draw' }, + { page: V, dom: '#kvm_table > thead > tr', file: 'scripts/vm.js', loses: 'folder rows lose their column spans' }, + { page: V, dom: '#kvm_list td.vm-name span.outer span.inner a', file: 'scripts/vm.js', loses: 'VMs are not read into their folders' }, + { page: V, dom: '#kvm_list td.vm-name span.hand > img.img', file: 'scripts/vm.js', loses: "folder previews show no VMs' icons" }, + { page: V, dom: '#kvm_list tr[id^="name-"]', file: 'scripts/vm.js', loses: 'VM detail rows escape their folders' }, + { page: V, dom: '#kvm_list a[onclick*="toggle_id"]', file: 'scripts/vm.js', loses: 'VM detail rows escape their folders' }, + { page: V, dom: '#kvm_table th.th1', file: 'scripts/vm.js', loses: 'the name column is not sized' }, + { page: V, dom: '#kvm_list input.autostart', file: 'scripts/vm.js', loses: 'the folder autostart switch throws' }, + { page: V, any: ['.js-actions', 'input[value="Add VM"]'], file: 'folder.view3.VMs.page', loses: 'no Add Folder button' }, + // The Dashboard's tiles + { page: B, dom: 'tbody#docker_view > tr.updated > td', file: 'scripts/dashboard.js', loses: 'Docker folders never draw' }, + { page: B, dom: 'tbody#vm_view > tr.updated > td', file: 'scripts/dashboard.js', loses: 'VM folders never draw' }, + { page: B, dom: 'tbody#docker_view span.outer.solid.apps > span.hand', file: 'scripts/dashboard.js', loses: 'containers are not moved into folder tiles' }, + { page: B, dom: 'tbody#docker_view span.outer.apps > span.inner', file: 'scripts/dashboard.js', loses: "containers' names are not read" }, + { page: B, dom: 'tbody#vm_view span.outer.vms > span.hand', file: 'scripts/dashboard.js', loses: 'VMs are not moved into folder tiles' }, + { page: B, dom: 'input#apps', file: 'scripts/dashboard.js', loses: "hide-stopped ignores Docker folders" }, + { page: B, dom: 'input#vms', file: 'scripts/dashboard.js', loses: 'hide-stopped ignores VM folders' }, + { page: B, dom: 'table.dashboard', file: 'styles/dashboard.css', loses: 'folder tiles lose their padding' }, + // Every page + { page: ALL, dom: 'link[href*="default-base"]', since: '7.1', file: 'scripts/include/customEvents.js', loses: "FV3 styles the page as 7.0's layout" }, + // Classes FV3 puts on its own markup for Unraid's stylesheet to colour + { page: ALL, css: 'green-text', file: 'scripts/docker.js', loses: 'a started folder loses its green state' }, + { page: ALL, css: 'red-text', file: 'scripts/docker.js', loses: 'a stopped folder loses its red state' }, + { page: ALL, css: 'orange-text', file: 'scripts/docker.js', loses: "a folder's drag handle and update mark lose their colour" }, + // Unraid's functions and jQuery plugins + { page: D, js: 'loadlist', file: 'scripts/docker.js', loses: 'folders never draw' }, + { page: D, js: 'listview', file: 'scripts/docker.js', loses: 'folders are not redrawn after a view toggle' }, + { page: D, js: 'openDocker', file: 'scripts/docker.js', loses: "a folder's Update does nothing" }, + { page: D, js: 'openTerminal', file: 'scripts/docker.js', loses: 'the console and log buttons do nothing' }, + { page: D, js: 'dockerload', file: 'scripts/docker.js', loses: 'no CPU and memory stats without the Unraid API' }, + { page: V, js: 'loadlist', file: 'scripts/vm.js', loses: 'folders never draw' }, + { page: ALL, js: 'context.attach', file: 'scripts/docker.js', loses: 'folders have no menus' }, + { page: ALL, js: 'swal', file: 'scripts/shared.js', loses: 'no confirm or error dialogs' }, + { page: ALL, js: 'csrf_token', file: 'scripts/include/customEvents.js', loses: "every FV3 save is refused" }, + { page: ALL, js: '$.fn.tooltipster', file: 'scripts/advanced-preview.js', loses: 'no advanced preview' }, + { page: D, js: '$.fn.switchButton', file: 'scripts/docker.js', loses: 'the folder autostart switch never draws' }, + { page: D, js: '$.fn.sortable', file: 'scripts/docker.js', loses: 'folders cannot be dragged' }, + { page: D, js: '$.cookie', file: 'scripts/docker.js', loses: 'the advanced view is not detected' }, + { page: D, js: '$.fn.readmore', file: 'scripts/shared.js', loses: "an opened folder's long descriptions are not folded" }, + { page: ALL, js: 'openBox', file: 'scripts/shared.js', loses: "a folder's user script actions do nothing" }, + // Unraid's endpoints FV3 intercepts or calls, as files in the webGUI + { url: '/plugins/dynamix.docker.manager/include/UserPrefs.php', file: 'scripts/docker.js', loses: "Unraid saves an order without FV3's folders" }, + { url: '/plugins/dynamix.vm.manager/include/UserPrefs.php', file: 'scripts/vm.js', loses: "Unraid saves an order without FV3's folders" }, + { url: '/plugins/dynamix.vm.manager/include/VMMachines.php', file: 'scripts/vm.js', loses: 'folders are not redrawn when the VM list reloads' }, + { url: '/webGui/include/DashboardApps.php', file: 'scripts/dashboard.js', loses: 'Dashboard folders are not redrawn when the tiles reload' }, + { url: '/plugins/dynamix.docker.manager/include/UpdateConfig.php', file: 'scripts/docker.js', loses: 'folder autostart falls out of step' }, + { url: '/plugins/dynamix.docker.manager/include/DockerUpdate.php', file: 'scripts/docker.js', loses: 'folders are not redrawn after an update' }, + { url: '/plugins/dynamix.vm.manager/include/VMajax.php', file: 'scripts/shared.js', loses: 'VM folder actions fail' }, + { url: '/plugins/dynamix.vm.manager/vnc.html', file: 'scripts/vm.js', loses: "a folder member's VNC button does nothing" }, + { url: '/plugins/dynamix.docker.manager/images/question.png', file: 'scripts/docker.js', loses: 'folders without an icon show a broken image' }, +]; + +// What a hook's FV3 file must still mention: a selector's ids, classes and quoted values, a function's own name, a URL's file +const names = (h) => (h.js ? [h.js.replace(/^\$\.(fn\.)?/, '')] : h.url ? [h.url.split('/').pop()] : h.css ? [h.css] + : (h.any || [h.dom]).flatMap((s) => [...s.matchAll(/[#.]([\w-]+)|"([^"]+)"/g)].map((m) => m[1] || m[2]))); +const describe = (h) => h.dom || (h.any && `any of ${h.any.join(', ')}`) || (h.css && `a stylesheet rule for .${h.css}`) || h.url || `the global ${h.js}`; +const older = (a, b) => { const [x, y] = [a, b].map((v) => v.split('.').map(Number)); const i = x.findIndex((n, k) => n !== y[k]); return i >= 0 && x[i] < y[i]; }; +const applies = (h, version) => !h.since || !older(version, h.since); + +// In the page: the indexes of the hooks it lacks. Rules nested in @media count; a sheet that cannot be read counts as none +function missingHooks(hooks) { + const flat = (rules) => rules.flatMap((r) => (r.cssRules ? [r, ...flat([...r.cssRules])] : [r])); + const selectors = flat([...document.styleSheets].flatMap((s) => { try { return [...s.cssRules]; } catch { return []; } })) + .map((r) => r.selectorText || '').join('\n'); + const present = (h) => { + if (h.dom) return !!document.querySelector(h.dom); + if (h.any) return h.any.some((s) => document.querySelector(s)); + if (h.css) return new RegExp(`\\.${h.css}(?![\\w-])`).test(selectors); + try { return (0, eval)(`typeof ${h.js}`) !== 'undefined'; } catch { return false; } + }; + return hooks.map((h, i) => (present(h) ? -1 : i)).filter((i) => i >= 0); +} + +module.exports = { HOOKS, names, describe, applies, missingHooks }; diff --git a/.github/unraid-compat/layout.js b/.github/unraid-compat/layout.js new file mode 100644 index 00000000..a7d011a2 --- /dev/null +++ b/.github/unraid-compat/layout.js @@ -0,0 +1,58 @@ +// The layout rules browser_test.js checks once FV3 has opened a folder, each from a fix FV3 has shipped, read in the page +'use strict'; + +// Whether the page, and the table wrapper where only the table scrolls (7.2's .TableContainer), fit without scrolling sideways +function widths() { + const page = document.documentElement, table = document.querySelector('.TableContainer'); + const fits = (el) => el.scrollWidth <= el.clientWidth + 1; + const size = (el) => `${el.scrollWidth} of ${el.clientWidth} px`; + return { page: fits(page), table: table ? fits(table) : null, sizes: `page ${size(page)}${table ? `, table ${size(table)}` : ''}` }; +} + +// Each rule's failure, '' when it holds. A folder against a loose container on its page (Unraid's name element, a link only +// with a template): name no taller, row no taller than 1.5x; at desktop width, its preview on one line inside its cell +function layoutState({ page, desktop }) { + const { seen, name, members } = window.fv3Test; + const box = (el) => el.getBoundingClientRect(); + const tall = (node) => { const r = document.createRange(); r.selectNodeContents(node); return Math.round(r.getBoundingClientRect().height); }; + const shown = (label, nameEl, icon, other, loose) => [ + !nameEl || !seen(nameEl) ? `${label}'s name cannot be seen` : tall(nameEl) > 1.5 * tall(other) ? `${label}'s name is ${tall(nameEl)} px tall, ${loose}'s ${tall(other)} px` : '', + !icon || !seen(icon) ? `${label}'s icon cannot be seen` : !icon.complete || !icon.naturalWidth ? `${label}'s icon did not load` : '', + ].filter(Boolean); + const rules = { name: [] }; + + if (page === 'Dashboard') { + const tile = [...document.querySelectorAll('tbody#docker_view span.outer')].find((o) => !o.closest('.folder-showcase-outer') && seen(o) && name(o) === 'app-d'); + const otherName = tile?.querySelector('.inner > *'); + if (!otherName) return { error: "no app-d tile to compare folders' tiles with" }; + rules.card = []; + for (const folder of document.querySelectorAll('.folder-showcase-outer')) { + const label = folder.querySelector('.fv3-folder-appname')?.innerText.trim() || 'a folder'; + rules.name.push(...shown(label, folder.querySelector('.fv3-folder-appname'), folder.querySelector('img.fv3-folder-icon'), otherName, 'app-d')); + const card = box(folder.closest('tbody')); + const out = [folder.querySelector(':scope > span.outer'), ...members(folder)].filter((o) => o && seen(o)).filter((o) => box(o).left < card.left - 1 || box(o).right > card.right + 1); + if (out.length) rules.card.push(`${label}'s ${out.map((o) => name(o) || 'tile').join(', ')} leave the card (${Math.round(card.left)}-${Math.round(card.right)})`); + } + } else { + const [list, cell, loose] = page === 'Docker' ? ['docker_list', 'ct-name', 'app-d'] : ['kvm_list', 'vm-name', 'Home Assistant']; + const rows = [...document.querySelectorAll(`#${list} > tr`)].filter(seen); + const other = rows.find((r) => !r.classList.contains('folder') && r.querySelector(`td.${cell} span.outer`) && name(r.querySelector(`td.${cell} span.outer`)) === loose); + const otherName = other?.querySelector(`td.${cell} span.inner > *`); + if (!otherName) return { error: `no ${loose} row to compare folders with` }; + rules.height = []; + if (desktop) rules.preview = []; + for (const row of rows.filter((r) => r.classList.contains('folder'))) { + const label = row.querySelector('a.folder-appname')?.innerText.trim() || 'a folder'; + rules.name.push(...shown(label, row.querySelector('a.folder-appname'), row.querySelector('img.folder-img'), otherName, loose)); + if (box(row).height > 1.5 * box(other).height) rules.height.push(`${label}'s row is ${Math.round(box(row).height)} px tall, ${loose}'s ${Math.round(box(other).height)} px`); + const items = [...row.querySelectorAll('.folder-preview span.outer')].filter(seen); + if (!desktop || !items.length) continue; + const c = box(row.querySelector('.folder-preview').closest('td')), top = box(items[0]).top; + const off = items.filter((i) => Math.abs(box(i).top - top) > 2 || box(i).left < c.left - 1 || box(i).right > c.right + 1); + if (off.length) rules.preview.push(`${label}'s preview wraps or leaves its cell at ${off.map(name).join(', ')}`); + } + } + return { rules: Object.fromEntries(Object.entries(rules).map(([rule, problems]) => [rule, problems.join('; ')])) }; +} + +module.exports = { widths, layoutState }; From 7c633914224779dde1f8f159fbfdd9cc04a9cf4a Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 12:49:39 +0800 Subject: [PATCH 02/13] ci: the Unraid-alone pass reads nothing from a page that never drew, hooks must be named as whole tokens, and a missing measurement fails only the width check --- .github/unraid-compat/browser_test.js | 17 +++++++++-------- .github/unraid-compat/hooks.js | 21 +++++++++++++-------- .github/unraid-compat/layout.js | 2 +- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index ce2ada0d..e44f071b 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -4,7 +4,7 @@ const fs = require('fs'); const path = require('path'); const { chromium, firefox } = require('playwright-core'); -const { HOOKS, names, describe, applies, missingHooks } = require('./hooks'); +const { HOOKS, tokens, mentions, describe, applies, missingHooks } = require('./hooks'); const { widths, layoutState } = require('./layout'); const [version, shots, fakeToken, tree, mode = 'fv3'] = process.argv.slice(2); @@ -220,7 +220,7 @@ const VIEW_LIMIT = 90000; // One page in one browser, theme and width, through one pass's steps; false when it ended before the page drew async function view(browser, kind, theme, [width, height], page, steps) { - const v = { where: `${kind} ${theme} ${width}px ${page}`, file: `${shots}/${kind}/${theme}-${width}-${page}`, theme, width, page, drew: false }; + const v = { where: `${kind} ${theme} ${width}px ${page}`, file: `${shots}/${kind}/${theme}-${width}-${page}${ALONE ? '-unraid-alone' : ''}`, theme, width, page, drew: false }; const { where, file } = v; const errors = []; let context, tab, timer; @@ -258,7 +258,7 @@ const measured = {}, lacking = new Map(); async function aloneSteps(tab, v) { await load(tab, v); v.drew = await tab.waitForSelector(LISTED[v.page], { timeout: 20000 }).then(() => true, () => false); - check(v.drew, `${v.where}: Unraid alone drew no ${LISTED[v.page]} within 20 s`); + if (!check(v.drew, `${v.where}: Unraid alone drew no ${LISTED[v.page]} within 20 s, so its hooks and widths were not read`)) return; measured[v.where] = await settled(tab, widths); const hooks = HOOKS.filter((h) => !h.url && [v.page, 'any page'].includes(h.page) && applies(h, version)); for (const i of await settled(tab, missingHooks, hooks)) lacking.set(hooks[i], [...(lacking.get(hooks[i]) || []), v.where]); @@ -288,8 +288,8 @@ async function fv3Steps(tab, v) { for (const problem of Object.values(layout.rules)) check(!problem, `${where}: ${problem}`); // Where Unraid alone already scrolls sideways (both tables at tablet and phone widths), FV3 may be wider const now = await tab.evaluate(widths), was = measured[where]; - check(was && (!was.page || now.page) && (was.table !== true || now.table), - `${where}: FV3 adds sideways scrolling Unraid alone does not have: ${now.sizes} (Unraid alone ${was?.sizes ?? 'not measured'})`); + if (was) check((!was.page || now.page) && (was.table !== true || now.table), `${where}: FV3 adds sideways scrolling Unraid alone does not have: ${now.sizes} (Unraid alone ${was.sizes})`); + else if (Object.keys(measured).length) check(false, `${where}: widths not compared, the Unraid-alone pass did not measure this view`); await tab.screenshot({ path: `${file}.png`, fullPage: true }); if (PREVIEW[page]) { await press(tab.locator(PREVIEW[page]).first(), `${PREVIEWED}'s preview icon`); @@ -333,7 +333,7 @@ async function fv3Setup(request, token) { function hookChecks(webgui) { for (const h of HOOKS) { const text = fs.existsSync(`${plugin}/${h.file}`) ? fs.readFileSync(`${plugin}/${h.file}`, 'utf8') : null; - const gone = text === null ? [h.file] : names(h).filter((n) => !text.includes(n)); + const gone = text === null ? [h.file] : tokens(h).filter((t) => !mentions(text, t)); check(!gone.length, `hooks.js names ${h.file} for ${describe(h)}, but FV3 no longer has ${gone.join(', ')} there`); } for (const [h, where] of lacking) check(false, `Unraid ${version} lacks ${describe(h)} on ${h.page} (${where.length} views, first ${where[0]}), which ${h.file} needs: ${h.loses}`); @@ -343,7 +343,7 @@ function hookChecks(webgui) { (async () => { const webgui = path.resolve(__dirname, '../..', tree || ''); if (!fs.existsSync('/.dockerenv') || !fakeToken || !fs.existsSync(`${webgui}/emhttp`)) { console.error('Run browser_test.sh: this needs the fake Unraid it starts and its webGUI tree'); process.exit(2); } - check(!fv3Unload.length, `FV3 adds an unload handler, which Chromium never runs: ${fv3Unload.join(', ')}`); + if (!ALONE) check(!fv3Unload.length, `FV3 adds an unload handler, which Chromium never runs: ${fv3Unload.join(', ')}`); const browsers = { chromium: await chromium.launch(), firefox: await firefox.launch() }; const setup = await browsers.chromium.newContext(); const tab = await setup.newPage(); @@ -353,7 +353,8 @@ function hookChecks(webgui) { const token = await tab.evaluate(() => typeof csrf_token === 'string' ? csrf_token : ''); if (token !== fakeToken) { console.error(`127.0.0.1 is not the fake Unraid browser_test.sh started (token "${token}")`); process.exit(2); } if (!ALONE) { - try { Object.assign(measured, JSON.parse(fs.readFileSync(MEASURED, 'utf8'))); } catch (e) { throw new Error(`the Unraid-alone pass left no measurements: ${e.message}`); } + // Without them only the width comparison is lost; FV3's pass still runs + try { Object.assign(measured, JSON.parse(fs.readFileSync(MEASURED, 'utf8'))); } catch (e) { check(false, `the Unraid-alone pass left no measurements, so no widths are compared: ${e.message}`); } await fv3Setup(setup.request, token); } let undrawn = 0; diff --git a/.github/unraid-compat/hooks.js b/.github/unraid-compat/hooks.js index b6445d80..c67a801e 100644 --- a/.github/unraid-compat/hooks.js +++ b/.github/unraid-compat/hooks.js @@ -9,7 +9,7 @@ const HOOKS = [ { page: D, dom: '#docker_list td.ct-name > span.outer > span.hand > img.img', file: 'scripts/docker.js', loses: "folder previews show no containers' icons" }, { page: D, dom: '#docker_list td.ct-name span.inner > span.appname > a.exec', file: 'scripts/docker.js', loses: 'containers are not read into their folders' }, { page: D, dom: '#docker_list td.ct-name span.outer i[id^="load-"]', file: 'scripts/docker.js', loses: "folder icons stop showing their containers' state" }, - { page: D, dom: '#docker_list td.updatecolumn', file: 'scripts/shared.js', loses: 'incognito leaves version text showing' }, + { page: D, dom: 'td.updatecolumn', file: 'scripts/shared.js', loses: 'incognito leaves version text showing' }, { page: D, dom: '#docker_list td.advanced', file: 'scripts/docker.js', loses: "the folder autostart switch cannot find its containers' switches" }, { page: D, dom: '#docker_list input.autostart', file: 'scripts/docker.js', loses: 'the folder autostart switch does nothing' }, { page: D, dom: '.switch-button-background', file: 'scripts/docker.js', loses: 'the folder autostart switch is unstyled' }, @@ -70,17 +70,22 @@ const HOOKS = [ { url: '/plugins/dynamix.docker.manager/images/question.png', file: 'scripts/docker.js', loses: 'folders without an icon show a broken image' }, ]; -// What a hook's FV3 file must still mention: a selector's ids, classes and quoted values, a function's own name, a URL's file -const names = (h) => (h.js ? [h.js.replace(/^\$\.(fn\.)?/, '')] : h.url ? [h.url.split('/').pop()] : h.css ? [h.css] - : (h.any || [h.dom]).flatMap((s) => [...s.matchAll(/[#.]([\w-]+)|"([^"]+)"/g)].map((m) => m[1] || m[2]))); +// What a hook's FV3 file must still mention: a selector's #ids, .classes and quoted values, a function's name, a URL's file +const tokens = (h) => (h.js ? [h.js.startsWith('$.fn.') ? h.js.slice(4) : h.js] : h.url ? [h.url.split('/').pop()] : h.css ? [h.css] + : (h.any || [h.dom]).flatMap((s) => [...s.matchAll(/([#.][\w-]+)|"([^"]+)"/g)].map((m) => m[1] || m[2]))); +const esc = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +// As a whole token (a #id or .class starts at its mark); a class may also be named in a class attribute or as a quoted string +const mentions = (text, t) => new RegExp(`${/^[#.]/.test(t) ? '' : '(? h.dom || (h.any && `any of ${h.any.join(', ')}`) || (h.css && `a stylesheet rule for .${h.css}`) || h.url || `the global ${h.js}`; const older = (a, b) => { const [x, y] = [a, b].map((v) => v.split('.').map(Number)); const i = x.findIndex((n, k) => n !== y[k]); return i >= 0 && x[i] < y[i]; }; const applies = (h, version) => !h.since || !older(version, h.since); -// In the page: the indexes of the hooks it lacks. Rules nested in @media count; a sheet that cannot be read counts as none +// In the page: the indexes of the hooks it lacks. Rules in @media and @import count; a sheet that cannot be read counts as none function missingHooks(hooks) { - const flat = (rules) => rules.flatMap((r) => (r.cssRules ? [r, ...flat([...r.cssRules])] : [r])); - const selectors = flat([...document.styleSheets].flatMap((s) => { try { return [...s.cssRules]; } catch { return []; } })) + const own = (sheet) => { try { return [...sheet.cssRules]; } catch { return []; } }; + const flat = (rules) => rules.flatMap((r) => (r.styleSheet ? flat(own(r.styleSheet)) : r.cssRules ? [r, ...flat([...r.cssRules])] : [r])); + const selectors = flat([...document.styleSheets].flatMap(own)) .map((r) => r.selectorText || '').join('\n'); const present = (h) => { if (h.dom) return !!document.querySelector(h.dom); @@ -91,4 +96,4 @@ function missingHooks(hooks) { return hooks.map((h, i) => (present(h) ? -1 : i)).filter((i) => i >= 0); } -module.exports = { HOOKS, names, describe, applies, missingHooks }; +module.exports = { HOOKS, tokens, mentions, describe, applies, missingHooks }; diff --git a/.github/unraid-compat/layout.js b/.github/unraid-compat/layout.js index a7d011a2..9dc27db5 100644 --- a/.github/unraid-compat/layout.js +++ b/.github/unraid-compat/layout.js @@ -10,7 +10,7 @@ function widths() { } // Each rule's failure, '' when it holds. A folder against a loose container on its page (Unraid's name element, a link only -// with a template): name no taller, row no taller than 1.5x; at desktop width, its preview on one line inside its cell +// with a template): name and row no taller than 1.5x theirs; at desktop width, its preview on one line inside its cell function layoutState({ page, desktop }) { const { seen, name, members } = window.fv3Test; const box = (el) => el.getBoundingClientRect(); From c4d56e1449d611f3a5e0bc8d55eedb8d2e7f145b Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 13:11:47 +0800 Subject: [PATCH 03/13] ci: the Dashboard opens Lab too, Unraid alone must be without FV3, and an endpoint FV3 intercepts must still be called by Unraid's pages --- .coderabbit.yaml | 7 ++- .github/unraid-compat/browser_test.js | 84 ++++++++++++++++----------- .github/unraid-compat/browser_test.sh | 5 +- .github/unraid-compat/hooks.js | 26 +++++---- 4 files changed, 70 insertions(+), 52 deletions(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 42e6488d..ad04c22e 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -241,9 +241,10 @@ reviews: browser_test.sh checks. - browser_test.sh runs an Unraid-alone pass first, FV3's three page hooks moved out of its plugin folder. It checks hooks.js, a - hand-written list of Unraid's DOM hooks, functions and endpoints - FV3 relies on, each naming the FV3 file that still mentions it and - what the user loses; any/since only where FV3 itself branches. + hand-written list of Unraid's DOM hooks, functions, stylesheet + classes and endpoints FV3 relies on, each naming the FV3 file that + still mentions it and what the user loses; any/since only where + FV3 itself branches. layout.js holds the layout rules FV3's pass checks against that pass and a loose container on the same page, each from a fix FV3 has shipped. diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index e44f071b..51546085 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -4,7 +4,7 @@ const fs = require('fs'); const path = require('path'); const { chromium, firefox } = require('playwright-core'); -const { HOOKS, tokens, mentions, describe, applies, missingHooks } = require('./hooks'); +const { HOOKS, tokens, mentions, describe, applies, forView, missingHooks } = require('./hooks'); const { widths, layoutState } = require('./layout'); const [version, shots, fakeToken, tree, mode = 'fv3'] = process.argv.slice(2); @@ -14,7 +14,8 @@ const MEASURED = `${shots}/unraid-alone.json`; const base = 'http://127.0.0.1'; const failures = []; let checks = 0; -// Each failure prints as it happens, so a run the step's time limit kills still shows what failed +// Each failure prints as it happens, so a run the step's time limit kills still shows what failed; a missing hook prints once the +// views end, as one line for all its views const check = (ok, what) => { checks++; if (!ok) { failures.push(what); console.log(`- ${what}`); } return ok; }; const same = (got, want) => JSON.stringify(got) === JSON.stringify(want); @@ -82,18 +83,21 @@ const WANT = { }, Dashboard: { shut: { docker: [`${SPARE} [] shows []`, 'Media [app-a, app-b] shows []', 'Tools [tool-c] shows []', 'app-d'], vms: ['Lab [Debian 12] shows []', 'Home Assistant', 'Windows 11'] }, - open: { docker: [`${SPARE} [] shows []`, 'Media [app-a, app-b] shows [app-a, app-b]', 'Tools [tool-c] shows []', 'app-d'], vms: ['Lab [Debian 12] shows []', 'Home Assistant', 'Windows 11'] }, + open: { docker: [`${SPARE} [] shows []`, 'Media [app-a, app-b] shows [app-a, app-b]', 'Tools [tool-c] shows []', 'app-d'], vms: ['Lab [Debian 12] shows [Debian 12]', 'Home Assistant', 'Windows 11'] }, }, }; -// FV3's events for a finished draw; the folder each page opens, its event when open, and how a user opens it +// FV3's events for a finished draw; the folders each page opens, their events once open, and how a user opens them const DRAWN = { Docker: ['docker-post-folders-creation'], VMs: ['vm-post-folders-creation'], Dashboard: ['docker-post-folders-creation', 'vm-post-folders-creation'] }; const OPEN = { - Docker: ['Media', 'docker-post-folder-expansion', (p) => press(p.locator(`button.dropDown-${MEDIA}`), "Media's chevron")], - VMs: ['Lab', 'vm-post-folder-expansion', (p) => press(p.locator(`button.dropDown-${LAB}`), "Lab's chevron")], - // The tile's menu, the item FV3's lang pack labels 'expand' - Dashboard: ['Media', 'docker-post-folder-expansion', async (p) => { - await press(p.locator(`#folder-id-${MEDIA}`), "Media's tile"); - await press(p.locator('ul.dropdown-context:visible li > a', { hasText: await p.evaluate(() => $.i18n('expand')) }), "its menu's Expand"); + Docker: ['Media', ['docker-post-folder-expansion'], (p) => press(p.locator(`button.dropDown-${MEDIA}`), "Media's chevron")], + VMs: ['Lab', ['vm-post-folder-expansion'], (p) => press(p.locator(`button.dropDown-${LAB}`), "Lab's chevron")], + // Each by its tile's menu, the item FV3's lang pack labels 'expand': Media on the Docker card, Lab on the VM card + Dashboard: ['Media and Lab', ['docker-post-folder-expansion', 'vm-post-folder-expansion'], async (p) => { + const expand = await p.evaluate(() => $.i18n('expand')); + for (const [id, folder] of [[MEDIA, 'Media'], [LAB, 'Lab']]) { + await press(p.locator(`#folder-id-${id}`), `${folder}'s tile`); + await press(p.locator('ul.dropdown-context:visible li > a', { hasText: expand }), `${folder}'s menu's Expand`); + } }], }; // FV3's Dashboard layouts for the Docker and VM cards in each theme, so every layout is drawn at every width @@ -257,14 +261,17 @@ async function load(tab, { where, page, theme }) { const measured = {}, lacking = new Map(); async function aloneSteps(tab, v) { await load(tab, v); + // An FV3 page hook left in place would compare FV3 with itself + const fv3 = await tab.$('script[src*="/plugins/folder.view3/"], link[href*="/plugins/folder.view3/"]'); + if (!check(!fv3, `${v.where}: FV3 is on the page, so this is not Unraid alone and nothing was read`)) return; v.drew = await tab.waitForSelector(LISTED[v.page], { timeout: 20000 }).then(() => true, () => false); if (!check(v.drew, `${v.where}: Unraid alone drew no ${LISTED[v.page]} within 20 s, so its hooks and widths were not read`)) return; measured[v.where] = await settled(tab, widths); - const hooks = HOOKS.filter((h) => !h.url && [v.page, 'any page'].includes(h.page) && applies(h, version)); + const hooks = forView(v.page, version); for (const i of await settled(tab, missingHooks, hooks)) lacking.set(hooks[i], [...(lacking.get(hooks[i]) || []), v.where]); } -// FV3's pass: drawn in the saved order, a folder opened as a user opens it, the layout rules, the advanced preview, no banners +// FV3's pass: drawn in the saved order, folders opened as a user opens them, the layout rules, the advanced preview, no banners async function fv3Steps(tab, v) { const { where, file, page, width } = v; await load(tab, v); @@ -280,13 +287,13 @@ async function fv3Steps(tab, v) { check(same(got, WANT[page].shut), `${where}: drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].shut)}`); const [folder, opened, open] = OPEN[page]; await open(tab); - await waitEvents(tab, [opened]).catch(() => { throw new Error(`${folder} did not open within 20 s (${opened})`); }); + await waitEvents(tab, opened).catch(() => { throw new Error(`${folder} did not open within 20 s (${opened.join(', ')})`); }); got = await settled(tab, READ[page]); check(same(got, WANT[page].open), `${where}: with ${folder} open, drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].open)}`); const layout = await settled(tab, layoutState, { page, desktop: width === SIZES[0][0] }); if (layout.error) throw new Error(layout.error); for (const problem of Object.values(layout.rules)) check(!problem, `${where}: ${problem}`); - // Where Unraid alone already scrolls sideways (both tables at tablet and phone widths), FV3 may be wider + // Only where Unraid alone fits: where it already scrolls sideways, FV3 may be wider const now = await tab.evaluate(widths), was = measured[where]; if (was) check((!was.page || now.page) && (was.table !== true || now.table), `${where}: FV3 adds sideways scrolling Unraid alone does not have: ${now.sizes} (Unraid alone ${was.sizes})`); else if (Object.keys(measured).length) check(false, `${where}: widths not compared, the Unraid-alone pass did not measure this view`); @@ -329,15 +336,21 @@ async function fv3Setup(request, token) { content: JSON.stringify({ name: SPARE, icon: '', regex: '', containers: [], settings: { preview: 1 }, actions: [] }) }, 'the empty folder'); } -// Each hook's FV3 file still mentions it; each missing hook once, with the views it was missing from. An endpoint is a webGUI file -function hookChecks(webgui) { +// Before the views: each hook's FV3 file still mentions it, and each endpoint is a webGUI file, called from Unraid's pages +// where FV3 intercepts it +function hookFiles(webgui) { for (const h of HOOKS) { const text = fs.existsSync(`${plugin}/${h.file}`) ? fs.readFileSync(`${plugin}/${h.file}`, 'utf8') : null; const gone = text === null ? [h.file] : tokens(h).filter((t) => !mentions(text, t)); check(!gone.length, `hooks.js names ${h.file} for ${describe(h)}, but FV3 no longer has ${gone.join(', ')} there`); } - for (const [h, where] of lacking) check(false, `Unraid ${version} lacks ${describe(h)} on ${h.page} (${where.length} views, first ${where[0]}), which ${h.file} needs: ${h.loses}`); - for (const h of HOOKS.filter((x) => x.url)) check(fs.existsSync(path.join(webgui, 'emhttp', h.url)), `Unraid ${version} lacks ${h.url}, which ${h.file} needs: ${h.loses}`); + const plugins = `${webgui}/emhttp/plugins`; + const pages = fs.readdirSync(plugins, { recursive: true }).filter((f) => /\.(page|php|js)$/.test(f)).map((f) => [`/plugins/${f}`, fs.readFileSync(`${plugins}/${f}`, 'utf8')]); + for (const h of HOOKS.filter((x) => x.url)) { + const file = h.url.replace(/^\/webGui\//, '/plugins/dynamix/'); + if (!check(fs.existsSync(`${webgui}/emhttp${file}`), `Unraid ${version} lacks ${h.url}, which ${h.file} needs: ${h.loses}`) || !h.intercepts) continue; + check(pages.some(([f, text]) => f !== file && text.includes(h.url)), `Unraid ${version}'s pages no longer call ${h.url}, which ${h.file} intercepts: ${h.loses}`); + } } (async () => { @@ -357,28 +370,31 @@ function hookChecks(webgui) { try { Object.assign(measured, JSON.parse(fs.readFileSync(MEASURED, 'utf8'))); } catch (e) { check(false, `the Unraid-alone pass left no measurements, so no widths are compared: ${e.message}`); } await fv3Setup(setup.request, token); } + if (ALONE) hookFiles(webgui); let undrawn = 0; - for (const [i, theme] of THEMES.entries()) { - // As Unraid's Display Settings saves it - await post(setup.request, '/update.php', { '#file': 'dynamix/dynamix.cfg', '#section': 'display', theme, csrf_token: token }, `the ${theme} theme`); - if (!ALONE) for (const [card, layout] of [['docker', LAYOUTS[i][0]], ['vm', LAYOUTS[i][1]]]) { - await post(setup.request, '/plugins/folder.view3/server/update_settings.php', { key: `dashboard_${card}_layout`, value: layout, csrf_token: token }, `the Dashboard's ${layout} ${card} card`); - } - for (const [kind, browser] of Object.entries(browsers)) { - fs.mkdirSync(`${shots}/${kind}`, { recursive: true }); - for (const size of SIZES) for (const page of ['Docker', 'VMs', 'Dashboard']) { - undrawn = (await view(browser, kind, theme, size, page, ALONE ? aloneSteps : fv3Steps)) ? 0 : undrawn + 1; - if (undrawn === 3) throw new Error(`3 views in a row ended before ${ALONE ? 'Unraid' : 'FV3'} drew, so the rest were not run`); + try { + for (const [i, theme] of THEMES.entries()) { + // As Unraid's Display Settings saves it + await post(setup.request, '/update.php', { '#file': 'dynamix/dynamix.cfg', '#section': 'display', theme, csrf_token: token }, `the ${theme} theme`); + if (!ALONE) for (const [card, layout] of [['docker', LAYOUTS[i][0]], ['vm', LAYOUTS[i][1]]]) { + await post(setup.request, '/plugins/folder.view3/server/update_settings.php', { key: `dashboard_${card}_layout`, value: layout, csrf_token: token }, `the Dashboard's ${layout} ${card} card`); + } + for (const [kind, browser] of Object.entries(browsers)) { + fs.mkdirSync(`${shots}/${kind}`, { recursive: true }); + for (const size of SIZES) for (const page of ['Docker', 'VMs', 'Dashboard']) { + undrawn = (await view(browser, kind, theme, size, page, ALONE ? aloneSteps : fv3Steps)) ? 0 : undrawn + 1; + if (undrawn === 3) throw new Error(`3 views in a row ended before ${ALONE ? 'Unraid' : 'FV3'} drew, so the rest were not run`); + } } } + } finally { + // Each missing hook once, with the views it was missing from, also when the run stops early + for (const [h, where] of lacking) check(false, `Unraid ${version} lacks ${describe(h)} on ${h.page} (${where.length} views, first ${where[0]}), which ${h.file} needs: ${h.loses}`); } await setup.close(); for (const browser of Object.values(browsers)) await browser.close(); - if (ALONE) { - hookChecks(webgui); - fs.writeFileSync(MEASURED, JSON.stringify(measured)); - } - const what = ALONE ? `Unraid alone has the ${HOOKS.length} hooks FV3 relies on, ${THEMES.length} themes at ${SIZES.length} widths in Chromium and Firefox` + if (ALONE) fs.writeFileSync(MEASURED, JSON.stringify(measured)); + const what = ALONE ? `Unraid alone has the ${HOOKS.filter((h) => applies(h, version)).length} hooks FV3 relies on, ${THEMES.length} themes at ${SIZES.length} widths in Chromium and Firefox` : `FV3's pages in Chromium and Firefox, ${THEMES.length} themes at ${SIZES.length} widths`; if (failures.length) { console.log(`FAILED [Unraid ${version}]: ${failures.length} of ${checks} checks (${ALONE ? 'Unraid alone' : "FV3's pages"}), each listed above`); diff --git a/.github/unraid-compat/browser_test.sh b/.github/unraid-compat/browser_test.sh index 27783073..fa44c2ee 100644 --- a/.github/unraid-compat/browser_test.sh +++ b/.github/unraid-compat/browser_test.sh @@ -28,9 +28,8 @@ token=$(docker exec "$fake" php -d auto_prepend_file= -r 'echo parse_ini_file("/ mkdir -p "$shots" || fail "cannot make $shots" browse() { docker run --rm --network container:"$fake" --shm-size=1g --user "$(id -u):$(id -g)" -e HOME=/tmp -v "$PWD:/repo:ro" \ -v "$(cd "$shots" && pwd):/shots" -w /repo/.github/unraid-compat "$browsers" node browser_test.js "$version" /shots "$token" "$tree" "$@"; } -# Unraid alone first, with FV3's page hooks out of its plugin folder; FV3's pass then compares with what it measured -pages='folder.view3.Docker.page folder.view3.VMs.page folder.view3.Dashboard.page' -docker exec "$fake" bash -c "mkdir -p /run/fv3-off && cd /usr/local/emhttp/plugins/folder.view3 && mv $pages /run/fv3-off/" || fail "FV3's pages could not be moved aside" +# Unraid alone first, with FV3's page hooks (folder.view3..page) out of its plugin folder; FV3's pass then compares with it +docker exec "$fake" bash -c 'mkdir -p /run/fv3-off && mv /usr/local/emhttp/plugins/folder.view3/folder.view3.*.page /run/fv3-off/' || fail "FV3's pages could not be moved aside" # FV3's pass must never compare with an earlier run's measurements rm -f "$shots/unraid-alone.json" browse unraid-alone; status=$? diff --git a/.github/unraid-compat/hooks.js b/.github/unraid-compat/hooks.js index c67a801e..9fc787de 100644 --- a/.github/unraid-compat/hooks.js +++ b/.github/unraid-compat/hooks.js @@ -1,5 +1,5 @@ -// Unraid's own parts FV3 relies on: each names the FV3 file that uses it and what the user loses without it. browser_test.js -// checks each on Unraid alone, and that the file still mentions it. any: FV3 takes whichever exists; since: FV3 needs it only from there +// Unraid's own parts FV3 relies on, each with the FV3 file that uses it and what the user loses without it. browser_test.js checks +// them on Unraid alone (endpoints as webGUI files), each file still naming its hook; any/since only where FV3 itself branches 'use strict'; const D = 'Docker', V = 'VMs', B = 'Dashboard', ALL = 'any page'; const HOOKS = [ @@ -12,7 +12,7 @@ const HOOKS = [ { page: D, dom: 'td.updatecolumn', file: 'scripts/shared.js', loses: 'incognito leaves version text showing' }, { page: D, dom: '#docker_list td.advanced', file: 'scripts/docker.js', loses: "the folder autostart switch cannot find its containers' switches" }, { page: D, dom: '#docker_list input.autostart', file: 'scripts/docker.js', loses: 'the folder autostart switch does nothing' }, - { page: D, dom: '.switch-button-background', file: 'scripts/docker.js', loses: 'the folder autostart switch is unstyled' }, + { page: D, dom: '.switch-button-background', file: 'scripts/docker.js', loses: "the folder autostart switch leaves its members' switches unchanged" }, { page: D, dom: '#docker_containers th.nine', file: 'scripts/shared.js', loses: 'the autostart column is sized wrong' }, { page: D, dom: '.advancedview', file: 'scripts/docker.js', loses: 'folders are not redrawn on the basic/advanced toggle' }, { page: D, any: ['.js-actions', 'input[value="Add Container"]'], file: 'folder.view3.Docker.page', loses: 'no Add Folder button' }, @@ -55,16 +55,16 @@ const HOOKS = [ { page: ALL, js: '$.fn.tooltipster', file: 'scripts/advanced-preview.js', loses: 'no advanced preview' }, { page: D, js: '$.fn.switchButton', file: 'scripts/docker.js', loses: 'the folder autostart switch never draws' }, { page: D, js: '$.fn.sortable', file: 'scripts/docker.js', loses: 'folders cannot be dragged' }, - { page: D, js: '$.cookie', file: 'scripts/docker.js', loses: 'the advanced view is not detected' }, + { page: D, js: '$.cookie', file: 'scripts/docker.js', loses: 'docker.js stops at load, so folders never draw' }, { page: D, js: '$.fn.readmore', file: 'scripts/shared.js', loses: "an opened folder's long descriptions are not folded" }, { page: ALL, js: 'openBox', file: 'scripts/shared.js', loses: "a folder's user script actions do nothing" }, - // Unraid's endpoints FV3 intercepts or calls, as files in the webGUI - { url: '/plugins/dynamix.docker.manager/include/UserPrefs.php', file: 'scripts/docker.js', loses: "Unraid saves an order without FV3's folders" }, - { url: '/plugins/dynamix.vm.manager/include/UserPrefs.php', file: 'scripts/vm.js', loses: "Unraid saves an order without FV3's folders" }, - { url: '/plugins/dynamix.vm.manager/include/VMMachines.php', file: 'scripts/vm.js', loses: 'folders are not redrawn when the VM list reloads' }, - { url: '/webGui/include/DashboardApps.php', file: 'scripts/dashboard.js', loses: 'Dashboard folders are not redrawn when the tiles reload' }, - { url: '/plugins/dynamix.docker.manager/include/UpdateConfig.php', file: 'scripts/docker.js', loses: 'folder autostart falls out of step' }, - { url: '/plugins/dynamix.docker.manager/include/DockerUpdate.php', file: 'scripts/docker.js', loses: 'folders are not redrawn after an update' }, + // Unraid's endpoints FV3 calls, as files in the webGUI; one it intercepts must also still be called from Unraid's pages + { url: '/plugins/dynamix.docker.manager/include/UserPrefs.php', intercepts: true, file: 'scripts/docker.js', loses: "Unraid saves an order without FV3's folders" }, + { url: '/plugins/dynamix.vm.manager/include/UserPrefs.php', intercepts: true, file: 'scripts/vm.js', loses: "Unraid saves an order without FV3's folders" }, + { url: '/plugins/dynamix.vm.manager/include/VMMachines.php', intercepts: true, file: 'scripts/vm.js', loses: 'folders are not redrawn when the VM list reloads' }, + { url: '/webGui/include/DashboardApps.php', intercepts: true, file: 'scripts/dashboard.js', loses: 'Dashboard folders are not redrawn when the tiles reload' }, + { url: '/plugins/dynamix.docker.manager/include/UpdateConfig.php', intercepts: true, file: 'scripts/docker.js', loses: 'folder autostart falls out of step' }, + { url: '/plugins/dynamix.docker.manager/include/DockerUpdate.php', intercepts: true, file: 'scripts/docker.js', loses: 'folders are not redrawn after an update' }, { url: '/plugins/dynamix.vm.manager/include/VMajax.php', file: 'scripts/shared.js', loses: 'VM folder actions fail' }, { url: '/plugins/dynamix.vm.manager/vnc.html', file: 'scripts/vm.js', loses: "a folder member's VNC button does nothing" }, { url: '/plugins/dynamix.docker.manager/images/question.png', file: 'scripts/docker.js', loses: 'folders without an icon show a broken image' }, @@ -80,6 +80,8 @@ const mentions = (text, t) => new RegExp(`${/^[#.]/.test(t) ? '' : '(? h.dom || (h.any && `any of ${h.any.join(', ')}`) || (h.css && `a stylesheet rule for .${h.css}`) || h.url || `the global ${h.js}`; const older = (a, b) => { const [x, y] = [a, b].map((v) => v.split('.').map(Number)); const i = x.findIndex((n, k) => n !== y[k]); return i >= 0 && x[i] < y[i]; }; const applies = (h, version) => !h.since || !older(version, h.since); +// The hooks one view checks: its page's and every page's that apply to this version (endpoints are checked as files) +const forView = (page, version) => HOOKS.filter((h) => !h.url && [page, ALL].includes(h.page) && applies(h, version)); // In the page: the indexes of the hooks it lacks. Rules in @media and @import count; a sheet that cannot be read counts as none function missingHooks(hooks) { @@ -96,4 +98,4 @@ function missingHooks(hooks) { return hooks.map((h, i) => (present(h) ? -1 : i)).filter((i) => i >= 0); } -module.exports = { HOOKS, tokens, mentions, describe, applies, missingHooks }; +module.exports = { HOOKS, tokens, mentions, describe, applies, forView, missingHooks }; From 0bfe2b763582250307f83cb5c9302df6ce193e1c Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 14:43:03 +0800 Subject: [PATCH 04/13] ci: a Dashboard folder's menu waits for the last one to close, and a press that finds nothing names its target --- .github/unraid-compat/browser_test.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index 51546085..85e592f8 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -91,12 +91,15 @@ const DRAWN = { Docker: ['docker-post-folders-creation'], VMs: ['vm-post-folders const OPEN = { Docker: ['Media', ['docker-post-folder-expansion'], (p) => press(p.locator(`button.dropDown-${MEDIA}`), "Media's chevron")], VMs: ['Lab', ['vm-post-folder-expansion'], (p) => press(p.locator(`button.dropDown-${LAB}`), "Lab's chevron")], - // Each by its tile's menu, the item FV3's lang pack labels 'expand': Media on the Docker card, Lab on the VM card + // Each by its tile's menu, the item FV3's lang pack labels 'expand'. Unraid fades a used menu out and then hides every menu, + // so a user's next menu waits for that: one opened during the fade closes at once Dashboard: ['Media and Lab', ['docker-post-folder-expansion', 'vm-post-folder-expansion'], async (p) => { const expand = await p.evaluate(() => $.i18n('expand')); for (const [id, folder] of [[MEDIA, 'Media'], [LAB, 'Lab']]) { await press(p.locator(`#folder-id-${id}`), `${folder}'s tile`); await press(p.locator('ul.dropdown-context:visible li > a', { hasText: expand }), `${folder}'s menu's Expand`); + await p.waitForFunction(() => [...document.querySelectorAll('ul.dropdown-context')].every((u) => !u.offsetParent), null, { timeout: 5000 }) + .catch(() => { throw new Error(`${folder}'s menu did not close within 5 s`); }); } }], }; @@ -170,7 +173,8 @@ const FRAME = [ // A user's click, the target scrolled to the middle first async function press(locator, what) { - await locator.evaluate((el) => el.scrollIntoView({ block: 'center', inline: 'center' })); + await locator.evaluate((el) => el.scrollIntoView({ block: 'center', inline: 'center' }), null, { timeout: 10000 }) + .catch(() => { throw new Error(`${what} is not on the page within 10 s`); }); try { await locator.click({ timeout: 5000 }); } catch (e) { @@ -182,7 +186,8 @@ async function press(locator, what) { if (frame.some((selector) => top.closest(selector))) return ''; const n = top.closest('[id], [class]') || top; return `${n.tagName.toLowerCase()}${n.id ? `#${n.id}` : ''}${[...n.classList].map((c) => `.${c}`).join('')}`; - }, FRAME.map(([selector]) => selector)); + }, FRAME.map(([selector]) => selector), { timeout: 5000 }).catch(() => undefined); + if (cover === undefined) throw new Error(`${what} could not be clicked, then left the page: ${e.message.split('\n')[0]}`); if (cover === null) throw new Error(`${what} could not be clicked: ${e.message.split('\n')[0]}`); if (cover) throw new Error(`${what} is covered by ${cover}`); await locator.dispatchEvent('click'); From 14e667250291889fc7a9d9670ef56026514b91d8 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 15:23:36 +0800 Subject: [PATCH 05/13] ci: a Dashboard folder's menu waits for the last menu's fade to end --- .github/unraid-compat/browser_test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index 85e592f8..5fdb48e2 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -91,14 +91,14 @@ const DRAWN = { Docker: ['docker-post-folders-creation'], VMs: ['vm-post-folders const OPEN = { Docker: ['Media', ['docker-post-folder-expansion'], (p) => press(p.locator(`button.dropDown-${MEDIA}`), "Media's chevron")], VMs: ['Lab', ['vm-post-folder-expansion'], (p) => press(p.locator(`button.dropDown-${LAB}`), "Lab's chevron")], - // Each by its tile's menu, the item FV3's lang pack labels 'expand'. Unraid fades a used menu out and then hides every menu, - // so a user's next menu waits for that: one opened during the fade closes at once + // Each by its tile's menu, the item FV3's lang pack labels 'expand'. Unraid fades a used menu out and hides every menu as each + // fade ends, so a user's next menu waits for the fade (jQuery's :animated): one opened during it closes at once Dashboard: ['Media and Lab', ['docker-post-folder-expansion', 'vm-post-folder-expansion'], async (p) => { const expand = await p.evaluate(() => $.i18n('expand')); for (const [id, folder] of [[MEDIA, 'Media'], [LAB, 'Lab']]) { await press(p.locator(`#folder-id-${id}`), `${folder}'s tile`); await press(p.locator('ul.dropdown-context:visible li > a', { hasText: expand }), `${folder}'s menu's Expand`); - await p.waitForFunction(() => [...document.querySelectorAll('ul.dropdown-context')].every((u) => !u.offsetParent), null, { timeout: 5000 }) + await p.waitForFunction(() => !$('ul.dropdown-context:animated').length && [...document.querySelectorAll('ul.dropdown-context')].every((u) => !u.offsetParent), null, { timeout: 5000 }) .catch(() => { throw new Error(`${folder}'s menu did not close within 5 s`); }); } }], From 2fc37a9974fbfa580c99f27b1cb55aa9e7b58840 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 15:23:47 +0800 Subject: [PATCH 06/13] ci: a layout failure names the folder even when its name is hidden --- .github/unraid-compat/layout.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/unraid-compat/layout.js b/.github/unraid-compat/layout.js index 9dc27db5..87b5a572 100644 --- a/.github/unraid-compat/layout.js +++ b/.github/unraid-compat/layout.js @@ -19,6 +19,8 @@ function layoutState({ page, desktop }) { !nameEl || !seen(nameEl) ? `${label}'s name cannot be seen` : tall(nameEl) > 1.5 * tall(other) ? `${label}'s name is ${tall(nameEl)} px tall, ${loose}'s ${tall(other)} px` : '', !icon || !seen(icon) ? `${label}'s icon cannot be seen` : !icon.complete || !icon.naturalWidth ? `${label}'s icon did not load` : '', ].filter(Boolean); + // A folder by its name's text, even where that text cannot be seen + const nameOf = (el) => el?.textContent.trim() || 'a folder'; const rules = { name: [] }; if (page === 'Dashboard') { @@ -27,7 +29,7 @@ function layoutState({ page, desktop }) { if (!otherName) return { error: "no app-d tile to compare folders' tiles with" }; rules.card = []; for (const folder of document.querySelectorAll('.folder-showcase-outer')) { - const label = folder.querySelector('.fv3-folder-appname')?.innerText.trim() || 'a folder'; + const label = nameOf(folder.querySelector('.fv3-folder-appname')); rules.name.push(...shown(label, folder.querySelector('.fv3-folder-appname'), folder.querySelector('img.fv3-folder-icon'), otherName, 'app-d')); const card = box(folder.closest('tbody')); const out = [folder.querySelector(':scope > span.outer'), ...members(folder)].filter((o) => o && seen(o)).filter((o) => box(o).left < card.left - 1 || box(o).right > card.right + 1); @@ -42,7 +44,7 @@ function layoutState({ page, desktop }) { rules.height = []; if (desktop) rules.preview = []; for (const row of rows.filter((r) => r.classList.contains('folder'))) { - const label = row.querySelector('a.folder-appname')?.innerText.trim() || 'a folder'; + const label = nameOf(row.querySelector('a.folder-appname')); rules.name.push(...shown(label, row.querySelector('a.folder-appname'), row.querySelector('img.folder-img'), otherName, loose)); if (box(row).height > 1.5 * box(other).height) rules.height.push(`${label}'s row is ${Math.round(box(row).height)} px tall, ${loose}'s ${Math.round(box(other).height)} px`); const items = [...row.querySelectorAll('.folder-preview span.outer')].filter(seen); From 181e40eb7367e293747f865bb7aba5c93c8418df Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:30:01 +0800 Subject: [PATCH 07/13] ci: a click waits for its target to stop moving, and a failed click names what Playwright says covered it --- .github/unraid-compat/browser_test.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index 5fdb48e2..b5d46f2b 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -171,13 +171,23 @@ const FRAME = [ ['#menu', "7.0's azure and gray sidebar: fixed at the left edge, it lies over the page below desktop width"], ]; -// A user's click, the target scrolled to the middle first +// A user's click, the target scrolled to the middle until it stays there: a folder opening above it grows for a moment async function press(locator, what) { - await locator.evaluate((el) => el.scrollIntoView({ block: 'center', inline: 'center' }), null, { timeout: 10000 }) - .catch(() => { throw new Error(`${what} is not on the page within 10 s`); }); + const middle = () => locator.evaluate((el) => { + el.scrollIntoView({ block: 'center', inline: 'center' }); + const r = el.getBoundingClientRect(); + return `${Math.round(r.top)},${Math.round(r.left)}`; + }, null, { timeout: 10000 }).catch(() => { throw new Error(`${what} is not on the page within 10 s`); }); + for (let at = await middle(), i = 0; i < 20; i++) { + await locator.page().waitForTimeout(100); + if (at === (at = await middle())) break; + } try { await locator.click({ timeout: 5000 }); } catch (e) { + // Playwright's own retries scroll the target elsewhere: what covers it is read back in the middle, beside Playwright's reason + const why = e.message.split('\n').find((l) => l.includes('intercepts pointer events'))?.trim().replace(/^- /, '') || e.message.split('\n')[0]; + await middle().catch(() => {}); const cover = await locator.evaluate((el, frame) => { if (!window.fv3Test.seen(el)) return null; const r = el.getBoundingClientRect(); @@ -187,9 +197,9 @@ async function press(locator, what) { const n = top.closest('[id], [class]') || top; return `${n.tagName.toLowerCase()}${n.id ? `#${n.id}` : ''}${[...n.classList].map((c) => `.${c}`).join('')}`; }, FRAME.map(([selector]) => selector), { timeout: 5000 }).catch(() => undefined); - if (cover === undefined) throw new Error(`${what} could not be clicked, then left the page: ${e.message.split('\n')[0]}`); - if (cover === null) throw new Error(`${what} could not be clicked: ${e.message.split('\n')[0]}`); - if (cover) throw new Error(`${what} is covered by ${cover}`); + if (cover === undefined) throw new Error(`${what} could not be clicked, then left the page: ${why}`); + if (cover === null) throw new Error(`${what} could not be clicked: ${why}`); + if (cover) throw new Error(`${what} is covered by ${cover} (${why})`); await locator.dispatchEvent('click'); } } From 3a11551784784816fa5bbe1763b04309e2067408 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:30:15 +0800 Subject: [PATCH 08/13] ci: a tile outside its card is named once --- .github/unraid-compat/browser_test.js | 2 +- .github/unraid-compat/layout.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index b5d46f2b..cb892e12 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -171,7 +171,7 @@ const FRAME = [ ['#menu', "7.0's azure and gray sidebar: fixed at the left edge, it lies over the page below desktop width"], ]; -// A user's click, the target scrolled to the middle until it stays there: a folder opening above it grows for a moment +// A user's click, the target scrolled to the middle until it stays there: a folder opening above it can still move it async function press(locator, what) { const middle = () => locator.evaluate((el) => { el.scrollIntoView({ block: 'center', inline: 'center' }); diff --git a/.github/unraid-compat/layout.js b/.github/unraid-compat/layout.js index 87b5a572..f9f8269d 100644 --- a/.github/unraid-compat/layout.js +++ b/.github/unraid-compat/layout.js @@ -32,8 +32,9 @@ function layoutState({ page, desktop }) { const label = nameOf(folder.querySelector('.fv3-folder-appname')); rules.name.push(...shown(label, folder.querySelector('.fv3-folder-appname'), folder.querySelector('img.fv3-folder-icon'), otherName, 'app-d')); const card = box(folder.closest('tbody')); - const out = [folder.querySelector(':scope > span.outer'), ...members(folder)].filter((o) => o && seen(o)).filter((o) => box(o).left < card.left - 1 || box(o).right > card.right + 1); - if (out.length) rules.card.push(`${label}'s ${out.map((o) => name(o) || 'tile').join(', ')} leave the card (${Math.round(card.left)}-${Math.round(card.right)})`); + const own = folder.querySelector(':scope > span.outer'); + const out = [own, ...members(folder)].filter((o) => o && seen(o)).filter((o) => box(o).left < card.left - 1 || box(o).right > card.right + 1); + if (out.length) rules.card.push(`${label}'s ${out.map((o) => (o === own ? 'tile' : name(o))).join(', ')} outside the card (${Math.round(card.left)} to ${Math.round(card.right)} px)`); } } else { const [list, cell, loose] = page === 'Docker' ? ['docker_list', 'ct-name', 'app-d'] : ['kvm_list', 'vm-name', 'Home Assistant']; From 63d6fdf24a63d03092dc56480528728f40fcbb44 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 17:50:51 +0800 Subject: [PATCH 09/13] ci: drop the preview line rule: FV3's preview clips an item that does not fit, which the readout already fails --- .github/unraid-compat/browser_test.js | 4 ++-- .github/unraid-compat/layout.js | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index cb892e12..d50bec9e 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -288,7 +288,7 @@ async function aloneSteps(tab, v) { // FV3's pass: drawn in the saved order, folders opened as a user opens them, the layout rules, the advanced preview, no banners async function fv3Steps(tab, v) { - const { where, file, page, width } = v; + const { where, file, page } = v; await load(tab, v); await waitEvents(tab, DRAWN[page]).catch(() => { throw new Error(`FV3 did not finish drawing within 20 s (${DRAWN[page].join(', ')})`); }); v.drew = true; @@ -305,7 +305,7 @@ async function fv3Steps(tab, v) { await waitEvents(tab, opened).catch(() => { throw new Error(`${folder} did not open within 20 s (${opened.join(', ')})`); }); got = await settled(tab, READ[page]); check(same(got, WANT[page].open), `${where}: with ${folder} open, drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].open)}`); - const layout = await settled(tab, layoutState, { page, desktop: width === SIZES[0][0] }); + const layout = await settled(tab, layoutState, page); if (layout.error) throw new Error(layout.error); for (const problem of Object.values(layout.rules)) check(!problem, `${where}: ${problem}`); // Only where Unraid alone fits: where it already scrolls sideways, FV3 may be wider diff --git a/.github/unraid-compat/layout.js b/.github/unraid-compat/layout.js index f9f8269d..b6aa0c7b 100644 --- a/.github/unraid-compat/layout.js +++ b/.github/unraid-compat/layout.js @@ -10,8 +10,8 @@ function widths() { } // Each rule's failure, '' when it holds. A folder against a loose container on its page (Unraid's name element, a link only -// with a template): name and row no taller than 1.5x theirs; at desktop width, its preview on one line inside its cell -function layoutState({ page, desktop }) { +// with a template): name and row no taller than 1.5x theirs. A preview item that does not fit is clipped, which the readout fails +function layoutState(page) { const { seen, name, members } = window.fv3Test; const box = (el) => el.getBoundingClientRect(); const tall = (node) => { const r = document.createRange(); r.selectNodeContents(node); return Math.round(r.getBoundingClientRect().height); }; @@ -43,16 +43,10 @@ function layoutState({ page, desktop }) { const otherName = other?.querySelector(`td.${cell} span.inner > *`); if (!otherName) return { error: `no ${loose} row to compare folders with` }; rules.height = []; - if (desktop) rules.preview = []; for (const row of rows.filter((r) => r.classList.contains('folder'))) { const label = nameOf(row.querySelector('a.folder-appname')); rules.name.push(...shown(label, row.querySelector('a.folder-appname'), row.querySelector('img.folder-img'), otherName, loose)); if (box(row).height > 1.5 * box(other).height) rules.height.push(`${label}'s row is ${Math.round(box(row).height)} px tall, ${loose}'s ${Math.round(box(other).height)} px`); - const items = [...row.querySelectorAll('.folder-preview span.outer')].filter(seen); - if (!desktop || !items.length) continue; - const c = box(row.querySelector('.folder-preview').closest('td')), top = box(items[0]).top; - const off = items.filter((i) => Math.abs(box(i).top - top) > 2 || box(i).left < c.left - 1 || box(i).right > c.right + 1); - if (off.length) rules.preview.push(`${label}'s preview wraps or leaves its cell at ${off.map(name).join(', ')}`); } } return { rules: Object.fromEntries(Object.entries(rules).map(([rule, problems]) => [rule, problems.join('; ')])) }; From d77299e66207de068cc8f11f4b28e945f953a51b Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 18:11:55 +0800 Subject: [PATCH 10/13] ci: Unraid alone's own browser errors fail its pass too --- .github/unraid-compat/browser_test.js | 4 ++-- .github/unraid-compat/layout.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index d50bec9e..113bc3b3 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -258,8 +258,8 @@ async function view(browser, kind, theme, [width, height], page, steps) { } finally { clearTimeout(timer); } - // Unraid alone's own errors are not FV3's - if (!ALONE) check(!errors.length, `${where}:\n ${[...new Set(errors)].join('\n ')}`); + // Unraid alone must run clean too: an error there is Unraid's or the fake's, and its readings would not hold + check(!errors.length, `${where}:\n ${[...new Set(errors)].join('\n ')}`); await context?.close().catch(() => {}); return v.drew; } diff --git a/.github/unraid-compat/layout.js b/.github/unraid-compat/layout.js index b6aa0c7b..39310694 100644 --- a/.github/unraid-compat/layout.js +++ b/.github/unraid-compat/layout.js @@ -10,7 +10,7 @@ function widths() { } // Each rule's failure, '' when it holds. A folder against a loose container on its page (Unraid's name element, a link only -// with a template): name and row no taller than 1.5x theirs. A preview item that does not fit is clipped, which the readout fails +// with a template): name and row no taller than 1.5x theirs. A preview item clipped wholly out of sight drops out of the readout function layoutState(page) { const { seen, name, members } = window.fv3Test; const box = (el) => el.getBoundingClientRect(); From b060ca8e6acddc49a2516e0a3c1efd783509fa3b Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 19:08:41 +0800 Subject: [PATCH 11/13] ci: stop when the last run's measurements cannot be removed --- .github/unraid-compat/browser_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/unraid-compat/browser_test.sh b/.github/unraid-compat/browser_test.sh index fa44c2ee..5624e2c0 100644 --- a/.github/unraid-compat/browser_test.sh +++ b/.github/unraid-compat/browser_test.sh @@ -31,7 +31,7 @@ browse() { docker run --rm --network container:"$fake" --shm-size=1g --user "$(i # Unraid alone first, with FV3's page hooks (folder.view3..page) out of its plugin folder; FV3's pass then compares with it docker exec "$fake" bash -c 'mkdir -p /run/fv3-off && mv /usr/local/emhttp/plugins/folder.view3/folder.view3.*.page /run/fv3-off/' || fail "FV3's pages could not be moved aside" # FV3's pass must never compare with an earlier run's measurements -rm -f "$shots/unraid-alone.json" +rm -f "$shots/unraid-alone.json" || fail "the last run's measurements could not be removed from $shots" browse unraid-alone; status=$? docker exec "$fake" bash -c 'mv /run/fv3-off/* /usr/local/emhttp/plugins/folder.view3/' || fail "FV3's pages could not be put back" browse || status=1 From 6d8a25a61a5afc93db714df06a4f2067dbdb8024 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:36:07 +0800 Subject: [PATCH 12/13] ci: a function hook must be callable and csrf_token a non-empty string; dockerload's hook is the addEventListener FV3 calls --- .github/unraid-compat/hooks.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/unraid-compat/hooks.js b/.github/unraid-compat/hooks.js index 9fc787de..d2fb6d1d 100644 --- a/.github/unraid-compat/hooks.js +++ b/.github/unraid-compat/hooks.js @@ -42,16 +42,16 @@ const HOOKS = [ { page: ALL, css: 'green-text', file: 'scripts/docker.js', loses: 'a started folder loses its green state' }, { page: ALL, css: 'red-text', file: 'scripts/docker.js', loses: 'a stopped folder loses its red state' }, { page: ALL, css: 'orange-text', file: 'scripts/docker.js', loses: "a folder's drag handle and update mark lose their colour" }, - // Unraid's functions and jQuery plugins + // Unraid's functions and jQuery plugins, each callable, and its CSRF token, a non-empty string { page: D, js: 'loadlist', file: 'scripts/docker.js', loses: 'folders never draw' }, { page: D, js: 'listview', file: 'scripts/docker.js', loses: 'folders are not redrawn after a view toggle' }, { page: D, js: 'openDocker', file: 'scripts/docker.js', loses: "a folder's Update does nothing" }, { page: D, js: 'openTerminal', file: 'scripts/docker.js', loses: 'the console and log buttons do nothing' }, - { page: D, js: 'dockerload', file: 'scripts/docker.js', loses: 'no CPU and memory stats without the Unraid API' }, + { page: D, js: 'dockerload.addEventListener', file: 'scripts/docker.js', loses: 'no CPU and memory stats without the Unraid API' }, { page: V, js: 'loadlist', file: 'scripts/vm.js', loses: 'folders never draw' }, { page: ALL, js: 'context.attach', file: 'scripts/docker.js', loses: 'folders have no menus' }, { page: ALL, js: 'swal', file: 'scripts/shared.js', loses: 'no confirm or error dialogs' }, - { page: ALL, js: 'csrf_token', file: 'scripts/include/customEvents.js', loses: "every FV3 save is refused" }, + { page: ALL, js: 'csrf_token', string: true, file: 'scripts/include/customEvents.js', loses: "every FV3 save is refused" }, { page: ALL, js: '$.fn.tooltipster', file: 'scripts/advanced-preview.js', loses: 'no advanced preview' }, { page: D, js: '$.fn.switchButton', file: 'scripts/docker.js', loses: 'the folder autostart switch never draws' }, { page: D, js: '$.fn.sortable', file: 'scripts/docker.js', loses: 'folders cannot be dragged' }, @@ -93,7 +93,10 @@ function missingHooks(hooks) { if (h.dom) return !!document.querySelector(h.dom); if (h.any) return h.any.some((s) => document.querySelector(s)); if (h.css) return new RegExp(`\\.${h.css}(?![\\w-])`).test(selectors); - try { return (0, eval)(`typeof ${h.js}`) !== 'undefined'; } catch { return false; } + try { + const value = (0, eval)(h.js); + return h.string ? typeof value === 'string' && value !== '' : typeof value === 'function'; + } catch { return false; } }; return hooks.map((h, i) => (present(h) ? -1 : i)).filter((i) => i >= 0); } From 030d65bed7e248d42aa15b217ab870bf2985d622 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:47:10 +0800 Subject: [PATCH 13/13] ci: a hook's expected type lives in HOOKS; a failed js hook names the function or non-empty string it lacked --- .github/unraid-compat/hooks.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/unraid-compat/hooks.js b/.github/unraid-compat/hooks.js index d2fb6d1d..ee7e7470 100644 --- a/.github/unraid-compat/hooks.js +++ b/.github/unraid-compat/hooks.js @@ -51,7 +51,7 @@ const HOOKS = [ { page: V, js: 'loadlist', file: 'scripts/vm.js', loses: 'folders never draw' }, { page: ALL, js: 'context.attach', file: 'scripts/docker.js', loses: 'folders have no menus' }, { page: ALL, js: 'swal', file: 'scripts/shared.js', loses: 'no confirm or error dialogs' }, - { page: ALL, js: 'csrf_token', string: true, file: 'scripts/include/customEvents.js', loses: "every FV3 save is refused" }, + { page: ALL, js: 'csrf_token', type: 'string', file: 'scripts/include/customEvents.js', loses: "every FV3 save is refused" }, { page: ALL, js: '$.fn.tooltipster', file: 'scripts/advanced-preview.js', loses: 'no advanced preview' }, { page: D, js: '$.fn.switchButton', file: 'scripts/docker.js', loses: 'the folder autostart switch never draws' }, { page: D, js: '$.fn.sortable', file: 'scripts/docker.js', loses: 'folders cannot be dragged' }, @@ -77,7 +77,8 @@ const esc = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // As a whole token (a #id or .class starts at its mark); a class may also be named in a class attribute or as a quoted string const mentions = (text, t) => new RegExp(`${/^[#.]/.test(t) ? '' : '(? h.dom || (h.any && `any of ${h.any.join(', ')}`) || (h.css && `a stylesheet rule for .${h.css}`) || h.url || `the global ${h.js}`; +const describe = (h) => h.dom || (h.any && `any of ${h.any.join(', ')}`) || (h.css && `a stylesheet rule for .${h.css}`) || h.url + || (h.type === 'string' ? `${h.js} as a non-empty string` : `the function ${h.js}`); const older = (a, b) => { const [x, y] = [a, b].map((v) => v.split('.').map(Number)); const i = x.findIndex((n, k) => n !== y[k]); return i >= 0 && x[i] < y[i]; }; const applies = (h, version) => !h.since || !older(version, h.since); // The hooks one view checks: its page's and every page's that apply to this version (endpoints are checked as files) @@ -95,7 +96,7 @@ function missingHooks(hooks) { if (h.css) return new RegExp(`\\.${h.css}(?![\\w-])`).test(selectors); try { const value = (0, eval)(h.js); - return h.string ? typeof value === 'string' && value !== '' : typeof value === 'function'; + return typeof value === (h.type || 'function') && value !== ''; } catch { return false; } }; return hooks.map((h, i) => (present(h) ? -1 : i)).filter((i) => i >= 0);