WebDriver-driven end-to-end tests against a real Jan desktop build, using
WebdriverIO and @wdio/tauri-service.
macOS, Linux and Windows. Each can have the app's data folder redirected by environment — on macOS and Linux through the OS's own variables, on Windows through one Jan provides. See Isolation.
On Linux you need the Tauri build dependencies plus a display. libssl-dev is
easy to miss: openssl-sys is in the app's default dependency graph, but GitHub
runners ship OpenSSL preinstalled and the CI workflows never install it, so a
clean machine is the only place the gap shows. (.devcontainer/postCreateCommand.sh
does list it.)
sudo apt-get install -y build-essential cmake pkg-config libssl-dev \
libglib2.0-dev libatk1.0-dev libpango1.0-dev libgtk-3-dev libsoup-3.0-dev \
libwebkit2gtk-4.1-dev librsvg2-dev xvfbNo webkit2gtk-driver: the embedded provider drives the webview in-process and
never launches WebKitWebDriver. You would only need it to switch to the
official provider.
Then run headless under Xvfb. Only the suite needs the display, so build first and wrap just the run:
yarn build:e2e:app # from the repo root
cd e2e && xvfb-run -a yarn testxvfb-run -a yarn e2e also works; it just puts the build — 6-11 minutes cold
on the hosted runners — inside the virtual display for no reason.
Five spec files, run in this order (see Spec order):
| Spec | Covers |
|---|---|
smoke.e2e.ts |
The app boots, React mounts, the first-run wizard renders, and the data folder Rust resolves is inside the throwaway profile. |
chat.e2e.ts |
Configure a provider and a model through the real dialogs; send; stream a reply; a second turn; survive a webview reload; delete the thread and confirm it left disk. |
message-actions.e2e.ts |
Regenerate; switch between reply versions; edit a user message and re-run; delete a single message; stop a reply mid-stream; New Chat into a fresh thread. |
image-limit.e2e.ts |
Image/document defaults and disabled state; persisted image limit; oversized rejection and accepted images through paste, drop and the hidden file input; inline base64 parts received by the mock. |
cowork-channel.e2e.ts |
The absent half of the channel gate: no sidebar tab, no settings entry, and a bookmarked /cowork, /artifacts or /settings/cowork URL lands where the guard sends it. |
The image spec generates valid PNGs inside the webview and dispatches synthetic
ClipboardEvent / DragEvent events, plus assigns a generated FileList to the
hidden image input and dispatches change. These exercise the real intake
handlers, validation and send path. They do not exercise the OS clipboard,
OS drag-and-drop or native file picker, which the embedded driver cannot drive.
The tests share state in declaration order and use their own mock model id.
Those are the load-bearing items of the manual checklist's D section: if the
chat loop and the actions on a message work, the product works. Much of D is
still manual — rename, the search dialog, Delete All, projects, switching
model mid-conversation, markdown/LaTeX/code-block rendering, native image pickers,
IME input, the token-speed readout.
Deliberately out of scope. llama.cpp: a real local model means a
multi-gigabyte download, minutes per run, and different behaviour on every
backend, so it needs its own platform-specific test rather than a place in the
critical path. Copy-to-clipboard: CopyButton calls
navigator.clipboard.writeText without awaiting it or handling a rejection, and
flips to the check icon either way, so a DOM assertion there would pass whether
or not anything reached the clipboard.
Not testable at all, as of the sidebar revamp (92b2de422). Starring a
thread, the Favorites/Recent split, Unstar All and the inline sidebar
search input were all rendered by containers/LeftPanel.tsx, which that commit
deleted. toggleFavorite, unstarAllThreads and getFavoriteThreads survive in
hooks/useThreads.ts with no production caller. The checklist still lists them.
yarn install # once, on a fresh clone -- see below
yarn e2e # from the repo rootThat builds icons, stubs the Tauri bundle resources, builds the workspace
packages, builds the frontend, compiles the app with --features e2e, then
installs and runs this package.
yarn e2e is not self-contained on a fresh clone, and cannot be: Yarn Berry
refuses to run any package script before node_modules exists
(Couldn't find the node_modules state file), so the install has to happen
outside the script. build:e2e:deps runs yarn install anyway, which is what
picks up dependency changes after a branch switch.
That deps stage is not optional. The workspace packages have to be built,
not just installed -- web-app imports @janhq/core, which resolves to
core/dist. Without it build:web fails with
TS2307: Cannot find module '@janhq/core'.
build:e2e:deps is deliberately the same four steps as Makefile:44-47,
including its redundant second build of core (build:extensions starts by
building core again). Staying in step with the Makefile is worth more than the
minute that would save.
To iterate on specs without rebuilding the app:
cd e2e && yarn test| Variable | Effect |
|---|---|
JAN_E2E_KEEP=1 |
Keep the throwaway profile after the run instead of deleting it. |
JAN_E2E_HOME=<dir> |
Use a validated <dir> strictly inside the OS temp root as the profile instead of a fresh temp dir. A directory supplied this way is never deleted — only a profile the harness created is cleaned up. Primarily how the launcher hands the path to its workers. |
This package is not a yarn workspace of the root project. It has its own
lockfile, because it shares no code with core/web-app and adding it to the
root workspaces put ~180MB of driver tooling into every yarn install — including
the release-build jobs that never run this suite.
Two workflows, deliberately split by cost:
.github/workflows/e2e-check.ymlruns on every PR that touchese2e/**. It runs focused launch-guard unit tests and type-checks this package on Linux, macOS and Windows, and enforces--immutableagainst its lockfile. It does not build the app, so it cannot run the suite..github/workflows/e2e-suite.ymlbuilds the app and runs the suite on ubuntu-latest, macos-latest, windows-latest and windows-11-arm. Nightly on Mon/Tue/Wed, plusworkflow_dispatchtaking a platform argument so one leg can be re-run by hand. Not per-PR: the suite is seconds, the build is minutes.
Hosted Linux runners have no display -- $DISPLAY is empty -- but do ship
/usr/bin/xvfb-run, so that leg wraps the run and installs no extra package.
The macOS runner is a real Aqua session and both Windows runners get an
interactive window station, so those three launch the app unwrapped. There is no
headless mode to use instead: the driver is compiled into the app and drives its
own webview, so there is no separate browser process to run headless.
Every leg uploads e2e/logs and the run's profile as e2e-logs-<platform>,
on success as well as failure -- a green log is what you diff against when a
later run goes red.
Tauri renders in the OS webview (WKWebView on macOS, WebKitGTK on Linux, WebView2 on Windows), so Playwright cannot drive it — Playwright only speaks to browsers it ships. WebDriver is the protocol the webviews themselves implement, which is why this is the approach Tauri documents.
On macOS there is no WKWebView driver to attach from outside, so the app hosts
an embedded WebDriver server itself via tauri-plugin-wdio-webdriver. Linux
and Windows use the same embedded provider — they could drive WebKitWebDriver
and msedgedriver through the official provider instead, but sharing one path
means no platform needs tauri-driver installed. The plugin backs all three
natively rather than assuming a Unix webview (src/platform/windows.rs talks to
WebView2 through webview2-com). That plugin is an optional dependency behind the e2e
cargo feature, and the e2e feature is not enabled by any supported build path
— not default, not desktop, and not by any command in the Makefile or
.github/workflows/.
Release binaries therefore do not contain a WebDriver listener. (This is a gate
against accidental inclusion, not a hard impossibility: anyone can pass
--features e2e to Cargo explicitly, which is exactly what build:e2e:app
does to produce the unbundled debug binary these tests drive.)
Verify the gate:
cargo tree --manifest-path src-tauri/Cargo.toml -i tauri-plugin-wdio-webdriver
# "did not match any packages" = correctly absent from a default buildThe e2e feature also disables tauri-plugin-single-instance. Its rendezvous
is a hardcoded /tmp/{identifier}_si.sock on macOS (platform_impl/macos.rs —
literally /tmp, not $TMPDIR, because the path must stay under 100 chars), a
session-bus D-Bus name on Linux, and a named mutex on Windows. None live
under HOME or any XDG directory, and the macOS socket ignores the pinned
TMPDIR too, so nothing in isolationEnv isolates them. A developer with the real Jan open would
otherwise see the test binary hand over its argv and exit before the WebDriver
server ever bound.
Each run gets a throwaway profile in a temp dir to redirect Jan application
data. This is not complete isolation: macOS WebKit storage and the other gaps
below can still touch the real user profile. The desktop app resolves its data folder from
core::app::paths::data_dir(); which variables that leaves you needing to
override depends on the platform.
| Platform | data_dir() |
Redirected by |
|---|---|---|
| macOS | $HOME/Library/Application Support |
HOME |
| Linux | $XDG_DATA_HOME, else $HOME/.local/share |
HOME and XDG_DATA_HOME |
| Windows | FOLDERID_RoamingAppData |
nothing the OS provides — see below |
HOME redirection does not isolate WKWebView localStorage. In native macOS
arm64 validation on #9457 and
#9464, thinhlpg observed writes under the
real ~/Library/WebKit/<bundle id>/WebsiteData/Default/.../LocalStorage/
(jan.ai.app), shared with an installed Jan. The redirected profile contained
no Library/WebKit; Library/Caches/jan.ai.app did redirect. Therefore both
normal and migration launches may read or modify installed-Jan browser state;
a passing migration smoke does not prove browser-storage isolation or migration.
Use a disposable macOS account/VM for separation, not merely JAN_E2E_HOME.
Follow-up (jan-internal#496, not fixed here): isolate macOS e2e WebKit storage, evaluating a distinct e2e bundle identifier, and verify with real installed-Jan storage that launches do not touch it. The possible connection to a missing setup wizard on an already-used Mac is unproven. This PR changes neither bundle IDs nor WebKit storage behavior.
Before profile seeding, recursive cleanup registration, or launch,
launch-guard.ts validates JAN_E2E_HOME. Inherited paths are checked before
mkdir; generated profiles require an initial mkdtemp allocation, preceded by
the environment check. It must be strictly inside the OS temp root; CI and local launches
allocate profiles with mkdtemp under Node’s os.tmpdir() (which may differ
from GitHub’s runner.temp). Real homes and
ancestors/descendants of known user Jan paths are rejected, including inherited
XDG/AppData locations. Existing prefixes are canonicalized (also for not-yet-created
paths) so symlink aliases cannot disguise overlap; sibling names are accepted.
Redirected seed/scratch roots, desktop configuration paths, and their
data_folder values outside the profile are rejected. This includes legacy
migration sources: Rust checks canonical Jan/settings.json first, then (only
if absent) copies and removes the first file found among bundle-id
settings.json and then, on Linux, .config/Jan/settings.json. The guard conservatively
validates all these sources even when shadowed by a higher-priority config,
including known nightly/beta bundle IDs (Rust's current migration constant is
jan.ai.app), and checks their directory/file symlinks before reading them.
Inherited profiles are never recursively deleted.
Unset nonempty JAN_DATA_ROOT on Unix: the WDIO service merges
{ ...process.env, ...options.env }, so omitting it from the Unix overrides
would otherwise preserve it and bypass native HOME/XDG lookup. Even a relative
value is rejected rather than relying on fallback behavior. Windows explicitly
overrides it. Nonempty JAN_DATA_FOLDER, CI=e2e, and APP_NAME values other
than Jan (including empty) are rejected too.
This is an accidental-launch guard, not a filesystem sandbox or a proof of complete confinement. It does not prevent concurrent symlink changes, hard-link aliases, every possible legacy/plugin/config escape, Windows registry folder redirection, the macOS WebKit gap, or the Windows CLI/updater gaps below. Use a disposable OS account or VM if stronger separation is needed. Existing profiles should be disposable; the harness merges a bootstrap seed into their backend settings.
Run cd e2e && yarn test:unit && yarn typecheck without an app build. The focused
node:test tests run via the existing tsx, use only temporary fixture homes,
and check rejection without writes, containment siblings, environment bypasses,
and symlink aliases (Windows skips only if privilege is unavailable).
On Linux the harness pins every XDG base directory
(XDG_DATA_HOME, XDG_CONFIG_HOME, XDG_STATE_HOME, XDG_CACHE_HOME) rather
than relying on them being unset. Each outranks its $HOME-relative default, so
a single inherited value defeats the HOME override.
XDG_CONFIG_HOME is the dangerous one and the reason this is belt-and-braces
rather than minimal. dirs::config_dir() feeds the legacy-config migration in
core/app/commands.rs, which does fs::copy followed by fs::remove_file. With
that variable inherited, a run deletes the developer's real
~/.config/Jan/settings.json — confirmed against a decoy, which did not survive
a single run.
On Windows there is no OS lever at all: dirs calls
SHGetKnownFolderPath(FOLDERID_RoamingAppData, ..), which reads the registry and
takes no environment input. So Jan supplies its own — core/app/paths.rs prefers
JAN_DATA_ROOT and falls back to dirs.
It is Jan's own variable rather than %APPDATA%, which would also have worked.
The cost is what rules it out: Windows sets %APPDATA% for every interactive
session and processes inherit it, so honouring it would move the data root of
every existing install onto a value Jan does not control — and the blast radius
includes the legacy-config migration's fs::copy + fs::remove_file. A
dedicated name is unset in every real install, so the shipping binary resolves
byte-identically to dirs on all three platforms.
paths.rs honours the variable everywhere — one that silently did nothing on two
platforms out of three would be a trap — but the harness sets it on Windows only.
macOS and Linux already have a lever, and pushing them down the override branch
would stop the suite exercising the dirs lookup a real user gets.
That closes the destructive legacy-config migration too, though not because one
known folder serves both: dirs::config_dir() sits behind
#[cfg(target_os = "linux")] in legacy_app_config_candidate_paths(), so the
only Windows candidate comes from resolve_bundle_app_data_dir() —
paths::data_dir() joined with the bundle identifier. One variable moves both
because both go through paths.rs.
APPDATA is still set alongside it, for agreement rather than because paths.rs
reads it: anything else in the process tree that reads the variable directly
would otherwise see the real profile.
USERPROFILE and LOCALAPPDATA are redirected as well, and the harness must
create AppData\Roaming and AppData\Local under the throwaway profile before
the app starts. SHGetKnownFolderPath resolves the Roaming and Local known
folders from REG_EXPAND_SZ values of the form %USERPROFILE%\AppData\...,
expands them against the process environment — so the USERPROFILE override does
move them — and then verifies the result exists, because dirs does not pass
KF_FLAG_DONT_VERIFY. Miss AppData\Local and dirs::cache_dir() is None,
which tauri-plugin-http's cookie jar turns into a startup panic
(PluginInitialization("http", "unknown path"), exit 101) before a window
exists; the embedded driver never binds and the run fails in onPrepare
reporting only code=101. The pair also takes the WebView2 user-data folder with
it, which Tauri puts at %LOCALAPPDATA%\<identifier>\EBWebView — keyed on the
bundle identifier (jan.ai.app) rather than on the executable name, so without
the override a test run and an installed Jan share one browser profile. Those
registry values are the default rather than a guarantee, though: folder
redirection or policy can make them literal paths that ignore USERPROFILE, so
isolation still rests on JAN_DATA_ROOT and paths.rs.
Two things Windows still cannot isolate, both of them accepted gaps enumerated
in isolation.ts next to XDG_RUNTIME_DIR:
dirs::home_dir()resolvesFOLDERID_Profilefrom the user's token rather than from a%USERPROFILE%template, soUSERPROFILEdoes not move it the way it moves the AppData pair. The readers under~/.jan—config.tomland the subagent directory — therefore read the real user profile whereHOMEredirects them on macOS and Linux. The reachable desktop callers are reads, so this is a read leak rather than a destructive one.updater.jsonis written throughtauri-plugin-store, which resolves its base with Tauri's own resolver rather thancore/app/paths.rs, landing it in the real%APPDATA%\jan.ai.app\. Created only when absent.
These are known desktop-suite residue or reads, not a full isolation guarantee.
Windows CLI/global-config callers and explicit saves are not covered; this
harness does not fix their known-folder escapes. The one Windows escape that was destructive —
deep-link registration, which rewrites the HKCU jan:// handler to point at
whichever binary is running — is compiled out under the e2e feature instead of
being documented, since no environment variable reaches the registry.
Two things that look like they'd work but don't:
JAN_DATA_FOLDER— despite the name, a different variable fromJAN_DATA_ROOTabove: it names the data folder itself rather than the OS root it sits under, and onlyresolve_jan_data_folder()reads it, which is the CLI path. The desktop build ignores it.CI=e2e(now rejected by the launch guard) short-circuitsget_app_configurations()to a hardcoded"./data", which would skip the config resolution these tests exist to cover.
With the default generated fresh profile, every run is a first launch — no
providers are configured, so / renders SetupScreen. The suite asserts that
rather than working around it. Reusing an inherited profile can retain providers
and other state, so it may not satisfy these first-launch assertions.
A first launch used to download: Jan fetches its embedding model
sentence-transformer-mini (~45MB) on a profile it has not bootstrapped before,
and announces it with a toast that mounts over the header at a moment set by
network speed. wdio.conf.ts now pre-seeds the one-shot flag that suppresses
that bootstrap, so a run neither downloads it nor shows the toast — a kept
profile is ~112KB rather than ~45MB. Set JAN_E2E_EMBEDDER_DOWNLOAD=1 to get
the real bootstrap back, which is what a spec about the embedder needs.
That is the one large download removed, not every network call: the app still fetches small metadata such as the model catalogue, and no attempt has been made to verify the suite on a machine with no network at all. What it buys is determinism — the toast was landing on whatever a spec was clicking, and see the analytics prompt section for what that cost.
browser.tauri.execute() is unavailable: it needs window.__TAURI__, which
requires withGlobalTauri: true in tauri.conf.json. That would expose the
full Tauri API to anything running in the webview, so it stays off. Assert
through the UI instead — which is closer to what users actually see.
Navigate with the goto() helper in helpers/navigation.ts rather than
browser.url(): the Tauri asset protocol has no SPA fallback for deep paths, so
a hard navigation 404s. The helper pushes history (which TanStack patches to
notify its own subscribers) and carries __TSR_index forward so back/forward
deltas stay valid.
goto() does bypass the nav UI and any guard in front of a route. Clicking a
real nav element exercises more and is worth preferring where a selector exists;
treat the helper as the escape hatch for routes that are awkward to reach.
Prefer data-testid selectors — around ten shipped components already carry
them. Note that a grep for data-testid turns up many more hits in
__tests__ mocks than in real components, so check whether the one you want
actually exists before assuming it does.
Before asserting that something is absent from disk, assert it was there
first. An "is it gone?" check against a path that was never written passes
whatever the code does, and it fails silently rather than loudly — nothing about
the green run says the assertion proved nothing. specs/chat.e2e.ts brackets its
delete this way: it waits for the thread directory to exist, deletes, then waits
for it to go away.
The same shape applies in time rather than on disk: when you are asserting on
something produced by a fire-and-forget background request, assert it before
doing anything that cancels it. The generated thread title is the live example,
and it is product behaviour rather than a harness quirk. The summarizer runs from
onFinish only on a refresh tick — the first assistant message, then every fourth
(web-app/src/routes/threads/$threadId.tsx:632-635,
TITLE_REFRESH_EVERY_N_ASSISTANT_MESSAGES = 4) — and sending the next message
aborts whatever title request is in flight (same file, line 957;
lib/thread-title-summarizer.ts swallows the AbortError and returns null). With
two assistant messages there is no second attempt, so a spec that sends again
before the title lands leaves the row reading "New Thread" permanently, and no
retry recovers it. specs/chat.e2e.ts asserts the title at the end of its first
test, while the thread has exactly one reply.
tauri-plugin-wdio-webdriver synthesizes every interaction in JavaScript. From
src/platform/executor.rs (v1.4):
dispatch_pointer_event()builds aMouseEvent(mousedown/mouseup/mousemove, plus aclicksynthesized after a same-spot down+up) and dispatches it atdocument.elementFromPoint(x, y). It never produces aPointerEvent.click_element()— whatelementClick, and soelem.click(), maps to — isel.scrollIntoView(); el.click(); el.focus().send_keys_to_element()focuses the element and then dispatches synthesizedkeydown/keyupatdocument.activeElement.
Three consequences, all of which read as a failure about the wrong thing:
- CSS
:hovernever applies. A synthesizedMouseEventdoes not move the hover state, somoveTo()cannot reveal hover-only UI, andbrowser.action('pointer')cannot either. - Radix components that open on
pointerdownnever open from a click.DropdownMenuTriggeris the one in Jan's sidebar.DialogTriggerandPopoverTriggeruseonClickand are fine. - The workaround for both is the keyboard, and it is not a hack — it is the
route a keyboard user takes.
elementClickleaves the element focused, which both satisfies agroup-focus-within:opacity-100rule and givesbrowser.keys('Enter')a target; Radix's trigger opens on Enter.specs/chat.e2e.tsdoes exactly this for the thread overflow menu and carries the long-form comment.
Do not use waitForClickable() in this suite. WDIO's clickability check
includes an elementFromPoint test; this driver's click does not.
click_element() goes straight through anything painted on top, so the precheck
can only ever reject clicks that would have succeeded — and on a first launch
there is plenty painted on top (the analytics consent panel over the composer,
the download toast over the header; both below). The failure mode is a 30-60s
timeout naming an element that is fine.
Use clickWhenReady(selector) from helpers/interactions.ts instead:
waitForDisplayed() + waitForEnabled() + click(). Displayed and enabled are
still worth waiting for, because they are real states this app uses — Add Model
stays disabled until the model-id field is non-empty, and the send button is
replaced outright by a stop button while a reply streams, so waiting for it to
exist is the streaming barrier.
opacity: 0 is not one of the differences, so clickWhenReady() is no help
there: waitForDisplayed() runs checkVisibility({opacityProperty: true})
browser-side and rejects a fully transparent element exactly as
waitForClickable() would. Anything revealed only on hover or focus needs
waitForExist() instead, then a plain click() to focus it before the
opacity-0 rule stops applying. Two live examples, and they are hidden by
different rules:
- the thread overflow menu (third test in
specs/chat.e2e.ts), which ismd:opacity-0with agroup-focus-within/menu-item:opacity-100escape (components/ui/sidebar.tsx:714), and additionally needsEnterbecause its Radix dropdown trigger opens on pointerdown; - the whole user-side message action row — Copy, Edit, Ask again, Delete —
which is
opacity-0 ... group-hover/message:opacity-100 focus-within:opacity-100(web-app/src/containers/MessageItem.tsx:631). The edit test inspecs/message-actions.e2e.tsreaches it withwaitForExist()+click()and nothing else:DialogTriggeropens ononClick, so unlike the dropdown no keypress is needed.
The assistant-side row has no opacity rule at all — it is only hidden
while that reply is streaming — so message actions on a reply need none of this.
Once a provider makes onboarding complete, PromptAnalytic
(web-app/src/containers/analytics/) floats the consent panel at
fixed bottom-4 right-4 z-50 — directly over the chat composer's send button.
The button stays present, enabled and non-zero-sized, so it fails only
WebDriver's elementFromPoint check and reports as "still not clickable", which
names an element that is fine.
denyAnalyticsConsent({ required }) in helpers/provider.ts answers it via
[data-testid="analytic-deny"] — deny rather than allow, because a test run has
no business opting into telemetry.
required is the part worth reading twice. The panel appears once per
profile, so exactly one spec in a run sees it: the first to complete
onboarding, which is specs/chat.e2e.ts. That one passes required: true,
because silently skipping a panel that has not appeared yet just defers it to
whatever is being clicked later. Every later spec passes required: false,
because waiting for a panel that has already been answered hangs for the full
timeout.
It is not the only thing that floats. The embedding-model download from
Isolation completes at a different moment every run depending on
network speed, and when it lands a sonner toast (Download Complete — Model
"sentence-transformer-mini" downloaded and verified successfully) mounts
top-right, over the header of whatever page is open. Anything that depends on the
header being unobstructed is therefore a coin flip. This produced three
consecutive red runs, with [data-testid="add-provider-trigger"] reported as
"still not clickable" while being present, enabled, visible and 132x32 — which is
the waitForClickable() ban above, in the wild.
A click that arrives in that window has also been seen to simply not take, and
this is the suite's one open problem. Twice: once on an otherwise idle
machine while the toast was landing, and once as a run of three consecutive red
runs — [data-testid="add-provider-trigger"] present and enabled, dialog never
appearing, in chat.e2e.ts and message-actions.e2e.ts alike — which then went
green on their own and have not returned.
Why it does not register is not known. The standing hypothesis is that
el.click() goes to a node React has just replaced; it is unverified, and
nothing observed supports the obvious culprit — the Toaster is a sibling of the
page in routes/__root.tsx, and routes/settings/providers/index.tsx does not
remount its header when the model list changes, so a mounting toast does not
re-key the trigger.
Attempts to reproduce it have all failed. Saturating every core produced 4/4
green runs with the current openDialog() and 4/4 with the check-then-click
version it replaced; a later series ran 30 consecutive whole-suite runs green —
20 idle, 10 under combined CPU and I/O saturation. So load is not the trigger,
and the current version is not known to fix anything. Do not read its shape as
a solved problem. What it does is narrow the window between finding the trigger
and clicking it from four round trips to none, and report what the last attempt
actually observed when it times out — "clicked", "already-open", "missing",
"disabled" or "hidden". If this goes red on CI, that word is the first thing to
read, and it is the evidence this paragraph is still missing.
Opening a dialog therefore goes through
openDialog(triggerSelector, dialogSelector) in helpers/interactions.ts, which
re-clicks until the dialog is displayed — kept because the retry is cheap and the
guard makes it safe, not because the cause is understood. The guard is the
load-bearing part and it is verified: Radix mirrors open state onto the trigger
as data-state="open", and the trigger's onClick is a toggle, so a blind
second click would shut a dialog that had in fact opened. The helper skips the
click whenever the trigger already reads data-state="open".
@wdio/tauri-service's beforeCommand hook calls ensureActiveWindowFocus()
for getTitle/findElement/findElements/$/$$/elementClick, which asks
the app for its window states over browser.tauri.execute(). That needs
window.__wdio_original_core__, absent here for the same reason
browser.tauri.execute() is unavailable to specs — withGlobalTauri is off — so
the probe cannot succeed. It times out after 5s per command, logging
Failed to get window states each time.
wdio.conf.ts's before hook turns it off by doing
browser.switchToWindow(await browser.getWindowHandle()): afterCommand treats
a successful non-internal switchToWindow as the user taking charge of window
selection and suppresses the probe for the rest of the session, so switching to
the handle we are already on is a no-op that disables it. Jan runs a single
window under test, so there is nothing to recover. The numbers are the spec
reporter's own per-file timings on macOS: smoke.e2e.ts went from 40.3s to
~70ms for the same three assertions, and chat.e2e.ts from dying on the Mocha
hook timeout to a few seconds. The work did not get faster — roughly 5s per
element lookup stopped being spent.
If a future spec is mysteriously slow and the log carries
Failed to get window states, that hook is what to check.
helpers/ holds the pieces more than one spec needs:
-
navigation.ts—goto(), described above. -
interactions.ts—clickWhenReady()andopenDialog(), both described above. They live here rather than in a spec because what they work around is the driver, not the screen. -
provider.ts—configureMockProvider()walks the real Add Provider and Add Model dialogs,d 6FCA enyAnalyticsConsent()answers the consent panel, andselectModel()picks a model in the composer. The last is not optional:useModelProviderdefaults to{ selectedProvider: 'llamacpp', selectedModel: null }andDropdownModelProvider's init effect only ever auto-selects a llamacpp model or clears the selection — it never reaches for a custom provider, so a spec that skips it sends at a model that is not there. -
chat.ts— theUSER_MESSAGES/ASSISTANT_MESSAGESselectors,sendPrompt()andwaitForStreamToFinish(). The two selectors pair the testid withdata-message-role, which matters: system notes take an early return inMessageItem.tsxand render neither attribute, so counting these counts real conversation turns and nothing else. -
paths.ts— two directories, and they are not the same one. Asserting against a real on-disk path is what makes a filesystem check meaningful; asserting againstisolationEnv()would only restate what the harness injected.janDataDir(testHome)— the directory the Rust side resolves for app data inside the throwaway profile (data_dir()/Jan).settings.jsonlives here.janUserDataDir(testHome)—janDataDir()/data, which is whatsettings.json'sdata_folderpoints at and what the Rust thread code takes as itsdata_folderargument (core/threads/utils.rs,get_thread_dir). Threads are atjanUserDataDir()/threads/<id>.
Picking the wrong one of those is quiet rather than loud, which is why it is worth stating: a path one segment short simply never exists, and an "is it gone?" assertion against it passes for the wrong reason.
-
mock-openai.ts— see below.
specs/chat.e2e.ts covers the loop the product lives or dies by — send, stream a
reply, keep it across a reload, delete it — against a mock OpenAI-compatible
server on loopback rather than a real one.
startMockOpenAI() binds port 0 on 127.0.0.1 and answers three things, all of
which the app genuinely asks for:
GET /v1/models—useProviderModels→fetchModelsFromProvider(services/providers/tauri.ts) fetches${base_url}/modelsas soon as the Add Model dialog opens. Without it that dialog renders an error state.POST /v1/chat/completionswithstream: true— SSE, echoingMOCK_REPLY_PREFIXplus the last user message back across several chunks. Echoing proves the typed text reached the server and returned; several chunks prove the webview assembles a stream rather than rendering one blob.- the same path with a falsy
stream— the thread-title summarizer, which goes throughgenerateText. It answers a fixedMOCK_TITLEso the sidebar assertion is deterministic.
This works from Node because Jan issues those requests from Rust
(getRuntimeFetch() → tauri-plugin-http), so the server sees an ordinary HTTP
client: no CORS, no preflight, and the capability set already allows
http://*:*. The provider is registered through the real Add Provider and Add
Model dialogs, so the configuration path is covered too.
startMockOpenAI() takes two options, both of which exist for a specific spec:
modelId— whatGET /v1/modelsadvertises. A second spec must override it. Nothing removes an earlier spec's provider, and the composer's dropdown keys its option testid on the model id alone (DropdownModelProvider.tsx:584,684), so two providers advertising the same id put two elements behindmodel-option-<id>— and one of them points at a server that was closed in the earlier spec'safter().chunkDelayMs— milliseconds between streamed chunks, and writable on the returned handle so one test can slow the stream down and put it back. At the default of 0 the whole echo lands well inside one WebDriver round trip, so there is nothing left to interrupt by the time a click on stop arrives.
The handle also carries streamedPrompts: the last user turn of every
streaming completion so far, live. It is there because some claims the UI
makes are not observable in the DOM at all. A regenerated reply to an unchanged
prompt is byte-identical to the one it replaced, so nothing on screen separates
"asked the model again" from "re-rendered what was already there" — and asking
again is the whole of what Regenerate does. Its mirror image is the version-nav
test, which asserts the count did not move: switching between two versions
has to read what the thread already holds. Title-summarizer calls are excluded,
since they are not conversation turns.
Start the server in before() and close it in after() — an open listener keeps
the worker's event loop alive and the run never exits.
What this deliberately does not cover is llama.cpp. A real local model means a multi-gigabyte download, minutes per run, and different behaviour on every backend; it needs its own platform-specific test rather than a place in the critical-path suite.
What the mock removes is the LLM download from the chat path, not every
download. The app still fetches its sentence-transformer-mini embedding model
on a profile that has not been bootstrapped, which the harness now seeds around
— see Isolation.
specs in wdio.conf.ts is an explicit array, not a glob, because state leaks
forwards between spec files: smoke.e2e.ts asserts the first-run setup wizard
and chat.e2e.ts configures a provider, which under an alphabetically sorted
glob ran first and broke it.
The order is pristine first, most-configured last — smoke → chat →
message-actions → image-limit → cowork-channel — and it is the reason
message-actions.e2e.ts can assume a provider has already been configured and
the analytics panel already answered.
It leaks further than a shared profile would explain. The embedded provider
spawns one app in the launcher's onPrepare and every spec file drives that
same process over its own WebDriver session — the run log carries a single
Tauri app spawned (PID: …) line, not one per file. So a later spec inherits
not just what an earlier one wrote to disk but the live webview: its route, its
zustand stores, and any dialog left open. Only an explicit browser.refresh()
clears the in-memory half, and goto() does not.
A new spec therefore has to be added to that array, and it is worth thinking about where: a spec that needs a pristine profile belongs before anything that configures the app.
The spec files leave no such element and stale element reference lines in
the wdio log even when every test passes — on a two-run Linux check, 14 and 23
of them respectively; on Windows, 53. They are INFO webdriver: RESULT
responses, not failures: waitForDisplayed(), waitUntil() and openDialog()
all work by polling, so every attempt before the one that succeeds is logged as
an error the client then swallows. React swapping a node under a held reference
produces the stale ones.
The consequence is that grepping a run for error tells you nothing. Read the
✓/✗ lines and the Spec Files: summary instead, and treat the exit code as
the verdict.
Those lines no longer reach the terminal at all: outputDir sends the driver
log to logs/<spec>-<cid>.log instead of the console, so what you see live is
the spec reporter alone. The lines are still worth reading when something does
fail — that file is where the last attempt before the give-up is recorded.
After building the same debug e2e binary described above:
cd e2e
xvfb-run -a yarn test:migration # Linux; omit xvfb-run on macOS/WindowsThis copies the committed src-tauri/tests/fixtures/upgrade/0.8.3 contents
(store, MCP config and two threads) into its own fresh guarded temporary
profile. It requires schema 3 and an Exa entry before starting. It launches
two sequential WDIO commands / real desktop processes, with the same
profile and no reseeding between them. The embedded driver port must be closed
before the first launch and after each launch; a still-listening process is
never killed by name or by port. A failed first phase stops the run.
Both starts assert on disk: schema 5, exactly the fixture MCP config minus Exa
(all other servers and settings unchanged), and all fixture thread IDs,
metadata, message IDs and content preserved. Both navigate to historical thread
784952d3-dc72-474e-ab24-0d78e7035280 and assert its user and assistant text.
There is no provider setup, model download or inference request. The embedder
bootstrap suppression flag is seeded once; incidental app metadata requests
are not blocked, so this is not an offline/network-isolation test.
JAN_E2E_SCENARIO accepts only default (the existing five specs) or migration
(only migration.e2e.ts); use the runner, not a hand-exported migration scenario.
test:migration rejects inherited JAN_E2E_HOME and
JAN_E2E_EMBEDDER_DOWNLOAD. It uses the same launch safety guard as the default
suite. On failure/interruption the owned profile and phase-specific runner and
WDIO logs remain under the printed temporary path. On success it removes them
unless JAN_E2E_KEEP=1. The migration runner directly spawns and retains handles
for the app and WDIO; the migration config disables the service launcher to avoid
a second app. It waits for the embedded /status readiness before starting WDIO.
The spec then waits for the historical sidebar row (thread-store hydration), not
merely #root, before navigating to the historical conversation.
SIGINT/SIGTERM and the ten-minute phase deadline cancel startup or execution and
await cleanup of both owned roots. Unix sends TERM then KILL after five seconds;
Windows invokes bounded taskkill /PID <owned-live-root> /T /F before the root
exits, rather than force-killing WDIO and losing its tree. No PID is discovered
from a port, log, process name, or PID file; no detached processes/groups or broad
image-name kills are used. Each phase also requires the driver port to close.
Any failure or uncertain teardown retains the profile. This is a guarantee for
tracked roots and driver closure, not proof that every Unix grandchild has
exited: Unix app/worker descendants are not independently enumerated. SIGKILL of
the runner, machine shutdown, or already-orphaned Windows descendants cannot be
reliably cleaned up by this harness. Retained profiles are evidence, not a claim
that every possible orphan was terminated. Injectable lifecycle tests cover
startup/run cancellation, real short-deadline automatic cancellation, escalation,
and cleanup failure. Work and teardown failures are retained together (including
the driver-port closure barrier), rather than cleanup masking the original error.
This covers startup migrations and persistence across a second process start,
not an installer upgrade, old binary execution, browser localStorage migration,
provider credential migration, or an exhaustive upgrade matrix. The fixture is
not a copy of an OS browser profile. yarn test:unit exercises fixture comparison,
strict scenario selection, and launch/barrier ordering without starting Jan;
it does not substitute for the desktop smoke.