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:
+6
-9
@@ -31,7 +31,7 @@ Output:
|
||||
| File | Contents |
|
||||
| --- | --- |
|
||||
| `releases/<version>/RuneStone_<version>_x64-setup.exe` | The setup file to distribute |
|
||||
| `releases/<version>/host.json` | The release version, the encoded toolchain and Windows versions, the path, the size in bytes, and the SHA-256 hash |
|
||||
| `releases/<version>/host.json` | The release version, the encoded toolchain and Windows versions, the file name, the size in bytes, and the SHA-256 hash |
|
||||
|
||||
The script prints `Installer available: <path>` when it completes.
|
||||
After a successful build, the version fields keep the new version.
|
||||
@@ -43,9 +43,9 @@ Example, from the 0.1.44 download link in the README: version `0.1.44` gives `re
|
||||
Source: `scripts/buildInstaller.mjs`.
|
||||
|
||||
1. Reads the version and makes sure that all version fields match the current version.
|
||||
2. Makes sure that downgrade protection stays on in `tauri.conf.json` and `tauri.windows.conf.json`.
|
||||
2. Makes sure that downgrade protection stays on in `tauri.conf.json` and `tauri.windows.conf.json`, and that the browser runtime is staged.
|
||||
3. Stops if the setup file or `host.json` exists in the bundle folder or in `releases/<version>/`.
|
||||
4. Saves copies of the four version files as `*.before` in `output/installer-build/<version>/`.
|
||||
4. Saves copies of the four version files as `*.before` in `output/installer-build/<version>/<time>/`, a new folder for each attempt.
|
||||
It also writes the NSIS template and a configuration override to that folder.
|
||||
5. Writes the new version to `package.json`, `tauri.conf.json`, `Cargo.toml`, and `Cargo.lock`.
|
||||
6. Runs `tauri build --no-bundle -- --locked`. This runs `pnpm build` and compiles the release app.
|
||||
@@ -55,12 +55,9 @@ Source: `scripts/buildInstaller.mjs`.
|
||||
|
||||
### Failure and rollback
|
||||
|
||||
If a step fails, the script restores the four version files.
|
||||
It moves partial setup files and `host.json` into `output/installer-build/<version>/` with a `.failed-<timestamp>` suffix.
|
||||
|
||||
Ctrl+C stops the script before this cleanup. The version files then keep the new version.
|
||||
Before you run the script again, copy the `*.before` files from `output/installer-build/<version>/` back to their original names.
|
||||
A new run with the same version replaces those copies.
|
||||
If a step fails, or you press Ctrl+C, the script restores the four version files.
|
||||
It moves partial setup files and `host.json` into the folder of that attempt with a `.failed-<timestamp>` suffix.
|
||||
If the process is killed before this cleanup, copy the `*.before` files of the attempt back to their original names.
|
||||
|
||||
## Installer requirements
|
||||
|
||||
|
||||
+43
-25
@@ -91,8 +91,12 @@ A new command needs an entry in `generate_handler!` in `lib.rs`, in the command
|
||||
| Folder | Content |
|
||||
| --- | --- |
|
||||
| `browser-runtime/` | The browser engine, its tests, filter lists, and third-party notices |
|
||||
| `scripts/` | Unit tests (`*.spec.ts`), browser smoke tests (`*.smoke.mjs`), and build and package tools |
|
||||
| `fixtures/` | Sample documents, a sample plugin, and a completion test page |
|
||||
| `tests/unit/<area>/` | Unit tests (`*.spec.ts`) that run in Node |
|
||||
| `tests/smoke/<area>/` | Browser smoke tests (`*.smoke.mjs`) and their shared harness in `_harness/` |
|
||||
| `tests/native/` | Tests that attach to a running desktop app |
|
||||
| `scripts/` | Build, release, package, and audit tools, and the smoke test runner |
|
||||
| `fixtures/` | A sample workspace (`fixtures/sample/`), a sample plugin, and a completion test page |
|
||||
| `design/` | Icon drafts |
|
||||
| `docs/` | User and developer documentation |
|
||||
|
||||
### Where data lives
|
||||
@@ -127,18 +131,19 @@ Run these commands from the repository folder. They do not need an installer.
|
||||
|
||||
| Command | Checks |
|
||||
| --- | --- |
|
||||
| `pnpm check` | Svelte and TypeScript types |
|
||||
| `pnpm test` | Unit tests in `scripts/*.spec.ts` |
|
||||
| `pnpm check` | Svelte and TypeScript types of the app, then of the unit tests (`tests/tsconfig.json`) |
|
||||
| `pnpm test` | Unit tests in `tests/unit/` |
|
||||
| `cargo test --manifest-path src-tauri/Cargo.toml --lib` | Rust unit tests |
|
||||
| `pnpm smoke` | Browser smoke tests. See [Browser smoke tests](#browser-smoke-tests). |
|
||||
| `pnpm build` | The production frontend build |
|
||||
| `pnpm check:menus` | The inventory of menu surfaces. See [Interface design](ui-design.md). |
|
||||
|
||||
To run one test file, use `node --experimental-strip-types --test tests/unit/tables/selection.spec.ts`.
|
||||
For type errors while you edit, run `pnpm check:watch`.
|
||||
|
||||
Some tests need files from outside this repository:
|
||||
Some tests need files from outside this repository. Without those files, the tests skip and state the reason:
|
||||
|
||||
- `tests/unit/plugins/plugins.spec.ts` and `tests/unit/tables/formulas.spec.ts` import the compiled Table Formulas package. Run `pnpm build:plugins` first. See [Build examples](plugin-development.md#build-examples).
|
||||
- `tests/unit/plugins/plugins.spec.ts` and `tests/unit/tables/formulas.spec.ts` import the compiled Table Formulas package. To run them, run `pnpm build:plugins` first. See [Build examples](plugin-development.md#build-examples).
|
||||
- `tests/unit/release/installerVersion.spec.ts` needs the NSIS compiler that the Tauri CLI downloads on Windows.
|
||||
- The Rust terminal tests start the real shells on the computer.
|
||||
|
||||
@@ -147,32 +152,45 @@ Some tests need files from outside this repository:
|
||||
Smoke tests run the real interface in headless Chromium with a mock of the desktop host.
|
||||
They do not replace tests in the native app. Real folder access, file writes, and terminals need `pnpm tauri dev`.
|
||||
|
||||
1. Make Playwright available. It is not a project dependency.
|
||||
Set `PLAYWRIGHT_MODULE` to the folder of an installed `playwright` package.
|
||||
If that package has no Chromium, set `CHROME_PATH` to an installed browser.
|
||||
2. Start the frontend with `pnpm dev`, or use the server of a running `pnpm tauri dev` session.
|
||||
3. In a second terminal, run one script, for example `node tests/smoke/layout/workbench.smoke.mjs`.
|
||||
| Command | Runs |
|
||||
| --- | --- |
|
||||
| `pnpm smoke` | All smoke tests, four at a time |
|
||||
| `pnpm smoke tabs tables/drag` | The tests whose path contains one of the filters |
|
||||
| `pnpm smoke --list` | Nothing. It lists each test, its requirements, and why a test would skip. |
|
||||
|
||||
Example for PowerShell. Replace the paths with your own:
|
||||
The runner starts the Vite server when nothing serves `SMOKE_URL`, and stops it at the end.
|
||||
Use `--no-serve` to require a running server, `--jobs <n>` to change the number of parallel tests, and `--timeout <seconds>` to change the limit for each test (default 180).
|
||||
After the parallel run, the runner runs each failed test one more time, alone. A test that passes then is reported as `flaky`. It does not fail the run, but the summary lists it. Use `--retries 0` to turn this off.
|
||||
Each test writes its output to `output/smoke/logs/<area>__<name>.log`. Screenshots go to `output/smoke/<area>/<name>/`.
|
||||
|
||||
```powershell
|
||||
$env:PLAYWRIGHT_MODULE = "C:\tools\browser-tests\node_modules\playwright"
|
||||
$env:CHROME_PATH = "C:\Program Files\Google\Chrome\Application\chrome.exe"
|
||||
node tests/smoke/layout/workbench.smoke.mjs
|
||||
```
|
||||
Playwright is a development dependency. When its own Chromium is not installed, the runner uses an installed Chrome or Edge.
|
||||
To use the Playwright browser, run `pnpm exec playwright install chromium`.
|
||||
|
||||
A test states what it needs near its top. The runner skips the test, with the reason, when a requirement is missing:
|
||||
|
||||
| Line | Requirement |
|
||||
| --- | --- |
|
||||
| `// @requires plugin:table-formulas` | `plugin-packages/table-formulas/`. Run `pnpm build:plugins`. |
|
||||
| `// @requires plugin:terminal` | The compiled Terminal plugin |
|
||||
| `// @requires repo:RuneStone_Git/dist` | A file or folder in a sibling plugin checkout |
|
||||
| `// @requires electron` | The browser engine dependencies. Run `npm ci --prefix browser-runtime`. |
|
||||
| `// @known-issue <defect>` | The test fails because of a known app defect. The run reports it as `known`. If the test passes, the run fails, so that someone removes the line. |
|
||||
|
||||
| Variable | Use |
|
||||
| --- | --- |
|
||||
| `SMOKE_URL` | The frontend address. The default is `http://127.0.0.1:1420`. |
|
||||
| `RUNESTONE_TERMINAL_DIST` | The compiled Terminal plugin. The default is `../RuneStone_Terminal/dist`. |
|
||||
| `RUNESTONE_TABLE_FORMULAS_ROOT`, `RUNESTONE_GIT_ROOT` | Sibling plugin checkouts in other folders |
|
||||
| `RUNESTONE_PLUGIN_REPOS` | The folder of the sibling plugin checkouts. The default is the parent folder of this repository. |
|
||||
| `RUNESTONE_TERMINAL_DIST` | The compiled Terminal plugin. The default is `RuneStone_Terminal/dist` in that folder. |
|
||||
| `CHROME_PATH` | A Chromium browser for Playwright |
|
||||
| `PLAYWRIGHT_MODULE` | A different Playwright package |
|
||||
|
||||
Smoke tests for plugins load compiled packages through the real module loader. Build those plugins first.
|
||||
`browserInteraction.smoke.mjs` and `browserFields.smoke.mjs` also start the browser engine from `browser-runtime`.
|
||||
To write a smoke test, start from an existing test in the same area. The harness in `tests/smoke/_harness/index.mjs` starts the browser, mocks the Tauri commands, and gives an in-memory workspace.
|
||||
A failed test saves `failure.png` in its output folder and prints the page console errors and warnings.
|
||||
You can also run one test file directly while `pnpm dev` runs, for example `node tests/smoke/tabs/order.smoke.mjs`.
|
||||
|
||||
A few scripts attach to a running desktop app instead, through the WebView2 remote-debugging port.
|
||||
Examples: `spellingNative.smoke.mjs`, `kanbanNative.smoke.mjs`, and `browserNativeAcceptance.mjs`.
|
||||
Before you start the app, set `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=<port>`. Each script states its port and variables at the top.
|
||||
The tests in `tests/native/` attach to a running desktop app through the WebView2 remote-debugging port, and `pnpm smoke` does not run them.
|
||||
Set `NATIVE_CDP_URL` to the debugging address, for example `http://127.0.0.1:9224`.
|
||||
Before you start the app, set `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=<port>`. Each file states its port and variables at the top.
|
||||
|
||||
## Built-in browser runtime
|
||||
|
||||
@@ -195,5 +213,5 @@ Each browser window gets a session token at startup. Native requests check that
|
||||
| The window shows the old interface | Look for compile errors in the terminal. Restart `pnpm tauri dev` if necessary. |
|
||||
| A page says that desktop features need `pnpm tauri dev` | You opened the Vite server in a browser. Use the native window. |
|
||||
| Windows cannot find `link.exe` | Install the C++ build tools and the Windows SDK from the Tauri prerequisites. Open a new terminal. |
|
||||
| A smoke test cannot find Playwright or Chromium | Set `PLAYWRIGHT_MODULE`. Install its Chromium, or set `CHROME_PATH`. |
|
||||
| A smoke test cannot find Chromium | Run `pnpm exec playwright install chromium`, or set `CHROME_PATH` to an installed browser. |
|
||||
| `cargo test --offline` reports missing crates | Run the command without `--offline` one time while you are online. |
|
||||
|
||||
Reference in New Issue
Block a user