Comfy-Org / Comfy-Org/ComfyUI_frontend
Fail closed for external PostHog ingest hosts in browser tests
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 704
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 512
Description
## Summary
Make the browser-test telemetry mock fail closed for PostHog ingest hosts.
`browser_tests/tests/agent/agentPanelMocks.ts` currently intercepts the fallback ingest host, `**://t.comfy.org/**`. `PostHogTelemetryProvider` can instead use `window.__CONFIG__?.posthog_api_host` or a host supplied through `posthog_config`. If a test payload adds one of these hosts, the request can bypass the route and contact an external service.
## Required changes
- Update the shared browser-test telemetry mock or helper to prevent telemetry requests to non-local hosts from leaving the test browser.
- Keep the current mocked success response for expected PostHog ingest requests, or provide an equivalent deterministic response.
- Ensure the solution handles both the fallback host and hosts configured through `window.__CONFIG__?.posthog_api_host` or `posthog_config`.
- Keep local test-server traffic available when it is required by browser tests.
## Rationale
Browser tests must not emit live third-party telemetry. A fail-closed mock makes new PostHog host configuration visible during test development instead of silently allowing external traffic.
## Affected area
- `browser_tests/tests/agent/agentPanelMocks.ts`
- Shared browser-test network mocking helpers, if a shared helper is the appropriate location
- `PostHogTelemetryProvider` configuration behavior
## Acceptance criteria
- A configured non-local PostHog API host cannot produce a live network request during browser tests.
- The fallback PostHog ingest host remains mocked.
- The test behavior is deterministic and does not require access to an external telemetry service.
- Existing browser tests that require local application requests continue to work.
## References
- Deferred from PR #16477: https://github.com/Comfy-Org/ComfyUI_frontend/pull/16477
- Review comment: https://github.com/Comfy-Org/ComfyUI_frontend/pull/16477#discussion_r3904277562
- Requested by @christian-byrne.
Contributor guide
Assessment
This issue has not been assessed yet.