Merge upstream: sharded test runs, auto-release follows CI (3.1.0)
Some checks failed
CI / plan (push) Waiting to run
CI / part (push) Blocked by required conditions
CI / build (push) Waiting to run
CI / translations (push) Waiting to run
CI / test (push) Blocked by required conditions
CI / timings (push) Blocked by required conditions
Container image / test (push) Has been cancelled
Container image / publish (push) Has been cancelled

The fork's Unreleased bullets stay above upstream's 3.1.0 section. The dark
mode test reads the theme script from the page's HTML, since the harness
now runs script bodies outside the DOM.
This commit is contained in:
jvanvik 2026-11-07 10:29:33 +01:00
commit 4b922aba02
22 changed files with 287 additions and 128 deletions

View file

@ -49,10 +49,11 @@ test('the choice applies at boot, from the <head>, before the page is painted',
assert.deepEqual(errors, []);
dom.window.close();
}
// The script that sets it sits in the <head>, before the styles: nothing is painted in the wrong colours first.
const doc = load().dom.window.document, head = [...doc.head.children];
const s = head.findIndex((e) => e.tagName === 'SCRIPT' && /sot-theme/.test(e.textContent)), st = head.findIndex((e) => e.tagName === 'STYLE');
assert.ok(s >= 0 && s < st, 'the theme script runs before the stylesheet');
// The script that sets it sits in the <head>, before the styles: nothing is painted in the wrong colours first. Read
// from the page's HTML (the harness runs script bodies outside the DOM, so a <script>'s text is empty there).
const html = assemble().html, headEnd = html.indexOf('</head>'), st = html.indexOf('<style>');
const scripts = [...html.slice(0, headEnd).matchAll(/<script>([\s\S]*?)<\/script>/g)], s = scripts.find((m) => /sot-theme/.test(m[1]));
assert.ok(s && st >= 0 && st < headEnd && s.index < st, 'the theme script runs before the stylesheet');
// Auto with a dark device: dark from the first paint as well.
const d = device(true), h = load({ browser: d });
assert.equal(h.dom.window.document.documentElement.getAttribute('data-theme'), 'dark');