storebound/cli/shots/browser.ts
CRT 1d2978d0bb console fill: opens the form itself and reuses the owner's Chrome sign-in
Navigation after sign-in (navPlan + navigate): App Store Connect Apps > + > New App
(EN/TR), App Privacy by /apps/<appId>/distribution/privacy or the app list, Play app
list by package name > Policy and programs > App content > Start / Manage. Every
navigation click goes through navClick: the click gate stays absolute, only a link
named exactly Start / Manage / Başla / Yönet passes. Each step is logged; a step not
found in time or two matching apps -> the printed steps and wait (no crash).
The TR gate now refuses "uygula" (apply) but not "uygulama" (app).

Browser (cli/console/session.ts): attach to a Chrome with remote debugging (--cdp or
DevToolsActivePort), else on macOS a temporary profile with only Local State and the
profile's Cookies filtered to the console hosts, opened in real Chrome and deleted at
the end, else storebound's own profile (--fresh-profile). Cookies are never printed.
Desktop: fresh_profile option, the dialog says it uses the Chrome sign-in.
Tests: navigation fixtures (ASC EN/TR, Play list, App content, missing step,
duplicates, deny-listed decoys), session file selection, host filter, cleanup, and a
real-Chrome copy-mode test on a throwaway profile and a local site.
2026-10-11 18:21:35 +00:00

49 lines
2.9 KiB
TypeScript

// Playwright is an optional peer dependency of storebound, resolved from the project (or the storebound folder), so a
// project that never renders screenshots never downloads a browser. The compiled desktop sidecar carries its own
// playwright-core (tools/build-sidecars.ts bundles it) and renders with the Chrome for Testing the desktop app manages
// (STOREBOUND_CHROME), so desktop users need neither playwright nor a browser in their project.
// Launch order: STOREBOUND_CHROME, Playwright's own Chromium, then an installed Google Chrome (channel "chrome").
import { join } from 'node:path';
import { compiled } from '../lib/runner';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async function chromium(root: string): Promise<any> {
for (const base of [root, join(import.meta.dir, '../..')]) {
try {
const p = Bun.resolveSync('playwright', base);
return (await import(p)).chromium;
} catch { /* next */ }
}
// only reached in the compiled sidecar: the bundled playwright-core (not a runtime dependency of the npm package)
if (compiled()) return (await import('playwright-core')).chromium;
throw new Error('playwright not found: in your project run `bun add -d playwright` (and `bunx playwright install chromium` if Google Chrome is not installed)');
}
/** Playwright's chromium (same resolution as `launch`), for connectOverCDP and Chrome-channel launches. */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const chromiumFor = (root: string): Promise<any> => chromium(root);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export async function launch(root: string, opts: Record<string, unknown>): Promise<any> {
const c = await chromium(root);
// the desktop app's own Chrome for Testing (or any Chrome the user points at)
const exe = process.env.STOREBOUND_CHROME;
if (exe) { try { return await c.launch({ ...opts, executablePath: exe }); } catch { /* fall back below */ } }
try { return await c.launch(opts); } catch (e) {
try { return await c.launch({ ...opts, channel: 'chrome' }); } catch { throw e; }
}
}
/**
* A persistent browser profile (cookies of a console sign-in the owner did by hand stay there between runs; storebound
* never reads them). Same resolution and launch order as `launch`. Used by `storebound console fill` (visible window).
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export async function launchPersistent(root: string, userDataDir: string, opts: Record<string, unknown>): Promise<any> {
const c = await chromium(root);
const exe = process.env.STOREBOUND_CHROME;
if (exe) { try { return await c.launchPersistentContext(userDataDir, { ...opts, executablePath: exe }); } catch { /* fall back below */ } }
try { return await c.launchPersistentContext(userDataDir, opts); } catch (e) {
try { return await c.launchPersistentContext(userDataDir, { ...opts, channel: 'chrome' }); } catch { throw e; }
}
}