Skip to content

test: tests for the programs layer - #1388

Open
gewenyu99 wants to merge 1 commit into
posthog/functional-r9-14-tests-for-the-agent-and-shared-layersfrom
posthog/functional-r9-15-tests-for-the-programs-layer
Open

gewenyu99 wants to merge 1 commit into
posthog/functional-r9-14-tests-for-the-agent-and-shared-layersfrom
posthog/functional-r9-15-tests-for-the-programs-layer

Conversation

@gewenyu99

@gewenyu99 gewenyu99 commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Phase 2 of Release C (#1320), PR 12 of 16, after #1387. Tests only. PRs 1 to 14 of this phase split one change into reviewable pieces and compile only as a stack: review them one by one, then land the whole phase together.

Problem

runProgram, the session store and the program folders change shape in #1376 to #1380, and the old tests drove them through ProgramStore, getUI() and steps.

Changes

Tests only: 48 files in src/programs.

  • run-program.test.ts is rewritten for runProgram on a SessionStore: detection, the run definition, the preflight (outage, settings conflicts), the order of each step, composed runs through the workflow, the audit ledger cleanup and diagnostics.
  • New: login.test.ts (logIn), api-key-login.test.ts, session/__tests__/interaction.test.ts (storeInteraction dismisses an open question on abort), detection/__tests__/detected-framework.test.ts, warehouse-decline.test.ts and warehouse-source/__tests__/reporting.test.ts.
  • Locks main's behavior that review fixes restored: a --ci ciPreRun gets the login it asked for, so the monorepo scan sees it; a stop decided during detection ends the run as aborted; a failed login is tried again, not cached; the CI login line; a composed run ends completed; the framework variant label on CI and TUI runs.
  • Moved with the code: metrics-program.test.ts to metrics/__tests__/metrics.test.ts, test/runner-context.ts to shared/__tests__/runner-context.no-jest.ts, the OAuth scope checks from the TUI's OAuth tests into oauth/__tests__/tokens.test.ts, session-properties.test.ts and session/__tests__/ask-policy.test.ts from the shared tests.
  • Updated: the detection tests (agentic-progress, agentic-retry, integration) pass onProgress instead of a UI, and program tests read each folder's config.
  • The rest are import and helper updates.

Test plan

Created with PostHog Desktop

@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci ai-observability
  • /wizard-ci basic-integration
  • /wizard-ci feature-flags
  • /wizard-ci mcp-analytics
  • /wizard-ci replay-vision
  • /wizard-ci revenue
  • /wizard-ci self-driving
  • /wizard-ci warehouse
  • /wizard-ci warehouse-seeded

Test an individual app:

  • /wizard-ci ai-observability/anthropic
  • /wizard-ci ai-observability/google-adk
  • /wizard-ci ai-observability/groq
Show more apps
  • /wizard-ci ai-observability/manual-capture
  • /wizard-ci ai-observability/openai
  • /wizard-ci ai-observability/openai-agents
  • /wizard-ci ai-observability/opentelemetry
  • /wizard-ci ai-observability/vercel-ai
  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/flutter
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci feature-flags/django
  • /wizard-ci feature-flags/next-js
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci replay-vision/javascript-node
  • /wizard-ci replay-vision/next-js
  • /wizard-ci replay-vision/react-vite
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit
  • /wizard-ci warehouse/monorepo-env
  • /wizard-ci warehouse/multi-source-next
  • /wizard-ci warehouse/stripe-node
  • /wizard-ci warehouse/zero-source
  • /wizard-ci warehouse-seeded/next-stripe
  • /wizard-ci warehouse-seeded/next-stripe-declined

Test against a Context Mill branch:

  • /wizard-ci all context-mill:my-branch

Add context-mill:<branch> to any command above to pin the Context Mill branch. It defaults to main.

Results will be posted here when complete.

@gewenyu99
gewenyu99 added this pull request to stack #1394 September 29, 2026 09:41
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-15-tests-for-the-programs-layer branch from 442ac61 to 353e334 Compare September 30, 2026 08:06
@gewenyu99
gewenyu99 removed this pull request from stack #1394 September 30, 2026 08:07
@gewenyu99
gewenyu99 added this pull request to stack #1400 September 30, 2026 08:07
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-15-tests-for-the-programs-layer branch from 353e334 to 1b87318 Compare September 30, 2026 08:44
@gewenyu99
gewenyu99 marked this pull request as ready for review September 30, 2026 09:16
@gewenyu99
gewenyu99 requested review from a team as code owners September 30, 2026 09:16
@gewenyu99
gewenyu99 requested review from TueHaulund, ablaszkiewicz, arnohillen, fasyy612, hpouillot and ksvat and removed request for a team, TueHaulund and fasyy612 September 30, 2026 09:16
@gewenyu99
gewenyu99 requested review from a team, TueHaulund, arnohillen, fasyy612 and ksvat and removed request for a team, TueHaulund, ablaszkiewicz, arnohillen, fasyy612, hpouillot and ksvat September 30, 2026 09:16
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-15-tests-for-the-programs-layer branch from 1b87318 to cb520c2 Compare September 30, 2026 14:11
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-15-tests-for-the-programs-layer branch from cb520c2 to 0392737 Compare October 1, 2026 06:43
@gewenyu99
gewenyu99 removed this pull request from stack #1400 October 1, 2026 06:47
@gewenyu99
gewenyu99 added this pull request to stack #1403 October 1, 2026 06:47

@johncwaters johncwaters left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Automated review. Not written by a human.

expect(s.session.aiSdkStampReported).toBe(true);
});

