:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(desktop): document live stack testing (#81957)
Adam Bowker31aac725c6bf
diff --git a/products/desktop/.claude/skills/test-electron-app/SKILL.md b/products/desktop/.claude/skills/test-electron-app/SKILL.mdindex 29f88e7e058f..7f25c3687f6a 100644--- a/products/desktop/.claude/skills/test-electron-app/SKILL.md+++ b/products/desktop/.claude/skills/test-electron-app/SKILL.md@@ -1,6 +1,6 @@---name: test-electron-app-description: Drive the real running PostHog Electron app (live tRPC, workspace-server, real data) over CDP with agent-browser. Connect to the running app on port 9222, snapshot the accessibility tree to verify changes, click/type/navigate, and screenshot the actual desktop app only when explicitly asked. Use when asked to test, verify, dogfood, screenshot or interact with the running app. For regression specs use the Playwright E2E suite.+description: Drive the real running PostHog Electron app (live tRPC, workspace-server, real data) over CDP with agent-browser. Connect to the running app on port 9222, test desktop changes against a local Django stack, snapshot the accessibility tree, inspect network requests, and screenshot only when explicitly asked. Use when asked to test, verify, dogfood, screenshot, interact with the running app, or run a live backend-to-desktop E2E check. For regression specs use the Playwright E2E suite.allowed-tools: Bash(agent-browser:*), Bash(npx agent-browser:*), Bash(pnpm app:cdp*)---@@ -19,6 +19,9 @@ whatever profile is signed into `~/.posthog-code`. Pick the right surface:| Verify or screenshot a change in the **real** app, live data | this skill (agent-browser + CDP :9222) || **Regression** coverage in CI | Playwright E2E (`apps/code/tests/e2e/`) |+For a live backend-to-desktop test, read+[`references/local-django-stack.md`](references/local-django-stack.md) before starting services.+## Prerequisites```bash@@ -157,6 +160,16 @@ agent-browser find role button click --name "New task"agent-browser find text "Settings" click```+For API-backed UI, inspect the request as well as the rendered state:++```bash+agent-browser network requests+```++A successful status code is not enough. Confirm required response fields and then+re-snapshot the component that consumes them. Repeat the request and interaction once+before reporting a pass or failure.+## Screenshots**Only screenshot when the user explicitly asks for one** ("screenshot", "showdiff --git a/products/desktop/.claude/skills/test-electron-app/references/local-django-stack.md b/products/desktop/.claude/skills/test-electron-app/references/local-django-stack.mdnew file mode 100644index 000000000000..59f801b7fa33--- /dev/null+++ b/products/desktop/.claude/skills/test-electron-app/references/local-django-stack.md@@ -0,0 +1,73 @@+# Test Electron against local Django++Use this workflow for a focused backend-to-desktop E2E test. Keep it scoped to the API and desktop surface under test.++## Plan the stack++Check for existing processes before starting anything. Reuse services you do not own and never stop a developer's Electron instance.++Prefer the smallest stack that exercises the contract:++- Docker data services required by the endpoint+- Django on the local PostHog URL+- root Vite when Django pages such as login and OAuth need it+- the desktop Electron dev process++Avoid starting every worker when the test does not use ingestion, Celery, Temporal, or the plugin server. A full stack and a native desktop rebuild can exhaust a small VM together.++From the monorepo root, prepare the cloud-task environment when needed:++```bash+bootstrap-dev-stack+uv sync+pnpm install --frozen-lockfile --prefer-offline+```++Load the repository's service environment before running Django so Postgres, ClickHouse, and Redis resolve to the same services used by migrations. Add the committed development OAuth signing key without sourcing unrelated example settings.++Run Django and root Vite as separate long-lived processes. Poll `http://localhost:8010/_health`; do not trust a launcher exit code as readiness.++From `products/desktop`, reuse installed dependencies and launch Electron as described in the parent skill. On a root-run Linux VM, use a virtual display and Electron's sandbox-disable environment for this disposable dev process.++## Authenticate through the real flow++The dev Electron profile has separate auth state. Select **Local development** in the app and complete the OAuth URL generated by Electron in a browser session against `localhost:8010`.++Use the normal login form or an in-page `/api/login/` request so cookies and CSRF state stay in the browser. Authorize the application and let its localhost callback return to Electron.++Do not rewrite scopes or insert tokens into desktop storage to make login pass. If authorization succeeds but Desktop has no project, inspect the OAuth token scope and the `/api/users/@me/` and organization/project requests. That is contract evidence, not setup noise.++## Seed prerequisites before opening the surface++Trace every server-side dependency of the endpoint before creating fixtures. Settings that point at an internal project, object store, or analytics database need real matching rows.++Create projects and teams through `Project.objects.create_with_team(...)` or the established bootstrap helper. Do not create a `Team` row directly; a team requires its paired `Project`.++For ClickHouse-backed fixtures:++- confirm the active database is `posthog`, not `default`+- use an ingestion path when the relevant workers are running+- otherwise use an existing test fixture helper deliberately and verify the inserted row with the production query+- timestamp usage after the task's creation time and match every attribution property used by the query++If the UI only mounts after runtime state exists, seed that state too. A task-cost indicator, for example, also needs a task run and a valid usage update in the session log before its query hook renders.++## Verify the contract and UI++Open the task through the app, then inspect requests over CDP:++```bash+agent-browser network requests+```++Verify all layers:++1. The endpoint returns the expected status.+2. Its JSON includes every field the desktop client reads.+3. The accessibility snapshot shows the value in the indicator.+4. Opening the popover shows the expected breakdown.+5. Reloading and repeating the interaction produces the same result.++Read Django logs for the exact exception when a request fails. Fix an in-scope PR bug and continue the same E2E run instead of ending at the first actionable failure.++Keep Electron running after the test as described in the parent skill. Stop only processes started for this run when the user is finished.