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,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