Update editor, themes, menus, backgrounds, and release tooling
This commit is contained in:
@@ -81,11 +81,11 @@ try {
|
||||
return expected ? JSON.stringify(colors) === JSON.stringify(expected) : Object.values(colors).every(Boolean) && new Set(Object.values(colors)).size === 3;
|
||||
}, expected);
|
||||
}
|
||||
const themeName = theme => ({ default: 'RuneStone', claude: 'Claude', sakura: 'Sakura' })[theme];
|
||||
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 }));
|
||||
async function choose(page, name, value) {
|
||||
await picker(page, name).click();
|
||||
await page.getByRole('menuitemradio', { name: name === 'Color theme' ? themeName(value) : value === 'light' ? 'Light' : 'Dark', exact: true }).click();
|
||||
async function choose(page, theme, mode) {
|
||||
await picker(page, 'Color theme').click();
|
||||
await page.getByRole('menuitemradio', { name: themeName(theme, mode), exact: true }).click();
|
||||
}
|
||||
async function openAppearance(page) {
|
||||
await page.goto(`${origin}/?settingsWindow=true`);
|
||||
@@ -100,17 +100,18 @@ try {
|
||||
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 picker(secondSettings, "Color theme").textContent()).trim(), themeName(theme));
|
||||
assert.equal((await picker(secondSettings, "Appearance").textContent()).trim(), mode === "light" ? "Light" : "Dark");
|
||||
assert.equal((await picker(secondSettings, "Color theme").textContent()).trim(), themeName(theme, mode));
|
||||
await main.waitForFunction(() => {
|
||||
const root = document.documentElement;
|
||||
const probe = document.createElement("i");
|
||||
probe.style.backgroundColor = getComputedStyle(root).getPropertyValue("--rs-bg");
|
||||
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(".monaco-editor .monaco-editor-background")];
|
||||
return surfaces.length > 0 && surfaces.every(element => getComputedStyle(element).backgroundColor === expected);
|
||||
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());
|
||||
}
|
||||
@@ -120,8 +121,7 @@ try {
|
||||
for (const theme of ["default", "claude", "sakura"]) {
|
||||
for (const mode of theme === "sakura" ? ["light"] : ["light", "dark"]) {
|
||||
const before = await editorIds();
|
||||
await choose(settings, 'Color theme', theme);
|
||||
if (theme !== "sakura") await choose(settings, 'Appearance', mode);
|
||||
await choose(settings, theme, mode);
|
||||
backgrounds.add(await expectAppearance(theme, mode));
|
||||
assert.deepEqual(await editorIds(), before, "Existing Monaco editors keep their identity when a theme changes");
|
||||
await openCode(nextCode++);
|
||||
@@ -154,10 +154,10 @@ try {
|
||||
}
|
||||
assert.equal(backgrounds.size, 5, "All supported combinations have distinct backgrounds");
|
||||
await picker(settings, 'Color theme').click();
|
||||
assert.deepEqual(await settings.getByRole('menuitemradio').allTextContents(), ['RuneStone', 'Claude', 'Sakura']);
|
||||
assert.deepEqual(await settings.getByRole('menuitemradio').allTextContents(), ['RuneStone Light', 'RuneStone Dark', 'Claude Light', 'Claude Dark', 'Sakura', 'Harvest Moon', 'Crimson Pilot', 'Silver Serpent']);
|
||||
await settings.keyboard.press('Escape');
|
||||
assert.equal(await picker(settings, 'Appearance').isDisabled(), true);
|
||||
assert.equal(await picker(secondSettings, 'Appearance').isDisabled(), true);
|
||||
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-parameter', 'syntax-keyword', 'syntax-local', 'syntax-static', 'syntax-instance', 'syntax-global'].map(key => [key, css.getPropertyValue(`--rs-${key}`).trim()]));
|
||||
@@ -177,14 +177,13 @@ try {
|
||||
}
|
||||
for (const [theme, mode] of [['default', 'dark'], ['claude', 'light'], ['claude', 'dark'], ['sakura', 'light']]) {
|
||||
await settings.setViewportSize({ width: 1100, height: 780 });
|
||||
await choose(settings, 'Color theme', theme);
|
||||
if (theme !== 'sakura') await choose(settings, 'Appearance', mode);
|
||||
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');
|
||||
const content = settings.locator('dialog .content');
|
||||
assert(await content.evaluate(node => node.scrollWidth <= node.clientWidth), 'Appearance controls do not overflow the content area');
|
||||
for (const name of ['Color theme', 'Appearance']) {
|
||||
for (const name of ['Color theme']) {
|
||||
const control = picker(settings, name);
|
||||
await control.scrollIntoViewIfNeeded();
|
||||
const bounds = await control.boundingBox();
|
||||
|
||||
@@ -1,14 +1,71 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { test } from 'node:test';
|
||||
import { parseAppearance, normalizeAppearance, THEMES } from '../src/lib/theme/appearance.ts';
|
||||
import { parseCustomTheme } from '../src/lib/theme/customThemes.ts';
|
||||
import { CHARACTER_THEMES, SYNTAX_ROLES } from '../src/lib/theme/characterThemes.ts';
|
||||
import { parseAppearance, normalizeAppearance, exportAppearanceTheme, BUILTIN_THEMES, THEMES, themeModes } from '../src/lib/theme/appearance.ts';
|
||||
|
||||
test('Removed palettes preserve the saved mode with the default palette', () => {
|
||||
for (const theme of ['gpt', 'terminal', 'unknown']) {
|
||||
for (const theme of ['gpt', 'terminal', 'unknown', 'renamon', 'asuka-school']) {
|
||||
for (const mode of ['light', 'dark'] as const) {
|
||||
assert.deepEqual(parseAppearance(JSON.stringify({ theme, mode })), { theme: 'default', mode });
|
||||
}
|
||||
}
|
||||
assert.deepEqual(THEMES, ['default', 'claude', 'sakura']);
|
||||
assert.deepEqual(THEMES, ['default', 'claude', 'sakura', 'harvest-moon', 'crimson-pilot', 'silver-serpent']);
|
||||
assert.deepEqual(BUILTIN_THEMES.map(theme => theme.id), THEMES);
|
||||
});
|
||||
|
||||
test('Renamed palettes preserve saved choices and backgrounds', () => {
|
||||
const newTabBackground = { imageId: '01234567-89ab-cdef-0123-456789abcdef', position: 'top left', size: 'auto', overlay: -0.4 };
|
||||
for (const [previous, theme] of [['holo', 'harvest-moon'], ['asuka', 'crimson-pilot'], ['malfoid', 'silver-serpent']]) {
|
||||
for (const mode of ['light', 'dark']) {
|
||||
assert.deepEqual(parseAppearance(JSON.stringify({ theme: previous, mode, newTabBackground })), { theme, mode: 'dark', newTabBackground });
|
||||
}
|
||||
}
|
||||
for (const theme of ['constructor', '__proto__', 'toString']) {
|
||||
assert.deepEqual(normalizeAppearance({ theme, mode: 'light' }), { theme: 'default', mode: 'light' });
|
||||
}
|
||||
});
|
||||
|
||||
test('Removed character themes retain the saved background', () => {
|
||||
const newTabBackground = { imageId: '01234567-89ab-cdef-0123-456789abcdef', position: 'top left', size: 'auto', overlay: -0.4 };
|
||||
for (const theme of ['renamon', 'asuka-school']) {
|
||||
assert.deepEqual(parseAppearance(JSON.stringify({ theme, mode: 'light', newTabBackground })), { theme: 'default', mode: 'light', newTabBackground });
|
||||
}
|
||||
});
|
||||
|
||||
function luminance(color: string) {
|
||||
const rgb = color.slice(1).match(/../g)!.map(value => parseInt(value, 16) / 255)
|
||||
.map(value => value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4);
|
||||
return rgb[0] * 0.2126 + rgb[1] * 0.7152 + rgb[2] * 0.0722;
|
||||
}
|
||||
function contrast(foreground: string, background: string) {
|
||||
const values = [luminance(foreground), luminance(background)].sort((a, b) => b - a);
|
||||
return (values[0] + 0.05) / (values[1] + 0.05);
|
||||
}
|
||||
test('Character palettes restore one appearance and export readable surfaces and syntax', () => {
|
||||
for (const theme of Object.keys(CHARACTER_THEMES) as (keyof typeof CHARACTER_THEMES)[]) {
|
||||
const exported = exportAppearanceTheme(theme);
|
||||
for (const mode of ['light', 'dark'] as const) {
|
||||
assert.deepEqual(parseAppearance(JSON.stringify({ theme, mode })), { theme, mode: CHARACTER_THEMES[theme].mode });
|
||||
const colors = exported[mode];
|
||||
for (const foreground of ['text', 'text-dim', 'text-strong', 'accent'] as const) {
|
||||
for (const background of ['bg', 'bg-elevated', 'bg-active', 'selection'] as const) {
|
||||
if (foreground === 'accent' && background === 'selection') continue;
|
||||
assert(contrast(colors[foreground]!, colors[background]!) >= 4.5, `${theme} ${mode}: ${foreground} on ${background}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
assert.deepEqual(themeModes(theme), [CHARACTER_THEMES[theme].mode]);
|
||||
assert.deepEqual(exported.light, exported.dark);
|
||||
assert.deepEqual(parseCustomTheme(exported), exported);
|
||||
for (const role of SYNTAX_ROLES) {
|
||||
for (const background of ['bg', 'bg-active'] as const) {
|
||||
assert(contrast(exported.light[`syntax-${role}`]!, exported.light[background]!) >= 4.5, `${theme}: ${role} on ${background}`);
|
||||
}
|
||||
}
|
||||
assert(new Set(SYNTAX_ROLES.map(role => exported.light[`syntax-${role}`])).size >= 7);
|
||||
assert.notDeepEqual(exported.dark, exportAppearanceTheme('default').dark);
|
||||
}
|
||||
});
|
||||
test('Sakura cannot restore or save a dark appearance', () => {
|
||||
assert.deepEqual(parseAppearance('{"theme":"sakura","mode":"dark"}'), { theme: 'sakura', mode: 'light' });
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { test } from 'node:test';
|
||||
import { characterTheme, SYNTAX_ROLES } from '../src/lib/theme/characterThemes.ts';
|
||||
|
||||
const rgb = (color: string) => color.slice(1).match(/../g)!.map(value => parseInt(value, 16));
|
||||
const mix = (foreground: string, background: string, opacity: number) => '#' + rgb(foreground)
|
||||
.map((value, index) => Math.round(value * opacity + rgb(background)[index] * (1 - opacity)).toString(16).padStart(2, '0')).join('');
|
||||
function luminance(color: string) {
|
||||
return rgb(color).map(value => value / 255)
|
||||
.map(value => value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4)
|
||||
.reduce((sum, value, index) => sum + value * [0.2126, 0.7152, 0.0722][index], 0);
|
||||
}
|
||||
function contrast(foreground: string, background: string) {
|
||||
const [high, low] = [luminance(foreground), luminance(background)].sort((a, b) => b - a);
|
||||
return (high + 0.05) / (low + 0.05);
|
||||
}
|
||||
|
||||
test('Crimson Pilot text and syntax remain readable in active and selected states', () => {
|
||||
const palette = characterTheme('crimson-pilot')!;
|
||||
const [background, elevated, active, , dim, text, strong, accent, selection] = palette.surfaces;
|
||||
const foregrounds = { dim, text, strong, accent, secondary: palette.secondary,
|
||||
...Object.fromEntries(SYNTAX_ROLES.map((role, index) => [`syntax-${role}`, palette.syntax[index]])) };
|
||||
for (const [role, foreground] of Object.entries(foregrounds)) {
|
||||
for (const surface of [background, elevated, active, selection]) {
|
||||
assert(contrast(foreground, surface) >= 4.5, `${role} on ${surface} needs 4.5:1 contrast`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('Crimson Pilot text remains readable on image-tinted editor and panel surfaces', () => {
|
||||
const palette = characterTheme('crimson-pilot')!;
|
||||
const [background, elevated, , , dim, text, strong] = palette.surfaces;
|
||||
const editor = mix(background, '#ffffff', 0.9);
|
||||
const codeBlock = mix(elevated, editor, 0.82);
|
||||
const panel = mix(elevated, '#ffffff', 0.82);
|
||||
for (const foreground of palette.syntax) {
|
||||
for (const surface of [editor, codeBlock]) {
|
||||
assert(contrast(foreground, surface) >= 4.5, `${foreground} on ${surface} needs 4.5:1 contrast`);
|
||||
}
|
||||
}
|
||||
for (const foreground of [dim, text, strong]) {
|
||||
assert(contrast(foreground, panel) >= 4.5, `${foreground} on image panel ${panel} needs 4.5:1 contrast`);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,142 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import { createRequire } from 'node:module';
|
||||
const { chromium } = createRequire(import.meta.url)(process.env.PLAYWRIGHT_MODULE || 'playwright');
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const output = '.audit/background-frames';
|
||||
const report = [];
|
||||
await mkdir(output, { recursive: true });
|
||||
try {
|
||||
for (const theme of ['light', 'dark']) {
|
||||
const page = await browser.newPage({ viewport: { width: 1280, height: 820 } });
|
||||
const errors = [];
|
||||
page.on('pageerror', error => errors.push(error.message));
|
||||
await page.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
const root = 'C:/background-test';
|
||||
const files = new Map([
|
||||
['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'],
|
||||
]);
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: 'main' }, currentWebview: { label: 'main' } }, transformCallback: () => 1, unregisterCallback() {},
|
||||
invoke: async (command, args = {}) => {
|
||||
if (command === 'workspace_last_path') return root;
|
||||
if (command === 'workspace_open') return { root, name: 'background-test', watch_mode: 'native' };
|
||||
if (command === 'workspace_list') return [...files.keys()].map(name => ({ name, rel_path: name, kind: 'file' }));
|
||||
if (command === 'workspace_read') { if (!files.has(args.rel)) throw new Error('missing'); return files.get(args.rel); }
|
||||
if (command === 'workspace_search') return [];
|
||||
if (command === 'plugins_snapshot') return { root, plugins: [] };
|
||||
return null;
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener() {} };
|
||||
});
|
||||
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:1420');
|
||||
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' } });
|
||||
const urls = await Promise.all([make('#bd486c', '#438f67'), make('#286f9b', '#725ea2')].map(async url => URL.createObjectURL(await (await fetch(url)).blob())));
|
||||
window.backgroundTest = { hub: backgroundHub, owner: Symbol(), urls, saved, theme };
|
||||
}, theme);
|
||||
const background = page.locator('.workarea-background');
|
||||
assert.equal(await background.count(), 1);
|
||||
assert.equal(await page.locator('.empty h1, .empty > p').count(), 0);
|
||||
assert.equal(await page.locator('.empty').evaluate(node => getComputedStyle(node).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 background.evaluate(node => getComputedStyle(node).backgroundImage), /blob:/);
|
||||
assert.match(await page.locator('.left').evaluate(node => getComputedStyle(node).backgroundColor), /(?:0\.82|82%)/);
|
||||
assert.match(await page.locator('.right').evaluate(node => getComputedStyle(node).backgroundColor), /(?:0\.82|82%)/);
|
||||
assert.match(await page.locator('.welcome-actions button').first().evaluate(node => getComputedStyle(node).backgroundColor), /(?:0\.82|82%)/);
|
||||
assert.doesNotMatch(await page.locator('header.header').evaluate(node => getComputedStyle(node).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 background.evaluate(node => getComputedStyle(node).backgroundSize), '100% 100%, contain, cover');
|
||||
assert.equal(await background.evaluate(node => getComputedStyle(node).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 background.evaluate(node => getComputedStyle(node).backgroundSize), '100% 100%, contain, cover');
|
||||
await page.screenshot({ path: `${output}/${theme}-portrait-layers-narrow.png` });
|
||||
await page.setViewportSize({ width: 1280, height: 820 });
|
||||
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 = await background.evaluate(node => Number(getComputedStyle(node, '::after').opacity));
|
||||
assert(opacity > 0 && opacity < 1, `Fade has an intermediate opacity: ${opacity}`);
|
||||
await page.waitForTimeout(900);
|
||||
assert.ok(await background.evaluate(node => Number(getComputedStyle(node, '::after').opacity) < 1), 'The fade remains active after one second');
|
||||
await page.waitForTimeout(1100);
|
||||
assert.equal(await background.evaluate(node => getComputedStyle(node, '::after').opacity), '1');
|
||||
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();
|
||||
await page.getByRole('textbox', { name: 'Writing editor', exact: true }).waitFor();
|
||||
assert.match(await page.locator('.editor > .body').evaluate(node => getComputedStyle(node).backgroundColor), /(?:0\.9|90%)/);
|
||||
await page.screenshot({ path: `${output}/${theme}-writer.png` });
|
||||
await page.getByRole('group', { name: 'Document view', exact: true }).hover();
|
||||
await page.getByRole('button', { name: 'Read', exact: true }).click();
|
||||
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` });
|
||||
await page.getByRole('button', { name: 'Split', exact: true }).click();
|
||||
await page.locator('.monaco-editor').waitFor();
|
||||
assert.equal(await page.locator('.monaco-editor-background').first().evaluate(node => getComputedStyle(node).backgroundColor), 'rgba(0, 0, 0, 0)');
|
||||
await page.screenshot({ path: `${output}/${theme}-split.png` });
|
||||
await page.getByRole('button', { name: 'Edit', exact: true }).click();
|
||||
await page.getByRole('group', { name: 'Editor layout', exact: true }).hover();
|
||||
await page.getByRole('button', { name: 'IDE', exact: true }).click();
|
||||
await page.locator('.monaco-editor').waitFor();
|
||||
await page.screenshot({ path: `${output}/${theme}-ide.png` });
|
||||
await page.setViewportSize({ width: 680, height: 720 });
|
||||
await page.getByRole('button', { name: 'Files', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'Hide outline', exact: true }).click();
|
||||
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().length), 0);
|
||||
await page.evaluate(() => { const { hub, owner, urls } = window.backgroundTest; hub.removeOwner(owner); urls.forEach(URL.revokeObjectURL); });
|
||||
assert.equal(await page.evaluate(() => document.body.style.getPropertyValue('--rs-background-previous-image')), '');
|
||||
assert.match(await background.evaluate(node => getComputedStyle(node).backgroundImage), /blob:/);
|
||||
await page.evaluate(async () => { const { saveAppearance } = await import('/src/lib/theme/appearance.ts'); saveAppearance({ theme: 'default', mode: window.backgroundTest.theme }); });
|
||||
assert.equal(await background.evaluate(node => getComputedStyle(node).backgroundImage), 'none');
|
||||
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();
|
||||
await page.locator('.editor > .body').waitFor();
|
||||
assert.equal(await page.locator('.editor > .body').evaluate(node => getComputedStyle(node).backgroundColor), await page.locator('.shell').evaluate(node => getComputedStyle(node).backgroundColor));
|
||||
await page.screenshot({ path: output + '/' + theme + '-removed.png' });
|
||||
assert.deepEqual(errors, []);
|
||||
report.push({ theme, passed: ['saved image', 'continuous workarea', 'sidebar transparency', 'button-only splash', 'keyboard focus', 'writer', 'reader scrolling', 'split', 'IDE 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));
|
||||
} finally { await browser.close(); }
|
||||
@@ -0,0 +1,155 @@
|
||||
import test from 'node:test';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
import { BackgroundHub, backgroundHub } from '../src/lib/plugins/backgrounds.ts';
|
||||
import { ExternalSession } from '../src/lib/plugins/externalSession.ts';
|
||||
import type { BackgroundFrame, PluginApi } from '../src/lib/plugins/sdk.ts';
|
||||
|
||||
const frame: BackgroundFrame = { url: 'blob:http://localhost/example', overlay: 0.3, position: 'center', size: 'cover' };
|
||||
|
||||
test('frames retain ownership, reveal earlier owners, and cannot mutate hub state', () => {
|
||||
const hub = new BackgroundHub(() => undefined);
|
||||
const first = Symbol(), second = Symbol();
|
||||
const events: string[] = [];
|
||||
hub.subscribe(target => events.push(target));
|
||||
hub.set(first, 'pm-all', frame);
|
||||
const received = hub.get('pm-all')!;
|
||||
received.url = 'blob:changed';
|
||||
assert.equal(hub.get('pm-all')!.url, frame.url);
|
||||
hub.set(second, 'pm-all', { ...frame, overlay: -0.4 });
|
||||
hub.set(first, 'app', frame);
|
||||
assert.equal(hub.get('pm-all')!.overlay, -0.4);
|
||||
hub.removeOwner(second);
|
||||
assert.equal(hub.get('pm-all')!.overlay, 0.3);
|
||||
hub.removeOwner(first);
|
||||
assert.equal(hub.get('pm-all'), null);
|
||||
assert.equal(hub.get('app'), null);
|
||||
assert.deepEqual(events, ['pm-all', 'pm-all', 'app', 'pm-all', 'pm-all', 'app']);
|
||||
});
|
||||
|
||||
test('app override uses body properties and removes them without changing current root appearance', () => {
|
||||
const root = new Map([['--rs-background-image', 'saved image']]);
|
||||
const properties = new Map<string, string>();
|
||||
const style = {
|
||||
getPropertyValue: (key: string) => properties.get(key) ?? '',
|
||||
getPropertyPriority: () => '',
|
||||
setProperty: (key: string, value: string) => properties.set(key, value),
|
||||
removeProperty: (key: string) => { properties.delete(key); },
|
||||
};
|
||||
const hub = new BackgroundHub(() => ({ style }) as unknown as HTMLElement);
|
||||
const owner = Symbol();
|
||||
hub.set(owner, 'app', frame);
|
||||
assert.match(properties.get('--rs-background-image')!, /blob:http/);
|
||||
assert.equal(properties.get('--rs-workarea-surface-opacity'), '82%');
|
||||
assert.equal(properties.get('--rs-workarea-plugin-bg'), 'transparent');
|
||||
root.set('--rs-background-image', 'new saved image');
|
||||
hub.set(owner, 'app', { ...frame, overlay: -0.5, size: 'contain' });
|
||||
assert.match(properties.get('--rs-background-image')!, /255,255,255,0.5/);
|
||||
hub.removeOwner(owner);
|
||||
assert.equal(properties.size, 0);
|
||||
assert.equal(root.get('--rs-background-image'), 'new saved image');
|
||||
});
|
||||
|
||||
test('invalid frames and targets do not enter the hub', () => {
|
||||
const hub = new BackgroundHub(() => undefined), owner = Symbol();
|
||||
for (const target of ['pm-board:../../x', 'unknown', 'pm-board:']) assert.throws(() => hub.set(owner, target, frame), /target/);
|
||||
for (const invalid of [{ ...frame, url: 'https://example.com/image.png' }, { ...frame, blurredUrl: 'https://example.com/image.png' }, { ...frame, blurredUrl: 'blob:bad")' }, { ...frame, overlay: NaN }, { ...frame, overlay: 2 }, { ...frame, url: 'blob:bad")' }]) {
|
||||
assert.throws(() => hub.set(owner, 'app', invalid), /frame/);
|
||||
}
|
||||
hub.set(owner, 'pm-board:0c18bcdc-f41e-4a31-87f4-87c369f398c1', frame);
|
||||
hub.removeOwner(owner);
|
||||
});
|
||||
|
||||
test('portrait frames retain a contained foreground and cover underlay through transitions and cleanup', () => {
|
||||
const properties = new Map<string, string>();
|
||||
const style = { getPropertyValue: (key: string) => properties.get(key) ?? '', getPropertyPriority: () => '',
|
||||
setProperty: (key: string, value: string) => properties.set(key, value), removeProperty: (key: string) => properties.delete(key) };
|
||||
const hub = new BackgroundHub(() => ({ style }) as unknown as HTMLElement), owner = Symbol();
|
||||
hub.set(owner, 'app', { ...frame, size: 'contain', blurredUrl: 'blob:blurred', previous: frame, transitionMs: 2000 });
|
||||
assert.equal(properties.get('--rs-background-layer-sizes'), '100% 100%, contain, cover');
|
||||
assert.equal(properties.get('--rs-background-layer-positions'), 'center, center, center');
|
||||
assert.equal(properties.get('--rs-background-previous-layer-sizes'), '100% 100%, cover');
|
||||
assert.match(properties.get('--rs-background-image')!, /blob:blurred/);
|
||||
const received = hub.get('app')!;
|
||||
received.blurredUrl = 'blob:changed';
|
||||
assert.equal(hub.get('app')!.blurredUrl, 'blob:blurred');
|
||||
hub.removeOwner(owner);
|
||||
assert.equal(properties.size, 0);
|
||||
});
|
||||
|
||||
test('fade frames validate previous images and keep nested data private', () => {
|
||||
const hub = new BackgroundHub(() => undefined), owner = Symbol();
|
||||
const fading = { ...frame, previous: { ...frame, url: 'blob:previous' }, transitionMs: 800 };
|
||||
hub.set(owner, 'pm-all', fading);
|
||||
fading.previous.url = 'blob:mutated';
|
||||
const received = hub.get('pm-all')!;
|
||||
assert.equal(received.previous!.url, 'blob:previous');
|
||||
received.previous!.url = 'blob:changed';
|
||||
assert.equal(hub.get('pm-all')!.previous!.url, 'blob:previous');
|
||||
for (const invalid of [
|
||||
{ ...frame, previous: { ...frame, url: 'https://example.com/image.png' } },
|
||||
{ ...frame, transitionMs: NaN }, { ...frame, transitionMs: -1 }, { ...frame, transitionMs: 5001 },
|
||||
]) assert.throws(() => hub.set(owner, 'pm-all', invalid), /frame/);
|
||||
});
|
||||
|
||||
test('subscriber errors do not prevent frame cleanup or remaining notifications', () => {
|
||||
const hub = new BackgroundHub(() => undefined), owner = Symbol();
|
||||
let events = 0;
|
||||
hub.subscribe(() => { throw new Error('Subscriber failure'); });
|
||||
hub.subscribe(() => { events++; });
|
||||
hub.set(owner, 'pm-all', frame);
|
||||
hub.removeOwner(owner);
|
||||
assert.equal(events, 2);
|
||||
assert.equal(hub.get('pm-all'), null);
|
||||
});
|
||||
|
||||
test('disable removes frames and subscriptions before cleanup and rejects pending file results', async () => {
|
||||
let api!: PluginApi;
|
||||
let finishRead!: (value: Uint8Array) => void;
|
||||
let finishList!: (value: { name: string }[]) => void;
|
||||
let finishPicker!: (value: string | null) => void;
|
||||
const session = new ExternalSession('org.test.backgrounds', {
|
||||
workspace: { list: async () => [], read: async () => '', write: async () => {} },
|
||||
settings: { read: async () => null, write: async () => {} },
|
||||
assets: { read: async () => new Uint8Array() },
|
||||
backgrounds: {
|
||||
chooseFolder: () => new Promise(resolve => { finishPicker = resolve; }),
|
||||
list: () => new Promise(resolve => { finishList = resolve; }),
|
||||
read: () => new Promise(resolve => { finishRead = resolve; }),
|
||||
},
|
||||
}, () => {}, () => {});
|
||||
let notifications = 0;
|
||||
await session.start({ activate(value) {
|
||||
api = value;
|
||||
api.backgrounds!.subscribe(() => { notifications++; });
|
||||
api.backgrounds!.set('app', frame);
|
||||
api.backgrounds!.set('pm-all', frame);
|
||||
api.onDispose(() => {
|
||||
assert.equal(backgroundHub.get('app'), null);
|
||||
assert.equal(backgroundHub.get('pm-all'), null);
|
||||
assert.throws(() => api.backgrounds!.get('app'), /disabled/);
|
||||
});
|
||||
} });
|
||||
const pending = [api.backgrounds!.read('folder', 'file.png'), api.backgrounds!.list('folder'), api.backgrounds!.chooseFolder()];
|
||||
const rejected = pending.map(request => assert.rejects(request, /disabled/));
|
||||
await session.stop();
|
||||
finishRead(new Uint8Array([1])); finishList([{ name: 'file.png' }]); finishPicker('folder');
|
||||
await Promise.all(rejected);
|
||||
assert.equal(notifications, 2);
|
||||
assert.throws(() => api.backgrounds!.set('app', frame), /disabled/);
|
||||
assert.throws(() => api.backgrounds!.read('folder', 'file.png'), /disabled/);
|
||||
assert.throws(() => api.backgrounds!.subscribe(() => {}), /disabled/);
|
||||
assert.equal(backgroundHub.get('app'), null);
|
||||
});
|
||||
|
||||
|
||||
test('background commands are allowed in main and settings windows', () => {
|
||||
const build = readFileSync(new URL('../src-tauri/build.rs', import.meta.url), 'utf8');
|
||||
for (const scope of ['default', 'settings']) {
|
||||
const capability = JSON.parse(readFileSync(new URL(`../src-tauri/capabilities/${scope}.json`, import.meta.url), 'utf8'));
|
||||
for (const command of ['backgrounds_choose_folder', 'backgrounds_default_folder', 'backgrounds_list', 'backgrounds_read', 'backgrounds_read_image_settings', 'backgrounds_write_image_settings']) {
|
||||
assert(build.includes(`"${command}"`), `${command} needs a generated desktop permission`);
|
||||
assert(capability.permissions.includes(`allow-${command.replaceAll('_', '-')}`), `${scope} must allow ${command}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,153 @@
|
||||
import { createRequire } from 'node:module';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { mkdtemp, mkdir, writeFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import os from 'node:os';
|
||||
import assert from 'node:assert/strict';
|
||||
const runtime = path.resolve('browser-runtime');
|
||||
const require = createRequire(path.join(runtime, 'package.json'));
|
||||
const { chromium } = require('playwright');
|
||||
const electron = require('electron');
|
||||
const root = await mkdtemp(path.join(os.tmpdir(), 'runestone-browser-ui-'));
|
||||
const child = spawn(electron, [path.join(runtime, 'test/interaction-engine.mjs')], {
|
||||
windowsHide: true, stdio: ['ignore', 'inherit', 'inherit', 'ipc'], env: { ...process.env, RS_INTERACTION_ROOT: root },
|
||||
});
|
||||
let sequence = 0, page, pendingFrame, painting = false;
|
||||
const pending = new Map();
|
||||
const commands = [];
|
||||
const rpc = (command, args = {}) => new Promise((resolve, reject) => {
|
||||
const id = ++sequence;
|
||||
const timeout = setTimeout(() => { pending.delete(id); reject(Error(`Runtime timeout: ${command}`)); }, 15000);
|
||||
pending.set(id, { resolve: value => { clearTimeout(timeout); resolve(value); }, reject: error => { clearTimeout(timeout); reject(error); } });
|
||||
child.send({ id, command, args });
|
||||
});
|
||||
async function paint() {
|
||||
if (painting || !page || !pendingFrame) return;
|
||||
painting = true;
|
||||
const frame = pendingFrame; pendingFrame = undefined;
|
||||
await page.evaluate(value => window.browserEmit?.('browser-frame', value), frame).catch(() => {});
|
||||
painting = false;
|
||||
if (pendingFrame) void paint();
|
||||
}
|
||||
const ready = new Promise((resolve, reject) => {
|
||||
child.on('error', reject);
|
||||
child.on('message', message => {
|
||||
if (message.ready) resolve();
|
||||
if (message.id) {
|
||||
const callback = pending.get(message.id); pending.delete(message.id);
|
||||
if (message.error) callback?.reject(Error(message.error)); else callback?.resolve(message.result);
|
||||
}
|
||||
if (message.event?.event === 'frame') { pendingFrame = message.event; void paint(); }
|
||||
else if (message.event && page) void page.evaluate(value => window.browserEmit?.('browser-state', value), message.event).catch(() => {});
|
||||
});
|
||||
});
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : { channel: 'chrome' }) });
|
||||
const errors = [];
|
||||
try {
|
||||
await ready;
|
||||
page = await browser.newPage({ viewport: { width: 1280, height: 800 }, deviceScaleFactor: Number(process.env.BROWSER_TEST_SCALE || 1) });
|
||||
page.on('pageerror', error => errors.push(error.message));
|
||||
await page.exposeFunction('browserRpc', async (command, args) => { const entry = { command, args, start: Date.now() }; commands.push(entry); const result = await rpc(command, args); entry.elapsed = Date.now() - entry.start; return result; });
|
||||
await page.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
const callbacks = new Map(), listeners = new Map(); let next = 0;
|
||||
window.browserEmit = (event, payload) => { for (const [id, entry] of listeners) if (entry.event === event) callbacks.get(entry.handler)?.({ event, id, payload }); };
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: 'main' }, currentWebview: { label: 'main' } },
|
||||
transformCallback: fn => { const id = ++next; callbacks.set(id, fn); return id; }, unregisterCallback: id => callbacks.delete(id),
|
||||
invoke: async (command, args = {}) => {
|
||||
if (command === 'plugin:event|listen') { const id = ++next; listeners.set(id, args); return id; }
|
||||
if (command === 'plugin:event|unlisten') { listeners.delete(args.eventId); return; }
|
||||
if (command === 'browser_connect') return 'test-session';
|
||||
if (command === 'browser_stop' || command === 'plugins_release') return;
|
||||
if (command === 'browser_request') return window.browserRpc(args.command, args.args);
|
||||
if (command === 'workspace_last_path') return null;
|
||||
if (command === 'workspace_recent') return [];
|
||||
if (command === 'plugins_snapshot') return { root: 'test', plugins: [] };
|
||||
if (command.startsWith('plugin:window|')) return false;
|
||||
throw Error(`Unhandled IPC: ${command}`);
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: (_event, id) => listeners.delete(id) };
|
||||
});
|
||||
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:1451');
|
||||
await page.getByRole('button', { name: 'Open browser', exact: true }).click();
|
||||
const surface = page.getByRole('application', { name: 'Web page', exact: true });
|
||||
await page.locator('[data-browser-state="ready"]').waitFor();
|
||||
const tabId = await page.locator('[data-browser-state="ready"]').getAttribute('data-browser-tab');
|
||||
const evaluate = code => rpc('testEvaluate', { tabId, code });
|
||||
async function expectRemote(code, expected) {
|
||||
for (let attempt = 0; attempt < 100; attempt++) {
|
||||
if (await evaluate(code) === expected) return;
|
||||
await page.waitForTimeout(50);
|
||||
}
|
||||
assert.equal(await evaluate(code), expected);
|
||||
}
|
||||
await evaluate(`document.body.innerHTML='<input id="typing" style="position:absolute;left:40px;top:40px;width:300px;height:40px"><textarea id="other" style="position:absolute;left:40px;top:140px;width:300px;height:80px"></textarea><div id="rich" contenteditable="true" style="position:absolute;left:40px;top:280px;width:300px;height:80px;border:1px solid">Rich text</div>'; true;`);
|
||||
await page.locator('.surface img').waitFor();
|
||||
await page.waitForTimeout(300);
|
||||
const box = await surface.boundingBox();
|
||||
await page.mouse.click(box.x + 100, box.y + 60);
|
||||
await page.waitForTimeout(150);
|
||||
assert.deepEqual(await evaluate('({active:document.activeElement.id,focused:document.hasFocus()})'), { active: 'typing', focused: true });
|
||||
await mkdir('.audit/browser-fields', { recursive: true });
|
||||
await page.waitForFunction(() => {
|
||||
const image = document.querySelector('.surface img');
|
||||
if (!image?.complete || !image.naturalWidth) return false;
|
||||
const surface = document.querySelector('.surface');
|
||||
const ratio = image.naturalWidth / surface.clientWidth;
|
||||
const canvas = document.createElement('canvas'); canvas.width = 12; canvas.height = 28;
|
||||
const context = canvas.getContext('2d');
|
||||
context.drawImage(image, 42 * ratio, 46 * ratio, 12 * ratio, 28 * ratio, 0, 0, 12, 28);
|
||||
const pixels = context.getImageData(0, 0, 12, 28).data;
|
||||
let dark = 0;
|
||||
for (let offset = 0; offset < pixels.length; offset += 4) if (pixels[offset] < 100 && pixels[offset + 1] < 100 && pixels[offset + 2] < 100) dark++;
|
||||
return dark >= 8;
|
||||
}, null, { timeout: 5000, polling: 50 });
|
||||
await page.screenshot({ path: `.audit/browser-fields/caret-${process.env.BROWSER_TEST_SCALE || 1}x.png` });
|
||||
await page.getByRole('textbox', { name: 'Address or search' }).focus();
|
||||
await page.waitForTimeout(100);
|
||||
assert.equal(await evaluate('document.hasFocus()'), false, 'The toolbar removes focus from the page');
|
||||
await page.mouse.click(box.x + 100, box.y + 60);
|
||||
await page.waitForTimeout(100);
|
||||
assert.equal(await evaluate('document.hasFocus()'), true, 'A page click restores focus');
|
||||
await page.keyboard.type('Hello World!');
|
||||
await expectRemote('document.querySelector("#typing").value', 'Hello World!');
|
||||
await page.mouse.move(box.x + 50, box.y + 60);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(box.x + 100, box.y + 60, { steps: 8 });
|
||||
await page.mouse.up();
|
||||
await page.waitForTimeout(200);
|
||||
assert(await evaluate('document.querySelector("#typing").selectionEnd > document.querySelector("#typing").selectionStart'), 'Dragging selects text in the embedded field');
|
||||
await page.mouse.click(box.x + 100, box.y + 170);
|
||||
await page.keyboard.type('Second field');
|
||||
await expectRemote('document.querySelector("#other").value', 'Second field');
|
||||
await page.mouse.click(box.x + 100, box.y + 310);
|
||||
await page.keyboard.press('Control+a');
|
||||
await page.keyboard.type('Edited rich text');
|
||||
await expectRemote('document.querySelector("#rich").textContent', 'Edited rich text');
|
||||
await evaluate(`document.body.insertAdjacentHTML('beforeend', '<iframe id="frame" style="position:absolute;left:40px;top:390px;width:300px;height:100px" srcdoc="<input id=framed style=width:200px;height:40px>"></iframe>'); true;`);
|
||||
await page.waitForTimeout(200);
|
||||
await page.mouse.click(box.x + 100, box.y + 415);
|
||||
await page.keyboard.type('Frame input');
|
||||
await expectRemote('document.querySelector("#frame").contentDocument.querySelector("#framed").value', 'Frame input');
|
||||
assert.equal(await evaluate('document.querySelector("#frame").contentDocument.hasFocus()'), true);
|
||||
await page.getByRole('textbox', { name: 'Address or search' }).focus();
|
||||
await page.waitForTimeout(100);
|
||||
assert.equal(await evaluate('document.querySelector("#frame").contentDocument.hasFocus()'), false);
|
||||
await rpc('navigate', { tabId, input: 'about:blank' });
|
||||
await page.waitForTimeout(100);
|
||||
await evaluate(`document.body.innerHTML='<input id="after-navigation" style="position:absolute;left:40px;top:40px;width:300px;height:40px">'; true;`);
|
||||
await page.waitForTimeout(400);
|
||||
await page.mouse.click(box.x + 100, box.y + 60);
|
||||
await page.keyboard.type('After navigation');
|
||||
await page.waitForTimeout(500);
|
||||
assert.equal(await evaluate('devicePixelRatio'), Number(process.env.BROWSER_TEST_SCALE || 1), 'Navigation preserves the host pixel ratio');
|
||||
await expectRemote('document.querySelector("#after-navigation").value', 'After navigation');
|
||||
assert.equal(await evaluate('document.hasFocus()'), true);
|
||||
assert.deepEqual(errors, []);
|
||||
console.log('PASS: visible caret, page focus, toolbar blur, input, textarea, contenteditable, iframe and navigation');
|
||||
} finally {
|
||||
await browser.close();
|
||||
await rpc('shutdown').catch(() => {}); child.kill();
|
||||
}
|
||||
@@ -74,7 +74,8 @@ async function selectProfile(id) {
|
||||
await profile.click();
|
||||
await page.getByRole('menuitemradio', { name: id === 'work' ? 'Work' : 'Personal', exact: true }).click();
|
||||
}
|
||||
const kind = section.getByRole('combobox', { name: 'Web data type', exact: true });
|
||||
const kind = section.getByRole('button', { name: 'Web data type', exact: true });
|
||||
async function selectKind(value) { await kind.click(); await page.getByRole('menuitemradio', { name: value === 'cookies' ? 'Cookies' : 'History', exact: true }).click(); }
|
||||
const filter = section.getByRole('searchbox', { name: 'Filter web data', exact: true });
|
||||
const refresh = section.getByRole('button', { name: 'Refresh', exact: true });
|
||||
const personalCookie = () => section.getByRole('button', { name: 'Remove cookie session from personal.example at /account', exact: true });
|
||||
@@ -109,7 +110,7 @@ try {
|
||||
await settle();
|
||||
await section.getByText('No matching cookies.', { exact: true }).waitFor();
|
||||
assert.equal(await page.evaluate(() => window.webDataTest.data.work.cookies.length), 1, 'Removing a cookie preserves another profile with the same ID');
|
||||
await kind.selectOption('history');
|
||||
await selectKind('history');
|
||||
await filter.fill('GUIDE');
|
||||
await section.getByRole('button', { name: 'Remove history entry Personal guide', exact: true }).click();
|
||||
await settle();
|
||||
@@ -122,7 +123,7 @@ try {
|
||||
await settle();
|
||||
assert.equal(await filter.inputValue(), '', 'Profile changes clear the prior filter');
|
||||
await section.getByText('Work guide', { exact: true }).waitFor();
|
||||
await kind.selectOption('cookies');
|
||||
await selectKind('cookies');
|
||||
await workCookie().waitFor();
|
||||
|
||||
// A delayed successful response from the previous profile must not replace the current rows.
|
||||
@@ -188,7 +189,7 @@ try {
|
||||
}, theme);
|
||||
assert.equal(await page.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue('--rs-bg').trim()), theme === 'light' ? '#f3f3f3' : '#141414');
|
||||
for (const dataType of ['cookies', 'history']) {
|
||||
await kind.selectOption(dataType);
|
||||
await selectKind(dataType);
|
||||
await section.scrollIntoViewIfNeeded();
|
||||
await page.screenshot({ path: `.audit/cards-2026-10-08-next/browser-web-data-${dataType}-${theme}.png` });
|
||||
const overflow = await section.evaluate(node => {
|
||||
|
||||
@@ -26,7 +26,7 @@ if (process.platform !== 'win32') throw Error('Build the Windows installer on Wi
|
||||
const artifactDir = path.join(root, 'src-tauri/target/release/bundle/nsis');
|
||||
const artifact = path.join(artifactDir, `RuneStone_${next.version}_x64-setup.exe`);
|
||||
const internalArtifact = path.join(artifactDir, `RuneStone_${next.toolchain}_x64-setup.exe`);
|
||||
const releaseDir = path.join(root, 'output/releases', next.version);
|
||||
const releaseDir = path.join(root, 'releases', next.version);
|
||||
const releaseArtifact = path.join(releaseDir, path.basename(artifact));
|
||||
const metadataPath = path.join(releaseDir, 'host.json');
|
||||
for (const file of new Set([artifact, internalArtifact, releaseArtifact, metadataPath])) if (await exists(file)) throw Error('The release file already exists: ' + file);
|
||||
@@ -75,15 +75,16 @@ try {
|
||||
await fs.copyFile(artifact, releaseArtifact, 1);
|
||||
const bytes = await fs.readFile(releaseArtifact);
|
||||
const metadata = { version: next.version, toolchainVersion: next.toolchain, windowsVersion: next.windows,
|
||||
source: artifact, path: releaseArtifact, bytes: bytes.length, sha256: createHash('sha256').update(bytes).digest('hex') };
|
||||
source: releaseArtifact, path: releaseArtifact, bytes: bytes.length, sha256: createHash('sha256').update(bytes).digest('hex') };
|
||||
await fs.writeFile(metadataPath, JSON.stringify(metadata, null, 2) + '\n', { flag: 'wx' });
|
||||
await fs.unlink(artifact);
|
||||
complete = true;
|
||||
console.log('Installer available: ' + releaseArtifact);
|
||||
} finally {
|
||||
if (!complete) {
|
||||
for (let i = 0; i < files.length; i++) await fs.writeFile(files[i], before[i]);
|
||||
for (const file of new Set([artifact, internalArtifact, releaseArtifact, metadataPath])) {
|
||||
if (await exists(file)) await fs.rename(file, file + '.failed-' + Date.now());
|
||||
if (await exists(file)) await fs.rename(file, path.join(staging, path.basename(file) + '.failed-' + Date.now()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,4 @@ execFileSync(process.execPath, [formulasBuild], { cwd: formulasRoot, stdio: "inh
|
||||
const formulasOutput = resolve(root, "plugin-packages/table-formulas");
|
||||
await mkdir(formulasOutput, { recursive: true });
|
||||
await cp(resolve(formulasRoot, "dist/plugin"), formulasOutput, { recursive: true });
|
||||
console.log(await packagePlugin(formulasOutput, resolve(root, "plugin-packages")));
|
||||
console.log(await packagePlugin(formulasOutput, resolve(formulasRoot, "releases")));
|
||||
|
||||
@@ -64,7 +64,9 @@ try {
|
||||
await page.getByRole('textbox', { name: 'Address or search' }).fill('https://example.com');
|
||||
await page.getByRole('textbox', { name: 'Address or search' }).press('Enter');
|
||||
await page.waitForFunction(() => window.builtinCheck.commands.includes('navigate'));
|
||||
assert.equal(await page.getByRole('combobox', { name: 'Browser profile' }).inputValue(), 'user');
|
||||
await page.getByRole('button', { name: 'Browser profile' }).click();
|
||||
assert.equal(await page.getByRole('menuitemradio', { checked: true }).count(), 1);
|
||||
await page.keyboard.press('Escape');
|
||||
await page.evaluate(async () => { window.builtinCheck.legacy = true; const { refreshPlugins } = await import(performance.getEntriesByType('resource').find(entry => new URL(entry.name).pathname === '/src/lib/plugins/external.ts').name); await refreshPlugins(); });
|
||||
assert.equal(await page.evaluate(() => window.builtinCheck.loads.includes('runestone.browser')), false);
|
||||
await page.evaluate(async () => { window.builtinCheck.removed = true; const { refreshPlugins } = await import(performance.getEntriesByType('resource').find(entry => new URL(entry.name).pathname === '/src/lib/plugins/external.ts').name); await refreshPlugins(); });
|
||||
@@ -87,7 +89,7 @@ try {
|
||||
await page.goto((process.env.SMOKE_URL || 'http://127.0.0.1:5174') + '/?settingsWindow=true');
|
||||
await page.getByRole('button', { name: 'Browser', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'Save browser settings' }).waitFor({ state: 'visible' });
|
||||
assert.equal(await page.getByRole('combobox', { name: 'Profile', exact: true }).inputValue(), 'user');
|
||||
assert.match(await page.getByRole('button', { name: 'Profile', exact: true }).innerText(), /Existing user/);
|
||||
await page.setViewportSize({ width: 360, height: 800 });
|
||||
for (const theme of ['dark', 'light']) {
|
||||
await page.evaluate(theme => document.documentElement.dataset.theme = theme, theme);
|
||||
@@ -97,10 +99,11 @@ try {
|
||||
assert.deepEqual(errors, []);
|
||||
console.log('Built-in browser, legacy package independence, same-tab replacement and plugin sidebar checks passed.');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
console.error(await page.evaluate(async () => {
|
||||
const m = await import(performance.getEntriesByType('resource').find(entry => new URL(entry.name).pathname === '/src/lib/plugins/external.ts').name);
|
||||
const read = store => { let value; store.subscribe(x => value = x)(); return value; };
|
||||
return { state: window.builtinCheck, text: document.body.innerText, errors: read(m.externalErrors), views: read(m.pluginEditors), tools: read(m.pluginTools) };
|
||||
}), errors);
|
||||
}).catch(reason => ({ diagnosticError: String(reason) })), errors);
|
||||
throw error;
|
||||
} finally { await browser.close(); }
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { mkdir } from 'node:fs/promises';
|
||||
import { createRequire } from 'node:module';
|
||||
|
||||
const { chromium } = createRequire(import.meta.url)(process.env.PLAYWRIGHT_MODULE || 'playwright');
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const origin = process.env.SMOKE_URL || 'http://127.0.0.1:1420';
|
||||
const output = '.audit/character-themes';
|
||||
const errors = [];
|
||||
await mkdir(output, { recursive: true });
|
||||
try {
|
||||
const context = await browser.newContext({ viewport: { width: 1100, height: 780 } });
|
||||
await context.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: 'main' }, currentWebview: { label: 'main' } },
|
||||
transformCallback: () => 1, unregisterCallback: () => {},
|
||||
invoke: async (command, args = {}) => {
|
||||
if (command === 'plugins_snapshot') return { root: 'C:/theme-smoke-plugins', plugins: [] };
|
||||
if (command === 'workspace_last_path') return 'C:\\theme-smoke';
|
||||
if (command === 'workspace_open') return { root: 'C:\\theme-smoke', name: 'theme-smoke', watch_mode: 'native' };
|
||||
if (command === 'workspace_list') return [{ name: 'Theme.md', rel_path: 'Theme.md', kind: 'file' }, { name: 'Theme.py', rel_path: 'Theme.py', kind: 'file' }];
|
||||
if (command === 'workspace_read' && args.rel === 'Theme.py') return '# Character colors\ndef sample(parameter):\n return parameter\nname = "RuneStone"\nprint(name, 42)\n';
|
||||
if (command === 'workspace_read') return '# Theme sample\n\nA calm surface with readable text.\n\n[Link](https://example.com)\n';
|
||||
if (command === 'workspace_search') return [];
|
||||
if (command === 'theme_export') { window.exportedTheme = JSON.parse(args.contents); return 'C:\\theme-smoke\\my-theme.json'; }
|
||||
if (command === 'plugin:event|listen') return args.handler;
|
||||
return null;
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
|
||||
});
|
||||
const main = await context.newPage();
|
||||
const settings = await context.newPage();
|
||||
const ide = await context.newPage();
|
||||
const fontSession = await context.newCDPSession(settings);
|
||||
await fontSession.send('DOM.enable');
|
||||
await fontSession.send('CSS.enable');
|
||||
for (const page of [main, settings, ide]) page.on('pageerror', error => errors.push(error.message));
|
||||
await main.goto(origin);
|
||||
await main.getByText('theme-smoke', { exact: true }).waitFor();
|
||||
await main.keyboard.press('Control+p');
|
||||
await main.getByRole('textbox', { name: 'Find a file' }).fill('Theme.md');
|
||||
await main.getByRole('textbox', { name: 'Find a file' }).press('Enter');
|
||||
await main.getByRole('textbox', { name: 'Writing editor', exact: true }).waitFor();
|
||||
await ide.goto(origin);
|
||||
await ide.getByText('theme-smoke', { exact: true }).waitFor();
|
||||
await ide.keyboard.press('Control+p');
|
||||
await ide.getByRole('textbox', { name: 'Find a file' }).fill('Theme.py');
|
||||
await ide.getByRole('textbox', { name: 'Find a file' }).press('Enter');
|
||||
await ide.locator('.monaco-editor textarea').waitFor();
|
||||
const editorIds = () => ide.evaluate(async () => {
|
||||
const { monaco } = await import('/src/lib/editor/monacoEnv.ts');
|
||||
return monaco.editor.getEditors().filter(editor => editor.getDomNode()?.isConnected).map(editor => editor.getId());
|
||||
});
|
||||
const initialEditors = await editorIds();
|
||||
const openSettings = async () => {
|
||||
await settings.goto(`${origin}/?settingsWindow=true`);
|
||||
await settings.getByRole('button', { name: 'Appearance', exact: true }).click();
|
||||
await settings.getByRole('img', { name: 'Color theme preview' }).waitFor();
|
||||
};
|
||||
const picker = name => settings.locator('.picker').and(settings.getByRole('button', { name, exact: true }));
|
||||
const choose = async (name, value) => {
|
||||
await picker(name).click();
|
||||
await settings.getByRole('menuitemradio', { name: value, exact: true }).click();
|
||||
};
|
||||
await openSettings();
|
||||
await picker('Color theme').click();
|
||||
assert.equal(await settings.getByRole('menuitemradio', { name: 'Renamon', exact: true }).count(), 0);
|
||||
assert.equal(await settings.getByRole('menuitemradio', { name: 'Asuka School Uniform', exact: true }).count(), 0);
|
||||
for (const label of ['Holo', 'Asuka Langley Soryu', 'Malfoid']) {
|
||||
assert.equal(await settings.getByRole('menuitemradio', { name: label, exact: true }).count(), 0);
|
||||
}
|
||||
await settings.keyboard.press('Escape');
|
||||
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 });
|
||||
const variant = label;
|
||||
await choose('Color theme', variant);
|
||||
for (const page of [main, settings, ide]) {
|
||||
await page.waitForFunction(({ theme, mode }) => document.documentElement.dataset.palette === theme && document.documentElement.dataset.theme === mode, { theme, mode });
|
||||
}
|
||||
const colors = await settings.evaluate(async theme => {
|
||||
const { exportAppearanceTheme } = await import('/src/lib/theme/appearance.ts');
|
||||
return exportAppearanceTheme(theme);
|
||||
}, theme);
|
||||
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(colors[mode]));
|
||||
assert.deepEqual(actual, colors[mode]);
|
||||
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.getByRole('button', { name: 'Export theme template' }).click();
|
||||
assert.deepEqual(await settings.evaluate(() => window.exportedTheme), colors);
|
||||
await ide.waitForFunction(expected => {
|
||||
const spans = [...document.querySelectorAll('.view-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[mode]['syntax-keyword'], RuneStone: colors[mode]['syntax-string'], 42: colors[mode]['syntax-number'], print: colors[mode]['syntax-keyword'], '# Character colors': colors[mode]['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, colors[mode].selection, 'File selection uses the same warm selection color');
|
||||
assert.equal(selectedRow.fill, 'rgb(72, 39, 20)', 'The selected file paints the warm fill');
|
||||
await main.screenshot({ path: `${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: `${output}/${theme}-${mode}-writer-selection.png` });
|
||||
await ide.evaluate(async () => {
|
||||
const { monaco } = await import('/src/lib/editor/monacoEnv.ts');
|
||||
const editor = monaco.editor.getEditors().find(editor => editor.getDomNode()?.isConnected);
|
||||
editor.setSelection(new monaco.Selection(1, 1, 3, 21)); editor.focus();
|
||||
});
|
||||
await ide.locator('.selected-text').first().waitFor();
|
||||
assert.equal(await ide.locator('.selected-text').first().evaluate(node => getComputedStyle(node).backgroundColor),
|
||||
'rgb(72, 39, 20)', 'IDE selection uses the same warm fill');
|
||||
await ide.screenshot({ path: `${output}/${theme}-${mode}-ide-selection.png` });
|
||||
await ide.evaluate(async () => {
|
||||
const { monaco } = await import('/src/lib/editor/monacoEnv.ts');
|
||||
monaco.editor.getEditors().find(editor => editor.getDomNode()?.isConnected).setPosition({ lineNumber: 1, column: 1 });
|
||||
});
|
||||
}
|
||||
await ide.screenshot({ path: `${output}/${theme}-${mode}-ide.png` });
|
||||
await settings.screenshot({ path: `${output}/${theme}-${mode}-settings.png` });
|
||||
await main.screenshot({ path: `${output}/${theme}-${mode}-document.png` });
|
||||
await settings.reload();
|
||||
await settings.getByRole('button', { name: 'Appearance', exact: true }).click();
|
||||
assert.equal((await picker('Color theme').textContent()).trim(), variant);
|
||||
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');
|
||||
await picker('Color theme').scrollIntoViewIfNeeded();
|
||||
await picker('Color theme').focus();
|
||||
await settings.keyboard.press('Enter');
|
||||
const current = settings.getByRole('menuitemradio', { name: variant, exact: true });
|
||||
await current.waitFor();
|
||||
assert.equal(await current.getAttribute('aria-checked'), 'true');
|
||||
assert(await current.evaluate(node => document.activeElement === node), 'The menu focuses the current theme');
|
||||
const bounds = await settings.getByRole('menu', { name: 'Color theme', exact: true }).boundingBox();
|
||||
assert(bounds.x >= 0 && bounds.x + bounds.width <= 360 && bounds.y >= 0 && bounds.y + bounds.height <= 480, 'The menu stays within the viewport');
|
||||
await settings.screenshot({ path: `${output}/${theme}-${mode}-360-menu.png` });
|
||||
await settings.keyboard.press('ArrowDown');
|
||||
await settings.keyboard.press('ArrowUp');
|
||||
assert(await current.evaluate(node => document.activeElement === node));
|
||||
await settings.keyboard.press('Escape');
|
||||
assert(await picker('Color theme').evaluate(node => document.activeElement === node), 'Dismissal returns focus');
|
||||
await settings.screenshot({ path: `${output}/${theme}-${mode}-360-focus.png` });
|
||||
await settings.evaluate(async () => {
|
||||
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: 16 }, (_, index) => ({ owner: 'org.example.theme-check', id: `settings-${index}`, title: `Plugin settings ${index + 1}`, surface: 'settings' })));
|
||||
});
|
||||
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: `${output}/${theme}-${mode}-360-long-navigation.png` });
|
||||
await settings.evaluate(async () => { const { pluginTools } = await import(performance.getEntriesByType('resource').find(entry => new URL(entry.name).pathname === '/src/lib/plugins/external.ts').name); pluginTools.set([]); });
|
||||
console.log(`PASS: ${theme} ${mode}, colors, fonts, IDE syntax, export, saved state, window sync, narrow menu, 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 => localStorage.setItem('runestone.appearance', JSON.stringify({ theme, mode: 'dark' })), previous);
|
||||
await openSettings();
|
||||
assert.equal((await picker('Color theme').textContent()).trim(), label);
|
||||
assert.equal(await settings.evaluate(() => document.documentElement.dataset.palette), theme);
|
||||
await choose('Color theme', label);
|
||||
assert.equal(await settings.evaluate(() => JSON.parse(localStorage.getItem('runestone.appearance')).theme), theme);
|
||||
}
|
||||
for (const [removed, mode] of [['renamon', 'light'], ['asuka-school', 'dark']]) {
|
||||
await settings.evaluate(({ theme, mode }) => localStorage.setItem('runestone.appearance', JSON.stringify({ theme, mode })), { theme: removed, mode });
|
||||
await settings.setViewportSize({ width: 1100, height: 780 });
|
||||
await openSettings();
|
||||
for (const page of [main, settings, ide]) {
|
||||
await page.waitForFunction(mode => document.documentElement.dataset.palette === 'default' && document.documentElement.dataset.theme === mode, mode);
|
||||
}
|
||||
assert.equal((await picker('Color theme').textContent()).trim(), `RuneStone ${mode === 'light' ? 'Light' : 'Dark'}`);
|
||||
assert((await settings.evaluate(() => getComputedStyle(document.body).fontFamily)).includes('Segoe UI'), 'The default font returns after a palette change');
|
||||
await settings.screenshot({ path: `${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: `${output}/default-${mode}-360-settings.png` });
|
||||
console.log(`PASS: ${removed} saved appearance restores RuneStone ${mode}`);
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
console.log('Character theme smoke passed.');
|
||||
} catch (error) {
|
||||
console.error('Page errors:', errors);
|
||||
for (const context of browser.contexts()) {
|
||||
for (const [index, page] of context.pages().entries()) await page.screenshot({ path: `${output}/failure-${index}.png` }).catch(() => {});
|
||||
}
|
||||
throw error;
|
||||
} finally { await browser.close(); }
|
||||
@@ -0,0 +1,57 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { initialDocumentPanes, syncDocumentPanes, splitDocumentPane, closeDocumentPane, selectPane, readDocumentPane } from "../src/lib/workspace/documentPanes.ts";
|
||||
import { paneBounds } from "../src/lib/workspace/splitLayout.ts";
|
||||
import { registerSelection, selectedEditorText } from "../src/lib/editor/selection.ts";
|
||||
|
||||
test("opening a link to the right keeps its source and focuses an existing pane for duplicate targets", () => {
|
||||
let state = syncDocumentPanes(initialDocumentPanes(), ["a", "b", "c"], "a");
|
||||
const primary = state.active;
|
||||
state = readDocumentPane(state, primary, true);
|
||||
state = splitDocumentPane(state, primary, "b", "right");
|
||||
assert.deepEqual(state.panes.map(pane => pane.documentId), ["a", "b"]);
|
||||
assert.equal(state.active, "right");
|
||||
assert.deepEqual(paneBounds(state.layout).right, { left: 50, top: 0, width: 50, height: 100 });
|
||||
state = splitDocumentPane(state, "right", "a", "unused");
|
||||
assert.equal(state.active, primary);
|
||||
assert.equal(state.panes.length, 2);
|
||||
assert.equal(state.panes[0].reading, true);
|
||||
state = splitDocumentPane(state, "right", "c", "third");
|
||||
assert.equal(paneBounds(state.layout).third.left, 75);
|
||||
});
|
||||
|
||||
test("closing a split preserves the remaining pane and a later tab selection can restore its hidden document", () => {
|
||||
let state = syncDocumentPanes(initialDocumentPanes(), ["a", "b"], "a");
|
||||
state = splitDocumentPane(state, state.active, "b", "right");
|
||||
state = closeDocumentPane(state, "right");
|
||||
assert.equal(state.panes[0].documentId, "a");
|
||||
assert.equal(state.layout, state.active);
|
||||
state = syncDocumentPanes(state, ["a", "b"], "b");
|
||||
assert.equal(state.panes[0].documentId, "b");
|
||||
});
|
||||
|
||||
test("tab replacement stays in its focused pane, and closing another tab collapses only its empty pane", () => {
|
||||
let state = syncDocumentPanes(initialDocumentPanes(), ["a", "b"], "a");
|
||||
state = splitDocumentPane(state, state.active, "b", "right");
|
||||
state = syncDocumentPanes(state, ["a", "c"], "c");
|
||||
assert.deepEqual(state.panes.map(pane => pane.documentId), ["a", "c"]);
|
||||
assert.equal(state.active, "right");
|
||||
const unchanged = syncDocumentPanes(state, ["a", "c"], "c");
|
||||
assert.equal(unchanged, state);
|
||||
state = syncDocumentPanes(state, ["c"], "c");
|
||||
assert.equal(state.panes.length, 1);
|
||||
assert.equal(state.layout, "right");
|
||||
assert.equal(selectPane(state, "missing"), state);
|
||||
});
|
||||
|
||||
test("selection readers remain available in both panes and disposal cannot clear a replacement reader", () => {
|
||||
const first = registerSelection("a", () => "first selection");
|
||||
const second = registerSelection("b", () => "second selection");
|
||||
assert.equal(selectedEditorText("a"), "first selection");
|
||||
assert.equal(selectedEditorText("b"), "second selection");
|
||||
const replacement = registerSelection("a", () => "new selection");
|
||||
first(); second();
|
||||
assert.equal(selectedEditorText("a"), "new selection");
|
||||
assert.equal(selectedEditorText("b"), "");
|
||||
replacement();
|
||||
});
|
||||
@@ -0,0 +1,160 @@
|
||||
import { createRequire } from "node:module";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||
page.setDefaultTimeout(15000);
|
||||
const errors = [];
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
page.on("console", message => { if (message.text().includes("binding_property_non_reactive")) errors.push(message.text()); });
|
||||
await mkdir(".audit", { recursive: true });
|
||||
await page.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
const root = "C:\\tab-menu-workspace";
|
||||
const files = new Map(["a.md", "b.md", "c.md", "d.md"].map(name => [name, `# ${name}\n\nOriginal text.\n\n\`\`\`js\nconst answer = 42;\n\`\`\`\n\n| Name | Value |\n| --- | --- |\n| Alpha | One |\n`]));
|
||||
files.set("a.md", "# Links\n\nSelected reading text.\n\n[Web label](https://example.com/path)\n\n[[b.md|Workspace note]]\n");
|
||||
files.set("a.md", "# Alpha\n\nOrigin paragraph.\n\n[[notes/b.md|Right note]]\n");
|
||||
files.set("notes/b.md", "# Bravo\n\nSecond paragraph.\n\n[Relative](c.md)\n\n[[/a.md|Original note]]\n");
|
||||
files.set("notes/c.md", "# Charlie\n\nThird paragraph.\n");
|
||||
files.set("sample.txt", "const answer = 42;\n");
|
||||
window.tabMenuTest = { prompts: [], answer: "Cancel", revealed: null, clipboard: null, opened: null, app: null, windows: [] };
|
||||
Object.defineProperty(navigator, "clipboard", { value: { writeText: async text => { window.tabMenuTest.clipboard = text; } } });
|
||||
window.tabMenuTest.files = files;
|
||||
let sequence = 0;
|
||||
const callbacks = new Map(), listeners = new Map();
|
||||
window.tabMenuTest.change = (path, text) => { files.set(path, text); callbacks.get(listeners.get("workspace-event"))?.({ event: "workspace-event", id: 1, payload: { root, kind: "modify", paths: [path] } }); };
|
||||
window.tabMenuTest.writes = [];
|
||||
window.spellingTest = { commands: [], emit: payload => callbacks.get(listeners.get("spelling-menu"))?.({ event: "spelling-menu", id: 1, payload }) };
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: "main" }, currentWebview: { label: "main" } },
|
||||
transformCallback: callback => { callbacks.set(++sequence, callback); return sequence; }, unregisterCallback: id => callbacks.delete(id),
|
||||
invoke: async (command, args = {}) => {
|
||||
if (command === "plugin:event|listen") { listeners.set(args.event, args.handler); return ++sequence; }
|
||||
if (command === "plugin:event|unlisten") return;
|
||||
if (command.startsWith("spelling_menu_")) { window.spellingTest.commands.push({ method: command, ...args }); return; }
|
||||
if (command === "spelling_suggestions") return { language: "en-US", words: ["Corrected"], misspelled: args.word === "Original" };
|
||||
if (command === "workspace_last_path") return root;
|
||||
if (command === "workspace_open") return { root, name: "tab-menu-workspace", watch_mode: "native" };
|
||||
if (command === "workspace_read") { if (!files.has(args.rel)) throw new Error("missing"); return files.get(args.rel); }
|
||||
if (command === "workspace_list") return [...(!args.rel ? [{ name: "notes", rel_path: "notes", kind: "folder" }] : []), ...[...files.keys()].filter(path => path.split("/").slice(0, -1).join("/") === (args.rel || "")).map(path => ({ name: path.split("/").at(-1), rel_path: path, kind: "file" }))];
|
||||
if (command === "workspace_search") { window.tabMenuTest.searched = args.query; return []; }
|
||||
if (command === "plugin:opener|open_url") { window.tabMenuTest.opened = args.url; return; }
|
||||
if (command === "workspace_open_default") { window.tabMenuTest.app = args.rel; return; }
|
||||
if (command === "workspace_open_window") { window.tabMenuTest.windows.push(args); return; }
|
||||
if (command === "workspace_write") { if (args.expected !== undefined && files.get(args.rel) !== args.expected) throw new Error("conflict"); files.set(args.rel, args.contents); window.tabMenuTest.writes.push(args.rel); return; }
|
||||
if (command === "workspace_rename") { files.set(args.to, files.get(args.from)); files.delete(args.from); return; }
|
||||
if (command === "workspace_abs_path") return `${root}\\${args.rel}`;
|
||||
if (command === "workspace_reveal") { window.tabMenuTest.revealed = args.rel; return; }
|
||||
if (command === "plugin:dialog|message") { window.tabMenuTest.prompts.push(args.message); return window.tabMenuTest.answer; }
|
||||
throw new Error(`Unhandled IPC: ${command}`);
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
|
||||
});
|
||||
|
||||
const output = '.audit/document-splits';
|
||||
await mkdir(output, {recursive:true});
|
||||
const pane = path => page.locator(`[data-document-path="${path}"]`);
|
||||
const item = name => page.getByRole('menuitem',{name,exact:true});
|
||||
async function openRight(path,label) {
|
||||
const current = pane(path);
|
||||
await current.locator('.cm-content').getByText(path === 'a.md' ? 'Origin paragraph.' : 'Second paragraph.',{exact:true}).click();
|
||||
await current.locator('.cm-content').getByText(label,{exact:true}).click({button:'right'});
|
||||
await item('Open to the right').click();
|
||||
}
|
||||
async function append(path, text) {
|
||||
const target=pane(path).locator('.cm-content');
|
||||
await target.click(); await page.keyboard.press('Control+End'); await page.keyboard.type(text);
|
||||
}
|
||||
async function text(path) { return pane(path).locator('.cm-content').evaluate(async node=> { const {EditorView}=await import('/node_modules/@codemirror/view/dist/index.js'); return EditorView.findFromDOM(node).state.doc.toString(); }); }
|
||||
async function focus(path) { await pane(path).locator('.cm-content').click(); }
|
||||
try {
|
||||
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:1420');
|
||||
await page.locator('[data-tree-rel="a.md"]').click(); await pane('a.md').locator('.cm-content').waitFor();
|
||||
await append('a.md','\nLeft unsaved.');
|
||||
await openRight('a.md','Right note'); await pane('notes/b.md').locator('.cm-content').waitFor();
|
||||
assert.equal(await page.locator('.document-pane').count(),2);
|
||||
assert.match(await text('a.md'),/Left unsaved/);
|
||||
await append('notes/b.md','\nRight saved.'); await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(()=>window.tabMenuTest.writes.includes('notes/b.md'));
|
||||
assert.equal(await page.evaluate(()=>window.tabMenuTest.writes.includes('a.md')),false,'Save uses the focused right pane');
|
||||
await focus('a.md'); await page.keyboard.press('Control+s'); await page.waitForFunction(()=>window.tabMenuTest.writes.includes('a.md'));
|
||||
await pane('notes/b.md').getByRole('group',{name:'Editor layout',exact:true}).hover();
|
||||
await pane('notes/b.md').getByRole('button',{name:'IDE',exact:true}).click(); await pane('notes/b.md').locator('.monaco-editor').waitFor();
|
||||
assert.equal(await pane('a.md').locator('.cm-content').count(),1,'Changing the right mode keeps the left editor');
|
||||
await openRight('a.md','Right note');
|
||||
assert.equal(await page.locator('.document-pane').count(),2);
|
||||
await page.waitForFunction(async()=>{const {monaco}=await import('/src/lib/editor/monacoEnv.ts');return monaco.editor.getEditors().some(editor=>editor.getModel()?.uri.path.endsWith('/b.md') && editor.hasTextFocus());}); await page.keyboard.press('Control+End'); await page.keyboard.type('\nIDE edit.'); await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(()=>window.tabMenuTest.files.get('notes/b.md').includes('IDE edit.'));
|
||||
await pane('notes/b.md').getByRole('group',{name:'Editor layout',exact:true}).hover();
|
||||
await pane('notes/b.md').getByRole('button',{name:'Writer',exact:true}).click(); await pane('notes/b.md').locator('.cm-content').waitFor();
|
||||
assert.match(await text('notes/b.md'),/IDE edit/);
|
||||
await pane('notes/b.md').getByRole('group',{name:'Document view',exact:true}).hover();
|
||||
await pane('notes/b.md').getByRole('button',{name:'Read',exact:true}).click(); await pane('notes/b.md').locator('.reading').waitFor();
|
||||
assert.equal(await pane('a.md').locator('.reading').count(),0,'Reading mode belongs to its pane');
|
||||
await focus('a.md'); assert.equal(await pane('notes/b.md').locator('.reading').count(),1);
|
||||
await pane('notes/b.md').getByRole('group',{name:'Document view',exact:true}).hover();
|
||||
await pane('notes/b.md').getByRole('button',{name:'Edit',exact:true}).click(); await pane('notes/b.md').locator('.cm-content').waitFor();
|
||||
for(const path of ['a.md','notes/b.md']) await pane(path).locator('.cm-content').evaluate(async node=> {
|
||||
const {EditorView}=await import('/node_modules/@codemirror/view/dist/index.js'); const v=EditorView.findFromDOM(node); const source=v.state.doc.toString(); const from=source.indexOf(source.includes('Alpha') ? 'Origin' : 'Second'); v.dispatch({selection:{anchor:from,head:from+6}});
|
||||
});
|
||||
const selections=await page.evaluate(async()=> { const {monaco}=await import('/src/lib/editor/monacoEnv.ts'); const resource=performance.getEntriesByType('resource').find(entry=>new URL(entry.name).pathname==='/src/lib/editor/selection.ts'); const {selectedEditorText}=await import(resource.name); return monaco.editor.getModels().map(model=>selectedEditorText(model.uri.path.split('/')[1])).filter(Boolean).sort(); });
|
||||
assert.deepEqual(selections,['Origin','Second'],'Each pane retains its own selection');
|
||||
await openRight('a.md','Right note'); assert.equal(await page.locator('.document-pane').count(),2);
|
||||
await page.waitForFunction(()=>document.activeElement?.closest('[data-document-path]')?.dataset.documentPath==='notes/b.md');
|
||||
await openRight('notes/b.md','Original note'); assert.equal(await page.locator('.document-pane').count(),2);
|
||||
await page.waitForFunction(()=>document.activeElement?.closest('[data-document-path]')?.dataset.documentPath==='a.md');
|
||||
await append('notes/b.md','\nRight still unsaved.');
|
||||
for(const theme of ['light','dark']) {
|
||||
await page.evaluate(async mode=> { const {saveAppearance}=await import('/src/lib/theme/appearance.ts'); saveAppearance({theme:'default',mode}); },theme);
|
||||
await page.screenshot({path:`${output}/two-editors-${theme}.png`});
|
||||
}
|
||||
await pane('notes/b.md').getByRole('button',{name:'Close split',exact:true}).click();
|
||||
assert.equal(await page.locator('.document-pane').count(),1); assert.equal(await pane('a.md').count(),1);
|
||||
assert.match(await text('a.md'),/Left unsaved/);
|
||||
assert.equal(await page.evaluate(async()=> { const {monaco}=await import('/src/lib/editor/monacoEnv.ts'); return monaco.editor.getModels().length; }),2,'Closing a split preserves both tab models');
|
||||
await page.getByRole('tab',{name:/b.md/}).click(); await pane('notes/b.md').locator('.cm-content').waitFor();
|
||||
assert.match(await text('notes/b.md'),/Right still unsaved/,'The closed split retains its unsaved buffer');
|
||||
await page.getByRole('tab',{name:/a.md/}).click(); await openRight('a.md','Right note'); await pane('notes/b.md').locator('.cm-content').waitFor();
|
||||
await openRight('notes/b.md','Relative'); await pane('notes/c.md').locator('.cm-content').waitFor();
|
||||
assert.equal(await page.locator('.document-pane').count(),3);
|
||||
assert.match(await text('notes/c.md'),/Charlie/,'Relative links use the pane document folder');
|
||||
await pane('notes/c.md').getByRole('button',{name:'Close split',exact:true}).click();
|
||||
assert.equal(await page.locator('.document-pane').count(),2);
|
||||
await page.evaluate(()=>window.tabMenuTest.change('notes/b.md','# Bravo disk\n\nExternal update.\n'));
|
||||
await pane('notes/b.md').getByRole('alert').waitFor();
|
||||
assert.equal(await pane('a.md').getByRole('alert').count(),0);
|
||||
assert.match(await text('notes/b.md'),/Right still unsaved/,'A disk conflict preserves the right pane edits');
|
||||
await focus('a.md');
|
||||
await pane('notes/b.md').getByRole('button',{name:'Use disk version',exact:true}).click();
|
||||
await page.waitForFunction(()=>document.querySelector('[data-document-path="notes/b.md"] .cm-content')?.textContent.includes('External update.'));
|
||||
assert.match(await text('a.md'),/Left unsaved/,'Resolving the other pane cannot replace the primary buffer');
|
||||
await page.getByRole('button',{name:'Files',exact:true}).click(); await page.getByRole('button',{name:'Hide outline',exact:true}).click();
|
||||
await page.setViewportSize({width:560,height:740});
|
||||
for(const theme of ['light','dark']) {
|
||||
await page.evaluate(async mode=> { const {saveAppearance}=await import('/src/lib/theme/appearance.ts'); saveAppearance({theme:'default',mode}); },theme);
|
||||
const first=await pane('a.md').boundingBox(), second=await pane('notes/b.md').boundingBox();
|
||||
assert.ok(first.width>500 && second.width>500 && second.y>=first.y+first.height-1,'Narrow panes stack with readable widths');
|
||||
await page.screenshot({path:`${output}/stacked-${theme}.png`});
|
||||
}
|
||||
await append('notes/b.md','\nNarrow edit.'); await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(()=>window.tabMenuTest.files.get('notes/b.md').includes('Narrow edit.'));
|
||||
await pane('notes/b.md').getByRole('button',{name:'Close split',exact:true}).click();
|
||||
await append('a.md','\nAfter closing split.'); await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(()=>window.tabMenuTest.files.get('a.md').includes('After closing split.'));
|
||||
await page.setViewportSize({width:1440,height:1000});
|
||||
await openRight('a.md','Right note'); await pane('notes/b.md').locator('.cm-content').waitFor();
|
||||
await append('notes/b.md','\nClose guard.');
|
||||
await page.keyboard.press('Control+w');
|
||||
await page.waitForFunction(()=>window.tabMenuTest.prompts.length>0);
|
||||
assert.equal(await pane('notes/b.md').count(),1,'Cancel keeps the dirty split open');
|
||||
await page.keyboard.press('Control+s'); await page.waitForFunction(()=>window.tabMenuTest.files.get('notes/b.md').includes('Close guard.'));
|
||||
await page.keyboard.press('Control+w'); await pane('notes/b.md').waitFor({state:'detached'});
|
||||
await focus('a.md'); await append('a.md','\nOther tab closed.'); await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(()=>window.tabMenuTest.files.get('a.md').includes('Other tab closed.'));
|
||||
assert.equal(await page.evaluate(async()=>{const {monaco}=await import('/src/lib/editor/monacoEnv.ts');return monaco.editor.getModels().some(model=>model.uri.path.endsWith('/b.md'));}),false,'Closing the tab releases only its model');
|
||||
assert.deepEqual(errors,[]);
|
||||
console.log(JSON.stringify({passed:['independent Writer/IDE/Reading modes','dirty close cancellation and model release','independent edits and saves','per-pane selections','focus existing duplicate target','closing split retains unsaved tabs and models','nested relative link origin','per-pane conflict resolution','narrow layout and save','light/dark screenshots'],nativeDesktop:'not tested'},null,2));
|
||||
} catch(error) { await page.screenshot({path:`${output}/failure.png`}); console.log(await page.locator('.status,.rs-menu').allTextContents()); throw error; } finally { await browser.close(); }
|
||||
@@ -24,6 +24,21 @@ function setup() {
|
||||
return { docs, disk, io };
|
||||
}
|
||||
|
||||
test("background loading for a split preserves the selected document and its unsaved edits", async () => {
|
||||
const { docs } = setup();
|
||||
await docs.open(entry("note.md"));
|
||||
const first = docs.active!;
|
||||
docs.edit(first.id, "unsaved text");
|
||||
await docs.open(entry("script.py"), "background");
|
||||
assert.equal(docs.active, first);
|
||||
assert.equal(first.contents, "unsaved text");
|
||||
assert.equal(docs.buffers.length, 2);
|
||||
await assert.rejects(docs.open(entry("missing.md"), "background"));
|
||||
assert.equal(docs.active, first);
|
||||
docs.select("script.py");
|
||||
assert.equal(docs.active?.relPath, "script.py");
|
||||
});
|
||||
|
||||
test("tab moves preserve selection, dirty buffers, and in-flight saves", async () => {
|
||||
const { docs, io, disk } = setup();
|
||||
await docs.open(entry("note.md"));
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
import { createRequire } from "node:module";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||
page.setDefaultTimeout(15000);
|
||||
const errors = [];
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
await mkdir(".audit", { recursive: true });
|
||||
await page.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
const root = "C:\\tab-menu-workspace";
|
||||
const files = new Map(["a.md", "b.md", "c.md", "d.md"].map(name => [name, `# ${name}\n\nOriginal [guide](docs/guide.md) text.\n\n| Name | Value |\n| --- | --- |\n| [Roadmap](docs/roadmap.md) | [[guide\\|Guide]] |\n| [One](same.md) + [Two](same.md) | Empty |\n`]));
|
||||
window.tabMenuTest = { prompts: [], answer: "Cancel", revealed: null, clipboard: null };
|
||||
Object.defineProperty(navigator, "clipboard", { value: { writeText: async text => { window.tabMenuTest.clipboard = text; } } });
|
||||
let sequence = 0;
|
||||
const callbacks = new Map(), listeners = new Map();
|
||||
window.spellingTest = { commands: [], emit: payload => callbacks.get(listeners.get("spelling-menu"))?.({ event: "spelling-menu", id: 1, payload }) };
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: "main" }, currentWebview: { label: "main" } },
|
||||
transformCallback: callback => { callbacks.set(++sequence, callback); return sequence; }, unregisterCallback: id => callbacks.delete(id),
|
||||
invoke: async (command, args = {}) => {
|
||||
if (command === "plugin:event|listen") { listeners.set(args.event, args.handler); return ++sequence; }
|
||||
if (command === "plugin:event|unlisten") return;
|
||||
if (command.startsWith("spelling_menu_")) { window.spellingTest.commands.push({ method: command, ...args }); return; }
|
||||
if (command === "spelling_suggestions") return { language: "en-US", words: [], misspelled: false };
|
||||
if (command === "workspace_last_path") return root;
|
||||
if (command === "workspace_open") return { root, name: "tab-menu-workspace", watch_mode: "native" };
|
||||
if (command === "workspace_read") { if (!files.has(args.rel)) throw new Error("missing"); return files.get(args.rel); }
|
||||
if (command === "workspace_list") return args.rel ? [] : [{ name: "notes", rel_path: "notes", kind: "folder" }, ...[...files.keys()].map(name => ({ name, rel_path: name, kind: "file" }))];
|
||||
if (command === "workspace_search") return [];
|
||||
if (command === "workspace_write") { files.set(args.rel, args.contents); return; }
|
||||
if (command === "workspace_rename") { files.set(args.to, files.get(args.from)); files.delete(args.from); return; }
|
||||
if (command === "workspace_abs_path") return `${root}\\${args.rel}`;
|
||||
if (command === "workspace_reveal") { window.tabMenuTest.revealed = args.rel; return; }
|
||||
if (command === "plugin:dialog|message") { window.tabMenuTest.prompts.push(args.message); return window.tabMenuTest.answer; }
|
||||
throw new Error(`Unhandled IPC: ${command}`);
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
|
||||
});
|
||||
|
||||
|
||||
try {
|
||||
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:1420');
|
||||
await page.locator('[data-tree-rel="a.md"]').click();
|
||||
await page.locator('.writer-table').waitFor();
|
||||
for(const theme of ['dark','light']) {
|
||||
await page.evaluate(async mode => (await import('/src/lib/theme/appearance.ts')).saveAppearance({theme:'default',mode}), theme);
|
||||
const prose = page.locator('.writer-link').filter({hasText:'guide'}).first();
|
||||
await prose.hover();
|
||||
await page.locator('.rs-tooltip:popover-open').waitFor();
|
||||
assert.equal(await prose.getAttribute('title'),null);
|
||||
await page.screenshot({path:'.audit/editor-link-tooltip-'+theme+'.png'});
|
||||
await page.keyboard.press('Escape');
|
||||
await prose.click();
|
||||
assert.equal(await page.locator('.writer-link-source').count(),1);
|
||||
const colored = await page.locator('.writer-link-source').evaluate(el => ({color:getComputedStyle(el).color, parent:getComputedStyle(el.parentElement).color}));
|
||||
assert.notEqual(colored.color,colored.parent);
|
||||
await page.screenshot({path:'.audit/editor-link-source-'+theme+'.png'});
|
||||
const cell=page.locator('.writer-table td').first();
|
||||
await cell.locator('a').click({position:{x:22,y:8}});
|
||||
assert.ok(await page.evaluate(()=>getSelection().anchorOffset > 0));
|
||||
await cell.click({button:'right'});
|
||||
await page.getByRole('menuitem',{name:'Edit link',exact:true}).click();
|
||||
assert.equal(await page.getByRole('dialog').count(),0);
|
||||
assert.equal(await page.evaluate(()=>getSelection().toString()),theme === 'dark' ? 'docs/roadmap.md' : 'docs/new-roadmap.md');
|
||||
await page.screenshot({path:'.audit/editor-table-source-'+theme+'.png'});
|
||||
await page.keyboard.type('docs/new-roadmap.md');
|
||||
await page.keyboard.press('Enter');
|
||||
assert.equal(await cell.locator('a').getAttribute('href'),'docs/new-roadmap.md');
|
||||
if(theme === 'dark') {
|
||||
await page.locator('.cm-line').filter({hasText:'Original'}).click();
|
||||
await page.keyboard.press('Control+z');
|
||||
assert.equal(await cell.locator('a').getAttribute('href'),'docs/roadmap.md');
|
||||
await page.keyboard.press('Control+Shift+z');
|
||||
assert.equal(await cell.locator('a').getAttribute('href'),'docs/new-roadmap.md');
|
||||
}
|
||||
await cell.locator('a').click({position:{x:22,y:8}});
|
||||
const selection=await page.evaluate(()=>{const s=getSelection();return {offset:s.anchorOffset,length:s.anchorNode.textContent.length};});
|
||||
assert.ok(selection.offset>0 && selection.offset<selection.length,JSON.stringify(selection));
|
||||
await page.keyboard.type('X');
|
||||
assert.ok((await cell.innerText()).includes('X'));
|
||||
await page.keyboard.press('Escape');
|
||||
const wiki=page.locator('.writer-table td').nth(1);
|
||||
await wiki.click({button:'right'});
|
||||
await page.getByRole('menuitem',{name:'Edit link',exact:true}).click();
|
||||
assert.equal(await page.evaluate(()=>getSelection().toString()),theme==='dark'?'guide':'new-guide');
|
||||
await page.keyboard.type('new-guide');
|
||||
await page.keyboard.press('Enter');
|
||||
assert.equal(await wiki.locator('a').getAttribute('href'),'new-guide');
|
||||
}
|
||||
const multi=page.locator('.writer-table td').nth(2);
|
||||
await multi.locator('a').nth(1).click({button:'right'});
|
||||
await page.getByRole('menuitem',{name:'Edit link',exact:true}).click();
|
||||
assert.equal(await page.evaluate(()=>getSelection().toString()),'same.md');
|
||||
await page.keyboard.type('second.md');
|
||||
await page.keyboard.press('Enter');
|
||||
assert.equal(await multi.locator('a').first().getAttribute('href'),'same.md');
|
||||
assert.equal(await multi.locator('a').nth(1).getAttribute('href'),'second.md');
|
||||
await page.getByRole('button',{name:'Hide outline',exact:true}).click();
|
||||
await page.getByRole('button',{name:'Files',exact:true}).click();
|
||||
await page.setViewportSize({width:620,height:700});
|
||||
await page.waitForTimeout(250);
|
||||
await page.locator('.table-add-row').scrollIntoViewIfNeeded();
|
||||
await page.waitForTimeout(100);
|
||||
await page.locator('.table-add-row').focus();
|
||||
await page.locator('.rs-tooltip:popover-open').waitFor();
|
||||
const rect=await page.locator('.rs-tooltip:popover-open').boundingBox();
|
||||
assert.ok(rect.x>=0 && rect.x+rect.width<=620);
|
||||
await page.screenshot({path:'.audit/editor-tooltip-narrow-focus.png'});
|
||||
await page.keyboard.press('Escape');
|
||||
assert.equal(await page.locator('.rs-tooltip:popover-open').count(),0);
|
||||
assert.equal(await page.locator('.table-edit-help:visible').count(),0);
|
||||
for (const mode of ['light','dark']) {
|
||||
await page.evaluate(async mode => (await import('/src/lib/theme/appearance.ts')).saveAppearance({theme:'default',mode}),mode);
|
||||
await page.locator('.writer-table td').nth(1).hover();
|
||||
await page.locator('.rs-tooltip:popover-open').waitFor();
|
||||
assert.match(await page.locator('.rs-tooltip:popover-open').innerText(),/Row 2, column 2/);
|
||||
await page.screenshot({path:'.audit/editor-cell-tooltip-narrow-'+mode+'.png'});
|
||||
await page.keyboard.press('Escape');
|
||||
await page.mouse.move(5,90);
|
||||
}
|
||||
|
||||
assert.deepEqual(errors,[]);
|
||||
console.log('Editor link and tooltip checks passed');
|
||||
} finally { await browser.close(); }
|
||||
@@ -0,0 +1,209 @@
|
||||
import { createRequire } from "node:module";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||
page.setDefaultTimeout(15000);
|
||||
const errors = [];
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
await mkdir(".audit", { recursive: true });
|
||||
await page.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
const root = "C:\\tab-menu-workspace";
|
||||
const files = new Map(["a.md", "b.md", "c.md", "d.md"].map(name => [name, `# ${name}\n\nOriginal text.\n\n\`\`\`js\nconst answer = 42;\n\`\`\`\n\n| Name | Value |\n| --- | --- |\n| Alpha | One |\n`]));
|
||||
files.set("a.md", "# Links\n\nSelected reading text.\n\n[Web label](https://example.com/path)\n\n[[b.md|Workspace note]]\n\n| Link | Note |\n| --- | --- |\n| [Cell web](https://example.com/cell) | [[b.md\\|Cell note]] |\n");
|
||||
files.set("sample.txt", "const answer = 42;\n");
|
||||
window.tabMenuTest = { prompts: [], answer: "Cancel", revealed: null, clipboard: null, opened: null, app: null, windows: [] };
|
||||
Object.defineProperty(navigator, "clipboard", { value: { writeText: async text => { window.tabMenuTest.clipboard = text; } } });
|
||||
window.tabMenuTest.files = files;
|
||||
let sequence = 0;
|
||||
const callbacks = new Map(), listeners = new Map();
|
||||
window.spellingTest = { commands: [], emit: payload => callbacks.get(listeners.get("spelling-menu"))?.({ event: "spelling-menu", id: 1, payload }) };
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: "main" }, currentWebview: { label: "main" } },
|
||||
transformCallback: callback => { callbacks.set(++sequence, callback); return sequence; }, unregisterCallback: id => callbacks.delete(id),
|
||||
invoke: async (command, args = {}) => {
|
||||
if (command === "plugin:event|listen") { listeners.set(args.event, args.handler); return ++sequence; }
|
||||
if (command === "plugin:event|unlisten") return;
|
||||
if (command.startsWith("spelling_menu_")) { window.spellingTest.commands.push({ method: command, ...args }); return; }
|
||||
if (command === "spelling_suggestions") return { language: "en-US", words: ["Corrected"], misspelled: args.word === "Original" };
|
||||
if (command === "workspace_last_path") return root;
|
||||
if (command === "workspace_open") return { root, name: "tab-menu-workspace", watch_mode: "native" };
|
||||
if (command === "workspace_read") { if (!files.has(args.rel)) throw new Error("missing"); return files.get(args.rel); }
|
||||
if (command === "workspace_list") return [...(!args.rel ? [{ name: "notes", rel_path: "notes", kind: "folder" }] : []), ...[...files.keys()].filter(path => path.split("/").slice(0, -1).join("/") === (args.rel || "")).map(path => ({ name: path.split("/").at(-1), rel_path: path, kind: "file" }))];
|
||||
if (command === "workspace_search") { window.tabMenuTest.searched = args.query; return []; }
|
||||
if (command === "plugin:opener|open_url") { window.tabMenuTest.opened = args.url; return; }
|
||||
if (command === "workspace_open_default") { window.tabMenuTest.app = args.rel; return; }
|
||||
if (command === "workspace_open_window") { window.tabMenuTest.windows.push(args); return; }
|
||||
if (command === "workspace_write") { files.set(args.rel, args.contents); return; }
|
||||
if (command === "workspace_rename") { files.set(args.to, files.get(args.from)); files.delete(args.from); return; }
|
||||
if (command === "workspace_abs_path") return `${root}\\${args.rel}`;
|
||||
if (command === "workspace_reveal") { window.tabMenuTest.revealed = args.rel; return; }
|
||||
if (command === "plugin:dialog|message") { window.tabMenuTest.prompts.push(args.message); return window.tabMenuTest.answer; }
|
||||
throw new Error(`Unhandled IPC: ${command}`);
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
|
||||
});
|
||||
|
||||
const menu = name => page.getByRole('menu', { name, exact: true });
|
||||
const item = name => page.getByRole('menuitem', { name, exact: true });
|
||||
const output = '.audit/editor-link-menus';
|
||||
await mkdir(output, { recursive: true });
|
||||
const dismiss = async () => { await page.keyboard.press('Escape'); await page.locator('.rs-menu').waitFor({ state: 'detached' }); };
|
||||
const report = [];
|
||||
async function writerMenu(target='Web label') {
|
||||
await page.locator('.cm-content').getByText('Selected reading text.', { exact: true }).click();
|
||||
await page.locator('.cm-content').getByText(target, { exact: true }).click({ button: 'right' });
|
||||
await menu('Markdown text actions').waitFor();
|
||||
}
|
||||
try {
|
||||
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:1420');
|
||||
await page.locator('[data-tree-rel="a.md"]').click();
|
||||
await page.locator('.cm-content').waitFor();
|
||||
await page.evaluate(async () => {
|
||||
const { pluginHost } = await import('/src/lib/plugins/registry.ts');
|
||||
pluginHost.register('link-smoke', 'browser', { open: async target => { window.tabMenuTest.browser = target; return true; }, mountSettings: () => () => {}, mountBookmarks: () => () => {} });
|
||||
});
|
||||
for (const theme of ['dark', 'light']) {
|
||||
await page.evaluate(async mode => { const { saveAppearance } = await import('/src/lib/theme/appearance.ts'); saveAppearance({theme:'default', mode}); }, theme);
|
||||
await writerMenu();
|
||||
for (const label of ['Open link in app browser', 'Open link in default browser', 'Copy URL', 'Edit link']) assert.equal(await item(label).count(), 1);
|
||||
await page.screenshot({ path: `${output}/writer-link-${theme}.png` });
|
||||
await item('Copy URL').click();
|
||||
await page.waitForFunction(() => window.tabMenuTest.clipboard === 'https://example.com/path');
|
||||
await writerMenu(); await item('Open link in default browser').click();
|
||||
await page.waitForFunction(() => window.tabMenuTest.opened === 'https://example.com/path');
|
||||
await writerMenu(); await item('Open link in app browser').click();
|
||||
await page.waitForFunction(() => window.tabMenuTest.browser === 'https://example.com/path');
|
||||
await writerMenu(); await item('Edit link').click();
|
||||
assert.equal(await page.evaluate(async () => { const { EditorView } = await import('/node_modules/@codemirror/view/dist/index.js'); const v = EditorView.findFromDOM(document.querySelector('.cm-content')); return v.state.sliceDoc(v.state.selection.main.from, v.state.selection.main.to); }), 'https://example.com/path');
|
||||
await page.screenshot({ path: `${output}/edit-url-${theme}.png` });
|
||||
await page.keyboard.type('https://changed.example');
|
||||
await page.keyboard.press('Control+z');
|
||||
await page.locator('.cm-content').getByText('Selected reading text.', {exact:true}).click();
|
||||
await writerMenu('Workspace note');
|
||||
for (const label of ['Open in new tab', 'Open in new window', 'Copy path', 'Bookmark', 'Show in system explorer', 'Reveal file in navigation', 'Edit link']) assert.equal(await item(label).count(), 1);
|
||||
for (const label of ['Rename…', 'Move file to…', 'Open in default app']) assert.equal(await item(label).count(), 0);
|
||||
await page.screenshot({ path: `${output}/workspace-link-${theme}.png` });
|
||||
await dismiss();
|
||||
await page.getByRole('button',{name:'Files',exact:true}).click(); await page.getByRole('button',{name:'Hide outline',exact:true}).click();
|
||||
await page.setViewportSize({width:560,height:620});
|
||||
await writerMenu('Workspace note'); await page.keyboard.press('End');
|
||||
assert.match(await page.evaluate(() => document.activeElement.textContent), /Select all/);
|
||||
await page.screenshot({path:`${output}/workspace-narrow-${theme}.png`});
|
||||
await dismiss(); await page.setViewportSize({width:1440,height:1000});
|
||||
await page.getByRole('button',{name:'Files',exact:true}).click(); await page.getByRole('button',{name:'Show outline',exact:true}).click();
|
||||
await writerMenu('Workspace note');
|
||||
await item('Copy path').focus(); await page.keyboard.press('ArrowRight'); await item('Workspace path').click();
|
||||
await page.waitForFunction(() => window.tabMenuTest.clipboard === 'b.md');
|
||||
await writerMenu('Workspace note'); await item('Show in system explorer').click(); await page.waitForFunction(() => window.tabMenuTest.revealed === 'b.md');
|
||||
await writerMenu('Workspace note'); await item('Reveal file in navigation').click();
|
||||
await page.waitForFunction(() => document.activeElement?.getAttribute('data-tree-rel') === 'b.md');
|
||||
await page.getByRole('group', { name: 'Document view', exact: true }).hover(); await page.getByRole('button', { name:'Read', exact:true }).click();
|
||||
const reading = page.locator('.reading');
|
||||
await reading.getByText('Selected reading text.',{exact:true}).evaluate(node => { const range = document.createRange(); range.selectNodeContents(node); const s = getSelection(); s.removeAllRanges(); s.addRange(range); node.closest('.reading').focus(); });
|
||||
await page.keyboard.press('Shift+F10');
|
||||
await menu('Reading actions').waitFor();
|
||||
await page.keyboard.press('End'); assert.match(await page.evaluate(() => document.activeElement.textContent), /^Search for/);
|
||||
await page.screenshot({ path: `${output}/reading-selection-${theme}.png` });
|
||||
await page.keyboard.press('Home'); await page.keyboard.press('Enter');
|
||||
await page.waitForFunction(() => window.tabMenuTest.clipboard === 'Selected reading text.');
|
||||
await page.keyboard.press('Shift+F10');
|
||||
await page.getByRole('menuitem', {name:/^Search for/}).click();
|
||||
await page.waitForFunction(() => window.tabMenuTest.searched === 'Selected reading text.');
|
||||
await page.evaluate(() => getSelection().removeAllRanges());
|
||||
await reading.getByRole('link',{name:'Web label'}).click({button:'right'});
|
||||
await item('Copy URL').click(); await page.waitForFunction(() => window.tabMenuTest.clipboard === 'https://example.com/path');
|
||||
await page.getByRole('button', { name: 'Search', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'Hide outline', exact: true }).click();
|
||||
await page.setViewportSize({ width: 560, height: 620 });
|
||||
await reading.getByRole('link',{name:'Web label'}).click({button:'right'});
|
||||
const rect=await menu('Reading actions').boundingBox(); assert.ok(rect.x>=0 && rect.x+rect.width<=560 && rect.y+rect.height<=620);
|
||||
await page.screenshot({ path: `${output}/reading-narrow-${theme}.png` });
|
||||
await dismiss();
|
||||
assert.equal(await reading.evaluate(node => node.contains(document.activeElement)), true);
|
||||
await page.setViewportSize({width:1440,height:1000});
|
||||
await page.getByRole('button', { name: 'Files', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'Show outline', exact: true }).click();
|
||||
await page.getByRole('group', { name: 'Document view', exact: true }).hover();
|
||||
await page.getByRole('button',{name:'Edit',exact:true}).click();
|
||||
await page.getByRole('group', { name:'Editor layout',exact:true }).hover(); await page.getByRole('button',{name:'IDE',exact:true}).click();
|
||||
await page.locator('.monaco-editor').waitFor();
|
||||
await page.evaluate(async () => { const {monaco}=await import('/src/lib/editor/monacoEnv.ts'); const editor=monaco.editor.getEditors()[0]; const model=editor.getModel(); const pos=model.getPositionAt(model.getValue().indexOf('Web label')+2); editor.setPosition(pos); editor.focus(); });
|
||||
await page.keyboard.press('Shift+F10'); await item('Edit link').click();
|
||||
assert.equal(await page.evaluate(async () => { const {monaco}=await import('/src/lib/editor/monacoEnv.ts'); const editor=monaco.editor.getEditors()[0]; return editor.getModel().getValueInRange(editor.getSelection()); }), 'https://example.com/path');
|
||||
await page.screenshot({ path: `${output}/ide-edit-url-${theme}.png` });
|
||||
await page.getByRole('group', { name:'Editor layout',exact:true }).hover(); await page.getByRole('button',{name:'Writer',exact:true}).click();
|
||||
await page.locator('.cm-content').getByText('Selected reading text.', {exact:true}).click();
|
||||
const cellLink = page.locator('.writer-table a').filter({hasText:'Cell web'});
|
||||
await cellLink.click({button:'right'});
|
||||
await item('Edit link').waitFor();
|
||||
await page.screenshot({path:`${output}/table-link-${theme}.png`});
|
||||
await item('Copy URL').click();
|
||||
await page.waitForFunction(() => window.tabMenuTest.clipboard === 'https://example.com/cell');
|
||||
await cellLink.click({button:'right'}); await item('Edit link').click();
|
||||
const sourceCell = page.locator('.writer-table .is-source-editing .writer-cell-editor');
|
||||
await sourceCell.waitFor();
|
||||
assert.equal(await page.getByLabel('Edit link target').count(), 0);
|
||||
assert.equal(await page.evaluate(() => getSelection().toString()), 'https://example.com/cell');
|
||||
assert.equal(await sourceCell.locator('.writer-link-target').innerText(), 'https://example.com/cell');
|
||||
await page.screenshot({path:`${output}/table-edit-${theme}.png`});
|
||||
await page.keyboard.type('https://changed.example/cell'); await page.keyboard.press('Enter');
|
||||
await page.waitForFunction(() => document.querySelector('.writer-table a')?.getAttribute('href') === 'https://changed.example/cell');
|
||||
await page.locator('.cm-content').getByText('Selected reading text.', {exact:true}).click();
|
||||
await page.keyboard.press('Control+z');
|
||||
await page.waitForFunction(() => document.querySelector('.writer-table a')?.getAttribute('href') === 'https://example.com/cell');
|
||||
const cellNote = page.locator('.writer-table a').filter({hasText:'Cell note'});
|
||||
await cellNote.click({button:'right'}); await item('Edit link').click();
|
||||
assert.equal(await page.evaluate(() => getSelection().toString()), 'b.md');
|
||||
await page.keyboard.type('c.md'); await page.keyboard.press('Enter');
|
||||
await page.waitForFunction(() => [...document.querySelectorAll('.writer-table a')].some(node => node.textContent === 'Cell note' && node.getAttribute('href') === 'c.md'));
|
||||
await page.locator('.cm-content').getByText('Selected reading text.', {exact:true}).click();
|
||||
await page.keyboard.press('Control+z');
|
||||
await page.waitForFunction(() => [...document.querySelectorAll('.writer-table a')].some(node => node.textContent === 'Cell note' && node.getAttribute('href') === 'b.md'));
|
||||
await cellLink.click({button:'right'}); await item('Edit link').click();
|
||||
await page.keyboard.type('https://escape.example'); await page.keyboard.press('Escape');
|
||||
assert.equal(await sourceCell.count(), 0);
|
||||
assert.equal(await cellLink.getAttribute('href'), 'https://escape.example');
|
||||
await page.locator('.cm-content').getByText('Selected reading text.', {exact:true}).click();
|
||||
await page.keyboard.press('Control+z');
|
||||
await page.waitForFunction(() => document.querySelector('.writer-table a')?.getAttribute('href') === 'https://example.com/cell');
|
||||
await page.getByRole('button',{name:'Files',exact:true}).click(); await page.getByRole('button',{name:'Hide outline',exact:true}).click();
|
||||
await page.setViewportSize({width:560,height:620});
|
||||
await cellLink.click(); await page.keyboard.press('Shift+F10'); await item('Edit link').waitFor();
|
||||
await page.screenshot({path:`${output}/table-narrow-${theme}.png`});
|
||||
await dismiss();
|
||||
await page.setViewportSize({width:1440,height:1000});
|
||||
await page.getByRole('button',{name:'Files',exact:true}).click(); await page.getByRole('button',{name:'Show outline',exact:true}).click();
|
||||
await page.locator('.cm-content').getByText('Selected reading text.', {exact:true}).click();
|
||||
report.push({theme,passed:['Writer and IDE edit URL selection','browser destinations','workspace file actions','Reader copy/search/link actions','inline table web/wiki link edits and undo','table source Escape and keyboard menu','keyboard focus return','narrow viewport'],nativeDesktop:'not tested'});
|
||||
}
|
||||
await writerMenu('Workspace note'); await item('Open in new window').click();
|
||||
await page.waitForFunction(() => window.tabMenuTest.windows.length === 1);
|
||||
await page.evaluate(() => { const {transfer}=window.tabMenuTest.windows[0]; dispatchEvent(new StorageEvent('storage',{key:`runestone.tab-transfer.${transfer}.accepted`,newValue:'true'})); });
|
||||
assert.equal(await page.getByRole('tab',{name:/b.md/}).count(),1,'Opening a linked document in a new window keeps the source tab');
|
||||
await page.locator('[data-tree-rel="a.md"]').click();
|
||||
await writerMenu('Workspace note'); await item('Bookmark').click();
|
||||
await page.waitForFunction(() => JSON.parse(window.tabMenuTest.files.get('.runestone/marks.json') || '{}').bookmarks?.includes('b.md'));
|
||||
await writerMenu('Workspace note'); await item('Copy path').focus(); await page.keyboard.press('ArrowRight'); await item('System path').click();
|
||||
await page.waitForFunction(() => window.tabMenuTest.clipboard.endsWith('\\b.md'));
|
||||
await page.getByRole('group', { name: 'Document view', exact: true }).hover(); await page.getByRole('button', { name:'Read', exact:true }).click();
|
||||
const readerWorkspaceMenu = async () => { await page.locator('.reading').getByRole('link',{name:'Workspace note'}).click({button:'right'}); };
|
||||
await readerWorkspaceMenu(); await item('Open in default app').click();
|
||||
await page.waitForFunction(() => window.tabMenuTest.app === 'b.md');
|
||||
await readerWorkspaceMenu(); await item('Rename…').click();
|
||||
await page.getByLabel('New file name').fill('renamed.md'); await page.getByRole('button',{name:'Continue',exact:true}).click();
|
||||
await page.waitForFunction(() => window.tabMenuTest.files.has('renamed.md') && !window.tabMenuTest.files.has('b.md'));
|
||||
assert.equal(await page.evaluate(() => JSON.parse(window.tabMenuTest.files.get('.runestone/marks.json')).bookmarks.includes('renamed.md')),true);
|
||||
await page.getByRole('group', { name: 'Document view', exact: true }).hover(); await page.getByRole('button', { name:'Edit', exact:true }).click();
|
||||
await page.locator('.cm-content').evaluate(async node => { const {EditorView}=await import('/node_modules/@codemirror/view/dist/index.js'); const view=EditorView.findFromDOM(node); const from=view.state.doc.toString().indexOf('b.md'); view.dispatch({changes:{from,to:from+4,insert:'renamed.md'}}); });
|
||||
await page.getByRole('group', { name: 'Document view', exact: true }).hover(); await page.getByRole('button', { name:'Read', exact:true }).click();
|
||||
await readerWorkspaceMenu(); await item('Move file to…').click();
|
||||
await page.getByLabel('Move file to (workspace path, including filename)').fill('notes/moved.md'); await page.getByRole('button',{name:'Continue',exact:true}).click();
|
||||
await page.waitForFunction(() => window.tabMenuTest.files.has('notes/moved.md') && !window.tabMenuTest.files.has('renamed.md'));
|
||||
assert.equal(await page.evaluate(() => JSON.parse(window.tabMenuTest.files.get('.runestone/marks.json')).bookmarks.includes('notes/moved.md')),true);
|
||||
assert.deepEqual(errors,[]); console.log(JSON.stringify(report,null,2));
|
||||
} catch(error) { await page.screenshot({path:`${output}/failure.png`}); console.log(await page.locator('.rs-menu').allTextContents()); throw error; } finally { await browser.close(); }
|
||||
@@ -21,3 +21,13 @@ test("bare and angle links omit prose punctuation and preserve balanced parenthe
|
||||
const source = 'Go to https://example.com/a_(b). Next (<https://example.org>). Mail <mailto:[email protected]>.';
|
||||
assert.deepEqual(documentLinks(source).map(link => link.target), ["https://example.com/a_(b)", "https://example.org", "mailto:[email protected]"]);
|
||||
});
|
||||
|
||||
test("edit link selects only its destination, preserving labels, titles, brackets, and spacing", () => {
|
||||
const source = '[Local](<notes/two words.md> "Title") and [Web](https://example.com/a_\\(b\\)) and [[ Another note#Heading |Alias]] and <https://example.org>.';
|
||||
const links = documentLinks(source);
|
||||
assert.deepEqual(links.map(link => source.slice(link.targetFrom, link.targetTo)), ["notes/two words.md", "https://example.com/a_\\(b\\)", "Another note#Heading", "https://example.org"]);
|
||||
});
|
||||
|
||||
test("wiki image embeds do not expose document actions", () => {
|
||||
assert.deepEqual(documentLinks('![[image.png]] [[note|label]]').map(link => link.target), ["note"]);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
import { createRequire } from "node:module";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||
page.setDefaultTimeout(15000);
|
||||
const errors = [];
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
await mkdir(".audit", { recursive: true });
|
||||
await page.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
const root = "C:\\tab-menu-workspace";
|
||||
const files = new Map(["a.md", "b.md", "c.md", "d.md"].map(name => [name, `# ${name}\n\nOriginal text.\n\n\`\`\`js\nconst answer = 42;\n\`\`\`\n\n| Name | Value |\n| --- | --- |\n| Alpha | One |\n`]));
|
||||
files.set("sample.txt", "const answer = 42;\n");
|
||||
window.tabMenuTest = { prompts: [], answer: "Cancel", revealed: null, clipboard: null };
|
||||
Object.defineProperty(navigator, "clipboard", { value: { writeText: async text => { window.tabMenuTest.clipboard = text; } } });
|
||||
let sequence = 0;
|
||||
const callbacks = new Map(), listeners = new Map();
|
||||
window.spellingTest = { commands: [], emit: payload => callbacks.get(listeners.get("spelling-menu"))?.({ event: "spelling-menu", id: 1, payload }) };
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: "main" }, currentWebview: { label: "main" } },
|
||||
transformCallback: callback => { callbacks.set(++sequence, callback); return sequence; }, unregisterCallback: id => callbacks.delete(id),
|
||||
invoke: async (command, args = {}) => {
|
||||
if (command === "plugin:event|listen") { listeners.set(args.event, args.handler); return ++sequence; }
|
||||
if (command === "plugin:event|unlisten") return;
|
||||
if (command.startsWith("spelling_menu_")) { window.spellingTest.commands.push({ method: command, ...args }); return; }
|
||||
if (command === "spelling_suggestions") return { language: "en-US", words: ["Corrected"], misspelled: args.word === "Original" };
|
||||
if (command === "workspace_last_path") return root;
|
||||
if (command === "workspace_open") return { root, name: "tab-menu-workspace", watch_mode: "native" };
|
||||
if (command === "workspace_read") { if (!files.has(args.rel)) throw new Error("missing"); return files.get(args.rel); }
|
||||
if (command === "workspace_list") return args.rel ? [] : [{ name: "notes", rel_path: "notes", kind: "folder" }, ...[...files.keys()].map(name => ({ name, rel_path: name, kind: "file" }))];
|
||||
if (command === "workspace_search") return [];
|
||||
if (command === "workspace_write") throw new Error("Keep unsaved edits for the close test");
|
||||
if (command === "workspace_rename") { files.set(args.to, files.get(args.from)); files.delete(args.from); return; }
|
||||
if (command === "workspace_abs_path") return `${root}\\${args.rel}`;
|
||||
if (command === "workspace_reveal") { window.tabMenuTest.revealed = args.rel; return; }
|
||||
if (command === "plugin:dialog|message") { window.tabMenuTest.prompts.push(args.message); return window.tabMenuTest.answer; }
|
||||
throw new Error(`Unhandled IPC: ${command}`);
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
|
||||
});
|
||||
|
||||
|
||||
const menu = name => page.getByRole('menu', { name, exact: true });
|
||||
const item = name => page.getByRole('menuitem', { name, exact: true });
|
||||
const output = '.audit/editor-surfaces';
|
||||
await mkdir(output, { recursive: true });
|
||||
const report = [];
|
||||
const dismiss = async () => { await page.keyboard.press('Escape'); await page.locator('.rs-menu').waitFor({ state: 'detached' }); };
|
||||
const styles = panel => panel.evaluate(node => {
|
||||
const row = node.querySelector(':scope > button');
|
||||
const a = getComputedStyle(node), b = getComputedStyle(row);
|
||||
return [a.backgroundColor, a.borderRadius, a.padding, b.minHeight, b.padding, b.font];
|
||||
});
|
||||
try {
|
||||
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:1420');
|
||||
await page.locator('[data-tree-rel="a.md"]').click();
|
||||
await page.locator('.cm-content').waitFor();
|
||||
for (const theme of ['dark', 'light']) {
|
||||
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||
await page.evaluate(async mode => {
|
||||
const { saveAppearance } = await import('/src/lib/theme/appearance.ts');
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = 800; canvas.height = 600;
|
||||
const c = canvas.getContext('2d');
|
||||
const g = c.createLinearGradient(0, 0, 800, 600);
|
||||
g.addColorStop(0, '#628ba8'); g.addColorStop(1, '#b47796');
|
||||
c.fillStyle = g; c.fillRect(0, 0, 800, 600);
|
||||
saveAppearance({ theme: 'default', mode, newTabBackground: { image: canvas.toDataURL(), overlay: .15, position: 'center', size: 'cover' } });
|
||||
}, theme);
|
||||
await page.locator('[data-tree-rel="a.md"]').click({ button: 'right' });
|
||||
const reference = await styles(menu('File actions'));
|
||||
await dismiss();
|
||||
const text = page.getByText('Original text.', { exact: true });
|
||||
await text.click({ button: 'right', position: { x: 20, y: 8 } });
|
||||
const writer = menu('Markdown text actions');
|
||||
assert.deepEqual(await styles(writer), reference);
|
||||
for (const name of ['Add link', 'Add external link', 'Format', 'Paragraph', 'Insert', 'Paste', 'Select all']) assert.equal(await item(name).count(), 1);
|
||||
await item('Corrected').waitFor();
|
||||
assert.equal(await item('Spelling').count(), 0, 'Corrections appear directly in the main menu');
|
||||
assert.equal(await writer.locator(':scope > button').first().textContent(), 'Corrected');
|
||||
await page.screenshot({ path: `${output}/writer-menu-${theme}.png` });
|
||||
await item('Corrected').focus(); await page.keyboard.press('Enter');
|
||||
await page.getByText('Corrected text.', { exact: true }).waitFor();
|
||||
await page.keyboard.press('Control+z');
|
||||
await text.waitFor();
|
||||
await page.getByRole('button', { name: 'Files', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'Hide outline', exact: true }).click();
|
||||
await page.setViewportSize({ width: 560, height: 620 });
|
||||
await text.click({ button: 'right', position: { x: 20, y: 8 } });
|
||||
await item('Corrected').waitFor();
|
||||
await page.keyboard.press('Home');
|
||||
assert.equal(await item('Corrected').evaluate(node => node === document.activeElement), true);
|
||||
const spellingBounds = await writer.boundingBox();
|
||||
assert.ok(spellingBounds.x >= 8 && spellingBounds.x + spellingBounds.width <= 552);
|
||||
await page.screenshot({ path: `${output}/spelling-narrow-${theme}.png` });
|
||||
await page.keyboard.press('Enter');
|
||||
await page.getByText('Corrected text.', { exact: true }).waitFor();
|
||||
await page.keyboard.press('Control+z');
|
||||
await text.waitFor();
|
||||
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||
await page.getByRole('button', { name: 'Files', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'Show outline', exact: true }).click();
|
||||
await page.locator('.cm-content').click({ button: 'right', position: { x: 600, y: 150 } });
|
||||
assert.deepEqual(await styles(writer), reference, 'Blank space uses the same actions');
|
||||
await item('Format').focus(); await page.keyboard.press('ArrowRight');
|
||||
await item('Bold').click();
|
||||
await page.locator('.cm-content').click({ button: 'right', position: { x: 600, y: 150 } });
|
||||
await page.getByRole('menuitem', { name: 'Undo Ctrl+Z', exact: true }).click();
|
||||
assert.equal(await page.locator('.cm-content').textContent().then(s => s.includes('**')), false, 'Undo reverses the menu edit');
|
||||
const tint = await page.locator('.writer-code-line').first().evaluate(node => getComputedStyle(node).backgroundColor);
|
||||
assert.ok(tint.includes('/ 0.82') || /rgba\(.+, 0\.82\)/.test(tint), `Writer code tint: ${tint}`);
|
||||
await page.screenshot({ path: `${output}/writer-code-${theme}.png` });
|
||||
await page.getByRole('group', { name: 'Document view', exact: true }).hover();
|
||||
await page.getByRole('button', { name: 'Read', exact: true }).click();
|
||||
const readingTint = await page.locator('pre.md-code').evaluate(node => getComputedStyle(node).backgroundColor);
|
||||
assert.equal(readingTint, tint, 'Reader and Writer use the same code tint');
|
||||
await page.screenshot({ path: `${output}/reader-code-${theme}.png` });
|
||||
await page.getByRole('button', { name: 'Edit', exact: true }).click();
|
||||
await page.getByRole('group', { name: 'Editor layout', exact: true }).hover();
|
||||
await page.getByRole('button', { name: 'IDE', exact: true }).click();
|
||||
await page.locator('.monaco-editor').waitFor();
|
||||
await page.locator('.monaco-host').click({ button: 'right', position: { x: 500, y: 400 } });
|
||||
assert.deepEqual(await styles(writer), reference, 'Markdown IDE retains the same menu');
|
||||
await dismiss();
|
||||
await page.locator('[data-tree-rel="sample.txt"]').click();
|
||||
await page.locator('.monaco-host').click({ button: 'right', position: { x: 500, y: 400 } });
|
||||
const code = menu('Code text actions');
|
||||
assert.deepEqual(await styles(code), reference, 'Code IDE uses the host menu');
|
||||
assert.equal(await page.locator('.monaco-menu').count(), 0);
|
||||
await page.screenshot({ path: `${output}/ide-menu-${theme}.png` });
|
||||
await page.getByRole('menuitem', { name: 'Command palette F1', exact: true }).click();
|
||||
const palette = page.locator('.quick-input-widget');
|
||||
await palette.waitFor({ state: 'visible' });
|
||||
const paletteMetrics = () => palette.evaluate(node => {
|
||||
const row = node.querySelector('.monaco-list-row.focused');
|
||||
const field = node.querySelector('.monaco-inputbox');
|
||||
const a = getComputedStyle(row), b = getComputedStyle(field);
|
||||
const probe = document.createElement('div');
|
||||
probe.style.background = 'var(--rs-item-selection-bg)'; probe.style.color = 'var(--rs-item-selection-border)';
|
||||
node.append(probe); const expected = getComputedStyle(probe);
|
||||
const result = { fill: a.backgroundColor, expectedFill: expected.backgroundColor, outline: a.outlineColor, expectedOutline: expected.color, radius: a.borderRadius, inputRadius: b.borderRadius, inputOutline: b.outlineColor, inputOutlineWidth: b.outlineWidth };
|
||||
probe.remove(); return result;
|
||||
});
|
||||
let p = await paletteMetrics();
|
||||
assert.equal(p.fill, p.expectedFill);
|
||||
assert.equal(p.outline, p.expectedOutline);
|
||||
assert.equal(p.radius, '5px'); assert.equal(p.inputRadius, '5px');
|
||||
assert.equal(p.inputOutline, p.expectedOutline); assert.equal(p.inputOutlineWidth, '2px');
|
||||
await page.keyboard.press('ArrowDown');
|
||||
p = await paletteMetrics(); assert.equal(p.fill, p.expectedFill);
|
||||
await page.screenshot({ path: `${output}/palette-${theme}.png` });
|
||||
await page.keyboard.press('Escape');
|
||||
await page.getByRole('button', { name: 'Files', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'Hide outline', exact: true }).click();
|
||||
await page.setViewportSize({ width: 560, height: 620 });
|
||||
await page.locator('.monaco-host').click({ button: 'right', position: { x: 100, y: 300 } });
|
||||
await code.waitFor();
|
||||
const bounds = await code.boundingBox();
|
||||
assert.ok(bounds.x >= 0 && bounds.x + bounds.width <= 560);
|
||||
await page.keyboard.press('End');
|
||||
assert.equal(await page.getByRole('menuitem', { name: 'Command palette F1', exact: true }).evaluate(n => n === document.activeElement), true);
|
||||
await page.screenshot({ path: `${output}/ide-narrow-${theme}.png` });
|
||||
await page.keyboard.press('Enter');
|
||||
await palette.waitFor({ state: 'visible' });
|
||||
await page.screenshot({ path: `${output}/palette-narrow-${theme}.png` });
|
||||
await page.keyboard.press('Escape');
|
||||
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||
await page.getByRole('button', { name: 'Files', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'Show outline', exact: true }).click();
|
||||
await page.locator('[data-tree-rel="a.md"]').click();
|
||||
await page.getByRole('group', { name: 'Editor layout', exact: true }).hover();
|
||||
await page.getByRole('button', { name: 'Writer', exact: true }).click();
|
||||
report.push({ theme, passed: ['word and blank menu parity', 'spelling correction and undo', 'Writer/IDE parity', 'undo menu action', 'code menu host styles', 'transparent code in Writer/Reader', 'palette selection/focus', 'narrow keyboard menu/palette'], nativeDesktop: 'not tested' });
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
console.log(JSON.stringify(report, null, 2));
|
||||
} catch (error) { await page.screenshot({path: `${output}/failure.png`}); console.log(await page.locator(".rs-menu").allTextContents()); throw error; } finally { await browser.close(); }
|
||||
@@ -0,0 +1,40 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { CHARACTER_THEMES, SYNTAX_ROLES } from '../src/lib/theme/characterThemes.ts';
|
||||
|
||||
const rgb = (hex: string) => hex.match(/[0-9a-f]{2}/gi)!.map(channel => parseInt(channel, 16));
|
||||
const luminance = (hex: string) => rgb(hex).map(channel => channel / 255)
|
||||
.map(channel => channel <= .04045 ? channel / 12.92 : ((channel + .055) / 1.055) ** 2.4)
|
||||
.reduce((sum, channel, index) => sum + channel * [.2126, .7152, .0722][index], 0);
|
||||
const contrast = (a: string, b: string) => (Math.max(luminance(a), luminance(b)) + .05) / (Math.min(luminance(a), luminance(b)) + .05);
|
||||
const mix = (a: string, b: string, ratio: number) => '#' + rgb(a)
|
||||
.map((channel, index) => Math.round(channel * ratio + rgb(b)[index] * (1 - ratio)).toString(16).padStart(2, '0')).join('');
|
||||
|
||||
test('Silver Serpent text and syntax remain readable on opaque and image surfaces', () => {
|
||||
const { surfaces, syntax, secondary } = CHARACTER_THEMES['silver-serpent'];
|
||||
const [bg, elevated, active, , dim, text, strong, accent, selection] = surfaces;
|
||||
const panelOnWhite = mix(elevated, '#ffffff', .82);
|
||||
const editorOnWhite = mix(bg, '#ffffff', .9);
|
||||
const backgrounds = {
|
||||
bg, elevated, active, selection,
|
||||
panelOnWhite,
|
||||
editorOnWhite,
|
||||
menuHoverOnWhite: mix(active, panelOnWhite, .82),
|
||||
controlHoverOnWhite: mix(active, '#ffffff', .92),
|
||||
codeBlockOnWhite: mix(elevated, editorOnWhite, .82),
|
||||
};
|
||||
const foregrounds = { dim, text, strong, accent, secondary,
|
||||
...Object.fromEntries(SYNTAX_ROLES.map((role, index) => [`syntax-${role}`, syntax[index]])) };
|
||||
for (const [backgroundName, background] of Object.entries(backgrounds)) {
|
||||
for (const [foregroundName, foreground] of Object.entries(foregrounds)) {
|
||||
assert(contrast(foreground, background) >= 4.5, `${foregroundName} on ${backgroundName}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('Silver Serpent selection has a readable perimeter and a separate fill', () => {
|
||||
const [bg, elevated, , , , , , accent, selection] = CHARACTER_THEMES['silver-serpent'].surfaces;
|
||||
assert(contrast(accent, selection) >= 3, 'selection perimeter');
|
||||
assert(contrast(selection, bg) >= 1.5, 'selection against the editor');
|
||||
assert(contrast(selection, elevated) >= 1.5, 'selection against a panel');
|
||||
});
|
||||
@@ -25,6 +25,7 @@ await page.addInitScript(() => {
|
||||
if (command === "plugin:event|listen") { listeners.set(args.event, args.handler); return ++sequence; }
|
||||
if (command === "plugin:event|unlisten") return;
|
||||
if (command.startsWith("spelling_menu_")) { window.spellingTest.commands.push({ method: command, ...args }); return; }
|
||||
if (command === "spelling_suggestions") return { language: "en-US", words: [], misspelled: false };
|
||||
if (command === "workspace_last_path") return root;
|
||||
if (command === "workspace_open") return { root, name: "tab-menu-workspace", watch_mode: "native" };
|
||||
if (command === "workspace_read") { if (!files.has(args.rel)) throw new Error("missing"); return files.get(args.rel); }
|
||||
@@ -70,13 +71,36 @@ try {
|
||||
for (const theme of ["dark", "light"]) {
|
||||
await page.evaluate(async mode => {
|
||||
const { saveAppearance } = await import('/src/lib/theme/appearance.ts');
|
||||
saveAppearance({ theme: 'default', mode });
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = 800; canvas.height = 600;
|
||||
const context = canvas.getContext('2d');
|
||||
const gradient = context.createLinearGradient(0, 0, 800, 600);
|
||||
gradient.addColorStop(0, '#628ba8'); gradient.addColorStop(1, '#b47796');
|
||||
context.fillStyle = gradient; context.fillRect(0, 0, 800, 600);
|
||||
saveAppearance({ theme: 'default', mode, newTabBackground: { image: canvas.toDataURL(), overlay: 0.15, position: 'center', size: 'cover' } });
|
||||
}, theme);
|
||||
await row.focus();
|
||||
await row.click({ button: "right" });
|
||||
const file = menu("File actions");
|
||||
await file.waitFor();
|
||||
const reference = await metrics(file);
|
||||
assert.equal(reference.row[1], "24px", "Menus use compact shared rows");
|
||||
assert.equal(reference.row[0], "2px 10px");
|
||||
const compactHeight = await file.evaluate(node => node.getBoundingClientRect().height);
|
||||
await page.evaluate(() => {
|
||||
document.documentElement.style.setProperty('--rs-menu-row-height', '30px');
|
||||
document.documentElement.style.setProperty('--rs-menu-row-padding', '4px 10px');
|
||||
});
|
||||
const previousHeight = await file.evaluate(node => node.getBoundingClientRect().height);
|
||||
await page.screenshot({ path: '.audit/todo-2026-10-14/menu-spacing-before-' + theme + '.png' });
|
||||
await page.evaluate(() => {
|
||||
document.documentElement.style.removeProperty('--rs-menu-row-height');
|
||||
document.documentElement.style.removeProperty('--rs-menu-row-padding');
|
||||
});
|
||||
assert.ok(compactHeight < previousHeight * .85, 'The same actions use at least 15% less vertical space');
|
||||
console.log(JSON.stringify({ theme, compactHeight, previousHeight }));
|
||||
await page.screenshot({ path: '.audit/todo-2026-10-14/menu-spacing-after-' + theme + '.png' });
|
||||
assert.ok(reference.panel[2].includes('/ 0.82') || /rgba\(.+, 0\.82\)/.test(reference.panel[2]), "Shared menus retain an 82% surface tint");
|
||||
assert.ok(reference.inset >= 5, "Rows need an inset from the panel border");
|
||||
assert.equal(await item("Pin").locator("svg.action-icon").count(), 1);
|
||||
const offsets = await file.locator(":scope > button").evaluateAll(nodes => nodes.map(node => Math.round(node.querySelector(".action-label").getBoundingClientRect().left - node.getBoundingClientRect().left)));
|
||||
@@ -131,6 +155,20 @@ try {
|
||||
return { x: bounds.left + bounds.width / 2, y: bounds.top + bounds.height / 2 };
|
||||
});
|
||||
await page.mouse.click(wordPoint.x, wordPoint.y, { button: "right" });
|
||||
await editor.waitFor();
|
||||
assert.deepEqual(await metrics(editor), reference, "Word and blank-space menus share styles");
|
||||
assert.equal(await item("Format").count(), 1, "Words retain the Markdown actions");
|
||||
await dismiss();
|
||||
await page.evaluate(() => {
|
||||
const input = document.createElement("input");
|
||||
input.id = "native-spelling-test";
|
||||
input.spellcheck = true;
|
||||
input.value = "Original";
|
||||
Object.assign(input.style, { position: "fixed", left: "500px", top: "100px" });
|
||||
document.body.append(input);
|
||||
input.focus();
|
||||
input.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true }));
|
||||
});
|
||||
await page.evaluate(() => window.spellingTest.emit({ request: "spelling-1", items: [
|
||||
{ id: 71, name: "suggestion", label: "Original", shortcut: "", kind: 0, enabled: true, checked: false, children: [] },
|
||||
{ id: 72, name: "addToDictionary", label: "Add to dictionary", shortcut: "", kind: 0, enabled: true, checked: false, children: [] },
|
||||
@@ -152,7 +190,7 @@ try {
|
||||
await page.keyboard.press("Enter");
|
||||
await spelling.waitFor({ state: "detached" });
|
||||
assert.deepEqual(await page.evaluate(() => window.spellingTest.commands.at(-1)), { method: "spelling_menu_select", request: "spelling-1", command: 71 });
|
||||
assert.equal(await page.locator(".cm-content").evaluate(node => node === document.activeElement), true);
|
||||
assert.equal(await page.locator("#native-spelling-test").evaluate(node => node === document.activeElement), true);
|
||||
async function emitSpelling(request) {
|
||||
await page.evaluate(request => window.spellingTest.emit({ request, items: [
|
||||
{ id: 81, name: "suggestion", label: "Replacement", shortcut: "", kind: 0, enabled: true, checked: false, children: [] },
|
||||
@@ -170,6 +208,7 @@ try {
|
||||
await emitSpelling("new");
|
||||
assert.deepEqual(await page.evaluate(() => window.spellingTest.commands.at(-1)), { method: "spelling_menu_select", request: "old", command: null });
|
||||
await dismiss();
|
||||
await page.locator("#native-spelling-test").evaluate(node => node.remove());
|
||||
await page.evaluate(() => {
|
||||
const input = document.createElement("input");
|
||||
input.spellcheck = false;
|
||||
@@ -216,6 +255,35 @@ try {
|
||||
assert.equal(await item("Action 29").evaluate(node => node === document.activeElement), true);
|
||||
await page.screenshot({ path: ".audit/menu-edge.png" });
|
||||
await dismiss();
|
||||
await page.evaluate(async () => {
|
||||
const { actionMenu } = await import("/src/lib/ui/actionMenu.ts");
|
||||
const dialog = document.createElement("dialog");
|
||||
dialog.id = "menu-modal-test";
|
||||
dialog.style.cssText = "height:220px;width:320px;overflow:auto";
|
||||
const content = document.createElement("div");
|
||||
content.style.height = "600px";
|
||||
dialog.append(content);
|
||||
document.body.append(dialog);
|
||||
dialog.showModal();
|
||||
dialog.scrollTop = 160;
|
||||
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
||||
window.menuModalScroll = dialog.scrollTop;
|
||||
const root = actionMenu(180, 280, Array.from({ length: 30 }, (_, index) => ({ label: `Modal action ${index}`, icon: "copy" })), () => root.remove(), "Modal scrolling test", dialog);
|
||||
const dismissOnAncestorScroll = event => { if (!root.contains(event.target)) root.remove(); };
|
||||
dialog.addEventListener("scroll", dismissOnAncestorScroll, true);
|
||||
});
|
||||
await page.keyboard.press("End");
|
||||
const modalMenu = menu("Modal scrolling test");
|
||||
await modalMenu.waitFor();
|
||||
assert.equal(await item("Modal action 29").evaluate(node => node === document.activeElement), true);
|
||||
assert.equal(await page.locator("#menu-modal-test").evaluate(dialog => dialog.scrollTop), await page.evaluate(() => window.menuModalScroll), "Keyboard traversal scrolls only the menu panel");
|
||||
const modalBounds = await modalMenu.boundingBox(), lastBounds = await item("Modal action 29").boundingBox();
|
||||
assert.ok(lastBounds.y >= modalBounds.y && lastBounds.y + lastBounds.height <= modalBounds.y + modalBounds.height + 1, "End keeps the last row visible inside a short modal");
|
||||
await page.screenshot({ path: ".audit/menu-modal-end.png" });
|
||||
await page.keyboard.press("Home");
|
||||
assert.equal(await item("Modal action 0").evaluate(node => node === document.activeElement), true);
|
||||
await dismiss();
|
||||
await page.locator("#menu-modal-test").evaluate(dialog => { dialog.close(); dialog.remove(); });
|
||||
assert.deepEqual(errors, []);
|
||||
console.log("PASS: menu styles, dark/light themes, icons, disabled rows, focus return, submenus, scrolling, and viewport edges");
|
||||
} finally { await browser.close(); }
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
import { readdir, readFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const root = fileURLToPath(new URL('../', import.meta.url));
|
||||
export const projects = ['RuneStone', 'RuneStone_ProjectManagement', 'RuneStone_Terminal', 'RuneStone_BG_Slideshow', 'RuneStone_LocalAutocomplete', 'RuneStone_Git', 'RuneStone_PDFViewer', 'RuneStone_TableFormulas', 'RuneStone_CSVViewer'];
|
||||
const patterns = {
|
||||
action: /\b(?:showActionMenu|actionMenu)\s*\(/g,
|
||||
svelteMenu: /<ContextMenu\b/g,
|
||||
nativeChoice: /<select\b|(?:createElement|el)\(\s*['"]select['"]/g,
|
||||
picker: /rs-picker(?:[\s"']|$)|role=['"]listbox['"]|setAttribute\(\s*['"]role['"],\s*['"]listbox['"]/g,
|
||||
localPopup: /(?:class|className)\s*=\s*['"][^'"\n]*(?:menu|picker|popup)|\.popover\s*=/g,
|
||||
};
|
||||
async function files(dir) {
|
||||
const entries = await readdir(dir, { withFileTypes: true });
|
||||
const results = await Promise.all(entries.filter(entry => !entry.isSymbolicLink()).map(entry => entry.isDirectory()
|
||||
? files(path.join(dir, entry.name)) : /\.(svelte|[cm]?[jt]s)$/.test(entry.name) ? [path.join(dir, entry.name)] : []));
|
||||
return results.flat();
|
||||
}
|
||||
export async function discover() {
|
||||
const surfaces = {}, missing = [];
|
||||
for (const project of projects) {
|
||||
const base = project === 'RuneStone' ? root : path.resolve(root, '..', project);
|
||||
let sources;
|
||||
try { sources = await files(path.join(base, 'src')); } catch (error) { if (error.code === 'ENOENT') { missing.push(project); continue; } throw error; }
|
||||
for (const file of sources) {
|
||||
const source = await readFile(file, 'utf8');
|
||||
const counts = Object.fromEntries(Object.entries(patterns).map(([name, pattern]) => [name, [...source.matchAll(pattern)].length]).filter(([, count]) => count));
|
||||
if (Object.keys(counts).length) surfaces[`${project}/${path.relative(base, file).replaceAll('\\', '/')}`] = counts;
|
||||
}
|
||||
}
|
||||
return { surfaces, missing };
|
||||
}
|
||||
export async function checkInventory() {
|
||||
const { surfaces, missing } = await discover();
|
||||
const inventory = JSON.parse(await readFile(path.join(root, 'docs/menu-surfaces.json'), 'utf8'));
|
||||
const failures = missing.map(project => `Missing checkout: ${project}`);
|
||||
for (const [file, counts] of Object.entries(surfaces)) {
|
||||
const entry = inventory.surfaces[file];
|
||||
if (!entry) failures.push(`Unreviewed surface: ${file}`);
|
||||
else if (JSON.stringify(counts) !== JSON.stringify(entry.counts)) failures.push(`Changed entry points: ${file}`);
|
||||
else if (!entry.design || !entry.check) failures.push(`Missing design or check: ${file}`);
|
||||
}
|
||||
for (const file of Object.keys(inventory.surfaces)) if (!(file in surfaces)) failures.push(`Stale inventory: ${file}`);
|
||||
for (const name of ['actionMenu.ts', 'managedActionMenu.ts', 'IconButton.svelte']) {
|
||||
try {
|
||||
const host = await readFile(path.join(root, 'src/lib/ui', name), 'utf8');
|
||||
const terminal = await readFile(path.resolve(root, '../RuneStone_Terminal/vendor/runestone/ui', name), 'utf8');
|
||||
if (host.replaceAll('\r\n', '\n') !== terminal.replaceAll('\r\n', '\n')) failures.push(`Terminal shared snapshot differs: ${name}`);
|
||||
} catch (error) { failures.push(`Cannot check Terminal snapshot ${name}: ${error.code}`); }
|
||||
}
|
||||
if (failures.length) { console.error(failures.join('\n')); return false; }
|
||||
console.log(`PASS: ${Object.keys(surfaces).length} source files across ${projects.length} projects match the reviewed menu inventory. Runtime checks remain separate.`);
|
||||
return true;
|
||||
}
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
if (process.argv.includes('--discover')) console.log(JSON.stringify(await discover(), null, 2));
|
||||
else if (!await checkInventory()) process.exitCode = 1;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { lstat, readdir, readFile, mkdir, writeFile, realpath, rename, unlink } from "node:fs/promises";
|
||||
import { lstat, readdir, readFile, mkdir, writeFile, realpath, link, unlink } from "node:fs/promises";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { resolve, relative, isAbsolute, join } from "node:path";
|
||||
import { resolve, relative, isAbsolute, join, dirname } from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { crc32, deflateRawSync } from "node:zlib";
|
||||
|
||||
@@ -50,9 +50,21 @@ function zip(files) {
|
||||
return Buffer.concat([...local, ...central, end]);
|
||||
}
|
||||
|
||||
export async function packagePlugin(source, destination = "plugin-packages") {
|
||||
export async function packagePlugin(source, destination) {
|
||||
const input = resolve(source);
|
||||
const output = resolve(destination);
|
||||
let project = input;
|
||||
if (!destination) {
|
||||
while (true) {
|
||||
try { await readFile(join(project, "package.json")); break; }
|
||||
catch (error) {
|
||||
if (error.code !== "ENOENT") throw error;
|
||||
const parent = dirname(project);
|
||||
requireValue(parent !== project, "Pass an output folder when the compiled folder has no project root.");
|
||||
project = parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
const output = resolve(destination ?? join(project, "releases"));
|
||||
const inputMeta = await lstat(input);
|
||||
requireValue(inputMeta.isDirectory() && !inputMeta.isSymbolicLink(), "Select a compiled plugin folder.");
|
||||
const files = [], names = new Set();
|
||||
@@ -102,7 +114,12 @@ export async function packagePlugin(source, destination = "plugin-packages") {
|
||||
const temporary = `${target}.${randomUUID()}.tmp`;
|
||||
try {
|
||||
await writeFile(temporary, archive, { flag: "wx" });
|
||||
await rename(temporary, target);
|
||||
try {
|
||||
await link(temporary, target);
|
||||
} catch (error) {
|
||||
if (error.code !== "EEXIST") throw error;
|
||||
requireValue((await readFile(target)).equals(archive), "The release file already contains different contents: " + target);
|
||||
}
|
||||
} finally {
|
||||
await unlink(temporary).catch(error => { if (error.code !== "ENOENT") throw error; });
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile, mkdir } from 'node:fs/promises';
|
||||
import { createRequire } from 'node:module';
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || 'playwright');
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const page = await browser.newPage();
|
||||
const url = process.env.SMOKE_URL || 'http://127.0.0.1:1420';
|
||||
const errors = [];
|
||||
page.on('pageerror', error => errors.push(error.message));
|
||||
await mkdir('.audit/menu-audit', { recursive: true });
|
||||
await page.route('**/__choice-audit__', route => route.fulfill({ contentType: 'text/html', body: '<link rel="stylesheet" href="/src/lib/theme/tokens.css"><link rel="stylesheet" href="/src/lib/ui/menu.css"><style>dialog{inset:0;margin:0;max-width:none;max-height:none;width:100%;height:100%;box-sizing:border-box;background:var(--rs-bg);color:var(--rs-text);padding:0;border:0}</style><dialog><main></main></dialog>' }));
|
||||
await page.route('**/__autocomplete__/*.mjs', async route => {
|
||||
const name = new URL(route.request().url()).pathname.split('/').pop();
|
||||
assert.ok(['main.mjs', 'engine.mjs'].includes(name));
|
||||
await route.fulfill({ contentType: 'application/javascript', body: await readFile(new URL(`../../RuneStone_LocalAutocomplete/src/${name}`, import.meta.url), 'utf8') });
|
||||
});
|
||||
try {
|
||||
for (const theme of ['light', 'dark']) for (const width of [1100, 390]) {
|
||||
await page.setViewportSize({ width, height: 850 });
|
||||
await page.goto(url + '/__choice-audit__');
|
||||
await page.evaluate(async theme => {
|
||||
document.documentElement.dataset.theme = theme;
|
||||
const { showActionMenu } = await import('/src/lib/ui/managedActionMenu.ts');
|
||||
const { activate } = await import('/__autocomplete__/main.mjs');
|
||||
let view;
|
||||
window.choiceAudit = { saved: null };
|
||||
await activate({ ui: { showActionMenu }, completion: { version: 1, transport() {}, invalidate() {}, registerProvider() { return () => {}; }, registerInput() { return { dispose() {}, request() {} }; } },
|
||||
settings: { read: async () => ({}), write: async value => { window.choiceAudit.saved = value; } },
|
||||
onDispose() {}, registerCommand() {}, registerView(value) { view = value; } });
|
||||
document.querySelector('dialog').showModal();
|
||||
window.choiceAudit.dispose = view.mount(document.querySelector('main'), { surface: 'settings' });
|
||||
}, theme);
|
||||
const trigger = page.getByRole('button', { name: 'Server type', exact: true });
|
||||
await trigger.click();
|
||||
const menu = page.getByRole('menu', { name: 'Server type', exact: true });
|
||||
assert.equal(await menu.evaluate(node => !!node.closest('dialog[open]')), true);
|
||||
await page.keyboard.press('End');
|
||||
assert.equal(await page.getByRole('menuitemradio', { name: 'Ollama', exact: true }).evaluate(node => node === document.activeElement), true);
|
||||
await page.screenshot({ path: `.audit/menu-audit/autocomplete-${theme}-${width}.png` });
|
||||
await page.keyboard.press('Enter');
|
||||
assert.match(await trigger.innerText(), /Ollama/);
|
||||
await page.getByRole('button', { name: 'Save settings', exact: true }).click();
|
||||
await page.waitForFunction(() => window.choiceAudit.saved?.adapter === 'ollama');
|
||||
await trigger.click(); await page.keyboard.press('Escape');
|
||||
assert.equal(await trigger.evaluate(node => node === document.activeElement), true);
|
||||
await trigger.click(); await page.evaluate(() => window.choiceAudit.dispose());
|
||||
assert.equal(await page.locator('.rs-menu').count(), 0);
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
console.log('PASS: Local Autocomplete shared choices, modal input, saved adapter, focus return, and cleanup in both themes at 1100/390px.');
|
||||
} finally { await browser.close(); }
|
||||
@@ -39,11 +39,16 @@ test("plugin packaging rejects invalid release inputs before writing an archive"
|
||||
await writeFile(join(source, "invalid file.txt"), "test");
|
||||
await assert.rejects(packagePlugin(source, output), /Invalid package path/);
|
||||
await rm(join(source, "invalid file.txt"));
|
||||
const path = await packagePlugin(source, output);
|
||||
await writeFile(join(root, "package.json"), JSON.stringify({ name: "test-plugin" }));
|
||||
const path = await packagePlugin(source);
|
||||
assert.equal(path, join(await realpath(output), "org.test.demo-1.0.0.zip"));
|
||||
const first = await readFile(path);
|
||||
await packagePlugin(source, output);
|
||||
assert.deepEqual(await readFile(path), first);
|
||||
await writeFile(join(source, "main.js"), "export function activate() { return 1; }");
|
||||
await assert.rejects(packagePlugin(source), /different contents/);
|
||||
assert.deepEqual(await readFile(path), first);
|
||||
await writeFile(join(source, "main.js"), "export function activate() {}");
|
||||
for (const version of ["0.2.28a", "0.2.28b", "0.2.28aa"]) {
|
||||
await save({ version });
|
||||
const hotfix = await packagePlugin(source, output);
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
// Run against `pnpm dev`. PLAYWRIGHT_MODULE may point to a shared installation.
|
||||
import { createRequire } from "node:module";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||
page.setDefaultTimeout(10000);
|
||||
const errors = [];
|
||||
await mkdir(".audit", { recursive: true });
|
||||
page.on("console", message => { if (message.type() === "error" || message.type() === "warning") console.log(message.type(), message.text()); });
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
await page.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
const root = "C:\\smoke-workspace";
|
||||
const files = new Map([
|
||||
["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"],
|
||||
]);
|
||||
const callbacks = new Map();
|
||||
const listeners = new Map();
|
||||
let sequence = 0;
|
||||
const calls = [];
|
||||
const emit = (event, payload) => {
|
||||
for (const id of listeners.get(event) || []) callbacks.get(id)?.({ event, id, payload });
|
||||
};
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: "main" }, currentWebview: { label: "main" } },
|
||||
transformCallback: callback => { const id = ++sequence; callbacks.set(id, callback); return id; },
|
||||
unregisterCallback: id => callbacks.delete(id),
|
||||
invoke: async (command, args = {}) => {
|
||||
calls.push({ command, args });
|
||||
if (command === "plugin:event|listen") {
|
||||
const list = listeners.get(args.event) || []; list.push(args.handler); listeners.set(args.event, list); return args.handler;
|
||||
}
|
||||
if (command === "plugin:event|unlisten") { callbacks.delete(args.eventId); return; }
|
||||
if (command === "workspace_last_path") return root;
|
||||
if (command === "workspace_open") return { root, name: "smoke-workspace", watch_mode: "native" };
|
||||
if (command === "workspace_read") { if (!files.has(args.rel)) throw new Error("missing"); return files.get(args.rel); }
|
||||
if (command === "workspace_write") {
|
||||
if (args.expected !== undefined && files.get(args.rel) !== args.expected) throw new Error("Save blocked: file changed on disk");
|
||||
files.set(args.rel, args.contents); emit("workspace-event", { root, kind: "modify", paths: [args.rel] }); return;
|
||||
}
|
||||
if (command === "workspace_list") {
|
||||
const prefix = args.rel ? args.rel + "/" : "";
|
||||
const entries = new Map();
|
||||
for (const path of files.keys()) {
|
||||
if (!path.startsWith(prefix) || path.startsWith(".runestone/")) continue;
|
||||
const tail = path.slice(prefix.length); const name = tail.split("/")[0];
|
||||
entries.set(name, { name, rel_path: prefix + name, kind: tail.includes("/") ? "folder" : "file" });
|
||||
}
|
||||
return [...entries.values()];
|
||||
}
|
||||
if (command === "workspace_create") { if (files.has(args.rel)) throw new Error("exists"); files.set(args.rel, ""); return; }
|
||||
if (command === "workspace_search") return [];
|
||||
if (command === "spelling_menu_install") return;
|
||||
if (command === "pty_open") {
|
||||
const data = [...new TextEncoder().encode("READY 🪨\r\n\x1b[6n")];
|
||||
emit("pty-data", { id: args.id, data: data.slice(0, 8) });
|
||||
emit("pty-data", { id: args.id, data: data.slice(8) });
|
||||
await new Promise(resolve => setTimeout(resolve, 50));
|
||||
return;
|
||||
}
|
||||
if (command.startsWith("pty_")) return;
|
||||
if (command === "plugin:dialog|message") return "Cancel";
|
||||
throw new Error(`Unhandled IPC: ${command}`);
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: (_event, id) => callbacks.delete(id) };
|
||||
window.__TEST__ = { files, calls, emit, root };
|
||||
});
|
||||
|
||||
try {
|
||||
await mkdir("output/editor-october12", { recursive: true });
|
||||
await page.goto(process.env.SMOKE_URL || "http://127.0.0.1:1420");
|
||||
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();
|
||||
await page.locator('.md-properties').waitFor();
|
||||
await page.evaluate(async () => {
|
||||
const { EditorView } = await import('/node_modules/@codemirror/view/dist/index.js');
|
||||
window.__CM__ = EditorView.findFromDOM(document.querySelector('.cm-content'));
|
||||
});
|
||||
const original = await page.evaluate(() => window.__CM__.state.sliceDoc());
|
||||
assert.equal(await page.evaluate(() => window.__CM__.state.selection.main.head), original.indexOf('\n\n') + 1);
|
||||
await page.locator('.md-properties summary').click();
|
||||
assert.equal(await page.locator('.md-properties').getAttribute('open'), '');
|
||||
assert.match(await page.locator('.md-properties pre').textContent(), /title: Welcome/);
|
||||
for (const mode of ['light', 'dark']) {
|
||||
await page.evaluate(async mode => {
|
||||
const { applyAppearance } = await import('/src/lib/theme/appearance.ts');
|
||||
applyAppearance({ theme: 'default', mode });
|
||||
}, mode);
|
||||
await page.setViewportSize({ width: 760, height: 900 });
|
||||
await page.screenshot({ path: `output/editor-october12/properties-${mode}-narrow.png` });
|
||||
}
|
||||
await page.evaluate(() => { window.__CM__.dispatch({ selection: { anchor: 11 } }); window.__CM__.focus(); });
|
||||
assert.equal(await page.locator('.md-properties').count(), 0);
|
||||
await page.keyboard.type('New ');
|
||||
assert.match(await page.evaluate(() => window.__CM__.state.sliceDoc()), /title: New Welcome/);
|
||||
await page.keyboard.press('Control+z');
|
||||
assert.equal(await page.evaluate(() => window.__CM__.state.sliceDoc()), original);
|
||||
await page.evaluate(() => window.__CM__.dispatch({ selection: { anchor: window.__CM__.state.doc.length } }));
|
||||
await page.locator('.md-properties').waitFor();
|
||||
await page.evaluate(() => { window.__CM__.dispatch({ selection: { anchor: 11 } }); window.__CM__.focus(); });
|
||||
await page.getByRole('group', { name: 'Document view' }).hover();
|
||||
await page.getByRole('button', { name: 'Read', exact: true }).click();
|
||||
await page.locator('.reading .md-properties').waitFor();
|
||||
await page.getByRole('group', { name: 'Document view' }).hover();
|
||||
await page.getByRole('button', { name: 'Edit', exact: true }).click();
|
||||
await page.getByRole('textbox', { name: 'Writing editor', exact: true }).waitFor();
|
||||
assert.equal(await page.locator('.writer-preview .md-properties').count(), 0);
|
||||
assert.equal(errors.length, 0, errors.join('\n'));
|
||||
console.log('Properties first-open, editing, undo, saved selection, and both themes passed.');
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
@@ -104,6 +104,13 @@ try {
|
||||
await table.waitFor();
|
||||
assert.equal(await result(1, 3).innerText(), '9.5');
|
||||
assert.equal(await result(3, 3).innerText(), '17.5');
|
||||
await cell(1, 3).hover();
|
||||
await page.locator('.rs-tooltip:popover-open').waitFor();
|
||||
assert.equal(await cell(1, 3).getAttribute('title'), null);
|
||||
assert.match(await page.locator('.rs-tooltip:popover-open').innerText(), /D2.*AVERAGE/);
|
||||
await page.screenshot({ path: '.audit/table-cell-hint.png' });
|
||||
await page.keyboard.press('Escape');
|
||||
assert.equal(await page.locator('.rs-tooltip:popover-open').count(), 0);
|
||||
await cell(1, 3).click();
|
||||
assert.equal(await page.locator('.table-formula-status').innerText(), 'D2 = 9.5');
|
||||
await edit.fill('=AVERAGE(B2+C2)');
|
||||
@@ -153,14 +160,17 @@ try {
|
||||
async function checkFooter() {
|
||||
const geometry = await page.evaluate(() => {
|
||||
const rect = selector => document.querySelector(selector).getBoundingClientRect().toJSON();
|
||||
return { table: rect('.live-writer .md-table-scroll'), footer: rect('.table-footer'), tools: rect('.table-formula-tools'), help: rect('.table-edit-help'), summary: rect('.table-formula-help summary'), status: rect('.table-formula-status') };
|
||||
return { table: rect('.live-writer .md-table-scroll'), footer: rect('.table-footer'), tools: rect('.table-formula-tools'), help: rect('.table-edit-help'), helpHidden: document.querySelector('.table-edit-help').hidden, summary: rect('.table-formula-help summary'), status: rect('.table-formula-status') };
|
||||
});
|
||||
assert.ok(Math.abs(geometry.table.x - geometry.footer.x) < 2);
|
||||
assert.ok(Math.abs(geometry.help.x - geometry.tools.x) < 2);
|
||||
assert.ok(Math.abs(geometry.footer.x - geometry.tools.x) < 2);
|
||||
if (!geometry.helpHidden) assert.ok(Math.abs(geometry.help.x - geometry.tools.x) < 2);
|
||||
assert.ok(geometry.footer.y >= geometry.table.bottom);
|
||||
assert.ok(geometry.footer.y - geometry.table.bottom <= 28, 'Only the add-row control sits between table and footer');
|
||||
assert.ok(geometry.tools.y >= geometry.help.bottom, 'Help must not overlap the controls');
|
||||
assert.ok(geometry.help.right <= geometry.footer.right + 1);
|
||||
if (!geometry.helpHidden) {
|
||||
assert.ok(geometry.tools.y >= geometry.help.bottom, 'Help must not overlap the controls');
|
||||
assert.ok(geometry.help.right <= geometry.footer.right + 1);
|
||||
}
|
||||
if (geometry.status.x > geometry.summary.right) assert.ok(Math.abs((geometry.status.y + geometry.status.height / 2) - (geometry.summary.y + geometry.summary.height / 2)) < 2);
|
||||
}
|
||||
await cell(3, 1).click();
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
import { createRequire } from "node:module";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||
page.setDefaultTimeout(15000);
|
||||
const errors = [];
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
await mkdir(".audit", { recursive: true });
|
||||
await page.addInitScript(() => {
|
||||
localStorage.clear();
|
||||
window.isTauri = true;
|
||||
const root = "C:\\tab-menu-workspace";
|
||||
const files = new Map([["a.md", '# Links\n\nOutside table.\n\n| Name | Value |\n| --- | --- |\n| One | Text |\n| Two | Text |\n| Three | Text |\n| Four | Text |\n| Five | [Roadmp](docs/roadmap.md) |\n| Keyboard | Before [Guide](docs/guide.md) after |\n| Wiki | [[guide\\|Guide]] |\n| Repeated | **Prefix** [One](same.md) + [Sec**ond**](same.md "Title") |\n']]);
|
||||
window.tabMenuTest = { files, prompts: [], answer: "Cancel", revealed: null, clipboard: null };
|
||||
Object.defineProperty(navigator, "clipboard", { value: { writeText: async text => { window.tabMenuTest.clipboard = text; } } });
|
||||
let sequence = 0;
|
||||
const callbacks = new Map(), listeners = new Map();
|
||||
window.spellingTest = { commands: [], emit: payload => callbacks.get(listeners.get("spelling-menu"))?.({ event: "spelling-menu", id: 1, payload }) };
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: "main" }, currentWebview: { label: "main" } },
|
||||
transformCallback: callback => { callbacks.set(++sequence, callback); return sequence; }, unregisterCallback: id => callbacks.delete(id),
|
||||
invoke: async (command, args = {}) => {
|
||||
if (command === "plugin:event|listen") { listeners.set(args.event, args.handler); return ++sequence; }
|
||||
if (command === "plugin:event|unlisten") return;
|
||||
if (command.startsWith("spelling_menu_")) { window.spellingTest.commands.push({ method: command, ...args }); return; }
|
||||
if (command === "spelling_suggestions") return { language: "en-US", words: [], misspelled: false };
|
||||
if (command === "workspace_last_path") return root;
|
||||
if (command === "workspace_open") return { root, name: "tab-menu-workspace", watch_mode: "native" };
|
||||
if (command === "workspace_read") { if (!files.has(args.rel)) throw new Error("missing"); return files.get(args.rel); }
|
||||
if (command === "workspace_list") return args.rel ? [] : [{ name: "notes", rel_path: "notes", kind: "folder" }, ...[...files.keys()].map(name => ({ name, rel_path: name, kind: "file" }))];
|
||||
if (command === "workspace_search") return [];
|
||||
if (command === "workspace_write") { files.set(args.rel, args.contents); return; }
|
||||
if (command === "workspace_rename") { files.set(args.to, files.get(args.from)); files.delete(args.from); return; }
|
||||
if (command === "workspace_abs_path") return `${root}\\${args.rel}`;
|
||||
if (command === "workspace_reveal") { window.tabMenuTest.revealed = args.rel; return; }
|
||||
if (command === "plugin:dialog|message") { window.tabMenuTest.prompts.push(args.message); return window.tabMenuTest.answer; }
|
||||
throw new Error(`Unhandled IPC: ${command}`);
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
|
||||
});
|
||||
|
||||
const output = '.audit/table-link-caret';
|
||||
await mkdir(output, { recursive: true });
|
||||
const sourceCell = () => page.locator('.is-source-editing .writer-cell-editor');
|
||||
async function clickTextAt(locator, offset, button = 'left') {
|
||||
const point = await locator.evaluate((element, offset) => {
|
||||
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
|
||||
let node;
|
||||
while ((node = walker.nextNode())) {
|
||||
if (offset > node.textContent.length) { offset -= node.textContent.length; continue; }
|
||||
const range = document.createRange();
|
||||
range.setStart(node, offset); range.collapse(true);
|
||||
const rect = range.getBoundingClientRect();
|
||||
return { x: rect.x, y: rect.y + rect.height / 2 };
|
||||
}
|
||||
throw new Error('No text position');
|
||||
}, offset);
|
||||
await page.mouse.click(point.x, point.y, { button });
|
||||
}
|
||||
const selected = () => page.evaluate(() => getSelection().toString());
|
||||
const caretPrefix = () => page.evaluate(() => {
|
||||
const selection = getSelection(), range = document.createRange();
|
||||
range.selectNodeContents(document.querySelector('.is-source-editing .writer-cell-editor'));
|
||||
range.setEnd(selection.anchorNode, selection.anchorOffset);
|
||||
return range.toString();
|
||||
});
|
||||
const documentText = () => page.locator('.cm-content').evaluate(async node => {
|
||||
const { EditorView } = await import('/node_modules/@codemirror/view/dist/index.js');
|
||||
return EditorView.findFromDOM(node).state.doc.toString();
|
||||
});
|
||||
|
||||
try {
|
||||
for (const theme of ['dark', 'light']) for (const width of [1440, 620]) {
|
||||
await page.setViewportSize({ width, height: 1000 });
|
||||
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:1420');
|
||||
await page.locator('[data-tree-rel="a.md"]').click();
|
||||
await page.locator('.writer-table').waitFor();
|
||||
await page.evaluate(async mode => (await import('/src/lib/theme/appearance.ts')).saveAppearance({ theme:'default', mode }), theme);
|
||||
if (width < 1000) {
|
||||
await page.getByRole('button', { name:'Files', exact:true }).click();
|
||||
await page.getByRole('button', { name:'Hide outline', exact:true }).click();
|
||||
}
|
||||
const cell = page.getByRole('cell', { name:'Row 6, column 2', exact:true });
|
||||
await clickTextAt(cell.locator('a'), 5);
|
||||
await sourceCell().waitFor();
|
||||
assert.equal(await cell.locator('.writer-link-target').innerText(), 'docs/roadmap.md', 'Ordinary click reveals the URL');
|
||||
assert.equal(await caretPrefix(), '[Roadm', 'The caret stays at the clicked label character');
|
||||
await page.keyboard.type('a');
|
||||
assert.equal(await sourceCell().innerText(), '[Roadmap](docs/roadmap.md)');
|
||||
await page.screenshot({ path:`${output}/click-label-${theme}-${width}.png` });
|
||||
await page.keyboard.press('Escape');
|
||||
assert.equal(await cell.locator('a').innerText(), 'Roadmap');
|
||||
await clickTextAt(cell.locator('a'), 3);
|
||||
await page.keyboard.press('Shift+F10');
|
||||
await page.getByRole('menuitem', { name:'Edit link', exact:true }).click();
|
||||
assert.equal(await selected(), 'docs/roadmap.md');
|
||||
assert.equal(await page.getByRole('dialog').count(), 0);
|
||||
await page.screenshot({ path:`${output}/edit-target-${theme}-${width}.png` });
|
||||
await page.keyboard.type('docs/changed.md');
|
||||
await page.keyboard.press('Enter');
|
||||
assert.equal(await cell.locator('a').getAttribute('href'), 'docs/changed.md');
|
||||
await page.locator('.cm-line').filter({ hasText:'Outside table.' }).click();
|
||||
await page.keyboard.press('Control+z');
|
||||
assert.equal(await cell.locator('a').getAttribute('href'), 'docs/roadmap.md');
|
||||
await page.keyboard.press('Control+y');
|
||||
assert.equal(await cell.locator('a').getAttribute('href'), 'docs/changed.md');
|
||||
await page.keyboard.press('Control+s');
|
||||
assert.match(await page.evaluate(() => window.tabMenuTest.files.get('a.md')), /\[Roadmap\]\(docs\/changed.md\)/);
|
||||
|
||||
const keyboard = page.getByRole('cell', { name:'Row 7, column 2', exact:true });
|
||||
await clickTextAt(keyboard, 7);
|
||||
assert.equal(await sourceCell().count(), 0, 'Plain cell text remains rendered');
|
||||
await page.keyboard.press('ArrowRight');
|
||||
await sourceCell().waitFor();
|
||||
assert.equal(await keyboard.locator('.writer-link-target').innerText(), 'docs/guide.md');
|
||||
assert.equal(await caretPrefix(), 'Before [G');
|
||||
await page.screenshot({ path:`${output}/keyboard-${theme}-${width}.png` });
|
||||
await page.keyboard.press('Escape');
|
||||
|
||||
const wiki = page.getByRole('cell', { name:'Row 8, column 2', exact:true });
|
||||
await clickTextAt(wiki.locator('a'), 3);
|
||||
await sourceCell().waitFor();
|
||||
assert.equal(await caretPrefix(), '[[guide\\|Gui');
|
||||
await page.keyboard.press('Shift+F10');
|
||||
await page.getByRole('menuitem', { name:'Edit link', exact:true }).click();
|
||||
assert.equal(await selected(), 'guide');
|
||||
await page.keyboard.type('new-guide');
|
||||
await page.keyboard.press('Enter');
|
||||
assert.equal(await wiki.locator('a').getAttribute('href'), 'new-guide');
|
||||
|
||||
const repeated = page.getByRole('cell', { name:'Row 9, column 2', exact:true });
|
||||
await clickTextAt(repeated.locator('a').nth(1), 4);
|
||||
await sourceCell().waitFor();
|
||||
assert.equal(await caretPrefix(), '**Prefix** [One](same.md) + [Sec**o');
|
||||
await page.keyboard.press('Shift+F10');
|
||||
await page.getByRole('menuitem', { name:'Edit link', exact:true }).click();
|
||||
assert.equal(await selected(), 'same.md');
|
||||
await page.keyboard.type('second.md');
|
||||
await page.keyboard.press('Enter');
|
||||
assert.equal(await repeated.locator('a').first().getAttribute('href'), 'same.md');
|
||||
assert.equal(await repeated.locator('a').nth(1).getAttribute('href'), 'second.md');
|
||||
assert.match(await documentText(), /\[Sec\*\*ond\*\*\]\(second.md "Title"\)/);
|
||||
assert.deepEqual(await page.evaluate(() => window.tabMenuTest.prompts), []);
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
console.log('PASS: ordinary link click reveals Markdown, exact spelling caret, keyboard entry, inline Edit link, URL selection, wiki aliases, repeated targets, formatted labels, title preservation, save, undo/redo, both themes, and narrow windows. Native WebView acceptance remains open.');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
await page.screenshot({ path:`${output}/failure.png` });
|
||||
console.log(await page.locator('.writer-cell-editor').allTextContents());
|
||||
console.log({errors, active:await page.evaluate(() => document.activeElement?.outerHTML.slice(0,300))});
|
||||
throw error;
|
||||
} finally { await browser.close(); }
|
||||
@@ -0,0 +1,30 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { documentLinks } from "../src/lib/editor/documentLinks.ts";
|
||||
import { tableLinkLabelPosition } from "../src/lib/editor/tableLinkSource.ts";
|
||||
|
||||
test("table link reveal retains the clicked character through Markdown label marks", () => {
|
||||
for (const [source, offset, prefix] of [
|
||||
["[Roadmap](docs/roadmap.md)", 5, "[Roadm"],
|
||||
['**Prefix** [One](same.md) + [Sec**ond**](same.md "Title")', 4, '**Prefix** [One](same.md) + [Sec**o'],
|
||||
["[A \\*star](note.md)", 3, "[A \\*"],
|
||||
["[Use `code`](note.md)", 5, "[Use `c"],
|
||||
["<https://example.org>", 8, "<https://"],
|
||||
] as const) {
|
||||
const link = documentLinks(source).at(-1)!;
|
||||
assert.equal(source.slice(0, tableLinkLabelPosition(source, link, offset)), prefix);
|
||||
}
|
||||
});
|
||||
|
||||
test("table wiki links retain literal label text, aliases, spaces, and escaped pipes", () => {
|
||||
for (const [source, offset, prefix] of [
|
||||
["[[guide\\|Guide]]", 3, "[[guide\\|Gui"],
|
||||
["[[guide\\|**Alias**]]", 2, "[[guide\\|**"],
|
||||
["[[ Guide ]]", 3, "[[ G"],
|
||||
["[[Guide\\|]]", 2, "[[Gu"],
|
||||
["[[guide\\|A\\|B]]", 2, "[[guide\\|A\\|"],
|
||||
] as const) {
|
||||
const link = documentLinks(source)[0];
|
||||
assert.equal(source.slice(0, tableLinkLabelPosition(source, link, offset)), prefix);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { test } from 'node:test';
|
||||
import { characterTheme, characterSyntax, SYNTAX_ROLES } from '../src/lib/theme/characterThemes.ts';
|
||||
|
||||
const rgb = (color: string) => color.slice(1).match(/../g)!.map(value => parseInt(value, 16) / 255);
|
||||
function luminance(color: string) {
|
||||
return rgb(color).map(value => value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4)
|
||||
.reduce((sum, value, index) => sum + value * [0.2126, 0.7152, 0.0722][index], 0);
|
||||
}
|
||||
function contrast(foreground: string, background: string) {
|
||||
const values = [luminance(foreground), luminance(background)].sort((a, b) => b - a);
|
||||
return (values[0] + 0.05) / (values[1] + 0.05);
|
||||
}
|
||||
|
||||
test('Harvest Moon text and syntax stay readable on editor, panel, and selected surfaces', () => {
|
||||
const palette = characterTheme('harvest-moon')!;
|
||||
const [background, elevated, active, , dim, text, strong, accent, selection] = palette.surfaces;
|
||||
for (const foreground of [dim, text, strong, accent, palette.secondary]) {
|
||||
for (const surface of [background, elevated, active, selection]) {
|
||||
assert(contrast(foreground, surface) >= 4.5, `${foreground} on ${surface} needs 4.5:1 contrast`);
|
||||
}
|
||||
}
|
||||
for (const [index, foreground] of palette.syntax.entries()) {
|
||||
for (const surface of [background, elevated, selection]) {
|
||||
assert(contrast(foreground, surface) >= 4.5, `${SYNTAX_ROLES[index]} on ${surface} needs 4.5:1 contrast`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('Harvest Moon uses the warm character colors for all palette roles', () => {
|
||||
const palette = characterTheme('harvest-moon')!;
|
||||
for (const color of [...palette.surfaces, palette.secondary, ...palette.syntax]) {
|
||||
assert.match(color, /^#[0-9a-f]{6}$/i);
|
||||
const [red, green, blue] = rgb(color);
|
||||
assert(red >= green && green >= blue, `${color} must follow the copper, amber, red, or cream palette`);
|
||||
}
|
||||
assert.equal(palette.mode, 'dark');
|
||||
assert.equal(Object.keys(characterSyntax('harvest-moon')).length, SYNTAX_ROLES.length);
|
||||
assert.deepEqual(characterSyntax('unknown'), {});
|
||||
});
|
||||
@@ -0,0 +1,145 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import { createRequire } from 'node:module';
|
||||
|
||||
const { chromium } = createRequire(import.meta.url)(process.env.PLAYWRIGHT_MODULE || 'playwright');
|
||||
const origin = process.env.SMOKE_URL || 'http://127.0.0.1:1420';
|
||||
const output = '.audit/theme-typography';
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const errors = [];
|
||||
const report = [];
|
||||
await mkdir(output, { recursive: true });
|
||||
try {
|
||||
const context = await browser.newContext({ viewport: { width: 1100, height: 780 } });
|
||||
await context.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: 'main' }, currentWebview: { label: 'main' } },
|
||||
transformCallback: () => 1, unregisterCallback: () => {},
|
||||
invoke: async (command, args = {}) => {
|
||||
if (command === 'plugins_snapshot') return { root: 'C:/font-smoke-plugins', plugins: [] };
|
||||
if (command === 'workspace_last_path') return 'C:\\font-smoke';
|
||||
if (command === 'workspace_open') return { root: 'C:\\font-smoke', name: 'font-smoke', watch_mode: 'native' };
|
||||
if (command === 'workspace_list') return [{ name: 'Typography.md', rel_path: 'Typography.md', kind: 'file' }];
|
||||
if (command === 'workspace_read') return '# 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';
|
||||
if (command === 'workspace_search') return [];
|
||||
if (command === 'plugin:event|listen') return args.handler;
|
||||
return null;
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
|
||||
});
|
||||
const main = await context.newPage();
|
||||
const settings = await context.newPage();
|
||||
for (const page of [main, settings]) page.on('pageerror', error => errors.push(error.message));
|
||||
await main.goto(origin);
|
||||
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(`${origin}/?settingsWindow=true`);
|
||||
await settings.getByRole('button', { name: 'Appearance', exact: true }).click();
|
||||
const sessions = new Map();
|
||||
async function rendered(page, selector) {
|
||||
await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))));
|
||||
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 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 });
|
||||
const picker = settings.locator('.picker').and(settings.getByRole('button', { name: 'Color theme', exact: true }));
|
||||
await picker.click();
|
||||
await settings.getByRole('menuitemradio', { 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(); });
|
||||
for (const page of [main, settings]) {
|
||||
await page.evaluate(font => {
|
||||
for (const role of ['ui', 'prose', 'heading']) document.documentElement.style.setProperty(`--rs-font-${role}`, `"${font}"`);
|
||||
}, oldFont);
|
||||
await page.screenshot({ path: `${output}/${theme}-before-${page === main ? 'document' : 'settings'}.png` });
|
||||
await page.evaluate(() => {
|
||||
for (const role of ['ui', 'prose', 'heading']) document.documentElement.style.removeProperty(`--rs-font-${role}`);
|
||||
});
|
||||
}
|
||||
const roles = {
|
||||
ui: await rendered(settings, '.picker[aria-label="Color theme"]'),
|
||||
prose: await rendered(main, '.cm-line:not(.writer-heading):not(.writer-blank)'),
|
||||
heading: await rendered(main, '.writer-h1'),
|
||||
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: `${output}/${theme}-after-settings.png` });
|
||||
await main.screenshot({ path: `${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: `${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`);
|
||||
await picker.scrollIntoViewIfNeeded(); await picker.focus(); await settings.keyboard.press('Enter');
|
||||
const current = settings.getByRole('menuitemradio', { name: label, exact: true });
|
||||
await current.waitFor();
|
||||
assert(await current.evaluate(node => node === document.activeElement));
|
||||
await settings.screenshot({ path: `${output}/${theme}-narrow-menu.png` });
|
||||
await settings.keyboard.press('Escape');
|
||||
assert(await picker.evaluate(node => node === document.activeElement));
|
||||
await settings.evaluate(async () => {
|
||||
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: 16 }, (_, index) => ({ owner: 'org.example.font-check', id: `settings-${index}`, title: `Plugin settings ${index + 1}`, surface: 'settings' })));
|
||||
});
|
||||
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: `${output}/${theme}-narrow-long-plugins.png` });
|
||||
await settings.evaluate(async () => {
|
||||
const { pluginTools } = await import(performance.getEntriesByType('resource').find(entry => new URL(entry.name).pathname === '/src/lib/plugins/external.ts').name); pluginTools.set([]);
|
||||
});
|
||||
const fallback = {};
|
||||
for (const [role, page, selector] of [['ui', settings, '.picker[aria-label="Color theme"]'], ['prose', main, '.cm-line:not(.writer-heading):not(.writer-blank)'], ['heading', main, '.writer-h1']]) {
|
||||
await page.evaluate(role => {
|
||||
const css = getComputedStyle(document.documentElement);
|
||||
const stack = css.getPropertyValue(`--rs-font-${role}`);
|
||||
document.documentElement.style.setProperty(`--rs-font-${role}`, stack.slice(stack.indexOf(',') + 1));
|
||||
}, role);
|
||||
fallback[role] = await rendered(page, selector);
|
||||
assert(fallback[role].rendered.length > 0);
|
||||
await page.evaluate(role => document.documentElement.style.removeProperty(`--rs-font-${role}`), role);
|
||||
}
|
||||
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(errors, []);
|
||||
await writeFile(`${output}/rendered-fonts.json`, JSON.stringify(report, null, 2));
|
||||
} finally { await browser.close(); }
|
||||
@@ -0,0 +1,137 @@
|
||||
import { createRequire } from 'node:module';
|
||||
import assert from 'node:assert/strict';
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || 'playwright');
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const context = await browser.newContext({ viewport: { width: 1280, height: 850 } });
|
||||
const page = await context.newPage();
|
||||
page.setDefaultTimeout(10000);
|
||||
const errors = [];
|
||||
page.on('pageerror', error => errors.push(error.message));
|
||||
await context.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
const root = 'C:\\navigation-check';
|
||||
const folders = new Set(['Untitled', 'Parent', 'Empty']);
|
||||
const files = new Map([['note.md', '# Note'], ['Parent/existing.md', '# Existing']]);
|
||||
const state = { folders, files, calls: [] };
|
||||
window.__NAVIGATION_CHECK__ = state;
|
||||
let sequence = 0;
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: 'main' }, currentWebview: { label: 'main' } },
|
||||
transformCallback: () => ++sequence, unregisterCallback: () => {},
|
||||
invoke: async (command, args = {}) => {
|
||||
state.calls.push({ command, args });
|
||||
if (command === 'plugins_snapshot') return { root: 'C:/plugins', plugins: [] };
|
||||
if (command === 'workspace_last_path') return state.noWorkspace ? null : root;
|
||||
if (command === 'workspace_open') return { root, name: 'navigation-check', watch_mode: 'native' };
|
||||
if (command === 'workspace_read') { if (!files.has(args.rel)) throw new Error('Missing file'); return files.get(args.rel); }
|
||||
if (command === 'workspace_write') { files.set(args.rel, args.contents); return; }
|
||||
if (command === 'workspace_list') {
|
||||
const prefix = args.rel ? args.rel + '/' : '';
|
||||
return [...[...folders].filter(path => path.startsWith(prefix) && !path.slice(prefix.length).includes('/')).map(path => ({ name: path.slice(prefix.length), rel_path: path, kind: 'folder' })),
|
||||
...[...files.keys()].filter(path => path.startsWith(prefix) && !path.slice(prefix.length).includes('/') && !path.startsWith('.runestone/')).map(path => ({ name: path.slice(prefix.length), rel_path: path, kind: 'file' }))];
|
||||
}
|
||||
if (command === 'workspace_create') { if (folders.has(args.rel) || files.has(args.rel)) throw new Error('Destination exists'); if (args.kind === 'folder') folders.add(args.rel); else files.set(args.rel, ''); return; }
|
||||
if (command === 'workspace_rename') {
|
||||
if (folders.has(args.to) || files.has(args.to)) throw new Error('Destination exists');
|
||||
if (folders.delete(args.from)) folders.add(args.to);
|
||||
else { files.set(args.to, files.get(args.from)); files.delete(args.from); }
|
||||
return;
|
||||
}
|
||||
if (command === 'plugin:event|listen') return ++sequence;
|
||||
if (command === 'plugin:window|is_maximized') return false;
|
||||
if (command === 'workspace_recent' || command === 'workspace_search') return [];
|
||||
return null;
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
|
||||
});
|
||||
const output = '.audit/todo-navigation';
|
||||
await mkdir(output, { recursive: true });
|
||||
const row = path => page.locator(`[data-tree-rel="${path}"]`);
|
||||
const input = () => page.locator('.tree input');
|
||||
const folderAction = () => page.getByRole('menuitem', { name: 'New folder', exact: true });
|
||||
async function checkRename(name) {
|
||||
await input().waitFor();
|
||||
await page.waitForFunction(() => document.activeElement?.matches('.tree input'));
|
||||
const state = await input().evaluate(node => ({ name: node.value, start: node.selectionStart, end: node.selectionEnd }));
|
||||
assert.deepEqual(state, { name, start: 0, end: name.length });
|
||||
assert.equal(await page.getByRole('dialog').count(), 0, 'New folder uses inline rename');
|
||||
}
|
||||
async function setMode(mode) {
|
||||
await page.evaluate(async mode => { const { saveAppearance } = await import('/src/lib/theme/appearance.ts'); saveAppearance({ theme: 'default', mode }); }, mode);
|
||||
}
|
||||
try {
|
||||
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:5194');
|
||||
await row('Untitled').waitFor();
|
||||
const welcome = page.locator('.welcome-actions');
|
||||
await welcome.waitFor();
|
||||
await welcome.getByRole('button', { name: 'Open browser', exact: true }).waitFor();
|
||||
assert.deepEqual(await welcome.locator('button').allTextContents().then(values => values.map(value => value.replace(/Ctrl [NOP]/g, '').trim())), ['New file', 'New note', 'Find file', 'Open folder', 'Open browser']);
|
||||
const firstRow = welcome.locator('.welcome-row').first();
|
||||
assert.equal(await firstRow.locator('button').count(), 3);
|
||||
const tops = await firstRow.locator('button').evaluateAll(nodes => nodes.map(node => node.getBoundingClientRect().top));
|
||||
assert.ok(tops.every(top => top === tops[0]), 'Wide layout has three actions in the first row');
|
||||
await welcome.getByRole('button', { name: /^New file/ }).focus();
|
||||
for (const name of ['New note', 'Find file', 'Open folder', 'Open browser']) {
|
||||
await page.keyboard.press('Tab');
|
||||
assert.ok((await page.evaluate(() => document.activeElement.textContent)).includes(name), `Tab reaches ${name} in order`);
|
||||
}
|
||||
for (const mode of ['dark', 'light']) {
|
||||
await setMode(mode);
|
||||
await welcome.getByRole('button', { name: /^New file/ }).focus();
|
||||
await page.screenshot({ path: `${output}/splash-${mode}.png` });
|
||||
await page.setViewportSize({ width: 850, height: 650 });
|
||||
await page.screenshot({ path: `${output}/splash-${mode}-narrow.png` });
|
||||
assert.ok(await welcome.locator('button').evaluateAll(nodes => nodes.every(node => { const rect = node.getBoundingClientRect(); return rect.left >= 0 && rect.right <= innerWidth; })), 'Narrow splash controls fit');
|
||||
await page.setViewportSize({ width: 1280, height: 850 });
|
||||
}
|
||||
await page.getByRole('navigation', { name: 'Workspace files' }).click({ button: 'right', position: { x: 80, y: 320 } });
|
||||
await folderAction().focus();
|
||||
await page.keyboard.press('Enter');
|
||||
await checkRename('untitled 2');
|
||||
await input().fill('Created folder');
|
||||
await input().press('Enter');
|
||||
await row('Created folder').waitFor();
|
||||
await row('Parent').click();
|
||||
await row('Parent').click();
|
||||
assert.equal(await row('Parent').getAttribute('aria-expanded'), 'false');
|
||||
await row('Parent').click({ button: 'right' });
|
||||
await folderAction().click();
|
||||
await checkRename('untitled');
|
||||
assert.equal(await row('Parent').getAttribute('aria-expanded'), 'true', 'Cached collapsed parent opens for rename');
|
||||
await input().press('Escape');
|
||||
await row('Parent/untitled').waitFor();
|
||||
for (const mode of ['dark', 'light']) {
|
||||
await setMode(mode);
|
||||
await row('Parent').click({ button: 'right' });
|
||||
await folderAction().click();
|
||||
const expected = mode === 'dark' ? 'untitled 2' : 'untitled 3';
|
||||
await checkRename(expected);
|
||||
await page.screenshot({ path: `${output}/new-folder-${mode}.png` });
|
||||
await page.setViewportSize({ width: 850, height: 650 });
|
||||
await page.screenshot({ path: `${output}/new-folder-${mode}-narrow.png` });
|
||||
await input().press('Escape');
|
||||
await page.setViewportSize({ width: 1280, height: 850 });
|
||||
}
|
||||
await row('Empty').click({ button: 'right' });
|
||||
await folderAction().click();
|
||||
await checkRename('untitled');
|
||||
await input().fill('First folder');
|
||||
await input().press('Enter');
|
||||
await row('Empty/First folder').waitFor();
|
||||
assert.equal(await page.evaluate(() => window.__NAVIGATION_CHECK__.folders.has('Empty/First folder')), true);
|
||||
const emptyPage = await context.newPage();
|
||||
await emptyPage.addInitScript(() => { window.__NAVIGATION_CHECK__.noWorkspace = true; });
|
||||
await emptyPage.goto(process.env.SMOKE_URL || 'http://127.0.0.1:5194');
|
||||
await emptyPage.locator('.welcome-actions').waitFor();
|
||||
await emptyPage.locator('.welcome-actions').getByRole('button', { name: 'Open browser', exact: true }).waitFor();
|
||||
assert.deepEqual(await emptyPage.locator('.welcome-actions button').allTextContents().then(values => values.map(value => value.replace(/Ctrl O/g, '').trim())), ['Open folder', 'Open browser']);
|
||||
await emptyPage.screenshot({ path: `${output}/splash-no-workspace.png` });
|
||||
await emptyPage.close();
|
||||
assert.deepEqual(errors, []);
|
||||
await writeFile(`${output}/checks.json`, JSON.stringify({ passed: true, checks: ['Case-insensitive root name collision', 'Selected inline name and no dialog', 'Enter saves rename', 'Escape retains created folder', 'Collapsed cached parent opens', 'Empty parent', 'Repeated unique names', 'Splash order and three-column maximum', 'Keyboard tab order', 'No workspace actions', 'Dark/light wide/narrow screenshots'], errors }, null, 2));
|
||||
console.log(`Navigation checks passed. Evidence: ${output}`);
|
||||
} finally { await browser.close(); }
|
||||
@@ -0,0 +1,115 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { createRequire } from 'node:module';
|
||||
import { mkdir } from 'node:fs/promises';
|
||||
const { chromium } = createRequire(import.meta.url)(process.env.PLAYWRIGHT_MODULE || '../browser-runtime/node_modules/playwright');
|
||||
const browser = await chromium.launch({ headless: true, executablePath: process.env.CHROME_PATH || 'C:/Program Files/Google/Chrome/Application/chrome.exe' });
|
||||
const output = '.audit/todo-ui';
|
||||
await mkdir(output, { recursive: true });
|
||||
try {
|
||||
for (const theme of ['light', 'dark']) {
|
||||
const page = await browser.newPage({ viewport: { width: 1100, height: 780 } });
|
||||
const errors = [];
|
||||
page.on('pageerror', error => errors.push(error.message));
|
||||
await page.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: 'main' }, currentWebview: { label: 'main' } }, transformCallback: () => 1, unregisterCallback() {},
|
||||
invoke: async (command, args = {}) => {
|
||||
if (command === 'workspace_last_path') return 'C:/todo-ui';
|
||||
if (command === 'workspace_open') return { root: 'C:/todo-ui', name: 'todo-ui', watch_mode: 'native' };
|
||||
if (command === 'workspace_list') return [{ name: 'sample.md', rel_path: 'sample.md', kind: 'file' }];
|
||||
if (command === 'workspace_read') return '# Selection sample\n\nThe same text color applies to each editor.\n';
|
||||
if (command === 'plugins_snapshot') return { root: 'C:/plugins', plugins: [] };
|
||||
if (command === 'workspace_search') return [];
|
||||
if (command === 'browser_request') {
|
||||
if (args.command === 'frameAck') window.blankAcks = (window.blankAcks || 0) + 1;
|
||||
return window.browserSnapshot;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener() {} };
|
||||
});
|
||||
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:1420');
|
||||
await page.getByText('todo-ui', { 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');
|
||||
await target.hover();
|
||||
const tooltip = page.locator('.rs-tooltip:popover-open');
|
||||
await tooltip.waitFor();
|
||||
assert.equal(await target.getAttribute('title'), null);
|
||||
assert.equal(await tooltip.evaluate(node => getComputedStyle(node).borderRadius), '5px');
|
||||
await page.screenshot({ path: `${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: `${output}/${theme}-narrow-tooltip.png` });
|
||||
await page.evaluate(() => { window.disposeTip(); document.getElementById('tooltip-test').remove(); });
|
||||
await page.setViewportSize({ width: 1100, height: 780 });
|
||||
await page.keyboard.press('Control+p');
|
||||
await page.getByRole('textbox', { name: 'Find a file' }).fill('sample.md');
|
||||
await page.getByRole('textbox', { name: 'Find a file' }).press('Enter');
|
||||
const writer = page.getByRole('textbox', { name: 'Writing editor', exact: true });
|
||||
await writer.waitFor(); await writer.click(); await page.keyboard.press('Control+a');
|
||||
const colors = await writer.evaluate(node => {
|
||||
const probe = document.createElement('span'); probe.style.backgroundColor = 'var(--rs-selection)'; node.append(probe);
|
||||
const expected = getComputedStyle(probe).backgroundColor; probe.remove();
|
||||
return { expected, native: getComputedStyle(node, '::selection').backgroundColor,
|
||||
layer: getComputedStyle(document.querySelector('.cm-selectionBackground')).backgroundColor };
|
||||
});
|
||||
assert.equal(colors.native, colors.expected); assert.equal(colors.layer, colors.expected);
|
||||
await page.screenshot({ path: `${output}/${theme}-writer-selection.png` });
|
||||
await page.getByRole('group', { name: 'Document view', exact: true }).hover();
|
||||
await page.getByRole('button', { name: 'Read', exact: true }).click();
|
||||
const reader = page.locator('.reading');
|
||||
await reader.waitFor();
|
||||
assert.equal(await reader.evaluate(node => getComputedStyle(node, '::selection').backgroundColor), colors.expected);
|
||||
await page.evaluate(async () => {
|
||||
const { mount } = await import('/node_modules/svelte/src/index-client.js');
|
||||
const { default: Browser } = await import('/src/lib/browser/Browser.svelte');
|
||||
const client = await import('/src/lib/browser/client.ts');
|
||||
const container = document.createElement('div'); container.id = 'browser-test';
|
||||
Object.assign(container.style, { position: 'fixed', inset: '50px 10px 20px', zIndex: '2000', background: 'linear-gradient(120deg,#945975,#395c72)' });
|
||||
document.body.append(container);
|
||||
window.browserSnapshot = { profiles: [{ id: 'user', name: 'User' }], tabs: [{ id: 'blank', profileId: 'user', url: 'about:blank', title: '', loading: false }], bookmarks: [], settings: {} };
|
||||
client.state.set(window.browserSnapshot);
|
||||
mount(Browser, { target: container, props: { initial: { tabId: 'blank' }, onSessionChange() {}, async newTab() {} } });
|
||||
window.browserClient = client;
|
||||
});
|
||||
const surface = page.locator('#browser-test .surface');
|
||||
await page.locator('#browser-test [data-browser-state="ready"]').waitFor();
|
||||
await page.evaluate(() => window.browserClient.frames.get('blank')({ tabId: 'blank', frameId: 1, width: 10, height: 10, mime: 'image/png', data: 'AA==' }));
|
||||
assert.equal(await surface.evaluate(node => getComputedStyle(node).backgroundColor), 'rgba(0, 0, 0, 0)');
|
||||
assert.equal(await surface.locator('img').count(), 0);
|
||||
assert.equal(await page.evaluate(() => window.blankAcks), 1);
|
||||
await page.screenshot({ path: `${output}/${theme}-blank-browser.png` });
|
||||
await page.evaluate(() => {
|
||||
window.browserSnapshot.tabs[0].url = 'https://example.com/minimal';
|
||||
window.browserClient.state.set({ ...window.browserSnapshot });
|
||||
const canvas = document.createElement('canvas'); canvas.width = 10; canvas.height = 10;
|
||||
const ctx = canvas.getContext('2d'); ctx.fillStyle = 'white'; ctx.fillRect(0, 0, 10, 10);
|
||||
window.browserClient.frames.get('blank')({ tabId: 'blank', frameId: 2, width: 10, height: 10, mime: 'image/png', data: canvas.toDataURL().split(',')[1] });
|
||||
});
|
||||
await surface.locator('img').waitFor();
|
||||
assert.notEqual(await surface.evaluate(node => getComputedStyle(node).backgroundColor), 'rgba(0, 0, 0, 0)');
|
||||
assert.deepEqual(errors, []);
|
||||
await page.close();
|
||||
}
|
||||
console.log('To do UI smoke passed: tooltips, selection, blank browser, light/dark/narrow.');
|
||||
} finally { await browser.close(); }
|
||||
@@ -62,8 +62,6 @@ try {
|
||||
window.__MONACO__ = (await import("/src/lib/editor/monacoEnv.ts")).monaco;
|
||||
window.__MONACO__.editor.getEditors().find(e => e.getDomNode()?.isConnected).setValue("My pending edit");
|
||||
});
|
||||
await page.getByRole("button", { name: "Terminal", exact: true }).click();
|
||||
await page.waitForFunction(() => window.__TEST__.calls.some(c => c.command === "pty_open"));
|
||||
const trigger = page.getByRole("button", { name: "Open folder", exact: true });
|
||||
const menu = page.getByRole("dialog", { name: "Workspaces", exact: true });
|
||||
await trigger.click();
|
||||
@@ -104,7 +102,6 @@ try {
|
||||
assert.deepEqual(await page.evaluate(() => window.__TEST__.windows), ["D:\\Writing\\Notes", "D:\\Other", "D:\\Projects\\Fresh notes"]);
|
||||
assert.equal(await page.evaluate(() => window.__TEST__.calls.filter(c => c.command === "workspace_open").length), opened);
|
||||
assert.equal(await page.evaluate(() => window.__TEST__.calls.filter(c => c.command === "plugin:dialog|message").length), 0);
|
||||
assert.equal(await page.evaluate(() => window.__TEST__.calls.filter(c => c.command === "pty_close").length), 0);
|
||||
assert.equal(await page.evaluate(() => window.__MONACO__.editor.getEditors().find(e => e.getDomNode()?.isConnected)?.getValue()), "My pending edit");
|
||||
assert(await page.getByRole("tab", { name: /note\.txt/ }).isVisible());
|
||||
await trigger.click();
|
||||
|
||||
Reference in New Issue
Block a user