Update editor, workspace, Git services, appearance, and project guides
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
// 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.
|
||||
// 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 assert from "node:assert/strict";
|
||||
|
||||
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 page = browser.contexts()[0].pages()[0];
|
||||
page.setDefaultTimeout(15000);
|
||||
try {
|
||||
await page.goto(process.env.SPELLING_APP_URL || "http://localhost:1420");
|
||||
const data = await page.evaluate(async () => {
|
||||
const { appDataDir } = await import("/node_modules/@tauri-apps/api/path.js");
|
||||
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");
|
||||
await mkdir(workspace, { recursive: true });
|
||||
await writeFile(resolve(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 });
|
||||
}, workspace);
|
||||
await page.reload();
|
||||
await page.locator('[data-tree-rel="Spelling.md"]').click();
|
||||
const editor = page.locator(".cm-content");
|
||||
await editor.waitFor();
|
||||
const line = page.getByText("I recieved a letter.", { exact: true });
|
||||
const rect = await line.boundingBox();
|
||||
await line.click();
|
||||
const before = await editor.innerText();
|
||||
await page.keyboard.press("End");
|
||||
await page.keyboard.type(" TEST");
|
||||
assert.notEqual(await editor.innerText(), before);
|
||||
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 menu.getByRole("menuitem", { name: "Undo Ctrl+Z", exact: true }).click();
|
||||
await page.waitForFunction(expected => document.querySelector(".cm-content")?.innerText === expected, before);
|
||||
console.log("PASS: real WebView2 command dispatch through the shared menu restores the editor text.");
|
||||
|
||||
await page.mouse.click(rect.x + 42, rect.y + rect.height / 2, { button: "right" });
|
||||
await menu.waitFor();
|
||||
const suggestion = menu.getByRole("menuitem", { name: "received", exact: true });
|
||||
if (await suggestion.count()) {
|
||||
await suggestion.click();
|
||||
await page.waitForFunction(() => document.querySelector(".cm-content")?.innerText.includes("I received a letter."));
|
||||
await page.keyboard.press("Control+z");
|
||||
await page.waitForFunction(() => document.querySelector(".cm-content")?.innerText.includes("I recieved a letter."));
|
||||
console.log("PASS: native spelling correction and editor undo.");
|
||||
} else {
|
||||
await page.keyboard.press("Escape");
|
||||
assert.notEqual(process.env.REQUIRE_NATIVE_SUGGESTIONS, "1", "The test WebView2 profile supplied no spelling suggestions");
|
||||
console.log("SKIP: native spelling correction. This WebView2 profile supplied no suggestions. Desktop acceptance is still required.");
|
||||
}
|
||||
} finally {
|
||||
await page.keyboard.press("Escape").catch(() => {});
|
||||
await browser.close();
|
||||
}
|
||||
Reference in New Issue
Block a user