Skip to content

test: ignore leaked requests in push and survey translation tests - #892

Merged
turnipdabeets merged 1 commit into
mainfrom
test/isolate-push-test-requests
Oct 1, 2026
Merged

turnipdabeets merged 1 commit into
mainfrom
test/isolate-push-test-requests

Conversation

@turnipdabeets

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Two more Swift Testing failures with the same cause as #885: a test reads a request sent by another test's still-running SDK instance.

Test CI failure
PostHogPushNotificationTest "registerPushNotificationToken with an explicit appId sends a request" (#889, run) device_token → "tok", app_id → "app": another push test's registration
PostHogSurveyTranslationsTest "survey sent reports each question in the language it was answered in" (#886 re-run; #869) events.first { $0.event == "survey sent" } → nil: another SDK's batch satisfied the wait first

Changes:

  • MockPostHogServer gets pushSubscriptionProjectToken. It works like test: ignore other SDK instances' batches in session event tests #885's batchProjectToken, but for /push_subscriptions: requests with a different api_key get a 200 response and aren't recorded.
  • PostHogPushNotificationTest uses a per-test push_<UUID> token instead of the shared testProjectToken, and enables both filters.
  • Both survey translation suites that read the server enable batchProjectToken. Their SDKs already use a UUID token per test.

Test-only.

💚 How did you test it?

Reproduced each failure with an SDK that sends the same kind of request during the test (iOS 26 simulator):

Suite main + repro this branch + repro
PostHogPushNotificationTest: an SDK on the shared token registers tok/app ❌ device_token → "tok" (same as CI) ✅ 108/108
PostHogSurveyTranslationsTest: an SDK with another token captures an event ❌ "survey sent" → nil (same as CI) ✅ 44/44
  • make lint: no new violations.

Other Swift Testing suites that read /batch or /push_subscriptions without a filter are left for a follow-up. Several of them need individual care: PostHogApiTest asserts api_key == "test_project_token", PostHogExceptionStepsTest deliberately uses two tokens, and PostHogEventSnapshotTests stores its token in a golden file.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Found with Claude Code (Claude Opus 5.5) while getting #886 and #889 green. It follows the pattern from #885.

🤖 Generated with Claude Code

Push tests get a per-test token with batch and push-subscription filtering; survey translation suites enable batch filtering.
@turnipdabeets
turnipdabeets requested a review from a team as a code owner October 1, 2026 19:53
@turnipdabeets turnipdabeets self-assigned this Oct 1, 2026
@turnipdabeets
turnipdabeets enabled auto-merge (squash) October 1, 2026 19:59
@turnipdabeets
turnipdabeets merged commit 750ee11 into main Oct 1, 2026
47 checks passed
@turnipdabeets
turnipdabeets deleted the test/isolate-push-test-requests branch October 1, 2026 20:28
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