@@ -185,9 +185,60 @@ describe('BrvConfig', () => {
185185 } )
186186 } )
187187
188+ describe ( 'withoutSpace' , ( ) => {
189+ it ( 'should create new config with space fields cleared, preserving all other fields' , ( ) => {
190+ const original = new BrvConfig ( validConstructorArgs )
191+ const cleared = original . withoutSpace ( )
192+
193+ expect ( cleared . spaceId ) . to . be . undefined
194+ expect ( cleared . spaceName ) . to . be . undefined
195+ expect ( cleared . teamId ) . to . be . undefined
196+ expect ( cleared . teamName ) . to . be . undefined
197+ expect ( cleared . chatLogPath ) . to . equal ( original . chatLogPath )
198+ expect ( cleared . cwd ) . to . equal ( original . cwd )
199+ expect ( cleared . ide ) . to . equal ( original . ide )
200+ expect ( cleared . createdAt ) . to . equal ( original . createdAt )
201+ expect ( cleared . version ) . to . equal ( original . version )
202+ } )
203+
204+ it ( 'should not mutate the original config' , ( ) => {
205+ const original = new BrvConfig ( validConstructorArgs )
206+ original . withoutSpace ( )
207+
208+ expect ( original . spaceId ) . to . equal ( validConstructorArgs . spaceId )
209+ expect ( original . teamId ) . to . equal ( validConstructorArgs . teamId )
210+ } )
211+
212+ it ( 'should produce a config that is not cloud-connected' , ( ) => {
213+ const original = new BrvConfig ( validConstructorArgs )
214+ expect ( original . isCloudConnected ( ) ) . to . be . true
215+ expect ( original . withoutSpace ( ) . isCloudConnected ( ) ) . to . be . false
216+ } )
217+
218+ it ( 'should preserve non-space fields (cipherAgent fields) through withoutSpace' , ( ) => {
219+ const original = new BrvConfig ( {
220+ ...validConstructorArgs ,
221+ cipherAgentContext : 'context-payload' ,
222+ cipherAgentModes : [ 'mode-a' , 'mode-b' ] ,
223+ cipherAgentSystemPrompt : 'system-prompt-text' ,
224+ } )
225+ const cleared = original . withoutSpace ( )
226+
227+ expect ( cleared . cipherAgentContext ) . to . equal ( 'context-payload' )
228+ expect ( cleared . cipherAgentModes ) . to . deep . equal ( [ 'mode-a' , 'mode-b' ] )
229+ expect ( cleared . cipherAgentSystemPrompt ) . to . equal ( 'system-prompt-text' )
230+ } )
231+ } )
232+
188233 describe ( 'fromSpace' , ( ) => {
189234 it ( 'should create config from Space entity with current version' , ( ) => {
190- const space = new Space ( { id : 'space-789' , isDefault : false , name : 'my-space' , teamId : 'team-abc' , teamName : 'my-team' } )
235+ const space = new Space ( {
236+ id : 'space-789' ,
237+ isDefault : false ,
238+ name : 'my-space' ,
239+ teamId : 'team-abc' ,
240+ teamName : 'my-team' ,
241+ } )
191242
192243 const config = BrvConfig . fromSpace ( {
193244 chatLogPath : '/path/to/logs' ,
@@ -203,6 +254,5 @@ describe('BrvConfig', () => {
203254 expect ( config . teamName ) . to . equal ( 'my-team' )
204255 expect ( config . createdAt ) . to . be . a ( 'string' )
205256 } )
206-
207257 } )
208258} )
0 commit comments