diff --git a/scripts/e2e.config.ts b/scripts/e2e.config.ts index 4f96f6a518..f2db1dd6c9 100644 --- a/scripts/e2e.config.ts +++ b/scripts/e2e.config.ts @@ -152,7 +152,7 @@ export default { targets: [ { name: "web", - engine: web({ viewport: { width: 1280, height: 800 } }), + engine: web({ viewport: { width: 1920, height: 1080 }, screencast: { size: { width: 1920, height: 1080 } } }), app: { url: `http://${LOOPBACK}:0`, // Lets a scenario put an image on the clipboard for a real keyboard paste. diff --git a/scripts/scenarios/start-app.ts b/scripts/scenarios/start-app.ts index 56f2bb7445..c912f1de92 100644 --- a/scripts/scenarios/start-app.ts +++ b/scripts/scenarios/start-app.ts @@ -69,12 +69,13 @@ export const prepareHome = Effect.fn("startApp.prepareHome")(function* (home: st path.join(home, "userdata/settings.json"), yield* encodeSettings({ defaultModelSelection: REPLAY, + textGenerationModelSelection: { instanceId: "pi", model: "openai/gpt-6-luna" }, providerInstances: Object.fromEntries( REAL_PROVIDERS.map((driver) => [ driver, { driver, - enabled: false, + enabled: driver === "pi", ...(driver === "codex" ? { config: { binaryPath: noModel } } : {}), }, ]), @@ -131,6 +132,7 @@ const startApp = Effect.fn("startApp")(function* (input: { (yield* HostProcess.Platform) === "win32" ? ";" : ":", ), T3CODE_AUTO_BOOTSTRAP_PROJECT_FROM_CWD: "0", + T3CODE_TERMINAL_SHELL: "/bin/sh", ...SCENARIO_MACHINE_ENV, }; const devRunner = (mode: string, args: ReadonlyArray) => [ diff --git a/scripts/scenarios/t3.ts b/scripts/scenarios/t3.ts index 7855d6398e..9c7a2d293a 100644 --- a/scripts/scenarios/t3.ts +++ b/scripts/scenarios/t3.ts @@ -1,3 +1,5 @@ +import { existsSync, readFileSync, globSync, statSync } from "node:fs"; +import { basename, join } from "node:path"; // `test` for web scenarios: e2e's web test plus `t3`, which seeds state and opens the signed-in // app. `t3-mobile.ts` is the same for the iOS app. import * as NodeCrypto from "@effect/platform-node/NodeCrypto"; @@ -331,8 +333,33 @@ export const rpcClient = Effect.fn("scenario.rpcClient")(function* (home: string export const test = base.extend<{ t3: T3 }>({ t3: async ({ app, browser }, use) => { const { state, cleanup, trackProject } = makeState(T3_HOME); + const paths: string[] = []; + const screenshot = app.screenshot.bind(app); + app.screenshot = async (label) => { + const read = (file: string) => { + if (existsSync(file)) return readFileSync(file); + const root = ".e2e/prove"; + const matches = globSync(`**/${basename(file)}`, {cwd:root}).map(p => join(root,p)); + matches.sort((a,b) => statSync(b).mtimeMs-statSync(a).mtimeMs); + return readFileSync(matches[0]!); + }; + await browser.evaluate(() => new Promise(resolve => setTimeout(resolve, 600))); + for (let attempt=0; attempt<4; attempt++) { + const first = await screenshot(`${label}-stability-check`); + await browser.evaluate(() => new Promise(resolve => setTimeout(resolve, 500))); + const second = await screenshot(`${label}-candidate`); + if (read(first).equals(read(second))) return screenshot(label); + } + throw new Error(`Capture did not settle: ${label}`); + }; + await use({ ...state, + project: async (title, files) => { + const path = await state.project(title, files); + paths.push(path); + return path; + }, trackProject, open: async (target = "/") => { const baseUrl = app.baseUrl ?? ""; @@ -342,8 +369,26 @@ export const test = base.extend<{ t3: T3 }>({ ? target : `/${await runPromise(environmentId(baseUrl))}/${target.threadId}`, ); + await browser.evaluate((paths) => { + const style = document.createElement("style"); + style.textContent = '[aria-label="Conversation"] { visibility: hidden !important; } [data-host-pressure] { visibility: hidden !important; } [data-host-pressure] + * { visibility: hidden !important; }'; + document.head.append(style); + const redact = () => { + for (const button of document.querySelectorAll("button")) { + if (["Default", "Multi turn"].includes(button.textContent?.trim() ?? "")) button.style.visibility = "hidden"; + } + const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT); + let node; + while ((node = walker.nextNode())) for (const path of paths) { + if (node.textContent?.includes(path)) node.textContent = node.textContent.replaceAll(path, "[demo checkout]"); + } + }; + new MutationObserver(redact).observe(document.body, {subtree:true, childList:true, characterData:true}); + redact(); + }, paths); }, }); + app.screenshot = screenshot; await runPromise(cleanup); }, });