@@ -306,6 +306,47 @@ describe("basecampOnboardingAdapter", () => {
306306 expect ( account . oauthClientSecret ) . toBeUndefined ( ) ;
307307 // Channel-level oauth should be set from prompted creds
308308 expect ( result . cfg . channels . basecamp . oauth ?. clientId ) . toBe ( "test-client-id" ) ;
309+ // Defaults persisted for fresh onboarding
310+ expect ( result . cfg . channels . basecamp . dmPolicy ) . toBe ( "pairing" ) ;
311+ expect ( result . cfg . channels . basecamp . engage ) . toEqual ( [ "dm" , "mention" , "assignment" , "checkin" ] ) ;
312+ } ) ;
313+
314+ it ( "re-running configure preserves existing dmPolicy and engage values" , async ( ) => {
315+ mockCliProfileListFull . mockRejectedValue ( new Error ( "not installed" ) ) ;
316+ mockResolveTokenFilePath . mockReturnValue ( "/tmp/tokens/default.json" ) ;
317+ mockInteractiveLogin . mockResolvedValue ( {
318+ accessToken : "tok" ,
319+ refreshToken : "ref" ,
320+ tokenType : "Bearer" ,
321+ } ) ;
322+ mockDiscoverIdentity . mockResolvedValue ( {
323+ identity : { id : 42 , firstName : "Bot" , lastName : "" , emailAddress : "b@t.com" } ,
324+ accounts : [ { id : 100 , name : "Co" , product : "bc3" } ] ,
325+ } ) ;
326+
327+ const prompter = createPrompter ( {
328+ selectAnswers : [ "done" ] ,
329+ } ) ;
330+
331+ const existingCfg = cfg ( {
332+ dmPolicy : "disabled" ,
333+ engage : [ "dm" ] ,
334+ oauth : { clientId : "aabbccdd00112233445566778899aabbccddeeff" } ,
335+ accounts : { default : { personId : "42" , oauthTokenFile : "/tmp/tokens/default.json" } } ,
336+ } ) ;
337+
338+ const result = await basecampOnboardingAdapter . configure ( {
339+ cfg : existingCfg ,
340+ runtime : { } as any ,
341+ prompter,
342+ accountOverrides : { } ,
343+ shouldPromptAccountIds : false ,
344+ forceAllowFrom : false ,
345+ } ) ;
346+
347+ // Existing values must survive — not overwritten with defaults
348+ expect ( result . cfg . channels . basecamp . dmPolicy ) . toBe ( "disabled" ) ;
349+ expect ( result . cfg . channels . basecamp . engage ) . toEqual ( [ "dm" ] ) ;
309350 } ) ;
310351
311352 it ( "uses existing channel-level OAuth clientId without prompting" , async ( ) => {
0 commit comments