it('keeps a throwing observer and a late event as diagnostics, not failures', async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Automated review. Not written by a human.

The title says a late event is kept as a diagnostic, but this test can't see that. runProgram copies progress.diagnostics() before it returns (run-program.ts line 139), and late?.(...) fires after that, so the late record goes into a list nothing reads. A regression that stopped recording late events would still pass.

Drop "a late event" from the title, or expose the late diagnostic somewhere the test can read it.

},
);

it('a program that needs no AI runs without an approval', async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Automated review. Not written by a human.

Nothing replaces this for the rule that now decides approval: needsAiApproval skips it for ci and signup sessions (run-program.ts lines 524-532). Every ci: true case in the new file logs in with an org that already approved AI, and every login(null) case is non-CI, so dropping !session.ci or !session.signup would fail no test.

Add an it.each over { ci: true } and { signup: true } stores with credentials: login(null) and no workflow, asserting RunOutcome.Success and one runAgent call.

// `reportWarehouseSourcesDetected` alone cannot fix, since it only knows
// about consent, not login state).
it('stamps once authenticate() completes, not when consent resolves first', async () => {
it('stamps once the login completes, not when consent resolves first', async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Automated review. Not written by a human.

This claims runProgram stamps after login, but it calls the local stampAfterLogin copy, which reads session.apiUser while runProgram passes credentials.apiUser. A regression in runProgram's ordering, arguments or once-guard can't fail it.

Narrow the title to what stampAiSdkDetected gates on its own, or move the ordering claim into run-program.test.ts.

);
});

it('fits every area in the checks viewer column', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Automated review. Not written by a human.

This removes the check that every seeded area fits COL_AREA_WIDTH, and nothing in this PR replaces it. The constant still exists in the TUI layout. Does a TUI-layer PR later in the stack add the check back? If not, it could move into a TUI test.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Covered: src/tui/programs/audit/__tests__/checks-viewer-layout.test.ts checks every AUDIT_SEED_CHECKS area fits COL_AREA_WIDTH (lands in #1389).

expect(result.posthog.host.region).toBe('eu');
});

it('reports the CI login line, as main printed it', async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Automated review. Not written by a human.

This pins the exact prose Using provided API key (CI mode - OAuth bypassed). AGENTS.md says "Do not add tests for prose", but the PR description says locking main's CI login line is deliberate. Is the copy pin worth keeping? The region and retry tests in this file keep the behavioral coverage either way.

expect(shouldDisableAsk(session)).toBe(true);
});

it('re-enables the bridge when the harness asks for it', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Automated review. Not written by a human.

The src/shared/__tests__/ask-policy.test.ts truth table already has the { ci: true, e2eAsk: true } row. This case adds only that buildSession passes e2eAsk through. Is that pass-through worth its own test?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping this one. The shared table only tests shouldDisableAsk; this is the only case that fails if buildSession stops passing e2eAsk through.

@@ -0,0 +1,46 @@
/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Automated review. Not written by a human.

This adds a 5-line header here and a 3-line narration at lines 33-35. AGENTS.md asks to keep new comments to one line, and the describe/it names already carry this intent.

@@ -1,49 +1,27 @@
import { Harness } from '@shared/constants';
/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Automated review. Not written by a human.

This header points at other test files, and nothing keeps those pointers true. Per the one-line comment rule in AGENTS.md, trim it to one line or drop it.

@@ -1,52 +1,28 @@
/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Automated review. Not written by a human.

Same as the other headers: this one lists what other files lock in, and those claims will drift. Trim it to one line or drop it.

@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-15-tests-for-the-programs-layer branch from 0392737 to be1ef32 Compare October 2, 2026 16:47
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-15-tests-for-the-programs-layer branch from be1ef32 to b91e463 Compare October 2, 2026 20:50
Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-15-tests-for-the-programs-layer branch from b91e463 to 8d1b5ea Compare October 3, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants