@@ -62,38 +62,40 @@ describe("buildSurveyProperties", () => {
6262 test ( "shapes PostHog custom survey properties" , ( ) => {
6363 const props = buildSurveyProperties ( "ship it" , {
6464 turnTraceId : "trace-1" ,
65- env : {
66- CORBITS_FEEDBACK_SURVEY_ID : "survey-abc" ,
67- CORBITS_FEEDBACK_QUESTION_ID : "q-1" ,
68- } ,
6965 } ) ;
70- expect ( props . $survey_id ) . toBe ( "survey-abc " ) ;
66+ expect ( props . $survey_id ) . toBe ( "019fe7ff-d12a-0000-7a63-303f3a874b90 " ) ;
7167 expect ( props . $survey_response ) . toBe ( "ship it" ) ;
7268 expect ( props . turn_trace_id ) . toBe ( "trace-1" ) ;
7369 expect ( props . $survey_questions ) . toEqual ( [
7470 {
75- id : "q-1 " ,
76- question : "What feedback do you have for Corbits Code?" ,
71+ id : "913862f4-82aa-4814-8f68-146c05c38a74 " ,
72+ question : "What feedback do you have about Corbits Code?" ,
7773 response : "ship it" ,
7874 } ,
7975 ] ) ;
8076 } ) ;
77+
78+ test ( "env override can blank the survey ids" , ( ) => {
79+ const props = buildSurveyProperties ( "x" , {
80+ env : {
81+ CORBITS_FEEDBACK_SURVEY_ID : "" ,
82+ CORBITS_FEEDBACK_QUESTION_ID : "" ,
83+ } ,
84+ } ) ;
85+ expect ( props . $survey_id ) . toBe ( "" ) ;
86+ } ) ;
8187} ) ;
8288
8389describe ( "captureFeedback" , ( ) => {
8490 test ( "sends survey sent when ambient telemetry is off" , ( ) => {
8591 const { telemetry, events } = captureSpy ( ) ;
8692 expect ( telemetry . enabled ) . toBe ( false ) ;
87- const status = captureFeedback ( telemetry , "great product" , {
88- env : {
89- CORBITS_FEEDBACK_SURVEY_ID : "s1" ,
90- CORBITS_FEEDBACK_QUESTION_ID : "q1" ,
91- } ,
92- } ) ;
93+ const status = captureFeedback ( telemetry , "great product" ) ;
9394 expect ( status ) . toBe ( "sent" ) ;
9495 expect ( events ) . toHaveLength ( 1 ) ;
9596 expect ( events [ 0 ] ?. event ) . toBe ( "survey sent" ) ;
9697 expect ( events [ 0 ] ?. properties . $survey_response ) . toBe ( "great product" ) ;
98+ expect ( events [ 0 ] ?. properties . $survey_id ) . toBe ( "019fe7ff-d12a-0000-7a63-303f3a874b90" ) ;
9799 } ) ;
98100
99101 test ( "rejects empty text" , ( ) => {
@@ -110,14 +112,7 @@ describe("captureFeedback", () => {
110112 batch : { size : 100 , intervalMs : 60_000 , queueLimit : 100 } ,
111113 fetchFn : noopFetch ,
112114 } ) ;
113- expect (
114- captureFeedback ( telemetry , "hi" , {
115- env : {
116- CORBITS_FEEDBACK_SURVEY_ID : "s1" ,
117- CORBITS_FEEDBACK_QUESTION_ID : "q1" ,
118- } ,
119- } ) ,
120- ) . toBe ( "blocked" ) ;
115+ expect ( captureFeedback ( telemetry , "hi" ) ) . toBe ( "blocked" ) ;
121116 } ) ;
122117
123118 test ( "blocks under env kill switch even with identity" , ( ) => {
@@ -133,30 +128,28 @@ describe("captureFeedback", () => {
133128 } ) ;
134129 expect (
135130 captureFeedback ( telemetry , "hi" , {
136- env : {
137- CORBITS_TELEMETRY : "0" ,
138- CORBITS_FEEDBACK_SURVEY_ID : "s1" ,
139- CORBITS_FEEDBACK_QUESTION_ID : "q1" ,
140- } ,
131+ env : { CORBITS_TELEMETRY : "0" } ,
141132 } ) ,
142133 ) . toBe ( "blocked" ) ;
143134 } ) ;
144135
145- test ( "fails closed when survey ids are missing " , ( ) => {
136+ test ( "fails closed when survey ids are blanked via env " , ( ) => {
146137 const { telemetry, events } = captureSpy ( ) ;
147- expect ( captureFeedback ( telemetry , "hi" , { env : { } } ) ) . toBe ( "unconfigured" ) ;
138+ expect (
139+ captureFeedback ( telemetry , "hi" , {
140+ env : {
141+ CORBITS_FEEDBACK_SURVEY_ID : "" ,
142+ CORBITS_FEEDBACK_QUESTION_ID : "" ,
143+ } ,
144+ } ) ,
145+ ) . toBe ( "unconfigured" ) ;
148146 expect ( events ) . toHaveLength ( 0 ) ;
149147 } ) ;
150148
151149 test ( "reports truncation when free text exceeds the cap" , ( ) => {
152150 const { telemetry, events } = captureSpy ( ) ;
153151 const long = "x" . repeat ( FEEDBACK_MAX_CHARS + 50 ) ;
154- const status = captureFeedback ( telemetry , long , {
155- env : {
156- CORBITS_FEEDBACK_SURVEY_ID : "s1" ,
157- CORBITS_FEEDBACK_QUESTION_ID : "q1" ,
158- } ,
159- } ) ;
152+ const status = captureFeedback ( telemetry , long ) ;
160153 expect ( status ) . toBe ( "sent_truncated" ) ;
161154 expect ( events ) . toHaveLength ( 1 ) ;
162155 expect ( String ( events [ 0 ] ?. properties . $survey_response ) . length ) . toBe ( FEEDBACK_MAX_CHARS ) ;
0 commit comments