RuneStone 1.0.0

This commit is contained in:
Knotty Wyvern
2026-11-03 00:23:07 -07:00
commit 5557443ed1
818 changed files with 239368 additions and 0 deletions
@@ -0,0 +1,143 @@
// Workarea backgrounds in both themes: splash, writer, reader, split, Source, narrow layouts, fades, reduced motion, and removal.
// The saved image shows through the Background feature (src/lib/features/background/). The test also sets its own frames.
import assert from 'node:assert/strict';
import { writeFile } from 'node:fs/promises';
import { chooseView, mockTauri, openPage, outputDir, runSmoke, showSavedImage, smokeUrl } from '../_harness/index.mjs';
const viewport = { width: 1280, height: 820 };
await runSmoke('appearance/backgroundFrames', async ({ browser }) => {
const output = await outputDir('appearance/backgroundFrames');
const report = [];
for (const theme of ['light', 'dark']) {
const page = await openPage(browser, { viewport });
await mockTauri(page, {
commands: test => ({
...test.workspace({
root: 'C:/background-test',
files: {
'welcome.md': '# Working notes\n\nKeep the image quiet behind readable text.\n\n## Next steps\n\n- Write a note\n- Review the code\n\n' + 'A paragraph with **bold text** and a [link](https://example.com).\n\n'.repeat(24),
'hello.ts': '// A focused code view\nexport function greet(name: string) {\n const message = `Hello ${name}`;\n return message;\n}\n',
},
}),
plugins_snapshot: () => ({ root: 'C:/background-test', plugins: [] }),
}),
});
await page.goto(smokeUrl);
await page.locator('.welcome-actions button').first().waitFor();
await page.getByText('background-test', { exact: true }).waitFor();
await page.evaluate(async theme => {
const { saveAppearance } = await import('/src/lib/theme/appearance.ts');
const { backgroundHub } = await import('/src/lib/plugins/backgrounds.ts');
const make = (first, second) => {
const canvas = document.createElement('canvas'); canvas.width = 1200; canvas.height = 800;
const ctx = canvas.getContext('2d'); const gradient = ctx.createLinearGradient(0, 0, 1200, 800);
gradient.addColorStop(0, first); gradient.addColorStop(1, second); ctx.fillStyle = gradient; ctx.fillRect(0, 0, 1200, 800);
ctx.strokeStyle = '#ffffff88'; ctx.lineWidth = 12;
for (let x = 0; x < 1400; x += 200) { ctx.beginPath(); ctx.moveTo(x, 0); ctx.lineTo(x - 300, 800); ctx.stroke(); }
return canvas.toDataURL();
};
const saved = make('#bd486c', '#438f67');
saveAppearance({ theme: 'default', mode: theme, newTabBackground: { image: saved, overlay: 0.15, position: 'center', size: 'cover' } });
// Decode the data URLs without fetch: the content security policy does not permit `data:` in connect-src.
const blob = url => new Blob([Uint8Array.from(atob(url.split(',')[1]), character => character.charCodeAt(0))], { type: 'image/png' });
const urls = [make('#bd486c', '#438f67'), make('#286f9b', '#725ea2')].map(url => URL.createObjectURL(blob(url)));
window.backgroundTest = { hub: backgroundHub, owner: Symbol(), urls, saved, theme };
}, theme);
await showSavedImage(page);
const background = page.locator('.workarea-background');
const style = (locator, property, pseudo) => locator.evaluate((node, [property, pseudo]) => getComputedStyle(node, pseudo)[property], [property, pseudo]);
async function openWelcome() {
await page.keyboard.press('Control+p');
await page.getByRole('textbox', { name: 'Find a file' }).fill('welcome');
await page.getByRole('dialog').getByRole('button').filter({ hasText: 'welcome.md' }).first().click();
}
assert.equal(await background.count(), 1);
assert.equal(await page.locator('.empty h1, .empty > p').count(), 0);
assert.equal(await style(page.locator('.empty'), 'backgroundImage'), 'none');
const bounds = await background.boundingBox();
assert.equal(bounds.x, 0); assert.equal(bounds.y, 36); assert.equal(bounds.width, 1280); assert.equal(bounds.height, 762);
assert.match(await style(background, 'backgroundImage'), /blob:/);
assert.match(await style(page.locator('.left'), 'backgroundColor'), /(?:0\.82|82%)/);
assert.match(await style(page.locator('.right'), 'backgroundColor'), /(?:0\.82|82%)/);
assert.match(await style(page.locator('.welcome-actions button').first(), 'backgroundColor'), /(?:0\.82|82%)/);
assert.doesNotMatch(await style(page.locator('header.header'), 'backgroundColor'), /(?:0\.82|82%)/);
await page.locator('.welcome-actions button').first().focus();
await page.keyboard.press('Tab');
assert(await page.locator('.welcome-actions').evaluate(node => node.contains(document.activeElement)));
await page.screenshot({ path: `${output}/${theme}-splash.png` });
await page.evaluate(() => {
const { hub, owner, urls } = window.backgroundTest;
hub.set(owner, 'app', { url: urls[0], blurredUrl: urls[1], overlay: 0.15, position: 'top', size: 'contain' });
});
assert.equal(await style(background, 'backgroundSize'), '100% 100%, contain, cover');
assert.equal(await style(background, 'backgroundPosition'), '50% 50%, 50% 0%, 50% 50%');
await page.screenshot({ path: `${output}/${theme}-portrait-layers.png` });
await page.setViewportSize({ width: 390, height: 700 });
assert.equal(await style(background, 'backgroundSize'), '100% 100%, contain, cover');
await page.screenshot({ path: `${output}/${theme}-portrait-layers-narrow.png` });
await page.setViewportSize(viewport);
await page.evaluate(() => {
const { hub, owner, urls } = window.backgroundTest;
hub.set(owner, 'app', { url: urls[1], overlay: 0.2, position: 'center', size: 'cover', previous: { url: urls[0], overlay: 0.15, position: 'center', size: 'cover' }, transitionMs: 2000 });
});
await page.waitForTimeout(180);
const opacity = Number(await style(background, 'opacity', '::after'));
assert(opacity > 0 && opacity < 1, `Fade has an intermediate opacity: ${opacity}`);
await page.waitForTimeout(900);
assert.ok(Number(await style(background, 'opacity', '::after')) < 1, 'The fade remains active after one second');
await page.waitForTimeout(1100);
assert.equal(await style(background, 'opacity', '::after'), '1');
await openWelcome();
await page.getByRole('textbox', { name: 'Writing editor', exact: true }).waitFor();
assert.match(await style(page.locator('.editor > .body'), 'backgroundColor'), /(?:0\.9|90%)/);
await page.screenshot({ path: `${output}/${theme}-writer.png` });
await chooseView(page, 'Read');
await page.locator('.md-page').waitFor();
const beforeScroll = await background.boundingBox();
await page.locator('.md-page').evaluate(node => { node.scrollTop = 600; });
assert.deepEqual(await background.boundingBox(), beforeScroll);
await page.screenshot({ path: `${output}/${theme}-reader.png` });
// Split shows the Write editor beside Read.
await chooseView(page, 'Split');
await page.locator('.live-writer .cm-content').waitFor();
assert.equal(await style(page.locator('.live-writer .cm-editor').first(), 'backgroundColor'), 'rgba(0, 0, 0, 0)');
await page.screenshot({ path: `${output}/${theme}-split.png` });
await chooseView(page, 'Split');
await chooseView(page, 'Source');
await page.locator('.source-editor .cm-content').waitFor();
await page.screenshot({ path: `${output}/${theme}-ide.png` });
await page.setViewportSize({ width: 680, height: 720 });
// The side panes give way in a narrow window and come back in a wide one (src/lib/layout/Workbench.svelte).
await page.screenshot({ path: `${output}/${theme}-ide-narrow.png` });
await page.keyboard.press('Control+t');
await page.locator('.welcome-actions').waitFor();
await page.setViewportSize({ width: 480, height: 640 });
assert(await page.locator('.empty').evaluate(node => node.scrollWidth <= node.clientWidth));
await page.screenshot({ path: `${output}/${theme}-splash-narrow.png` });
await page.emulateMedia({ reducedMotion: 'reduce' });
await page.evaluate(() => { const { hub, owner, urls } = window.backgroundTest; hub.set(owner, 'app', { url: urls[0], overlay: 0.2, position: 'center', size: 'cover', previous: { url: urls[1], overlay: 0.2, position: 'center', size: 'cover' }, transitionMs: 2000 }); });
assert.equal(await background.evaluate(node => node.getAnimations({ subtree: true }).length), 0);
await page.evaluate(() => { const { hub, owner, urls } = window.backgroundTest; hub.removeOwner(owner); urls.forEach(URL.revokeObjectURL); });
// The frame of Background (the saved image) shows again, without a fade.
assert.equal(await page.evaluate(() => document.body.style.getPropertyValue('--rs-background-previous-image')), 'none');
assert.match(await style(background, 'backgroundImage'), /blob:/);
await page.evaluate(async () => { const { saveAppearance } = await import('/src/lib/theme/appearance.ts'); saveAppearance({ theme: 'default', mode: window.backgroundTest.theme }); });
await page.waitForFunction(() => getComputedStyle(document.querySelector('.workarea-background')).backgroundImage === 'none');
assert.equal(await page.evaluate(() => document.body.style.getPropertyValue('--rs-background-image')), '', 'Without an image, the body has no background properties');
await openWelcome();
await page.locator('.editor > .body').waitFor();
assert.equal(await style(page.locator('.editor > .body'), 'backgroundColor'), await style(page.locator('.shell'), 'backgroundColor'));
await page.screenshot({ path: `${output}/${theme}-removed.png` });
assert.deepEqual(page.errors, []);
report.push({ theme, passed: ['saved image', 'continuous workarea', 'sidebar transparency', 'button-only splash', 'keyboard focus', 'writer', 'reader scrolling', 'split', 'Source transparency', 'narrow layout', 'fade', 'reduced motion', 'slideshow removal', 'saved image removal'], screenshots: `${output}/${theme}-*.png`, nativeDesktop: 'not tested' });
await page.close();
console.log(`PASS: ${theme} workarea backgrounds, editors, keyboard, narrow layout, fade, and restoration`);
}
await writeFile(`${output}/report.json`, JSON.stringify(report, null, 2));
});
@@ -0,0 +1,138 @@
// New-tab background images: large uploads, cross-window sync, reload, theme reuse, removal, picker menus, and narrow settings.
import assert from 'node:assert/strict';
import { writeFile } from 'node:fs/promises';
import path from 'node:path';
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from '../_harness/index.mjs';
// The image is painted on .workarea-background, not on the empty tab (src/lib/theme/background.css).
// Background (src/lib/features/background/) loads after the first render, so each check waits for the image.
const waitForImage = page => page.waitForFunction(() => getComputedStyle(document.querySelector('.workarea-background')).backgroundImage.includes('blob:'));
await runSmoke('appearance/backgroundImages', async ({ browser }) => {
const output = await outputDir('appearance/backgroundImages');
const context = await browser.newContext({ viewport: { width: 1100, height: 780 } });
await mockTauri(context, {
commands: test => {
const workspace = test.workspace({
root: 'C:\\host-todo-test',
files: {
'a.md': '# Note\n\nOriginal text.',
'.runestone/templates/Daily.md': '# Daily\n\n## Tasks',
'.runestone/marks.json': JSON.stringify({ pins: ['a.md'], bookmarks: ['a.md'], order: { '': ['a.md'] } }),
},
});
return {
...workspace,
workspace_list: args => workspace.workspace_list(args).filter(entry => entry.rel_path !== '.runestone'),
plugins_snapshot: () => ({ root: 'C:/plugins', plugins: [] }),
'plugin:window|is_maximized': () => false,
};
},
});
const main = await openPage(context), settings = await openPage(context);
const imageInput = () => settings.getByLabel('Background image file', { exact: true });
const background = () => main.locator('.workarea-background').evaluate(node => /url\("(blob:[^"]+)"\)/.exec(getComputedStyle(node).backgroundImage)?.[1]);
const decoded = (page, url) => page.evaluate(async url => { const image = new Image(); image.src = url; await image.decode(); return image.naturalWidth; }, url);
const savedImageId = () => settings.evaluate(() => window.__TEST__.settings('appearance').newTabBackground.imageId);
const picker = name => settings.locator('.picker').and(settings.getByRole('button', { name, exact: true }));
await main.goto(smokeUrl); await main.locator('.empty').waitFor();
await settings.goto(smokeUrl + '/?settingsWindow=true');
await settings.getByRole('button', { name: 'Appearance', exact: true }).click();
const image = await main.evaluate(() => {
const canvas = document.createElement('canvas'); canvas.width = canvas.height = 700;
const ctx = canvas.getContext('2d'), pixels = ctx.createImageData(700, 700);
let seed = 23;
for (let i = 0; i < pixels.data.length; i++) { seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0; pixels.data[i] = i % 4 === 3 ? 255 : seed >>> 24; }
ctx.putImageData(pixels, 0, 0); return canvas.toDataURL();
});
const bytes = Buffer.from(image.split(',')[1], 'base64');
assert.ok(image.length > 2 ** 21 && bytes.length < 2_000_000, 'Fixture crosses the CSS limit but fits the upload limit');
await imageInput().setInputFiles({ name: 'large.png', mimeType: 'image/png', buffer: bytes });
await main.waitForFunction(() => getComputedStyle(document.querySelector('.workarea-background')).backgroundImage.includes('blob:'));
let url = await background();
assert.equal(await decoded(main, url), 700, 'The actual new-tab image decodes');
await main.reload(); await main.locator('.empty').waitFor(); await waitForImage(main);
url = await background(); assert.equal(await decoded(main, url), 700, 'The saved image survives reload');
const pixel = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+jM1sAAAAASUVORK5CYII=', 'base64');
const largeFile = path.join(output, '50MiB.png');
await writeFile(largeFile, Buffer.concat([pixel, Buffer.alloc(50 * 1024 * 1024 - pixel.length)]));
await imageInput().setInputFiles(largeFile);
await main.waitForFunction(old => /url\("(blob:[^"]+)"\)/.exec(getComputedStyle(document.querySelector('.workarea-background')).backgroundImage)?.[1] !== old, url);
url = await background(); assert.equal(await decoded(main, url), 1, '50 MiB image decodes');
assert.ok(await settings.evaluate(() => JSON.stringify(window.__TEST__.settings('appearance')).length < 500), 'Image bytes stay outside the settings file');
await main.reload(); await main.locator('.empty').waitFor(); await waitForImage(main);
url = await background(); assert.equal(await decoded(main, url), 1, '50 MiB image survives reload');
const acceptedId = await savedImageId();
const tooLargeFile = path.join(output, 'too-large.png');
await writeFile(tooLargeFile, Buffer.alloc(50 * 1024 * 1024 + 1));
await imageInput().setInputFiles(tooLargeFile);
await settings.getByRole('alert').filter({ hasText: '50 MiB' }).waitFor();
assert.equal(await savedImageId(), acceptedId);
assert.equal(await settings.locator('input[type=color]').count(), 0);
await settings.getByLabel('Image overlay', { exact: true }).fill('55');
await main.waitForFunction(() => getComputedStyle(document.querySelector('.workarea-background')).backgroundImage.includes('0.55'));
await settings.getByLabel('Image overlay', { exact: true }).fill('-40');
await main.waitForFunction(() => getComputedStyle(document.querySelector('.workarea-background')).backgroundImage.includes('255, 255, 255, 0.4'));
// A theme card chooses the theme and its light or dark mode together (src/lib/theme/ThemePicker.svelte).
for (const mode of ['dark', 'light']) {
await settings.getByRole('radio', { name: mode === 'dark' ? 'RuneStone Dark' : 'RuneStone Light', exact: true }).click();
await main.waitForFunction(mode => document.documentElement.dataset.theme === mode, mode);
assert.equal(await background(), url, 'Theme changes reuse the current image URL');
await main.screenshot({ path: `${output}/background-${mode}.png` });
// The image position menu is a shared menu of Appearance settings.
for (const name of ['Image position']) {
await picker(name).click();
const menu = settings.getByRole('menu', { name, exact: true });
assert.equal(await menu.evaluate(node => getComputedStyle(node).fontSize), '13px');
// Shared menu rows are 24px high (src/lib/theme/tokens.css:31, --rs-menu-row-height).
assert.equal(await menu.locator(':scope > button').first().evaluate(node => getComputedStyle(node).minHeight), '24px');
// The current choice shows a check mark in the icon column (src/lib/ui/actionMenu.ts).
assert.equal(await menu.locator('[aria-checked="true"] svg').count(), 1);
assert.equal(await menu.evaluate(node => { const reference = document.createElement('span'); reference.style.color = 'var(--rs-menu-border)'; node.append(reference); const matches = getComputedStyle(node).borderColor === getComputedStyle(reference).color; reference.remove(); return matches; }), true, 'Menu uses the shared border token');
assert.equal(await menu.evaluate(node => getComputedStyle(node).borderColor), 'rgba(0, 0, 0, 0)', 'Menus have no visible border');
await settings.screenshot({ path: `${output}/${name.replaceAll(' ', '-')}-${mode}.png` });
await settings.keyboard.press('Escape');
assert.equal(await picker(name).evaluate(node => node === document.activeElement), true);
}
}
await settings.setViewportSize({ width: 360, height: 480 });
await picker('Image position').scrollIntoViewIfNeeded();
await picker('Image position').click();
const box = await settings.getByRole('menu', { name: 'Image position', exact: true }).boundingBox();
assert.ok(box.x >= 0 && box.x + box.width <= 360 && box.y + box.height <= 480);
await settings.screenshot({ path: `${output}/menu-narrow.png` });
await settings.keyboard.press('Escape');
await settings.getByRole('button', { name: 'Remove image', exact: true }).click();
await main.waitForFunction(() => getComputedStyle(document.querySelector('.workarea-background')).backgroundImage === 'none');
assert.equal(await main.evaluate(async url => { try { await fetch(url); return false; } catch { return true; } }, url), true, 'Removing an image releases its URL');
assert.equal(await settings.evaluate(async id => (await import('/src/lib/theme/backgroundImages.ts')).readBackgroundImage(id).then(Boolean), acceptedId), false, 'Removal deletes stored image bytes');
await settings.evaluate(async () => {
const external = await import(performance.getEntriesByType('resource').find(entry => new URL(entry.name).pathname === '/src/lib/plugins/external.ts').name);
external.pluginTools.update(items => [...items, ...Array.from({ length: 30 }, (_, index) => ({ owner: `test.plugin${index}`, id: 'settings', title: `Plugin settings ${index}`, kind: 'view', surface: 'settings' }))]);
});
for (const theme of ['light', 'dark']) {
await settings.evaluate(async mode => { const { saveAppearance } = await import('/src/lib/theme/appearance.ts'); saveAppearance({ theme: 'default', mode }); window.dispatchEvent(new Event('focus')); }, theme);
await settings.setViewportSize({ width: 360, height: 600 });
assert.equal(await settings.getByRole('navigation', { name: 'Settings categories' }).getByRole('button').count() >= 34, true);
assert.equal(await settings.locator('.content').evaluate(node => node.clientHeight > 240 && node.clientWidth > 300), true, 'Long navigation leaves room for settings');
await settings.screenshot({ path: `${output}/long-plugin-list-${theme}-narrow.png` });
await main.setViewportSize({ width: 600, height: 700 });
await main.keyboard.press('F1');
await main.getByRole('dialog', { name: 'Help and about' }).waitFor();
// The shortcut list is open by default (src/lib/layout/SettingsDialog.svelte).
assert.equal(await main.locator('.help-card details[open]').count(), 1);
await main.locator('.help-card summary').first().focus(); await main.keyboard.press('Enter');
assert.equal(await main.locator('.help-card details[open]').count(), 2);
await main.keyboard.press('Enter');
await main.screenshot({ path: `${output}/help-${theme}-narrow.png` });
await main.getByRole('button', { name: 'Close help', exact: true }).click();
}
assert.deepEqual([...main.errors, ...settings.errors], []);
console.log('PASS: large image upload, decoding, cross-window sync, reload, theme reuse, removal, shared menu dimensions, keyboard dismissal, and narrow viewport.');
});
@@ -0,0 +1,70 @@
// Background image position and size: menu choices, a stable surface under overflow, persistence, keyboard choice, both themes, narrow settings.
import assert from 'node:assert/strict';
import { writeFile } from 'node:fs/promises';
import path from 'node:path';
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from '../_harness/index.mjs';
// The image is painted on .workarea-background, not on the empty tab (src/lib/theme/background.css).
// The controls are in Appearance → Background (src/lib/features/background/BackgroundSettings.svelte).
await runSmoke('appearance/backgroundLayout', async ({ browser }) => {
const output = await outputDir('appearance/backgroundLayout');
const context = await browser.newContext({ viewport: { width: 1100, height: 780 } });
await mockTauri(context, {
commands: () => ({
plugins_snapshot: () => ({ root: 'C:/plugins', plugins: [] }),
'plugin:window|is_maximized': () => false,
}),
});
const main = await openPage(context), settings = await openPage(context);
const screenshots = [];
await main.goto(smokeUrl);
await main.locator('.empty').waitFor();
await settings.goto(smokeUrl + '/?settingsWindow=true');
await settings.getByRole('button', { name: 'Appearance', exact: true }).click();
const png = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+jM1sAAAAASUVORK5CYII=', 'base64');
await settings.getByLabel('Background image file', { exact: true }).setInputFiles({ name: 'image.png', mimeType: 'image/png', buffer: png });
await main.waitForFunction(() => getComputedStyle(document.querySelector('.workarea-background')).backgroundImage.includes('blob:'));
for (const [control, choice] of [['Image position', 'Top left'], ['Image size', 'Actual size']]) {
const button = settings.getByRole('button', { name: control, exact: true });
await button.click();
await settings.getByRole('menuitemradio', { name: choice, exact: true }).click();
assert.equal(await button.evaluate(node => node === document.activeElement), true);
}
await main.waitForFunction(() => getComputedStyle(document.querySelector('.workarea-background')).backgroundPosition.endsWith('0% 0%'));
const layout = () => main.locator('.workarea-background').evaluate(node => {
const style = getComputedStyle(node), box = node.getBoundingClientRect();
return { position: style.backgroundPosition, size: style.backgroundSize, width: box.width, height: box.height };
});
const before = await layout();
assert.equal(before.size, '100% 100%, auto');
await main.locator('.empty').evaluate(node => {
const content = document.createElement('div'); content.style.cssText = 'height:2000px;flex-shrink:0;width:100%'; node.append(content);
});
assert.deepEqual(await layout(), before, 'Overflowing content does not resize or reposition the image surface');
await main.reload();
await main.locator('.empty').waitFor();
await main.waitForFunction(() => getComputedStyle(document.querySelector('.workarea-background')).backgroundImage.includes('blob:'));
assert.equal((await layout()).position, before.position);
assert.equal((await layout()).size, before.size);
await settings.getByRole('button', { name: 'Image position', exact: true }).click();
await settings.keyboard.press('End');
await settings.keyboard.press('Enter');
await main.waitForFunction(() => getComputedStyle(document.querySelector('.workarea-background')).backgroundPosition.endsWith('100% 100%'));
for (const mode of ['light', 'dark']) {
await settings.evaluate(async mode => {
const appearance = await import('/src/lib/theme/appearance.ts');
appearance.saveAppearance({ ...appearance.readAppearance(), mode });
window.dispatchEvent(new Event('focus'));
}, mode);
await main.waitForFunction(mode => document.documentElement.dataset.theme === mode, mode);
for (const width of [1100, 360]) {
await settings.setViewportSize({ width, height: 700 });
const file = path.join(output, `settings-${mode}-${width}.png`);
await settings.screenshot({ path: file }); screenshots.push(file);
assert.equal(await settings.locator('.content').evaluate(node => node.scrollWidth <= node.clientWidth + 1), true);
}
}
await writeFile(path.join(output, 'report.json'), JSON.stringify({ card: 'ab7b1a06-fd5a-4b74-aaa1-da64eafdf71c', checks: ['Alignment and sizing choices persist across reload and windows', 'Overflow does not resize the background surface', 'Keyboard choice and focus return', 'Both themes and narrow settings'], screenshots, native: 'Desktop visual acceptance remains pending.' }, null, 2));
assert.deepEqual([...main.errors, ...settings.errors], []);
console.log('PASS: background alignment, size, stable surface, persistence, keyboard, both themes, narrow settings.');
});
@@ -0,0 +1,64 @@
// Background image overlay: signed numeric entry, slider sync, persistence, clamping, both themes, narrow settings, keyboard focus.
import assert from 'node:assert/strict';
import { writeFile } from 'node:fs/promises';
import path from 'node:path';
import { mockTauri, outputDir, runSmoke, smokeUrl } from '../_harness/index.mjs';
await runSmoke('appearance/backgroundOverlay', async ({ page: settings }) => {
const output = await outputDir('appearance/backgroundOverlay');
await settings.setViewportSize({ width: 1100, height: 780 });
await mockTauri(settings, {
commands: () => ({
plugins_snapshot: () => ({ root: 'C:/plugins', plugins: [] }),
'plugin:window|is_maximized': () => false,
}),
});
await settings.goto(smokeUrl + '/?settingsWindow=true');
await settings.getByRole('button', { name: 'Appearance', exact: true }).click();
await settings.getByLabel('Background image file', { exact: true }).setInputFiles({
name: 'image.png', mimeType: 'image/png',
buffer: Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+jM1sAAAAASUVORK5CYII=', 'base64'),
});
const input = settings.getByRole('spinbutton', { name: 'Image overlay percentage' });
const slider = settings.getByRole('slider', { name: 'Image overlay', exact: true });
const saved = () => settings.evaluate(() => window.__TEST__.settings('appearance').newTabBackground.overlay);
await input.fill('-37');
assert.equal(await slider.inputValue(), '-37');
assert.equal(await saved(), -0.37);
await settings.reload();
await settings.getByRole('button', { name: 'Appearance', exact: true }).click();
assert.equal(await input.inputValue(), '-37');
await input.fill('');
assert.equal(await saved(), -0.37);
await input.blur();
assert.equal(await input.inputValue(), '-37');
await input.fill('150');
await input.blur();
assert.equal(await input.inputValue(), '100');
assert.equal(await saved(), 1);
await slider.fill('24');
assert.equal(await input.inputValue(), '24');
assert.equal(await saved(), 0.24);
for (const mode of ['light', 'dark']) {
await settings.evaluate(async mode => {
const appearance = await import('/src/lib/theme/appearance.ts');
appearance.saveAppearance({ ...appearance.readAppearance(), mode });
window.dispatchEvent(new Event('focus'));
}, mode);
for (const width of [1100, 360]) {
await settings.setViewportSize({ width, height: 780 });
await input.focus();
assert.equal(await input.evaluate(node => node === document.activeElement), true);
assert.equal(await settings.locator('.content').evaluate(node => node.scrollWidth <= node.clientWidth + 1), true);
await settings.screenshot({ path: path.join(output, `${mode}-${width}.png`) });
}
}
await writeFile(path.join(output, 'report.json'), JSON.stringify({
card: '2d1ae11e-8142-4840-bf0a-70f682e90e53',
hostChecks: ['Signed numeric entry and slider synchronization', 'Persistence after reload', 'Empty input retains saved value', 'Values clamp to -100 through 100', 'Both themes, keyboard focus, 360px and 1100px settings'],
shared: ['--rs-settings-control-height', '--rs-settings-gap', '--rs-control-radius'],
screenshotFolder: output,
native: 'Native desktop acceptance remains pending.',
}, null, 2));
console.log('PASS: numeric overlay, slider, persistence, bounds, themes, narrow settings, keyboard focus.');
});
@@ -0,0 +1,216 @@
// Character themes: colors, fonts, Source syntax, export, window sync, narrow theme cards, selection fills, and legacy or removed theme IDs.
import assert from 'node:assert/strict';
import path from 'node:path';
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from '../_harness/index.mjs';
await runSmoke('appearance/characterThemes', async ({ browser }) => {
const output = await outputDir('appearance/characterThemes');
const context = await browser.newContext({ viewport: { width: 1100, height: 780 } });
await mockTauri(context, {
commands: test => ({
...test.workspace({
root: 'C:\\theme-smoke',
files: {
'Theme.md': '# Theme sample\n\nA calm surface with readable text.\n\n[Link](https://example.com)\n',
'Theme.py': '# Character colors\ndef sample(parameter):\n return parameter\nname = "RuneStone"\nprint(name, 42)\n',
},
}),
plugins_snapshot: () => ({ root: 'C:/theme-smoke-plugins', plugins: [] }),
theme_export: args => { window.exportedTheme = JSON.parse(args.contents); return 'C:\\theme-smoke\\my-theme.json'; },
}),
});
const main = await openPage(context);
const settings = await openPage(context);
const ide = await openPage(context);
const pages = [main, settings, ide];
try {
const fontSession = await context.newCDPSession(settings);
await fontSession.send('DOM.enable');
await fontSession.send('CSS.enable');
async function openFile(page, name) {
await page.goto(smokeUrl);
await page.getByText('theme-smoke', { exact: true }).waitFor();
await page.keyboard.press('Control+p');
await page.getByRole('textbox', { name: 'Find a file' }).fill(name);
await page.getByRole('textbox', { name: 'Find a file' }).press('Enter');
}
await openFile(main, 'Theme.md');
await main.getByRole('textbox', { name: 'Writing editor', exact: true }).waitFor();
await openFile(ide, 'Theme.py');
await ide.locator('.source-editor .cm-content').waitFor();
// Mark each mounted editor once. A new editor has no mark, so it gets a new identifier.
const editorIds = () => ide.evaluate(() => [...document.querySelectorAll('.source-editor .cm-editor')]
.map(node => node.dataset.smokeId ||= String(window.__editorSerial = (window.__editorSerial || 0) + 1)));
const initialEditors = await editorIds();
const openSettings = async () => {
await settings.goto(`${smokeUrl}/?settingsWindow=true`);
await settings.getByRole('button', { name: 'Appearance', exact: true }).click();
await settings.getByRole('img', { name: 'Color theme preview' }).waitFor();
};
// The Color theme cards are one radio group (src/lib/theme/ThemePicker.svelte).
const card = name => settings.getByRole('radiogroup', { name: 'Color theme', exact: true }).getByRole('radio', { name, exact: true });
const choose = async (_, value) => { await card(value).click(); };
const waitForAppearance = (theme, mode) => Promise.all(pages.map(page => page.waitForFunction(({ theme, mode }) => document.documentElement.dataset.palette === theme && document.documentElement.dataset.theme === mode, { theme, mode })));
// Settings and the app import external.ts with a version query, so reuse the loaded module URL.
const setPluginTools = count => settings.evaluate(async count => {
const { pluginTools } = await import(performance.getEntriesByType('resource').find(entry => new URL(entry.name).pathname === '/src/lib/plugins/external.ts').name);
pluginTools.set(Array.from({ length: count }, (_, index) => ({ owner: 'org.example.theme-check', id: `settings-${index}`, title: `Plugin settings ${index + 1}`, surface: 'settings' })));
}, count);
await openSettings();
assert.equal(await card('Renamon').count(), 0);
assert.equal(await card('Asuka School Uniform').count(), 0);
for (const label of ['Holo', 'Asuka Langley Soryu', 'Malfoid']) {
assert.equal(await card(label).count(), 0);
}
const cases = [
['harvest-moon', 'Harvest Moon', 'dark', { ui: 'Candara', prose: 'Constantia', heading: 'Constantia' }],
['crimson-pilot', 'Crimson Pilot', 'dark', { ui: 'Bahnschrift', prose: 'Segoe UI', heading: 'Bahnschrift' }],
['silver-serpent', 'Silver Serpent', 'dark', { ui: 'Corbel', prose: 'Palatino Linotype', heading: 'Palatino Linotype' }],
];
for (const [theme, label, mode, expectedFonts] of cases) {
await settings.setViewportSize({ width: 1100, height: 780 });
await choose('Color theme', label);
await waitForAppearance(theme, mode);
// The export is one schema 3 theme file with every role, for the theme's own mode (exportAppearanceTheme in src/lib/theme/appearance.ts).
const template = await settings.evaluate(async theme => {
const { exportAppearanceTheme } = await import('/src/lib/theme/appearance.ts');
return exportAppearanceTheme(theme);
}, theme);
const colors = template.colors;
// The applied selection color caps its alpha at a6 so text backgrounds show through (appliedColors in src/lib/theme/contrast.ts).
const applied = { ...colors, selection: `${colors.selection.slice(0, 7)}a6` };
const actual = await settings.evaluate(keys => {
const css = getComputedStyle(document.documentElement);
return Object.fromEntries(keys.map(key => [key, css.getPropertyValue(`--rs-${key}`).trim()]));
}, Object.keys(applied));
assert.deepEqual(actual, applied);
const fonts = await settings.evaluate(() => {
const css = getComputedStyle(document.documentElement);
return { ui: css.getPropertyValue('--rs-font-ui'), prose: getComputedStyle(document.querySelector('.preview-prose')).fontFamily,
heading: getComputedStyle(document.querySelector('.preview-document strong')).fontFamily,
code: getComputedStyle(document.querySelector('.preview-code')).fontFamily };
});
for (const key of ['ui', 'prose', 'heading']) assert(fonts[key].includes(expectedFonts[key]), `${theme}: ${key} uses its font`);
assert(fonts.code.includes('Cascadia Mono'), 'Code retains the shared monospace font');
const { root } = await fontSession.send('DOM.getDocument');
const { nodeId } = await fontSession.send('DOM.querySelector', { nodeId: root.nodeId, selector: '.preview-prose' });
const rendered = await fontSession.send('CSS.getPlatformFontsForNode', { nodeId });
assert(rendered.fonts.some(item => item.glyphCount > 0), 'The font renders visible glyphs');
console.log(`${theme} rendered fonts: ${rendered.fonts.map(item => item.familyName).join(', ')}`);
await settings.evaluate(() => { window.exportedTheme = undefined; });
await settings.getByRole('button', { name: 'Export theme template' }).click();
await settings.waitForFunction(() => window.exportedTheme);
assert.deepEqual(await settings.evaluate(() => window.exportedTheme), template);
await ide.waitForFunction(expected => {
const spans = [...document.querySelectorAll('.source-editor .cm-line span')].filter(node => !node.children.length);
return Object.entries(expected).every(([text, color]) => {
const node = spans.find(node => node.textContent.replaceAll('\u00a0', ' ').includes(text));
const probe = document.createElement('i');
probe.style.color = color; document.body.append(probe);
const target = getComputedStyle(probe).color; probe.remove();
return node && getComputedStyle(node).color === target;
});
}, { return: colors['syntax-keyword'], RuneStone: colors['syntax-string'], 42: colors['syntax-number'], print: colors['syntax-function'], '# Character colors': colors['syntax-comment'] });
assert.deepEqual(await editorIds(), initialEditors, 'Theme changes preserve the editor');
if (theme === 'harvest-moon') {
const normalized = await settings.evaluate(async () => {
const { normalizeAppearance } = await import('/src/lib/theme/appearance.ts');
return normalizeAppearance({ theme: 'harvest-moon', mode: 'light' });
});
assert.equal(normalized.mode, 'dark', 'Harvest Moon keeps its fixed dark appearance');
await main.locator('[data-tree-rel="Theme.md"]').click();
const selectedRow = await main.locator('[data-tree-rel="Theme.md"]').evaluate(node => {
const css = getComputedStyle(node);
return { selected: node.getAttribute('aria-selected'), fill: css.backgroundColor,
selection: getComputedStyle(document.documentElement).getPropertyValue('--rs-item-selection-bg').trim() };
});
assert.equal(selectedRow.selected, 'true');
assert.equal(selectedRow.selection, applied.selection, 'File selection uses the same warm selection color');
// Selection fills use the capped a6 (0.65) alpha (src/lib/theme/appearance.ts:197-203).
const warmFill = 'rgba(82, 40, 20, 0.65)';
assert.equal(selectedRow.fill, warmFill, 'The selected file paints the warm fill');
await main.screenshot({ path: path.join(output, `${theme}-${mode}-file-selection.png`) });
await main.getByRole('textbox', { name: 'Writing editor', exact: true }).evaluate(node => {
node.focus();
const walker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT);
let text;
while ((text = walker.nextNode()) && !text.textContent.includes('A calm surface')) {}
const range = document.createRange(); range.selectNodeContents(text);
const selection = window.getSelection(); selection.removeAllRanges(); selection.addRange(range);
});
assert.equal(await main.evaluate(() => window.getSelection().toString()), 'A calm surface with readable text.');
await main.screenshot({ path: path.join(output, `${theme}-${mode}-writer-selection.png`) });
await ide.evaluate(async () => {
const { EditorView } = await import('/node_modules/@codemirror/view/dist/index.js');
const view = EditorView.findFromDOM(document.querySelector('.source-editor .cm-content'));
view.dispatch({ selection: { anchor: 0, head: view.state.doc.line(3).from + 20 } }); view.focus();
});
await ide.locator('.source-editor .cm-selectionBackground').first().waitFor();
assert.equal(await ide.locator('.source-editor .cm-selectionBackground').first().evaluate(node => getComputedStyle(node).backgroundColor),
warmFill, 'Source selection uses the same warm fill');
await ide.screenshot({ path: path.join(output, `${theme}-${mode}-ide-selection.png`) });
await ide.evaluate(async () => {
const { EditorView } = await import('/node_modules/@codemirror/view/dist/index.js');
EditorView.findFromDOM(document.querySelector('.source-editor .cm-content')).dispatch({ selection: { anchor: 0 } });
});
}
await ide.screenshot({ path: path.join(output, `${theme}-${mode}-ide.png`) });
await settings.screenshot({ path: path.join(output, `${theme}-${mode}-settings.png`) });
await main.screenshot({ path: path.join(output, `${theme}-${mode}-document.png`) });
await settings.reload();
await settings.getByRole('button', { name: 'Appearance', exact: true }).click();
assert.equal(await card(label).getAttribute('aria-checked'), 'true');
await settings.setViewportSize({ width: 360, height: 480 });
const content = settings.locator('dialog .content');
assert(await content.evaluate(node => node.scrollWidth <= node.clientWidth), 'Narrow settings fit the content area');
// The current card is the one Tab stop of the group, and its focus outline shows.
const current = card(label);
await current.scrollIntoViewIfNeeded();
await current.focus();
// Reach the card with the keyboard, so :focus-visible applies.
await settings.keyboard.press('Shift+Tab');
await settings.keyboard.press('Tab');
assert(await current.evaluate(node => document.activeElement === node), 'Tab returns to the current card');
assert.equal(await current.getAttribute('tabindex'), '0');
assert.notEqual(await current.evaluate(node => getComputedStyle(node).outlineStyle), 'none', 'Keyboard focus shows an outline');
const bounds = await settings.getByRole('radiogroup', { name: 'Color theme', exact: true }).boundingBox();
assert(bounds.x >= 0 && bounds.x + bounds.width <= 360, 'The cards stay within the viewport');
await settings.screenshot({ path: path.join(output, `${theme}-${mode}-360-focus.png`) });
await setPluginTools(16);
const navigation = settings.locator('dialog aside');
const bodyBounds = await settings.locator('dialog .body').boundingBox();
assert((await navigation.boundingBox()).height <= bodyBounds.height * 0.4 + 1, 'Long plugin navigation leaves room for settings');
assert(await content.evaluate(node => node.scrollWidth <= node.clientWidth));
await settings.getByRole('button', { name: 'Plugin settings 16', exact: true }).scrollIntoViewIfNeeded();
await settings.screenshot({ path: path.join(output, `${theme}-${mode}-360-long-navigation.png`) });
await setPluginTools(0);
console.log(`PASS: ${theme} ${mode}, colors, fonts, Source syntax, export, saved state, window sync, narrow theme cards, keyboard and focus`);
}
for (const [previous, theme, label] of [['holo', 'harvest-moon', 'Harvest Moon'], ['asuka', 'crimson-pilot', 'Crimson Pilot'], ['malfoid', 'silver-serpent', 'Silver Serpent']]) {
await settings.evaluate(theme => window.__TEST__.writeSettings('appearance', { theme, mode: 'dark' }), previous);
await openSettings();
assert.equal(await card(label).getAttribute('aria-checked'), 'true');
assert.equal(await settings.evaluate(() => document.documentElement.dataset.palette), theme);
await choose('Color theme', label);
assert.equal(await settings.evaluate(() => window.__TEST__.settings('appearance').theme), theme);
}
for (const [removed, mode] of [['renamon', 'light'], ['asuka-school', 'dark']]) {
await settings.evaluate(({ theme, mode }) => window.__TEST__.writeSettings('appearance', { theme, mode }), { theme: removed, mode });
await settings.setViewportSize({ width: 1100, height: 780 });
await openSettings();
await waitForAppearance('default', mode);
assert.equal(await card(`RuneStone ${mode === 'light' ? 'Light' : 'Dark'}`).getAttribute('aria-checked'), 'true');
assert((await settings.evaluate(() => getComputedStyle(document.body).fontFamily)).includes('Segoe UI'), 'The default font returns after a palette change');
await settings.screenshot({ path: path.join(output, `${removed}-fallback-${mode}-settings.png`) });
await settings.setViewportSize({ width: 360, height: 480 });
assert(await settings.locator('dialog .content').evaluate(node => node.scrollWidth <= node.clientWidth));
await settings.screenshot({ path: path.join(output, `default-${mode}-360-settings.png`) });
console.log(`PASS: ${removed} saved appearance restores RuneStone ${mode}`);
}
assert.deepEqual(pages.flatMap(page => page.errors), []);
} catch (error) {
for (const [index, page] of pages.entries()) await page.screenshot({ path: path.join(output, `failure-${index}.png`) }).catch(() => {});
throw error;
}
});
@@ -0,0 +1,42 @@
// The Color theme cards in Settings work from the keyboard, Settings has no color inputs, and the main window's empty tab uses the new theme background.
import assert from "node:assert/strict";
import { mockTauri, openPage, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("appearance/colorThemeMenu", async ({ browser }) => {
// The settings window changes the main window through the mock settings file, so both pages need one context.
const context = await browser.newContext({ viewport: { width: 1200, height: 850 } });
await mockTauri(context, {
commands: test => ({
...test.workspace({ root: "C:\\color-theme-menu", files: { "a.md": "# Note\n\nOriginal text." } }),
plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }),
spelling_menu_install: () => null,
}),
});
const page = await openPage(context);
await page.goto(smokeUrl);
await page.locator('[data-tree-rel="a.md"]').waitFor();
const settings = await openPage(context);
await settings.goto(smokeUrl + "/?settingsWindow=true");
await settings.getByRole("button", { name: "Appearance", exact: true }).click();
// Cards name the mode ("RuneStone Dark" is the default). The next card is Claude Light, and an arrow key selects it (src/lib/theme/ThemePicker.svelte).
await settings.getByRole("radio", { name: "RuneStone Dark", exact: true }).focus();
await settings.keyboard.press("ArrowDown");
await settings.waitForFunction(() => document.documentElement.dataset.palette === "claude");
assert.equal(await settings.evaluate(() => document.documentElement.dataset.palette), "claude");
assert.equal(await settings.locator("input[type=color]").count(), 0);
await page.getByRole("button", { name: "New tab (Ctrl+T)", exact: true }).click();
await page.locator(".empty").waitFor();
await page.waitForFunction(() => document.documentElement.dataset.palette === "claude");
// The empty tab is transparent over the work area layer, which paints the theme background (src/lib/layout/Workbench.svelte:1258, :1548).
assert.equal(await page.locator(".empty").evaluate(node => getComputedStyle(node).backgroundColor), "rgba(0, 0, 0, 0)");
assert.equal(await page.locator(".workarea-background").evaluate(node => {
const reference = document.createElement("span");
reference.style.color = "var(--rs-bg)";
node.append(reference);
const matches = getComputedStyle(node).backgroundColor === getComputedStyle(reference).color;
reference.remove();
return matches;
}), true);
assert.deepEqual([...page.errors, ...settings.errors], []);
console.log("PASS: keyboard theme selection, no color inputs, and the empty tab uses the theme background");
});
+93
View File
@@ -0,0 +1,93 @@
// Compact layout: pane-aligned ribbon, square tables, focus-only tree outline, joined tabs, line hover marker, Git line history, narrow width.
import assert from "node:assert/strict";
import path from "node:path";
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("appearance/density", async ({ page }) => {
const output = await outputDir("appearance/density");
await page.setViewportSize({ width: 1280, height: 800 });
await mockTauri(page, {
commands: test => ({
...test.workspace({
root: "D:\\LayoutTest",
files: { "note.md": "# Layout test\n\nA note with a short paragraph.\n\nA second paragraph.\n\n| Name | Value |\n| --- | --- |\n| Alpha | 12 |\n| Beta | 24 |\n" },
}),
plugins_snapshot: () => ({ root: "D:\\LayoutTest\\plugins", plugins: [] }),
// The Git feature asks the host for the line history. The test turns the answer on with `blameOn`.
git_blame: ({ path, line }) => {
if (!window.blameOn) return null;
window.blameCalls.push({ path, line });
return { commit: "123456789abcdef", author: "UI test", date: "2026-10-07T12:34:00Z", summary: `Changed line ${line}` };
},
}),
});
const row = page.locator('[data-tree-rel="note.md"]');
// The checked choice of the view control. Arrow keys, Home, and End move the choice (src/lib/layout/ViewModes.svelte).
const view = () => page.getByRole("radiogroup", { name: "View" }).getByRole("radio", { checked: true });
const setTheme = theme => page.evaluate(theme => { document.documentElement.dataset.theme = theme; }, theme);
await page.goto(smokeUrl);
await row.waitFor();
await row.click();
await page.locator(".writer-table table").waitFor();
const alignment = await page.evaluate(() => ({ header: document.querySelector(".header-left").getBoundingClientRect().right, content: document.querySelector(".center").getBoundingClientRect().left }));
assert.ok(Math.abs(alignment.header - alignment.content) <= 1, JSON.stringify(alignment));
const table = await page.locator(".writer-table table").evaluate(el => ({ width: el.getBoundingClientRect().width, heights: [...el.rows].map(row => row.getBoundingClientRect().height), radius: getComputedStyle(el.parentElement).borderRadius }));
assert.ok(table.width < 400, JSON.stringify(table));
assert.ok(table.heights.every(height => height <= 36), JSON.stringify(table));
assert.equal(table.radius, "0px");
await row.focus();
assert.equal(await row.locator(".selection-outline").evaluate(el => getComputedStyle(el).visibility), "visible");
await page.locator(".cm-content").click({ position: { x: 80, y: 100 } });
assert.equal(await row.locator(".selection-outline").evaluate(el => getComputedStyle(el).visibility), "hidden");
assert.equal(await row.getAttribute("aria-selected"), "true");
const line = page.locator(".cm-line").filter({ hasText: "A second paragraph." });
await line.hover();
assert.equal(await line.evaluate(el => getComputedStyle(el, "::before").width), "3px");
assert.equal(await page.locator(".line-history").count(), 0);
await page.evaluate(() => { window.blameCalls = []; window.blameOn = true; });
await line.click();
await page.locator(".line-history").waitFor();
assert.match(await page.locator(".line-history").getAttribute("title"), /Line 5 · UI test/);
await page.keyboard.type("x");
await page.locator(".line-history").waitFor({ state: "hidden" });
await page.keyboard.press("Control+z");
await page.locator(".line-history").waitFor();
for (const theme of ["dark", "light"]) {
await setTheme(theme);
const tab = await page.locator(".tab.active").evaluate(el => ({ background: getComputedStyle(el).backgroundColor, border: getComputedStyle(el).borderBottomColor, shadow: getComputedStyle(el).boxShadow }));
const pane = await page.locator(".chrome-bar").evaluate(el => getComputedStyle(el).backgroundColor);
assert.equal(tab.background, pane);
assert.equal(tab.border, "rgba(0, 0, 0, 0)");
assert.equal(tab.shadow, "none");
await line.hover();
await page.screenshot({ path: path.join(output, `writer-${theme}.png`) });
await view().press("End");
await page.locator(".md-page .reading").waitFor();
const paragraph = page.locator(".md-page p").filter({ hasText: "A second paragraph." });
await paragraph.hover();
assert.equal(await paragraph.evaluate(el => getComputedStyle(el, "::before").width), "3px");
assert.ok((await page.locator(".md-page table").boundingBox()).width < 400);
await page.screenshot({ path: path.join(output, `read-${theme}.png`) });
await view().press("Home");
}
await view().press("ArrowRight");
await page.locator(".source-editor .cm-content").waitFor();
await page.locator(".line-history").waitFor();
// Git off removes the line history at once.
await page.evaluate(() => { window.blameOn = false; window.__TEST__.writeSettings("features", { git: false }); });
await page.locator(".line-history").waitFor({ state: "hidden" });
await view().press("Home");
await page.getByRole("button", { name: "Hide outline", exact: true }).click();
await page.setViewportSize({ width: 760, height: 640 });
for (const theme of ["dark", "light"]) {
await setTheme(theme);
const dimensions = await page.locator(".header-left .icon-btn").evaluateAll(els => els.map(el => ({ width: el.getBoundingClientRect().width, svg: el.querySelector("svg").getBoundingClientRect().width })));
assert.ok(dimensions.every(size => size.width >= 28 && size.svg >= 16), JSON.stringify(dimensions));
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth));
await page.screenshot({ path: path.join(output, `narrow-${theme}.png`) });
}
console.log("PASS: pane-aligned ribbon, compact square tables, focus-only tree border, joined tabs, Writer/Read hover marker, Git line slot lifecycle, both themes and narrow width");
}, { timeout: 30000 });
@@ -0,0 +1,52 @@
// The empty tab background image: set it in Settings, keep it after a reload, and remove it. The source stays Image.
import assert from "node:assert/strict";
import path from "node:path";
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
const name = "appearance/newTabBackground";
await runSmoke(name, async ({ browser }) => {
const output = await outputDir(name);
// The settings window changes the main window through the mock settings file and shared IndexedDB, so both pages need one context.
const context = await browser.newContext({ viewport: { width: 1200, height: 850 } });
await mockTauri(context, {
commands: test => ({
...test.workspace({ root: "C:\\new-tab-background", files: { "a.md": "# Note\n\nOriginal text." } }),
plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }),
spelling_menu_install: () => null,
}),
});
const page = await openPage(context);
await page.goto(smokeUrl);
await page.locator('[data-tree-rel="a.md"]').waitFor();
await page.getByRole("button", { name: "New tab (Ctrl+T)", exact: true }).click();
await page.locator(".empty").waitFor();
const settings = await openPage(context);
await settings.goto(smokeUrl + "/?settingsWindow=true");
await settings.getByRole("button", { name: "Appearance", exact: true }).click();
const png = Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+jM1sAAAAASUVORK5CYII=", "base64");
// The image lives on the work area layer behind the empty tab (src/lib/theme/background.css).
const layer = ".workarea-background";
await settings.getByLabel("Background image file", { exact: true }).setInputFiles({ name: "test.png", mimeType: "image/png", buffer: png });
await page.waitForFunction(layer => getComputedStyle(document.querySelector(layer)).backgroundImage.includes("blob:"), layer);
assert.equal(await page.evaluate(() => window.__TEST__.settings("background").source), "image", "A chosen image selects the image source");
await page.reload();
await page.locator(".empty").waitFor();
await page.waitForFunction(layer => getComputedStyle(document.querySelector(layer)).backgroundImage.includes("blob:"), layer);
await settings.getByRole("button", { name: "Remove image", exact: true }).click();
await page.waitForFunction(layer => getComputedStyle(document.querySelector(layer)).backgroundImage === "none", layer);
for (const mode of ["light", "dark"]) {
await settings.evaluate(async mode => {
const { saveAppearance, readAppearance } = await import("/src/lib/theme/appearance.ts");
saveAppearance({ ...readAppearance(), theme: "default", mode });
window.dispatchEvent(new Event("focus"));
}, mode);
await settings.setViewportSize({ width: 650, height: 760 });
await settings.screenshot({ path: path.join(output, `appearance-${mode}-narrow.png`) });
}
assert.equal(await settings.getByRole("button", { name: "Reset background", exact: true }).count(), 0);
assert.equal(await settings.getByRole("button", { name: "Background source", exact: true }).innerText(), "Image");
assert.equal(await settings.getByRole("button", { name: "Choose image…", exact: true }).count(), 1);
await page.waitForFunction(() => !window.__TEST__.settings("appearance").newTabBackground);
assert.deepEqual([...page.errors, ...settings.errors], []);
console.log("PASS: background image applies, survives a reload, and is removed; the image source stays selected");
});
+164
View File
@@ -0,0 +1,164 @@
// Built-in palettes: modes, light-only Sakura, migration, persistence, typography, cross-window sync, source editor updates, and narrow settings.
import assert from "node:assert/strict";
import path from "node:path";
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("appearance/palettes", async ({ browser }) => {
const output = await outputDir("appearance/palettes");
const context = await browser.newContext({ viewport: { width: 1100, height: 780 } });
await mockTauri(context, {
commands: test => ({
...test.workspace({
root: "C:\\appearance-smoke",
files: Object.fromEntries(Array.from({ length: 12 }, (_, index) => [`theme-${index}.py`, `# Theme sample ${index}\ndef sample(parameter):\n return parameter\nname = "RuneStone"\nprint(name, 42)\n`])),
}),
plugins_snapshot: () => ({ root: "C:/appearance-smoke-plugins", plugins: [] }),
"plugin:window|is_maximized": () => false,
}),
});
const main = await openPage(context);
const settings = await openPage(context);
const secondSettings = await openPage(context);
const pages = [main, settings, secondSettings];
try {
await main.goto(smokeUrl);
await main.getByText("appearance-smoke", { exact: true }).waitFor();
async function openCode(index) {
await main.keyboard.press("Control+p");
await main.getByRole("textbox", { name: "Find a file" }).fill(`theme-${index}.py`);
await main.getByRole("dialog").getByRole("button").filter({ hasText: `theme-${index}.py` }).first().waitFor();
await main.getByRole("textbox", { name: "Find a file" }).press("Enter");
await main.locator(".source-editor .cm-content").waitFor();
await main.waitForFunction(file => document.querySelector(".editor .breadcrumb")?.title.endsWith(file)
&& document.querySelector(".source-editor .cm-content")?.dataset.language === "python", `theme-${index}.py`);
await main.locator(".source-editor .cm-line").filter({ hasText: `Theme sample ${index}` }).waitFor();
}
async function editorIds() {
// Mark each mounted editor once. A new editor has no mark, so it gets a new identifier.
return main.evaluate(() => [...document.querySelectorAll(".source-editor .cm-editor")]
.map(node => node.dataset.smokeId ||= String(window.__editorSerial = (window.__editorSerial || 0) + 1)));
}
// Wait until "RuneStone", "def", and "42" have three distinct syntax colors.
async function waitForSyntax() {
await main.waitForFunction(() => {
const spans = [...document.querySelectorAll(".source-editor .cm-line span")];
const colors = ["RuneStone", "def", "42"].map(text => {
const span = spans.find(node => !node.children.length && node.textContent.includes(text));
return span ? getComputedStyle(span).color : null;
});
return colors.every(Boolean) && new Set(colors).size === 3;
});
}
const themeName = (theme, mode) => theme === "sakura" ? "Sakura" : `${({ default: "RuneStone", claude: "Claude" })[theme]} ${mode === "light" ? "Light" : "Dark"}`;
const picker = (page, name) => page.locator(".picker").filter({ has: page.locator("svg") }).and(page.getByRole("button", { name, exact: true }));
// The Color theme cards are one radio group (src/lib/theme/ThemePicker.svelte).
const card = (page, name) => page.getByRole("radiogroup", { name: "Color theme", exact: true }).getByRole("radio", { name, exact: true });
async function choose(page, theme, mode) {
await card(page, themeName(theme, mode)).click();
}
async function openAppearance(page) {
await page.goto(`${smokeUrl}/?settingsWindow=true`);
await page.getByRole("button", { name: "Appearance", exact: true }).click();
await page.getByRole("radiogroup", { name: "Color theme", exact: true }).waitFor();
}
await openCode(0);
await openAppearance(settings);
await openAppearance(secondSettings);
async function expectAppearance(theme, mode) {
for (const page of [settings, secondSettings, main]) {
await page.waitForFunction(({ theme, mode }) => document.documentElement.dataset.palette === theme && document.documentElement.dataset.theme === mode, { theme, mode });
assert.equal(await page.evaluate(() => getComputedStyle(document.documentElement).colorScheme), mode);
}
assert.equal(await card(secondSettings, themeName(theme, mode)).getAttribute("aria-checked"), "true");
await main.waitForFunction(() => {
const root = document.documentElement;
const probe = document.createElement("i");
probe.style.backgroundColor = getComputedStyle(root).getPropertyValue("--rs-workarea-editor-bg");
document.body.append(probe);
const expected = getComputedStyle(probe).backgroundColor;
probe.remove();
const surfaces = [...document.querySelectorAll(".source-editor .cm-editor")];
const workarea = document.querySelector(".editor > .body");
return surfaces.length > 0 && surfaces.every(element => getComputedStyle(element).backgroundColor === "rgba(0, 0, 0, 0)")
&& workarea && getComputedStyle(workarea).backgroundColor === expected;
});
return settings.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue("--rs-bg").trim());
}
let nextCode = 1;
const backgrounds = new Set();
for (const theme of ["default", "claude", "sakura"]) {
for (const mode of theme === "sakura" ? ["light"] : ["light", "dark"]) {
const before = await editorIds();
await choose(settings, theme, mode);
backgrounds.add(await expectAppearance(theme, mode));
assert.deepEqual(await editorIds(), before, "Existing source editors keep their identity when a theme changes");
await openCode(nextCode++);
assert.notDeepEqual(await editorIds(), before, "A new file creates a new source editor");
await expectAppearance(theme, mode);
await waitForSyntax();
assert.deepEqual(await settings.evaluate(() => window.__TEST__.settings("appearance")), { theme, mode });
await settings.screenshot({ path: path.join(output, `appearance-${theme}-${mode}.png`) });
await main.screenshot({ path: path.join(output, `appearance-editor-${theme}-${mode}.png`) });
if (theme === "sakura") {
const keywordColor = await main.locator(".source-editor .cm-line span").evaluateAll(spans => {
const keyword = spans.find(span => !span.children.length && span.textContent.trim() === "def");
return keyword ? getComputedStyle(keyword).color : null;
});
assert.equal(keywordColor, "rgb(160, 68, 107)", "Sakura keywords use the Rose Garden hue");
}
const typography = await settings.evaluate(() => ({
body: getComputedStyle(document.body).fontFamily,
heading: getComputedStyle(document.querySelector("h2")).fontFamily,
prose: getComputedStyle(document.documentElement).getPropertyValue("--rs-font-prose").trim(),
}));
if (theme === "claude") {
assert.match(typography.body, /Lora.*Georgia/);
assert.match(typography.prose, /Lora.*Georgia/);
assert.match(typography.heading, /Poppins.*Arial/);
assert.equal(await settings.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue("--rs-accent").trim()), mode === "light" ? "#ab4e2f" : "#ed8968");
} else assert.doesNotMatch(typography.body, /Lora|Georgia/);
console.log(`PASS: ${theme} ${mode}, saved state, cross-window selection, existing and new source editors`);
}
}
assert.equal(backgrounds.size, 5, "All supported combinations have distinct backgrounds");
assert.deepEqual((await settings.getByRole("radiogroup", { name: "Color theme", exact: true }).getByRole("radio").allTextContents()).map(name => name.trim()), ["RuneStone Light", "RuneStone Dark", "Claude Light", "Claude Dark", "Sakura", "Harvest Moon", "Crimson Pilot", "Silver Serpent"]);
assert.equal(await picker(settings, "Appearance").count(), 0);
assert.equal(await picker(secondSettings, "Appearance").count(), 0);
const sakura = await settings.evaluate(() => {
const css = getComputedStyle(document.documentElement);
return Object.fromEntries(["bg", "border", "selection", "bg-active", "syntax-keyword", "syntax-variable", "syntax-property", "syntax-constant", "syntax-punctuation"].map(key => [key, css.getPropertyValue(`--rs-${key}`).trim()]));
});
// The applied selection color caps its alpha at a6 so text backgrounds show through (appliedColors in src/lib/theme/contrast.ts).
assert.deepEqual(sakura, { bg: "#fefcfc", border: "#efd3dd", selection: "#ffc9dca6", "bg-active": "#f8dbe6", "syntax-keyword": "#a0446b", "syntax-variable": "#513346", "syntax-property": "#47658e", "syntax-constant": "#316a83", "syntax-punctuation": "#566575" });
for (const [theme, savedMode, expectedTheme, mode] of [
["gpt", "light", "default", "light"],
["terminal", "dark", "default", "dark"],
["sakura", "dark", "sakura", "light"],
]) {
await settings.evaluate(value => window.__TEST__.writeSettings("appearance", value), { theme, mode: savedMode });
await settings.reload();
await settings.getByRole("button", { name: "Appearance", exact: true }).click();
await expectAppearance(expectedTheme, mode);
assert.deepEqual(await settings.evaluate(() => window.__TEST__.settings("appearance")), { theme: expectedTheme, mode });
console.log(`PASS: saved ${theme} ${savedMode} migrates to ${expectedTheme} ${mode}`);
}
for (const [theme, mode] of [["default", "dark"], ["claude", "light"], ["claude", "dark"], ["sakura", "light"]]) {
await settings.setViewportSize({ width: 1100, height: 780 });
await choose(settings, theme, mode);
await expectAppearance(theme, mode);
await settings.setViewportSize({ width: 360, height: 480 });
assert(await settings.evaluate(() => document.documentElement.scrollWidth <= innerWidth), "Narrow settings do not overflow the viewport");
assert(await settings.locator("dialog .content").evaluate(node => node.scrollWidth <= node.clientWidth), "Appearance controls do not overflow the content area");
const control = card(settings, themeName(theme, mode));
await control.scrollIntoViewIfNeeded();
const bounds = await control.boundingBox();
assert(bounds.x >= 0 && bounds.x + bounds.width <= 360 && bounds.height >= 28, "The current theme card remains reachable at 360px");
await settings.screenshot({ path: path.join(output, `appearance-${theme}-${mode}-360.png`) });
}
assert.deepEqual(pages.flatMap(page => page.errors), []);
} catch (error) {
for (const [index, page] of pages.entries()) await page.screenshot({ path: path.join(output, `appearance-failure-${index}.png`) }).catch(() => {});
throw error;
}
});
@@ -0,0 +1,116 @@
// Theme picker cards and the theme editor tab: keyboard selection, the check mark, a live preview, contrast badges, Save, Discard, Duplicate, and narrow windows.
import assert from "node:assert/strict";
import path from "node:path";
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("appearance/themeEditor", async ({ browser }) => {
const output = await outputDir("appearance/themeEditor");
const context = await browser.newContext({ viewport: { width: 1200, height: 820 } });
const commands = test => ({
...test.workspace({ root: "C:\\theme-editor", files: { "a.md": "# Note\n\nSome text with a [link](https://example.com).\n" } }),
plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }),
spelling_menu_install: () => null,
"plugin:window|is_maximized": () => false,
});
// The Settings window label names the window that opened it (src-tauri/src/settings.rs).
const main = await openPage(context);
await mockTauri(main, { label: "main", commands });
const settings = await openPage(context);
await mockTauri(settings, { label: "settings-main", commands });
await main.goto(smokeUrl);
await main.locator('[data-tree-rel="a.md"]').waitFor();
await settings.goto(smokeUrl + "/?settingsWindow=true");
await settings.getByRole("button", { name: "Appearance", exact: true }).click();
const token = (page, role) => page.evaluate(role => getComputedStyle(document.documentElement).getPropertyValue(`--rs-${role}`).trim(), role);
// Picker cards: one radio group with a check mark on the current theme.
const cards = settings.getByRole("radiogroup", { name: "Color theme", exact: true });
const card = name => cards.getByRole("radio", { name, exact: true });
assert.equal(await card("RuneStone Dark").getAttribute("aria-checked"), "true");
assert.equal(await card("RuneStone Dark").locator(".card-name svg").count(), 1, "The current card shows a check mark");
assert.equal(await card("Claude Light").locator(".card-name svg").count(), 0);
await card("RuneStone Dark").focus();
await settings.keyboard.press("ArrowRight");
await settings.waitForFunction(() => document.documentElement.dataset.palette === "claude" && document.documentElement.dataset.theme === "light");
assert.equal(await card("Claude Light").evaluate(node => node === document.activeElement && node.getAttribute("aria-checked") === "true"), true);
await settings.keyboard.press("ArrowLeft");
await settings.waitForFunction(() => document.documentElement.dataset.palette === "default" && document.documentElement.dataset.theme === "dark");
await main.waitForFunction(() => document.documentElement.dataset.palette === "default");
await settings.screenshot({ path: path.join(output, "picker-cards.png") });
// Edit theme opens the editor tab in the window that opened Settings.
await settings.getByRole("button", { name: "Edit theme", exact: true }).click();
const editor = main.getByRole("region", { name: "Theme editor", exact: true });
await editor.waitFor();
await main.getByRole("tab", { name: /Theme editor/ }).waitFor();
assert.equal(await editor.getByRole("textbox", { name: "Theme name", exact: true }).inputValue(), "RuneStone Dark copy");
assert.match(await editor.getByRole("status").textContent(), /All readability checks pass/);
// A change shows at once in this window, and not in Settings before a save.
const hex = role => editor.getByRole("textbox", { name: `Hex value of ${role}`, exact: true });
await hex("accent").fill("#ff7a1a");
await hex("accent").press("Tab");
await main.waitForFunction(() => getComputedStyle(document.documentElement).getPropertyValue("--rs-accent").trim() === "#ff7a1a");
assert.equal(await token(settings, "accent"), "#55dcf5");
await main.getByRole("tab", { name: "• Theme editor", exact: true }).waitFor();
// A color that fails a rule shows the failure on its row and in the summary. Reset takes the base color again.
await hex("text-dim").fill("#3a3a3a");
await hex("text-dim").press("Tab");
await editor.getByRole("status").filter({ hasText: /readability checks fail/ }).waitFor();
const dimRow = hex("text-dim").locator("xpath=..");
assert.equal(await dimRow.locator(".badge.fail").count(), 1);
await main.screenshot({ path: path.join(output, "editor-failing-role.png") });
await editor.getByRole("button", { name: "Reset text-dim", exact: true }).click();
assert.equal(await dimRow.locator(".badge.fail").count(), 0);
assert.equal(await token(main, "text-dim"), "#ababab");
// Save copies the built-in theme to a custom theme with a base, and every window selects it.
await editor.getByRole("button", { name: "Save", exact: true }).click();
await editor.getByRole("status").filter({ hasText: "Saved RuneStone Dark copy." }).waitFor();
await settings.waitForFunction(() => document.documentElement.dataset.palette === "custom:runestone-dark-copy");
assert.equal(await token(settings, "accent"), "#ff7a1a");
const saved = await main.evaluate(() => window.__TEST__.settings("customThemes"));
assert.deepEqual(saved.map(theme => [theme.id, theme.base, theme.mode, theme.colors]), [["runestone-dark-copy", "default", "dark", { accent: "#ff7a1a" }]]);
assert.equal(await card("RuneStone Dark copy").getAttribute("aria-checked"), "true");
await main.getByRole("tab", { name: "Theme editor", exact: true }).waitFor();
// Discard returns to the saved colors.
await hex("bg").fill("#202040");
await hex("bg").press("Tab");
await main.waitForFunction(() => getComputedStyle(document.documentElement).getPropertyValue("--rs-bg").trim() === "#202040");
await editor.getByRole("button", { name: "Discard", exact: true }).click();
await main.waitForFunction(() => getComputedStyle(document.documentElement).getPropertyValue("--rs-bg").trim() === "#151617");
// Duplicate saves a copy and selects it.
await editor.getByRole("button", { name: "Duplicate", exact: true }).click();
await editor.getByRole("status").filter({ hasText: "Saved RuneStone Dark copy copy." }).waitFor();
await settings.waitForFunction(() => document.documentElement.dataset.palette === "custom:runestone-dark-copy-copy");
assert.equal((await main.evaluate(() => window.__TEST__.settings("customThemes"))).length, 2);
// A narrow pane keeps the editor inside the window, and keyboard focus is visible.
// A 520-pixel window without the outline leaves the editor about 215 pixels, below its 240-pixel breakpoint.
await main.getByRole("button", { name: "Hide outline", exact: true }).click();
await main.setViewportSize({ width: 520, height: 760 });
assert.ok(await editor.evaluate(node => node.clientWidth <= 240));
await hex("accent").focus();
assert.equal(await editor.evaluate(node => node.scrollWidth <= node.clientWidth + 1), true, "The editor does not scroll sideways in a narrow pane");
assert.notEqual(await hex("accent").evaluate(node => getComputedStyle(node).outlineStyle), "none");
await main.screenshot({ path: path.join(output, "editor-narrow.png") });
await main.setViewportSize({ width: 1200, height: 820 });
await settings.setViewportSize({ width: 360, height: 640 });
assert.equal(await settings.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true, "Narrow settings do not overflow");
const box = await cards.boundingBox();
assert(box.x >= 0 && box.x + box.width <= 360, "The cards fit at 360 pixels");
await settings.screenshot({ path: path.join(output, "picker-cards-360.png") });
// Closing the editor with a change keeps the saved theme in the window.
await hex("accent").fill("#00ff00");
await hex("accent").press("Tab");
await main.waitForFunction(() => getComputedStyle(document.documentElement).getPropertyValue("--rs-accent").trim() === "#00ff00");
await main.getByRole("button", { name: /^Close .*Theme editor$/ }).click();
await editor.waitFor({ state: "detached" });
await main.waitForFunction(() => getComputedStyle(document.documentElement).getPropertyValue("--rs-accent").trim() === "#ff7a1a");
assert.deepEqual([...main.errors, ...settings.errors], []);
console.log("PASS: picker cards, the editor tab, live preview, contrast badges, Save, Discard, Duplicate, and narrow windows");
});
@@ -0,0 +1,31 @@
// Export theme template in Settings > Appearance: success, cancel, and an export error.
import assert from "node:assert/strict";
import { mockTauri, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("appearance/themeExport", async ({ page }) => {
await mockTauri(page, {
state: { exportResult: "C:\\exports\\my-theme.json", exportError: "" },
commands: test => ({
...test.workspace({ root: "C:\\theme-export" }),
plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }),
theme_export: () => {
if (test.state.exportError) throw new Error(test.state.exportError);
return test.state.exportResult;
},
}),
});
const exportButton = page.getByRole("button", { name: "Export theme template" });
await page.goto(smokeUrl + "/?settingsWindow=true");
await page.getByRole("button", { name: "Appearance", exact: true }).click();
await exportButton.click();
await page.getByRole("status").filter({ hasText: "Theme saved to" }).waitFor();
// Exported templates use theme schema 3 (exportAppearanceTheme in src/lib/theme/appearance.ts).
assert.equal(await page.evaluate(() => JSON.parse(window.__TEST__.calls.find(call => call.command === "theme_export").args.contents).schema), 3);
await page.evaluate(() => { window.__TEST__.state.exportResult = null; });
await exportButton.click();
await page.getByText("Export canceled.", { exact: true }).waitFor();
await page.evaluate(() => { window.__TEST__.state.exportError = "Disk is full"; });
await exportButton.click();
await page.getByRole("alert").filter({ hasText: "Disk is full" }).waitFor();
console.log("PASS: theme export success, cancel, and error");
}, { viewport: { width: 1200, height: 850 } });
@@ -0,0 +1,46 @@
// Import custom theme files in Settings > Appearance: schema 1 palettes for each mode, and a short schema 3 file with a base theme.
import assert from "node:assert/strict";
import path from "node:path";
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
const name = "appearance/themeImport";
await runSmoke(name, async ({ page }) => {
const output = await outputDir(name);
await mockTauri(page, {
commands: test => ({
...test.workspace({ root: "C:\\theme-import", files: { "a.md": "# Alpha\n" } }),
plugins_snapshot: () => ({ plugins: [], issues: [] }),
}),
});
await page.goto(smokeUrl + "/?settingsWindow=true");
await page.getByRole("button", { name: "Appearance", exact: true }).click();
const theme = { schema: 1, id: "smoke", name: "Smoke theme", light: { bg: "#fefefe", text: "#222222", accent: "#334499" }, dark: { bg: "#181820", text: "#eeeeee", accent: "#aabbff" } };
const importTheme = (file = theme) => page.locator('input[type=file][aria-label="Theme JSON file"]').setInputFiles({ name: "smoke.json", mimeType: "application/json", buffer: Buffer.from(JSON.stringify(file)) });
const token = name => page.evaluate(name => getComputedStyle(document.documentElement).getPropertyValue(`--rs-${name}`).trim(), name);
const background = () => token("bg");
await importTheme();
await page.waitForFunction(() => document.documentElement.dataset.palette === "custom:smoke");
assert.equal(await background(), "#181820");
// A custom theme now keeps one palette. A schema 1 file converts with the current mode (src/lib/theme/customThemes.ts:38,
// src/lib/theme/AppearanceSettings.svelte), and the light/dark select became the Color theme cards (src/lib/theme/ThemePicker.svelte).
await page.getByRole("radio", { name: "RuneStone Light", exact: true }).click();
await page.waitForFunction(() => document.documentElement.dataset.palette !== "custom:smoke");
await importTheme();
await page.waitForFunction(() => document.documentElement.dataset.palette === "custom:smoke");
assert.equal(await background(), "#fefefe");
await page.screenshot({ path: path.join(output, "custom-theme-light.png") });
// A short schema 3 file takes the missing colors and fonts from its base theme. An earlier theme ID names the base.
await importTheme({ schema: 3, id: "short", name: "Short theme", mode: "dark", base: "holo", colors: { accent: "#00c8ff" } });
await page.waitForFunction(() => document.documentElement.dataset.palette === "custom:short");
assert.deepEqual([await background(), await token("accent"), await token("link"), await token("syntax-keyword")], ["#1c0f0a", "#00c8ff", "#00c8ff", "#f38c48"]);
assert.match(await token("font-ui"), /Candara/);
assert.equal(await page.evaluate(() => document.documentElement.dataset.theme), "dark");
await page.screenshot({ path: path.join(output, "custom-theme-short.png") });
// A base without a palette in the file's mode stops the installation with an error.
await importTheme({ schema: 3, id: "wrong", name: "Wrong base", mode: "dark", base: "sakura", colors: {} });
await page.getByRole("alert").filter({ hasText: "Use a built-in theme with a dark palette as the base." }).waitFor();
assert.equal(await page.evaluate(() => document.documentElement.dataset.palette), "custom:short");
console.log("PASS: custom theme import applies schema 1 palettes, a short schema 3 file with a base, and rejects a wrong base");
}, { timeout: 15000 });
@@ -0,0 +1,93 @@
// Theme variants: transparency slider in eight variants, custom theme fonts, a single tooltip, plugin command icons,
// and the native Background commands in the command palette.
import assert from 'node:assert/strict';
import path from 'node:path';
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from '../_harness/index.mjs';
await runSmoke('appearance/themeVariants', async ({ browser }) => {
const output = await outputDir('appearance/themeVariants');
const context = await browser.newContext({ viewport: { width: 1100, height: 800 } });
await mockTauri(context, {
commands: test => ({
...test.workspace({
root: 'C:\\appearance-smoke',
files: Object.fromEntries(Array.from({ length: 12 }, (_, index) => [`theme-${index}.py`, `# Theme sample ${index}\ndef sample(parameter):\n return parameter\nname = "RuneStone"\nprint(name, 42)\n`])),
}),
plugins_snapshot: () => ({ root: 'C:/appearance-smoke-plugins', plugins: [] }),
'plugin:window|is_maximized': () => false,
}),
});
const page = await openPage(context);
await page.goto(`${smokeUrl}/?settingsWindow=true`);
await page.getByRole('button', { name: 'Appearance', exact: true }).click();
const transparent = page.getByRole('switch', { name: 'Transparent surfaces', exact: true });
for (const [theme, mode] of [['default', 'dark'], ['default', 'light'], ['claude', 'dark'], ['claude', 'light'], ['sakura', 'light'], ['harvest-moon', 'dark'], ['crimson-pilot', 'dark'], ['silver-serpent', 'dark']]) {
await page.evaluate(async ({ theme, mode }) => {
(await import('/src/lib/theme/appearance.ts')).saveAppearance({ theme, mode, transparency: { enabled: true, amount: 18 } });
window.dispatchEvent(new Event('focus'));
}, { theme, mode });
const slider = page.locator('#surface-transparency');
await slider.fill('100');
assert.equal(await page.evaluate(() => window.__TEST__.settings('appearance').transparency.amount), 100);
await slider.focus(); await page.keyboard.press('Home'); assert.equal(await slider.inputValue(), '0');
await page.keyboard.press('End'); assert.equal(await slider.inputValue(), '100');
await page.screenshot({ path: path.join(output, `${theme}-${mode}-slider-focus.png`) });
await transparent.uncheck();
assert(await slider.isDisabled());
await page.screenshot({ path: path.join(output, `${theme}-${mode}-slider-disabled.png`) });
await transparent.check();
await page.setViewportSize({ width: 360, height: 740 }); await slider.scrollIntoViewIfNeeded();
assert(await page.locator('.content').evaluate(node => node.scrollWidth <= node.clientWidth));
await page.screenshot({ path: path.join(output, `${theme}-${mode}-narrow.png`) });
await page.setViewportSize({ width: 1100, height: 800 });
}
await page.evaluate(async () => {
const { installTheme } = await import('/src/lib/theme/customThemes.ts');
const { saveAppearance, exportAppearanceTheme } = await import('/src/lib/theme/appearance.ts');
const theme = exportAppearanceTheme('default'); theme.fonts = { ui: 'Arial, sans-serif', prose: 'Georgia, serif', heading: 'Georgia, serif', mono: 'Consolas, monospace' };
installTheme(theme); saveAppearance({ theme: 'custom:my-theme', mode: 'dark' }); window.dispatchEvent(new Event('focus'));
});
assert.match(await page.locator('.preview-prose').evaluate(node => getComputedStyle(node).fontFamily), /Georgia/);
assert.match(await page.evaluate(async () => (await import('/src/lib/theme/appearance.ts')).exportAppearanceTheme('custom:my-theme').fonts.ui), /Arial/);
await page.screenshot({ path: path.join(output, 'custom-fonts.png') });
const main = await openPage(context); await main.goto(smokeUrl);
await main.bringToFront();
await main.getByRole('button', { name: 'Files', exact: true }).waitFor();
// The commands of the native Background feature (src/lib/features/catalog.ts) are in the command palette, without the feature code.
await main.keyboard.press('Control+Shift+P');
const palette = main.getByRole('dialog', { name: 'Commands', exact: true });
await palette.getByRole('textbox', { name: 'Find a command', exact: true }).fill('background');
for (const title of ['Next background image', 'Pause background']) await palette.getByRole('button').filter({ hasText: title }).first().waitFor();
assert.equal(await main.evaluate(async () => (await import('/src/lib/features/loader.ts')).featureRequested('background')), false, 'The palette lists the commands without the feature code');
await main.keyboard.press('Escape');
// A third-party plugin with command icons. The Commands menu lists plugin commands only (src/lib/plugins/PluginAccessMenu.svelte).
await main.evaluate(async () => {
const loaded = performance.getEntriesByType('resource').map(entry => entry.name).find(name => new URL(name).pathname === '/src/lib/plugins/external.ts');
const { pluginTools, refreshPlugins } = await import(loaded || '/src/lib/plugins/external.ts');
await refreshPlugins();
const invoke = window.__TAURI_INTERNALS__.invoke;
window.__TAURI_INTERNALS__.invoke = (command, args) => command === 'plugins_snapshot' ? Promise.resolve(null) : invoke(command, args);
const commands = [{ owner: 'org.test.slideshow', id: 'next-image', title: 'Next test image', kind: 'command', surface: 'commands', icon: 'skip-forward' }, { owner: 'org.test.slideshow', id: 'pause-resume', title: 'Pause or resume test slideshow', kind: 'command', surface: 'commands', icon: 'pause' }];
pluginTools.set(commands);
});
const visibleTooltips = () => main.locator('[role=tooltip]:visible').count();
for (const mode of ['dark', 'light']) {
await main.evaluate(async mode => (await import('/src/lib/theme/appearance.ts')).saveAppearance({ theme: 'default', mode }), mode);
const button = main.getByRole('button', { name: 'Commands', exact: true });
assert.equal(await button.getAttribute('title'), null);
await button.hover(); await main.waitForTimeout(1100);
assert.equal(await visibleTooltips(), 1);
await main.screenshot({ path: path.join(output, `${mode}-single-tooltip.png`) });
await main.keyboard.press('Escape'); assert.equal(await visibleTooltips(), 0);
await main.mouse.move(400, 400);
await button.evaluate(node => node.blur());
await button.focus(); await main.waitForTimeout(600); assert.equal(await visibleTooltips(), 1);
await button.click(); await main.getByRole('menu').waitFor();
const paths = await main.locator('.rs-menu svg').evaluateAll(nodes => nodes.map(node => node.innerHTML));
assert(paths.some(path => path.includes('M7 4v16'))); assert(paths.some(path => path.includes('m4 4 12 8')));
await main.screenshot({ path: path.join(output, `${mode}-plugin-command-icons.png`) }); await main.keyboard.press('Escape');
}
assert.deepEqual([...page.errors, ...main.errors], []);
console.log('PASS: eight theme variants, slider endpoints, persistence, disabled states, narrow layout, font import/export, single tooltip, and command icons.');
});
@@ -0,0 +1,53 @@
// Shared tooltips (attachTooltip) in both themes: no title attribute, rounded corners, Escape and focus, and placement inside a narrow window.
import assert from "node:assert/strict";
import path from "node:path";
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
const name = "appearance/tooltipPlacement";
await runSmoke(name, async ({ browser }) => {
const output = await outputDir(name);
for (const theme of ["light", "dark"]) {
const page = await openPage(browser, { viewport: { width: 1100, height: 780 } });
await mockTauri(page, {
commands: test => ({
...test.workspace({ root: "C:\\tooltip-placement", files: { "sample.md": "# Tooltip sample\n" } }),
plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }),
}),
});
await page.goto(smokeUrl);
await page.getByText("tooltip-placement", { exact: true }).waitFor();
await page.evaluate(async theme => {
const { saveAppearance } = await import("/src/lib/theme/appearance.ts");
saveAppearance({ theme: "default", mode: theme });
const { attachTooltip } = await import("/src/lib/ui/tooltip.ts");
const cell = document.createElement("button");
cell.id = "tooltip-test";
cell.textContent = "Formula cell";
Object.assign(cell.style, { position: "fixed", left: "20px", top: "100px", zIndex: "2000" });
document.body.append(cell);
window.disposeTip = attachTooltip(cell, () => "B6 · Click to edit · Type = for a formula");
}, theme);
const target = page.locator("#tooltip-test");
const tooltip = page.locator(".rs-tooltip:popover-open");
await target.hover();
await tooltip.waitFor();
assert.equal(await target.getAttribute("title"), null);
assert.equal(await tooltip.evaluate(node => getComputedStyle(node).borderRadius), "5px");
await page.screenshot({ path: path.join(output, `${theme}-tooltip.png`) });
await page.keyboard.press("Escape");
assert.equal(await page.locator(".rs-tooltip:popover-open").count(), 0);
await target.focus();
await tooltip.waitFor();
await page.setViewportSize({ width: 390, height: 620 });
await page.locator("header").first().hover();
await target.hover();
await tooltip.waitFor();
const bounds = await tooltip.boundingBox();
assert(bounds.x >= 8 && bounds.x + bounds.width <= 382);
await page.screenshot({ path: path.join(output, `${theme}-narrow-tooltip.png`) });
await page.evaluate(() => { window.disposeTip(); document.getElementById("tooltip-test").remove(); });
assert.deepEqual(page.errors, []);
await page.close();
console.log(`PASS: ${theme} tooltip`);
}
});
@@ -0,0 +1,118 @@
// Tab tooltips, translucent text selection, zero-transparency backgrounds, a stable transparency slider, and the themed install checkbox.
import assert from "node:assert/strict";
import path from "node:path";
import { mockTauri, outputDir, runSmoke, showSavedImage, smokeUrl } from "../_harness/index.mjs";
await runSmoke("appearance/tooltipsAndSelection", async ({ page }) => {
const output = await outputDir("appearance/tooltipsAndSelection");
page.on("console", message => { if (message.type() === "error" || message.type() === "warning") console.log(message.type(), message.text()); });
await mockTauri(page, {
commands: test => ({
...test.workspace({
root: "C:\\smoke-workspace",
writeEvents: true,
files: {
"notes/welcome.md": "---\ntitle: Welcome\n---\n\n# Working notes\n\nFirst paragraph.\n\n- [ ] A task\n\n[[second]]\n",
"notes/second.md": "# Second note\n",
"src/hello.py": "print('hello')\n",
},
}),
plugins_snapshot: () => ({ root: "C:/theme-test-plugins", plugins: [] }),
"plugin:window|is_maximized": () => false,
spelling_menu_install: () => null,
}),
});
const tooltip = page.locator(".rs-tooltip:popover-open");
try {
await page.goto(smokeUrl);
await page.getByText("smoke-workspace", { exact: true }).waitFor();
await page.keyboard.press("Control+p");
await page.getByRole("textbox", { name: "Find a file" }).fill("welcome.md");
await page.getByRole("dialog").getByRole("button").filter({ hasText: "welcome.md" }).first().click();
await page.getByRole("textbox", { name: "Writing editor", exact: true }).waitFor();
for (const mode of ["dark", "light"]) {
await page.evaluate(async mode => {
const { saveAppearance } = await import("/src/lib/theme/appearance.ts");
saveAppearance({ theme: "default", mode, transparency: { enabled: true, amount: 0 }, newTabBackground: { image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+jM1sAAAAASUVORK5CYII=" } });
}, mode);
await showSavedImage(page);
const tab = page.getByRole("tab", { name: /welcome\.md/ });
assert.equal(await tab.getAttribute("title"), null);
await page.mouse.move(600, 600);
await tab.hover();
await tooltip.waitFor();
assert.match(await tooltip.innerText(), /welcome\.md/);
await page.screenshot({ path: path.join(output, `${mode}-tab-tooltip.png`) });
await page.keyboard.press("Escape");
assert.equal(await tooltip.count(), 0);
await tab.focus();
await tooltip.waitFor();
await page.keyboard.press("Escape");
const writer = page.getByRole("textbox", { name: "Writing editor", exact: true });
await writer.click(); await page.keyboard.press("Control+a");
const colors = await writer.evaluate(node => {
const root = getComputedStyle(document.documentElement), body = getComputedStyle(document.body);
// Background sets the image and the surfaces on the body (src/lib/plugins/backgrounds.ts).
return { selection: root.getPropertyValue("--rs-selection"), bg: getComputedStyle(node, "::selection").backgroundColor,
text: getComputedStyle(node).color, image: body.getPropertyValue("--rs-background-image"), pluginBg: body.getPropertyValue("--rs-workarea-plugin-bg") };
});
assert.match(colors.selection.trim(), /^#[0-9a-f]{6}a6$/i);
assert.match(colors.bg, /0\.65/);
assert.notEqual(colors.image.trim(), "none");
assert.equal(colors.pluginBg.trim(), "transparent");
console.log(mode, colors);
await page.screenshot({ path: path.join(output, `${mode}-selection.png`) });
await page.getByRole("button", { name: "New tab (Ctrl+T)", exact: true }).click();
await page.locator(".empty").waitFor();
await page.screenshot({ path: path.join(output, `${mode}-zero-background.png`) });
await page.getByRole("tab", { name: /welcome\.md/ }).click();
}
await page.goto(`${smokeUrl}/?settingsWindow=true`);
await page.getByRole("button", { name: "Appearance", exact: true }).click();
for (const mode of ["dark", "light"]) {
await page.evaluate(async mode => {
(await import("/src/lib/theme/appearance.ts")).saveAppearance({ theme: "default", mode });
window.dispatchEvent(new Event("focus"));
}, mode);
const slider = page.locator("#surface-transparency");
for (const width of [1100, 390]) {
await page.setViewportSize({ width, height: 800 });
await slider.fill("0"); const zero = await slider.boundingBox();
for (const amount of ["1", "9", "11", "18", "99", "100"]) {
await slider.fill(amount); const current = await slider.boundingBox();
assert.equal(current.x, zero.x); assert.equal(current.width, zero.width);
}
await page.screenshot({ path: path.join(output, `${mode}-${width}-slider.png`) });
}
}
await page.evaluate(() => {
const invoke = window.__TAURI_INTERNALS__.invoke;
window.__TAURI_INTERNALS__.invoke = (command, args) => command === "plugins_choose"
? Promise.resolve([{ token: "theme-test", source: "C:/Downloads/example.zip", error: null,
manifest: { id: "example", name: "Theme example", version: "0.1.0", description: "Theme control test", author: "RuneStone", entry: "main.js" } }])
: invoke(command, args);
});
await page.getByRole("button", { name: "Plug-ins", exact: true }).click();
for (const [theme, mode] of [["harvest-moon", "dark"], ["default", "light"]]) {
await page.evaluate(async ({ theme, mode }) => {
(await import("/src/lib/theme/appearance.ts")).saveAppearance({ theme, mode }); window.dispatchEvent(new Event("focus"));
}, { theme, mode });
await page.getByRole("button", { name: "Install plugin ZIP", exact: true }).click();
const checkbox = page.getByRole("checkbox", { name: "Theme example", exact: true });
await checkbox.waitFor();
assert.equal(await checkbox.evaluate(node => getComputedStyle(node).accentColor), await page.evaluate(() => {
const probe = document.createElement("span"); probe.style.color = "var(--rs-accent)"; document.body.append(probe);
const color = getComputedStyle(probe).color; probe.remove(); return color;
}));
await checkbox.focus();
await page.screenshot({ path: path.join(output, `${theme}-${mode}-install-checkbox.png`) });
await page.getByRole("button", { name: "Cancel", exact: true }).click();
}
console.log("PASS: exact tab tooltips, translucent text selection, retained zero-transparency background, stable slider, themed installation checkbox.");
} catch (error) {
await page.screenshot({ path: path.join(output, "failure.png") });
throw error;
}
});
+135
View File
@@ -0,0 +1,135 @@
// Character theme typography: CSS families and the fonts Chromium renders for UI, prose, headings, and code, plus narrow settings.
import assert from 'node:assert/strict';
import { writeFile } from 'node:fs/promises';
import path from 'node:path';
import { mockTauri, openPage, outputDir, runSmoke, settle, smokeUrl } from '../_harness/index.mjs';
await runSmoke('appearance/typography', async ({ browser }) => {
const output = await outputDir('appearance/typography');
const report = [];
const context = await browser.newContext({ viewport: { width: 1100, height: 780 } });
await mockTauri(context, {
commands: test => ({
...test.workspace({
root: 'C:\\font-smoke',
files: { 'Typography.md': '# A place for your ideas\n\nRead the next chapter, collect clear notes, and keep your work close. Small letters, open spaces, and steady lines help each sentence stay readable.\n\n## Details worth keeping\n\nThe quick brown fox jumps over the lazy dog. Il1 O0 rn m, 0123456789.\n\n`const name = "RuneStone";`\n' },
}),
plugins_snapshot: () => ({ root: 'C:/font-smoke-plugins', plugins: [] }),
}),
});
const main = await openPage(context);
const settings = await openPage(context);
await main.goto(smokeUrl);
await main.getByText('font-smoke', { exact: true }).waitFor();
await main.keyboard.press('Control+p');
await main.getByRole('textbox', { name: 'Find a file' }).fill('Typography.md');
await main.getByRole('textbox', { name: 'Find a file' }).press('Enter');
await main.getByRole('textbox', { name: 'Writing editor', exact: true }).waitFor();
await settings.goto(`${smokeUrl}/?settingsWindow=true`);
await settings.getByRole('button', { name: 'Appearance', exact: true }).click();
const sessions = new Map();
// The CSS font of `selector` and the platform fonts Chromium used to draw its glyphs.
async function rendered(page, selector) {
await settle(page);
let session = sessions.get(page);
if (!session) {
session = await context.newCDPSession(page);
await session.send('DOM.enable'); await session.send('CSS.enable'); sessions.set(page, session);
}
const { root } = await session.send('DOM.getDocument');
const { nodeId } = await session.send('DOM.querySelector', { nodeId: root.nodeId, selector });
assert(nodeId, selector);
const { fonts } = await session.send('CSS.getPlatformFontsForNode', { nodeId });
const style = await page.locator(selector).first().evaluate(node => {
const css = getComputedStyle(node);
return { family: css.fontFamily, size: css.fontSize, weight: css.fontWeight, lineHeight: css.lineHeight };
});
return { ...style, rendered: fonts.filter(font => font.glyphCount).map(({ familyName, postScriptName, glyphCount, isCustomFont }) => ({ familyName, postScriptName, glyphCount, isCustomFont })) };
}
const setPluginTools = count => settings.evaluate(async count => {
const { pluginTools } = await import(performance.getEntriesByType('resource').find(entry => new URL(entry.name).pathname === '/src/lib/plugins/external.ts').name);
pluginTools.set(Array.from({ length: count }, (_, index) => ({ owner: 'org.example.font-check', id: `settings-${index}`, title: `Plugin settings ${index + 1}`, surface: 'settings' })));
}, count);
const selectors = { ui: '.theme-actions button', prose: '.cm-line:not(.writer-heading):not(.writer-blank)', heading: '.writer-h1' };
const cases = [
['harvest-moon', 'Harvest Moon', 'Constantia', 'Candara', 'Constantia', 'Constantia'],
['crimson-pilot', 'Crimson Pilot', 'Bahnschrift', 'Bahnschrift', 'Segoe UI', 'Bahnschrift'],
['silver-serpent', 'Silver Serpent', 'Palatino Linotype', 'Corbel', 'Palatino Linotype', 'Palatino Linotype'],
];
for (const [theme, label, oldFont, ui, prose, heading] of cases) {
await settings.setViewportSize({ width: 1100, height: 780 });
await settings.getByRole('radio', { name: label, exact: true }).click();
await main.waitForFunction(theme => document.documentElement.dataset.palette === theme, theme);
await main.getByRole('textbox', { name: 'Writing editor', exact: true }).press('Control+Home');
await main.evaluate(() => { getSelection().removeAllRanges(); document.activeElement?.blur(); });
// The theme sets its fonts as inline properties of the root. Put back those values after each temporary change.
for (const page of [main, settings]) {
const saved = await page.evaluate(font => ['ui', 'prose', 'heading'].map(role => {
const value = document.documentElement.style.getPropertyValue(`--rs-font-${role}`);
document.documentElement.style.setProperty(`--rs-font-${role}`, `"${font}"`);
return value;
}), oldFont);
await page.screenshot({ path: path.join(output, `${theme}-before-${page === main ? 'document' : 'settings'}.png`) });
await page.evaluate(saved => {
['ui', 'prose', 'heading'].forEach((role, index) => document.documentElement.style.setProperty(`--rs-font-${role}`, saved[index]));
}, saved);
}
const roles = {
ui: await rendered(settings, selectors.ui),
prose: await rendered(main, selectors.prose),
heading: await rendered(main, selectors.heading),
mono: await rendered(settings, '.preview-code'),
};
for (const [role, family] of Object.entries({ ui, prose, heading })) {
assert(roles[role].family.includes(family), `${theme}: ${role} CSS family`);
assert(roles[role].rendered.some(font => font.familyName === family), `${theme}: ${role} actually renders ${family}: ${JSON.stringify(roles[role])}`);
}
assert.equal(roles.ui.size, '13px');
assert.equal(roles.prose.size, '15px');
assert(roles.mono.family.includes('Cascadia Mono'));
assert(roles.mono.rendered.some(font => font.familyName === 'Cascadia Mono'));
await settings.screenshot({ path: path.join(output, `${theme}-after-settings.png`) });
await main.screenshot({ path: path.join(output, `${theme}-after-document.png`) });
await main.getByRole('textbox', { name: 'Writing editor', exact: true }).evaluate(node => {
node.focus();
const paragraph = [...node.querySelectorAll('.cm-line')].find(line => line.textContent.includes('Read the next chapter'));
const range = document.createRange(); range.selectNodeContents(paragraph);
const selection = window.getSelection(); selection.removeAllRanges(); selection.addRange(range);
});
assert((await main.evaluate(() => getSelection().toString())).includes('Read the next chapter'));
await main.screenshot({ path: path.join(output, `${theme}-selected-prose.png`) });
await settings.setViewportSize({ width: 360, height: 480 });
const content = settings.locator('dialog .content');
assert(await content.evaluate(node => node.scrollWidth <= node.clientWidth), `${theme}: narrow overflow`);
// The current theme card stays reachable from the keyboard in a narrow window.
const current = settings.getByRole('radio', { name: label, exact: true });
await current.scrollIntoViewIfNeeded(); await current.focus();
assert.equal(await current.getAttribute('aria-checked'), 'true');
assert(await current.evaluate(node => node === document.activeElement));
await settings.screenshot({ path: path.join(output, `${theme}-narrow-cards.png`) });
await setPluginTools(16);
const bodyBounds = await settings.locator('dialog .body').boundingBox();
assert((await settings.locator('dialog aside').boundingBox()).height <= bodyBounds.height * .4 + 1);
await settings.getByRole('button', { name: 'Plugin settings 16', exact: true }).scrollIntoViewIfNeeded();
assert(await content.evaluate(node => node.scrollWidth <= node.clientWidth));
await settings.screenshot({ path: path.join(output, `${theme}-narrow-long-plugins.png`) });
await setPluginTools(0);
// Drop the first family from each stack and check that the fallback still renders glyphs.
const fallback = {};
for (const [role, page] of [['ui', settings], ['prose', main], ['heading', main]]) {
const stack = await page.evaluate(role => {
const stack = getComputedStyle(document.documentElement).getPropertyValue(`--rs-font-${role}`);
document.documentElement.style.setProperty(`--rs-font-${role}`, stack.slice(stack.indexOf(',') + 1));
return stack;
}, role);
fallback[role] = await rendered(page, selectors[role]);
assert(fallback[role].rendered.length > 0);
await page.evaluate(([role, stack]) => document.documentElement.style.setProperty(`--rs-font-${role}`, stack), [role, stack]);
}
report.push({ theme, oldFont, roles, fallback });
console.log(`PASS ${theme}: real UI and prose sizes, rendered fonts, shared monospace, selection, narrow settings, keyboard focus, long plugin navigation`);
}
assert.deepEqual([...main.errors, ...settings.errors], []);
await writeFile(path.join(output, 'rendered-fonts.json'), JSON.stringify(report, null, 2));
});