Move the smoke tests onto the shared harness
Each smoke test now uses tests/smoke/_harness/ for Playwright, the Tauri IPC mock, the in-memory workspace, and output folders, instead of its own copy. The tests keep their interactions and assertions. Mock handlers that the app never calls are gone. - Split the four mixed regression scripts into 18 feature tests. - Update tests that broke when the app changed on purpose. Each update cites the app source that shows the new behavior. - Mark two real app defects with @known-issue: the settings window controls are 1px shorter than the main window controls, and plugin tabs cannot be reordered by dragging without a workspace. - Merge three palette unit tests into one table-driven test. - The native tests load Playwright through the harness and read NATIVE_CDP_URL, with their old variable names as fallbacks. - A failed smoke test saves a screenshot and prints the console errors. - The runner runs failed tests once more, alone, and reports a test that then passes as flaky. Result: 89 passed, 1 flaky, 2 known issues, 0 failed. Before, 45 of 78 passed.
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
import { createRequire } from 'node:module';
|
||||
// Native built-in browser: page rendering at device pixel ratio, the page context menu, editing commands, and session checks.
|
||||
// Start a debug app with an isolated identifier (com.runestone.browser-test or com.runestone.spelling-test) and remote debugging on port 9224:
|
||||
// set WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9224
|
||||
// pnpm tauri dev --config "{\"identifier\":\"com.runestone.browser-test\"}"
|
||||
// The browser runtime needs `npm ci --prefix browser-runtime`. The test loads https://example.com/.
|
||||
// Run `node tests/native/browser.native.mjs`. NATIVE_CDP_URL (or the older BROWSER_NATIVE_CDP) overrides http://127.0.0.1:9224.
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { writeFile } from 'node:fs/promises';
|
||||
const require = createRequire(path.resolve('browser-runtime/package.json'));
|
||||
const { chromium } = require('playwright');
|
||||
const browser = await chromium.connectOverCDP(process.env.BROWSER_NATIVE_CDP || 'http://127.0.0.1:9224');
|
||||
import { outputDir, playwright } from '../smoke/_harness/index.mjs';
|
||||
const { chromium } = playwright();
|
||||
const browser = await chromium.connectOverCDP(process.env.NATIVE_CDP_URL || process.env.BROWSER_NATIVE_CDP || 'http://127.0.0.1:9224');
|
||||
const output = await outputDir('native/browser');
|
||||
const page = browser.contexts()[0].pages()[0];
|
||||
const raw = (command, args = {}) => page.evaluate(({ command, args }) => window.__TAURI_INTERNALS__.invoke(command, args), { command, args });
|
||||
const profile = await raw('plugins_snapshot');
|
||||
@@ -46,8 +52,8 @@ try {
|
||||
await address.fill('https://example.com/');
|
||||
await assert.rejects(raw('browser_request', { command: 'edit', args: { tabId, action: 'copy' }, session: 'invalid-session' }), /session/i);
|
||||
await assert.rejects(request('contextAction', { tabId, token: 'stale-menu', action: 'saveImage' }), /no longer available/);
|
||||
await page.screenshot({ path: 'output/browser-native-acceptance.png' });
|
||||
await writeFile('output/browser-native-acceptance.json', JSON.stringify({ dimensions, passed: [
|
||||
await page.screenshot({ path: path.join(output, 'acceptance.png') });
|
||||
await writeFile(path.join(output, 'acceptance.json'), JSON.stringify({ dimensions, passed: [
|
||||
'Native Tauri-to-Electron page rendering and high-DPI frame delivery', 'Native page context event opens the shared host menu',
|
||||
'Native editing commands copy real webpage text', 'Session and stale-menu checks reject invalid requests',
|
||||
] }, null, 2));
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
// Use only an isolated com.runestone.spelling-test debug window.
|
||||
import { createRequire } from 'node:module';
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
// Native editing menus in inputs, textareas, and dialogs: unsupported WebView2 commands stay hidden, Undo and spelling work, and focus returns, in both themes.
|
||||
// Start a debug app with the isolated identifier com.runestone.spelling-test and remote debugging on port 9237:
|
||||
// set WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9237
|
||||
// pnpm tauri dev --config "{\"identifier\":\"com.runestone.spelling-test\"}"
|
||||
// Run `node tests/native/menuScope.native.mjs`. NATIVE_CDP_URL (or the older SPELLING_CDP_URL) overrides http://127.0.0.1:9237.
|
||||
import { writeFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
const { chromium } = createRequire(import.meta.url)(process.env.PLAYWRIGHT_MODULE || 'playwright');
|
||||
const browser = await chromium.connectOverCDP(process.env.SPELLING_CDP_URL || 'http://127.0.0.1:9237');
|
||||
import { outputDir, playwright } from '../smoke/_harness/index.mjs';
|
||||
const { chromium } = playwright();
|
||||
const browser = await chromium.connectOverCDP(process.env.NATIVE_CDP_URL || process.env.SPELLING_CDP_URL || 'http://127.0.0.1:9237');
|
||||
const page = browser.contexts()[0].pages()[0];
|
||||
page.setDefaultTimeout(15000);
|
||||
const captures = [];
|
||||
@@ -18,7 +23,8 @@ try {
|
||||
await listen('spelling-menu', ({ payload }) => window.nativeMenuPayload = payload);
|
||||
await (await import('/node_modules/@tauri-apps/api/core.js')).invoke('spelling_menu_install');
|
||||
});
|
||||
await mkdir('output/todo-menus', { recursive: true });
|
||||
const output = await outputDir('native/menuScope');
|
||||
const capturesFile = path.join(output, 'native-filtered-items.json');
|
||||
const menu = page.getByRole('menu', { name: 'Spelling actions', exact: true });
|
||||
for (const mode of ['dark', 'light']) {
|
||||
await page.evaluate(async mode => { const { saveAppearance } = await import('/src/lib/theme/appearance.ts'); saveAppearance({ theme: 'default', mode }); }, mode);
|
||||
@@ -39,7 +45,7 @@ try {
|
||||
await menu.waitFor();
|
||||
const payload = await page.evaluate(() => window.nativeMenuPayload);
|
||||
captures.push({ mode, kind, value: await field.inputValue(), payload });
|
||||
await writeFile('output/todo-menus/native-filtered-items.json', JSON.stringify(captures, null, 2));
|
||||
await writeFile(capturesFile, JSON.stringify(captures, null, 2));
|
||||
const flatten = items => items.flatMap(item => [item, ...flatten(item.children)]);
|
||||
const entries = flatten(payload.items);
|
||||
assert.ok(entries.every(item => item.kind === 3 || !['share', 'writingDirection', 'voiceTyping', 'other'].includes(item.name)));
|
||||
@@ -48,7 +54,7 @@ try {
|
||||
assert.ok(entries.some(item => item.name === 'copy'));
|
||||
assert.equal(await menu.getByRole('menuitem', { name: /More tools|Writing direction|Voice typing|Share/ }).count(), 0);
|
||||
assert.equal(await menu.evaluate(node => getComputedStyle(node).borderColor), 'rgba(0, 0, 0, 0)');
|
||||
if (kind === 'textarea') await page.screenshot({ path: `output/todo-menus/native-${mode}.png` });
|
||||
if (kind === 'textarea') await page.screenshot({ path: path.join(output, `native-${mode}.png`) });
|
||||
await menu.getByRole('menuitem', { name: 'Undo Ctrl+Z', exact: true }).click();
|
||||
await page.waitForFunction(() => document.getElementById('native-menu-field').value === 'I recieved a letter.').catch(async error => { console.error('Undo result', await field.inputValue()); throw error; });
|
||||
await field.click({ button: 'right', position: { x: 48, y: kind === 'input' ? 50 : 22 } });
|
||||
@@ -62,7 +68,7 @@ try {
|
||||
assert.equal(await field.evaluate(node => document.activeElement === node), true);
|
||||
}
|
||||
}
|
||||
await writeFile('output/todo-menus/native-filtered-items.json', JSON.stringify(captures, null, 2));
|
||||
await writeFile(capturesFile, JSON.stringify(captures, null, 2));
|
||||
console.log('PASS: real WebView2 menus omit unsupported commands, retain editing and spelling, execute native Undo, correct spelling with undo, and restore focus in fields and dialogs in both themes.');
|
||||
} finally {
|
||||
await page.evaluate(() => { document.getElementById('native-menu-field')?.remove(); document.getElementById('native-menu-dialog')?.remove(); }).catch(() => {});
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
// Use a debug app with TAURI_CONFIG identifier com.runestone.spelling-test,
|
||||
// a hidden window, and a separate WEBVIEW2_USER_DATA_FOLDER outside Vite's watch paths.
|
||||
// Set WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9224 before launch.
|
||||
// Native spelling menu in Writer, inputs, textareas, and dialogs: WebView2 Undo, spelling corrections, and editor undo.
|
||||
// Start a debug app with the isolated identifier com.runestone.spelling-test, a hidden window, a separate
|
||||
// WEBVIEW2_USER_DATA_FOLDER outside Vite's watch paths, and remote debugging on port 9224:
|
||||
// set WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9224
|
||||
// pnpm tauri dev --config "{\"identifier\":\"com.runestone.spelling-test\"}"
|
||||
// Run `node tests/native/spelling.native.mjs`. NATIVE_CDP_URL (or the older SPELLING_CDP_URL) overrides http://127.0.0.1:9224.
|
||||
// SPELLING_APP_URL overrides http://localhost:1420. SPELLING_WORKSPACE overrides the workspace folder in output/smoke/native/spelling/.
|
||||
// The normal app identifier is rejected before this test writes any workspace files.
|
||||
import { createRequire } from "node:module";
|
||||
import { mkdir, writeFile } from "node:fs/promises";
|
||||
import { resolve } from "node:path";
|
||||
import path from "node:path";
|
||||
import assert from "node:assert/strict";
|
||||
import { outputDir, playwright } from "../smoke/_harness/index.mjs";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.connectOverCDP(process.env.SPELLING_CDP_URL || "http://127.0.0.1:9224");
|
||||
const { chromium } = playwright();
|
||||
const browser = await chromium.connectOverCDP(process.env.NATIVE_CDP_URL || process.env.SPELLING_CDP_URL || "http://127.0.0.1:9224");
|
||||
const page = browser.contexts()[0].pages()[0];
|
||||
page.setDefaultTimeout(15000);
|
||||
try {
|
||||
@@ -19,9 +22,10 @@ try {
|
||||
return appDataDir();
|
||||
});
|
||||
assert.match(data, /[\\/]com\.runestone\.spelling-test[\\/]?$/, "Use the isolated spelling-test app identifier");
|
||||
const workspace = resolve(process.env.SPELLING_WORKSPACE || ".audit/spelling-workspace");
|
||||
const output = await outputDir("native/spelling");
|
||||
const workspace = path.resolve(process.env.SPELLING_WORKSPACE || path.join(output, "workspace"));
|
||||
await mkdir(workspace, { recursive: true });
|
||||
await writeFile(resolve(workspace, "Spelling.md"), "# Spelling\n\nI recieved a letter.\n");
|
||||
await writeFile(path.join(workspace, "Spelling.md"), "# Spelling\n\nI recieved a letter.\n");
|
||||
await page.evaluate(async path => {
|
||||
const { invoke } = await import("/node_modules/@tauri-apps/api/core.js");
|
||||
await invoke("workspace_open", { path });
|
||||
@@ -41,8 +45,7 @@ try {
|
||||
await page.mouse.click(rect.x + 42, rect.y + rect.height / 2, { button: "right" });
|
||||
const menu = page.getByRole("menu", { name: "Spelling actions", exact: true });
|
||||
await menu.waitFor();
|
||||
await mkdir(".audit", { recursive: true });
|
||||
await page.screenshot({ path: ".audit/spelling-native.png" });
|
||||
await page.screenshot({ path: path.join(output, "spelling-menu.png") });
|
||||
const undo = menu.getByRole("menuitem", { name: "Undo Ctrl+Z", exact: true });
|
||||
assert.equal(await undo.isEnabled(), true, "The native Undo command is enabled after typing");
|
||||
await undo.click();
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import {createRequire} from 'node:module';
|
||||
// Native windows: an empty-tab transfer opens a window that acknowledges the saved tab, and the settings window's theme export rejects invalid JSON.
|
||||
// Start a debug app with the isolated identifier com.runestone.spelling-test, a workspace open, and remote debugging on port 9224:
|
||||
// set WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9224
|
||||
// pnpm tauri dev --config "{\"identifier\":\"com.runestone.spelling-test\"}"
|
||||
// Run `node tests/native/tabTransferAndThemeExport.native.mjs`. NATIVE_CDP_URL (or the older SPELLING_CDP_URL) overrides http://127.0.0.1:9224.
|
||||
import assert from 'node:assert/strict';
|
||||
const {chromium}=createRequire(import.meta.url)(process.env.PLAYWRIGHT_MODULE || 'playwright');
|
||||
const browser=await chromium.connectOverCDP(process.env.SPELLING_CDP_URL || 'http://127.0.0.1:9224');
|
||||
import { playwright } from '../smoke/_harness/index.mjs';
|
||||
const {chromium}=playwright();
|
||||
const browser=await chromium.connectOverCDP(process.env.NATIVE_CDP_URL || process.env.SPELLING_CDP_URL || 'http://127.0.0.1:9224');
|
||||
const context=browser.contexts()[0];
|
||||
const page=context.pages().find(page => new URL(page.url()).pathname === '/' && !new URL(page.url()).search);
|
||||
assert.ok(page, 'The isolated main window must be open.');
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
import { createRequire } from 'node:module';
|
||||
// Native tree and windows: rename undo keeps folders expanded, Open in new window moves a tab without changing the saved layout,
|
||||
// 50 MiB of JSON passes through workspace IPC, and a large background image survives a reload.
|
||||
// Start a debug app with the isolated identifier com.runestone.pass3-test and remote debugging on port 9236:
|
||||
// set WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9236
|
||||
// pnpm tauri dev --config "{\"identifier\":\"com.runestone.pass3-test\"}"
|
||||
// Run `node tests/native/treeRename.native.mjs`. NATIVE_CDP_URL (or the older NAVIGATION_NATIVE_CDP) overrides http://127.0.0.1:9236.
|
||||
// The test opens a workspace in the system temporary folder.
|
||||
import assert from 'node:assert/strict';
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import { resolve, join } from 'node:path';
|
||||
import { join } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { outputDir, playwright } from '../smoke/_harness/index.mjs';
|
||||
|
||||
const { chromium } = createRequire(import.meta.url)(process.env.PLAYWRIGHT_MODULE || 'playwright');
|
||||
const browser = await chromium.connectOverCDP(process.env.NAVIGATION_NATIVE_CDP || 'http://127.0.0.1:9236');
|
||||
const { chromium } = playwright();
|
||||
const browser = await chromium.connectOverCDP(process.env.NATIVE_CDP_URL || process.env.NAVIGATION_NATIVE_CDP || 'http://127.0.0.1:9236');
|
||||
const context = browser.contexts()[0];
|
||||
const page = context.pages().find(page => new URL(page.url()).pathname === '/' && !new URL(page.url()).search);
|
||||
assert.ok(page, 'The isolated main window must be open.');
|
||||
page.setDefaultTimeout(20000);
|
||||
const output = resolve('output/host-navigation-pass3-native');
|
||||
const output = await outputDir('native/treeRename');
|
||||
// Settings and reload pages use the app's own dev server, not a fixed port.
|
||||
const origin = new URL(page.url()).origin;
|
||||
const workspace = join(tmpdir(), 'runestone-pass3-native-workspace');
|
||||
const results = {};
|
||||
let detached;
|
||||
@@ -18,7 +27,6 @@ try {
|
||||
const identity = await page.evaluate(async () => (await import('/node_modules/@tauri-apps/api/path.js')).appDataDir());
|
||||
assert.match(identity, /[\\/]com\.runestone\.pass3-test[\\/]?$/);
|
||||
results.identity = identity;
|
||||
await mkdir(output, { recursive: true });
|
||||
await mkdir(join(workspace, 'folder', 'nested'), { recursive: true });
|
||||
await mkdir(join(workspace, 'other'), { recursive: true });
|
||||
await writeFile(join(workspace, 'folder', 'nested', 'note.md'), '# Native note\n\nText for transfer.\n');
|
||||
@@ -75,17 +83,18 @@ try {
|
||||
return { bytes, jsonLength: contents.length, matches: read === contents, writeMs: Math.round(written - start), readMs: Math.round(performance.now() - written) };
|
||||
});
|
||||
assert.equal(results.imageJsonIpc.matches, true);
|
||||
await page.goto('http://127.0.0.1:5186/?settingsWindow=true');
|
||||
await page.goto(`${origin}/?settingsWindow=true`);
|
||||
await page.getByRole('button', { name: 'Appearance', exact: true }).click();
|
||||
const pixel = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+jM1sAAAAASUVORK5CYII=', 'base64');
|
||||
const largeImage = Buffer.concat([pixel, Buffer.alloc(1_900_000 - pixel.length)]);
|
||||
await page.getByLabel('Background image file', { exact: true }).setInputFiles({ name: 'native-large.png', mimeType: 'image/png', buffer: largeImage });
|
||||
await page.waitForFunction(() => !!JSON.parse(localStorage.getItem('runestone.appearance'))?.newTabBackground?.imageId);
|
||||
await page.goto('http://127.0.0.1:5186/');
|
||||
await page.goto(`${origin}/`);
|
||||
// The image is on the work area layer behind the empty tab (src/lib/layout/Workbench.svelte:1258, :1543-1549).
|
||||
await page.locator('.empty').waitFor();
|
||||
await page.waitForFunction(() => getComputedStyle(document.querySelector('.empty')).backgroundImage.includes('blob:'));
|
||||
await page.waitForFunction(() => getComputedStyle(document.querySelector('.workarea-background')).backgroundImage.includes('blob:'));
|
||||
await page.reload(); await page.locator('.empty').waitFor();
|
||||
await page.waitForFunction(() => getComputedStyle(document.querySelector('.empty')).backgroundImage.includes('blob:'));
|
||||
await page.waitForFunction(() => getComputedStyle(document.querySelector('.workarea-background')).backgroundImage.includes('blob:'));
|
||||
results.largeBackground = { bytes: largeImage.length, renderedAfterReload: true };
|
||||
await page.screenshot({ path: join(output, 'large-background.png') });
|
||||
await writeFile(join(output, 'results.json'), JSON.stringify(results, null, 2));
|
||||
|
||||
Reference in New Issue
Block a user