@@ -244,23 +244,31 @@ test("existing teammate evidence and identities survive contact enrichment", ()
244244 assert . equal ( contactUpdate ( profile , remote ( ) , "tips" ) . userId , "cap-user" ) ;
245245} ) ;
246246
247- test ( "migration joins a new list without overwriting any explicit preference" , ( ) => {
248- const profile = classifyProfile ( input ( ) ) ;
249- const update = importContactUpdate ( profile , remote ( ) , "new-list" ) ;
250- assert . deepEqual ( "mailingLists" in update && update . mailingLists , {
251- "new-list" : true ,
252- } ) ;
247+ test ( "migration preserves missing, removed and unsubscribed list preferences" , ( ) => {
248+ const profile = {
249+ ...classifyProfile ( input ( ) ) ,
250+ capOnboardingEligible : true ,
251+ capLifecycleEnabled : true ,
252+ capLifecycleStage : "free" ,
253+ } ;
254+ const update = importContactUpdate ( profile , remote ( ) , "tips" ) ;
255+ assert . equal ( "mailingLists" in update , false ) ;
253256 assert . equal ( update . capPromotionalEligible , true ) ;
254- assert . equal ( update . capLifecycleEnabled , false ) ;
257+ assert . equal ( update . capLifecycleEnabled , true ) ;
255258 assert . equal ( "subscribed" in update , false ) ;
256259 for ( const contact of [
257260 { ...remote ( ) , subscribed : false } ,
258- { ...remote ( ) , mailingLists : { "new-list" : false } } ,
261+ { ...remote ( ) , mailingLists : { } } ,
262+ { ...remote ( ) , mailingLists : { other : true } } ,
263+ { ...remote ( ) , mailingLists : { tips : false } } ,
259264 ] ) {
260- const held = importContactUpdate ( profile , contact , "new-list " ) ;
265+ const held = importContactUpdate ( profile , contact , "tips " ) ;
261266 assert . equal ( "mailingLists" in held , false ) ;
262267 assert . equal ( "subscribed" in held , false ) ;
263268 assert . equal ( held . capPromotionalEligible , false ) ;
269+ assert . equal ( held . capOnboardingEligible , false ) ;
270+ assert . equal ( held . capLifecycleEnabled , false ) ;
271+ assert . equal ( held . capLifecycleStage , "idle" ) ;
264272 }
265273} ) ;
266274
0 commit comments