@@ -520,7 +520,70 @@ describe('Launcher', function () {
520520 const npmrc = await fs . readFile ( path . join ( config . dir , 'project' , '.npmrc' ) )
521521 npmrc . toString ( ) . should . eql ( '// test\n' )
522522 } )
523-
523+ it ( 'Keeps legacy theme name' , async function ( ) {
524+ const copyOfSnapshot = JSON . parse ( JSON . stringify ( setup . snapshot ) )
525+ copyOfSnapshot . modules [ 'node-red' ] = '4.2.0'
526+ copyOfSnapshot . editorTheme = { theme : 'forge-dark' } // old theme
527+ const launcher = newLauncher ( { config : { ...config , theme : 'forge-dark' } } , null , 'projectId' , copyOfSnapshot )
528+ await launcher . writeSettings ( )
529+ const setFile = await fs . readFile ( path . join ( config . dir , 'project' , 'settings.json' ) )
530+ const settings = JSON . parse ( setFile )
531+ settings . should . have . property ( 'editorTheme' )
532+ settings . editorTheme . should . have . property ( 'theme' , 'forge-dark' )
533+ } )
534+ it ( 'Updates legacy theme name for Node-RED >= 5.0.0' , async function ( ) {
535+ const copyOfSnapshot = JSON . parse ( JSON . stringify ( setup . snapshot ) )
536+ copyOfSnapshot . modules [ 'node-red' ] = '5.0.0'
537+ copyOfSnapshot . editorTheme = { theme : 'forge-light' } // old theme name
538+ const launcher = newLauncher ( { config : { ...config , theme : 'forge-light' } } , null , 'projectId' , copyOfSnapshot )
539+ await launcher . writeSettings ( )
540+ const setFile = await fs . readFile ( path . join ( config . dir , 'project' , 'settings.json' ) )
541+ const settings = JSON . parse ( setFile )
542+ settings . should . have . property ( 'editorTheme' )
543+ settings . editorTheme . should . have . property ( 'theme' , 'forge' ) // updated to forge
544+ } )
545+ it ( 'Updates legacy theme name for Node-RED "latest"' , async function ( ) {
546+ const copyOfSnapshot = JSON . parse ( JSON . stringify ( setup . snapshot ) )
547+ copyOfSnapshot . modules [ 'node-red' ] = 'latest'
548+ copyOfSnapshot . editorTheme = { theme : 'forge-light' } // old theme name
549+ const launcher = newLauncher ( { config : { ...config , theme : 'forge-light' } } , null , 'projectId' , copyOfSnapshot )
550+ await launcher . writeSettings ( )
551+ const setFile = await fs . readFile ( path . join ( config . dir , 'project' , 'settings.json' ) )
552+ const settings = JSON . parse ( setFile )
553+ settings . should . have . property ( 'editorTheme' )
554+ settings . editorTheme . should . have . property ( 'theme' , 'forge' ) // updated to forge
555+ } )
556+ it ( 'Updates legacy theme name for Node-RED "next"' , async function ( ) {
557+ const copyOfSnapshot = JSON . parse ( JSON . stringify ( setup . snapshot ) )
558+ copyOfSnapshot . modules [ 'node-red' ] = 'next'
559+ copyOfSnapshot . editorTheme = { theme : 'forge-light' } // old theme name
560+ const launcher = newLauncher ( { config : { ...config , theme : 'forge-light' } } , null , 'projectId' , copyOfSnapshot )
561+ await launcher . writeSettings ( )
562+ const setFile = await fs . readFile ( path . join ( config . dir , 'project' , 'settings.json' ) )
563+ const settings = JSON . parse ( setFile )
564+ settings . should . have . property ( 'editorTheme' )
565+ settings . editorTheme . should . have . property ( 'theme' , 'forge' ) // updated to forge
566+ } )
567+ it ( 'Keeps custom theme name for Node-RED < 5.0.0' , async function ( ) {
568+ const copyOfSnapshot = JSON . parse ( JSON . stringify ( setup . snapshot ) )
569+ copyOfSnapshot . modules [ 'node-red' ] = '4.2.0'
570+ const launcher = newLauncher ( { config : { ...config , theme : 'custom-theme' } } , null , 'projectId' , copyOfSnapshot )
571+ await launcher . writeSettings ( )
572+ const setFile = await fs . readFile ( path . join ( config . dir , 'project' , 'settings.json' ) )
573+ const settings = JSON . parse ( setFile )
574+ settings . should . have . property ( 'editorTheme' )
575+ settings . editorTheme . should . have . property ( 'theme' , 'custom-theme' ) // keeps custom theme name
576+ } )
577+ it ( 'Keeps custom theme name for Node-RED >= 5.0.0' , async function ( ) {
578+ const copyOfSnapshot = JSON . parse ( JSON . stringify ( setup . snapshot ) )
579+ copyOfSnapshot . modules [ 'node-red' ] = '5.0.0'
580+ const launcher = newLauncher ( { config : { ...config , theme : 'custom-theme' } } , null , 'projectId' , copyOfSnapshot )
581+ await launcher . writeSettings ( )
582+ const setFile = await fs . readFile ( path . join ( config . dir , 'project' , 'settings.json' ) )
583+ const settings = JSON . parse ( setFile )
584+ settings . should . have . property ( 'editorTheme' )
585+ settings . editorTheme . should . have . property ( 'theme' , 'custom-theme' ) // keeps custom theme name
586+ } )
524587 it ( 'Uses custom catalogue when licensed' , async function ( ) {
525588 const licensedConfig = {
526589 ...config ,
0 commit comments