Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
test(e2e): assert the Cowork surface is unreachable on a stable build
thinhlpgea8d65c0497f
diff --git a/e2e/README.md b/e2e/README.mdindex cb2a6ece5..004570977 100644--- a/e2e/README.md+++ b/e2e/README.md@@ -36,13 +36,14 @@ on the hosted runners — inside the virtual display for no reason.## What it covers-Three spec files, run in this order (see [Spec order](#spec-order-is-maintained-by-hand)):+Four spec files, run in this order (see [Spec order](#spec-order-is-maintained-by-hand)):| 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. |+| `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. |Those are the load-bearing items of the manual checklist's D section: if thechat loop and the actions on a message work, the product works. Much of D isdiff --git a/e2e/helpers/navigation.ts b/e2e/helpers/navigation.tsindex 97fdcb5a0..cc2f228b2 100644--- a/e2e/helpers/navigation.ts+++ b/e2e/helpers/navigation.ts@@ -1,7 +1,8 @@import { browser } from '@wdio/globals'/**- * Navigate the TanStack router client-side.+ * Push a history entry the way the router expects, without waiting for a route+ * to settle.** A hard `browser.url()` would ask the Tauri asset protocol for a deep path it* has no SPA fallback for, and 404. TanStack patches `history.pushState` to@@ -11,8 +12,12 @@ import { browser } from '@wdio/globals'* The state object matters: TanStack tracks position in `__TSR_index` and* computes back/forward deltas by subtracting it. Pushing a bare `{}` wipes* that key and turns later deltas into NaN, so carry the index forward.+ *+ * Split out of `goto()` for routes that answer with a redirect: there the+ * requested path never becomes the current one, so a caller has to wait for+ * where the app lands instead.*/-export async function goto(path: string) {+export async function pushRoute(path: string) {await browser.execute((target: string) => {const previous = (window.history.state ?? {}) as Record<string, unknown>const index =@@ -24,9 +29,18 @@ export async function goto(path: string) {target)}, path)+}+/** Wait until the app's current path is `path`. */+export async function waitForPath(path: string, timeout = 20_000) {await browser.waitUntil(async () => (await browser.execute(() => window.location.pathname)) === path,- { timeout: 20_000, timeoutMsg: `never navigated to ${path}` }+ { timeout, timeoutMsg: `never navigated to ${path}` })}++/** Navigate the TanStack router client-side and wait for it to arrive. */+export async function goto(path: string) {+ await pushRoute(path)+ await waitForPath(path)+}diff --git a/e2e/specs/cowork-channel.e2e.ts b/e2e/specs/cowork-channel.e2e.tsnew file mode 100644index 000000000..ec2edb403--- /dev/null+++ b/e2e/specs/cowork-channel.e2e.ts@@ -0,0 +1,85 @@+import { expect, $ } from '@wdio/globals'++import { goto, pushRoute, waitForPath } from '../helpers/navigation.js'++/**+ * Cowork ships in the `nightly` channel only (web-app/src/lib/version.ts), and+ * this suite is the only place the *stable* half can be proven against a+ * launched app.+ *+ * `yarn build:e2e:app` builds the web app with vite and serves it from the+ * Tauri asset protocol, so the webview is not on localhost and VERSION carries+ * no `-`: exactly the channel where the surface must be absent. The render side+ * is covered by web-app/src/components/left-sidebar/__tests__/coworkGate.test.tsx+ * and web-app/src/lib/__tests__/coworkAccess.test.tsx, but neither can prove+ * what a bookmarked URL does in a real app, which is what this spec exists for.+ *+ * The nightly half is a manual step: the QA checklist carries it, because a+ * nightly build cannot be produced inside a single suite run.+ */+const COWORK_TAB = 'a[href="/cowork"]'+const COWORK_SETTINGS_ENTRY = 'a[href="/settings/cowork"]'+const CHAT_SIDEBAR = '[data-testid="new-chat-button"]'++describe('Cowork is hidden on a build that does not ship it', () => {+ before(async () => {+ await $('#root').waitForExist({ timeout: 60_000 })+ await goto('/')+ })++ it('shows the chat sidebar without a Cowork tab', async () => {+ // Positive control first: the chat surface's own control is on screen, so+ // the assertions below are about the sidebar that is actually rendered and+ // not about a shell that failed to mount. An absence check on its own+ // passes for the wrong reason (see "Writing specs" in e2e/README.md).+ await $(CHAT_SIDEBAR).waitForDisplayed({ timeout: 30_000 })++ // The tab and the Home/Cowork switcher are the same element: with Cowork+ // gone, the switcher has one surface left and NavTabs renders nothing at+ // all, so no Home pill survives without it.+ expect(await $(COWORK_TAB).isExisting()).toBe(false)+ })++ it('leaves the Cowork settings entry out of the settings menu', async () => {+ await goto('/settings/general')++ // Same bracket: the Data Folder row is General's own content, so the+ // settings page mounted before the menu is inspected.+ await $('[data-testid="app-data-folder-path"]').waitForDisplayed({+ timeout: 30_000,+ })++ expect(await $(COWORK_SETTINGS_ENTRY).isExisting()).toBe(false)+ // ...and the menu itself is there, since one of its other entries is.+ expect(await $('a[href="/settings/general"]').isExisting()).toBe(true)+ })++ it('sends a bookmarked Cowork URL to Home', async () => {+ // pushRoute and not goto: the guard redirects, so `/cowork` never becomes+ // the current path and goto would wait for something that cannot happen.+ await pushRoute('/cowork')+ await waitForPath('/')++ // The URL alone would also settle back to `/` if the page had redirected+ // itself from a broken state, so assert the surface is not mounted.+ expect(await $('[data-testid="cowork-surface"]').isExisting()).toBe(false)+ await $(CHAT_SIDEBAR).waitForDisplayed({ timeout: 30_000 })+ })++ it('sends a bookmarked artifacts URL to Home', async () => {+ await pushRoute('/artifacts')+ await waitForPath('/')++ expect(await $('[data-testid="cowork-surface"]').isExisting()).toBe(false)+ })++ it('sends the Cowork settings URL to General settings', async () => {+ await pushRoute('/settings/cowork')+ await waitForPath('/settings/general')++ await $('[data-testid="app-data-folder-path"]').waitForDisplayed({+ timeout: 30_000,+ })+ expect(await $(COWORK_SETTINGS_ENTRY).isExisting()).toBe(false)+ })+})diff --git a/e2e/wdio.conf.ts b/e2e/wdio.conf.tsindex 8a299934d..a8a91e0ab 100644--- a/e2e/wdio.conf.ts+++ b/e2e/wdio.conf.ts@@ -258,14 +258,18 @@ export const config: WebdriverIO.Config = {// The cost is that this list is maintained by hand: a new spec that is not// added here does not run, and nothing reports its absence.//- // The order below is smoke -> chat -> message-actions, pristine first and- // most-configured last. message-actions.e2e.ts registers a second provider- // and leaves two threads behind, so it has to come after anything that cares- // what the profile holds.+ // The order below is smoke -> chat -> message-actions -> cowork-channel,+ // pristine first and most-configured last. message-actions.e2e.ts registers a+ // second provider and leaves two threads behind, so it has to come after+ // anything that cares what the profile holds. cowork-channel.e2e.ts writes+ // nothing and reads only the sidebar, the settings menu and where a URL+ // lands, so it would pass anywhere; last keeps the three calibrated specs in+ // the order they were tuned in.specs: ['./specs/smoke.e2e.ts','./specs/chat.e2e.ts','./specs/message-actions.e2e.ts',+ './specs/cowork-channel.e2e.ts',],maxInstances: 1,capabilities: [