quit nav: File→Quit always exits to the project overview, never history.back()

Quit used to mimic the Back button (history.back() whenever a referrer
existed), but every in-app entry and every tool switch is a hard
location.assign that pushes a history entry — so after schematic ⇄ pcb
switches, one step back is another editor, not the page the user left from.
Quit now navigates to the project overview explicitly (projectPath; "/" for
lib editors), which also covers deep links uniformly.

New VITE_QUIT_ORIGIN ("" ⇒ same-origin) lets the backed editor deployment
exit to the management app's project page instead of the standalone's own;
build-editor.mjs sets it (override with --app-origin).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Istvan Matejcsok 2026-07-16 14:25:10 +02:00
commit 8a20f69c5e
2 changed files with 32 additions and 33 deletions

View file

@ -2,14 +2,15 @@ import { test, expect, type Page } from '@playwright/test';
import { clickMenuBarItem, clickMenuItemByText } from '../e2e/utils/element-tracker';
/**
* File Quit e2e: quitting an editor must leave it, like the browser Back
* button return to wherever the user navigated in from (the project page),
* falling back to the project page on a deep link with no same-origin history.
* File Quit e2e: quitting an editor must leave it for the project overview,
* however the editor was entered (project-page link or deep link).
*
* The wx wasm port notifies the page when the app's top window is destroyed
* (window.wxAppTopWindowClosed, wxwidgets src/wasm/toplevel.cpp); WasmTool maps
* that to history.back() / location.assign(projectPath). A quit vetoed by the
* unsaved-changes prompt never destroys the frame, so it never navigates.
* that to location.assign(projectPath) deliberately NOT history.back(),
* which strands the user in the previous editor after a tool switch (see
* quit-after-tool-switch.spec.ts). A quit vetoed by the unsaved-changes prompt
* never destroys the frame, so it never navigates.
*
* URL-only assertions no screenshots.
*/
@ -70,11 +71,11 @@ test.describe('web app — File → Quit leaves the editor', () => {
await page.waitForURL(PROJECT_URL_RE, { timeout: 30000 });
});
test('quit on a deep-linked editor falls back to the project page', async ({ page }) => {
test('quit on a deep-linked editor goes to the project page', async ({ page }) => {
test.setTimeout(300000);
// Direct entry (typed URL): no referrer, nothing meaningful to go back
// to — quit must land on the project page via the fallback URL.
// Direct entry (typed URL): no project page in this tab's history —
// quit must land on the project overview all the same.
await page.goto(`/${SCOPE}/projects/demo/demo.kicad_sch`);
await waitForToolReady(page, /demo — Schematic Editor/i);