@@ -416,6 +416,35 @@ describe('Launcher', function () {
416416 pkg . name . should . eqls ( 'TEST_PROJECT' )
417417 pkg . version . should . eqls ( '0.0.0-aaaabbbbcccc' )
418418 } )
419+ it ( 'Removes nr-assistant from package.json when assistant is explicitly disabled' , async function ( ) {
420+ const snapshot = JSON . parse ( JSON . stringify ( setup . snapshot ) )
421+ snapshot . modules [ '@flowfuse/nr-assistant' ] = '0.1.0'
422+ const settings = { assistant : { enabled : false } }
423+ const launcher = newLauncher ( { config } , null , 'projectId' , snapshot , settings )
424+ await launcher . writePackage ( )
425+ const pkgFile = await fs . readFile ( path . join ( config . dir , 'project' , 'package.json' ) )
426+ const pkg = JSON . parse ( pkgFile )
427+ pkg . dependencies . should . not . have . property ( '@flowfuse/nr-assistant' )
428+ } )
429+ it ( 'Keeps nr-assistant in package.json when assistant is enabled' , async function ( ) {
430+ const snapshot = JSON . parse ( JSON . stringify ( setup . snapshot ) )
431+ snapshot . modules [ '@flowfuse/nr-assistant' ] = '0.1.0'
432+ const settings = { assistant : { enabled : true } }
433+ const launcher = newLauncher ( { config } , null , 'projectId' , snapshot , settings )
434+ await launcher . writePackage ( )
435+ const pkgFile = await fs . readFile ( path . join ( config . dir , 'project' , 'package.json' ) )
436+ const pkg = JSON . parse ( pkgFile )
437+ pkg . dependencies . should . have . property ( '@flowfuse/nr-assistant' , '0.1.0' )
438+ } )
439+ it ( 'Keeps nr-assistant in package.json when assistant settings are not configured' , async function ( ) {
440+ const snapshot = JSON . parse ( JSON . stringify ( setup . snapshot ) )
441+ snapshot . modules [ '@flowfuse/nr-assistant' ] = '0.1.0'
442+ const launcher = newLauncher ( { config } , null , 'projectId' , snapshot )
443+ await launcher . writePackage ( )
444+ const pkgFile = await fs . readFile ( path . join ( config . dir , 'project' , 'package.json' ) )
445+ const pkg = JSON . parse ( pkgFile )
446+ pkg . dependencies . should . have . property ( '@flowfuse/nr-assistant' , '0.1.0' )
447+ } )
419448
420449 it ( 'Updates package.json with user defined Node-RED version' , async function ( ) {
421450 const newSettings = {
0 commit comments