feat(surveys): auto-submit rating and single-choice selections - #808
feat(surveys): auto-submit rating and single-choice selections#808lucasheriques wants to merge 3 commits into
Conversation
Decode skipSubmitButton and expose it on public display questions. Hide the submit button and advance when a rating or eligible single choice is selected. Retain explicit submission for multi-select and open-choice questions, matching posthog-js. Reset selection state between consecutive eligible questions. Verified red/green mapping and eligibility tests; 79 survey tests on macOS; 84 survey tests on iOS 26.5 simulator; make lint; updated public API snapshot. CodeScene quality gate passed; legacy test-file health remains stable.
Prompt To Fix All With AI### Issue 1
PostHog/Surveys/QuestionTypes.swift:155-159
**Auto-submit wiring lacks coverage**
The new tests verify decoding and eligibility, but they do not exercise the SwiftUI behavior added here. There is no interaction test confirming that selecting a rating or single choice calls `onNextQuestion` exactly once with the correct answer, hides the submit button, and resets selection state when the question changes. A regression in this core behavior could therefore pass the test suite. Please add an interaction test that hosts the affected question views or `SurveySheet` and verifies these behaviors.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "feat(surveys): auto-submit rating and si..." | Re-trigger Greptile |
| .onChange(of: rating) { value in | ||
| if question.skipSubmitButton, let value { | ||
| onNextQuestion(value) | ||
| } | ||
| .disabled(!canSubmit) | ||
| } |
There was a problem hiding this comment.
Auto-submit wiring lacks coverage
The new tests verify decoding and eligibility, but they do not exercise the SwiftUI behavior added here. There is no interaction test confirming that selecting a rating or single choice calls onNextQuestion exactly once with the correct answer, hides the submit button, and resets selection state when the question changes. A regression in this core behavior could therefore pass the test suite. Please add an interaction test that hosts the affected question views or SurveySheet and verifies these behaviors.
Prompt To Fix With AI
This is a comment left during a code review.
Path: PostHog/Surveys/QuestionTypes.swift
Line: 155-159
Comment:
**Auto-submit wiring lacks coverage**
The new tests verify decoding and eligibility, but they do not exercise the SwiftUI behavior added here. There is no interaction test confirming that selecting a rating or single choice calls `onNextQuestion` exactly once with the correct answer, hides the submit button, and resets selection state when the question changes. A regression in this core behavior could therefore pass the test suite. Please add an interaction test that hosts the affected question views or `SurveySheet` and verifies these behaviors.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
CI exposed a race between forced survey loading and the remote-config listener's flag refresh. Seed survey data separately and await flag loading, matching the neighboring feature-flag eligibility test. The matching suite passes (10 tests), and the previously failing test passes 10 consecutive runs. CodeScene gate passed with stable test-file health.
posthog-ios Compliance ReportDate: 2026-09-08 20:35:55 UTC ✅ All Tests Passed!45/45 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 16/16 tests passed View Details
|
Submit from the selection bindings used by numeric/emoji ratings and single-choice controls. This makes auto-submit synchronous with selection and allows direct callback regression tests without new dependencies. Cover eligible and disabled flags, open options, answer values, and clearing a selection. Keep explicit submission and per-question view identity. Verification: make testOniOSSimulator and make lint passed. CodeScene gate passed; the existing large survey test file stayed stable. Tests exercise the production bindings, not automated taps or visual button visibility.
Motivation and Context
A survey question configured with
skipSubmitButtonnow advances when the user selects a rating or a single choice, without an extra submit tap. The setting was previously discarded during decoding.Match posthog-js: retain the submit button for multi-select questions and for any single-choice question with an open-ended option. Expose the raw setting to custom delegates, default missing settings to false, and reset rating/single-choice selection state between question IDs so consecutive questions do not inherit answers.
Closes #448. Independent of the partial-response change in #807.
Testing
make test filter=PostHogSurveysTest: 79 tests passed.xcodebuild test -only-testing:PostHogTests/PostHogSurveysTest(includes the iOS-specific build).make testOniOSSimulatorpassed with the added callback tests. These exercise production bindings; automated view tapping and visual button visibility remain outside this coverage.make lintpassed; public API snapshot updated and checked.Includes a minor release changeset. Compatibility-table minimum versions can be updated after release.