diff --git a/packages/@dcl/sdk-commands/src/commands/start/explorer-alpha.ts b/packages/@dcl/sdk-commands/src/commands/start/explorer-alpha.ts index 4b5efefd9..ac81fc534 100644 --- a/packages/@dcl/sdk-commands/src/commands/start/explorer-alpha.ts +++ b/packages/@dcl/sdk-commands/src/commands/start/explorer-alpha.ts @@ -4,12 +4,6 @@ import { CliComponents } from '../../components' const isWindows = /^win/.test(process.platform) -// Helper function to convert string to boolean -function stringToBoolean(value: string | undefined, defaultValue: boolean = true): boolean { - if (!value) return defaultValue - return value.toLowerCase() === 'true' -} - export async function runExplorerAlpha( components: CliComponents, opts: { @@ -48,27 +42,32 @@ async function runApp( const cmd = isWindows ? 'start' : 'open' const position = args['--position'] ?? `${baseCoords.x},${baseCoords.y}` const realm = args['--realm'] ?? realmValue - const localScene = stringToBoolean(args['--local-scene'], true) - const debug = stringToBoolean(args['--debug'], true) const dclenv = args['--dclenv'] ?? 'org' - const skipAuthScreen = stringToBoolean(args['--skip-auth-screen'], true) - const landscapeTerrainEnabled = stringToBoolean(args['--landscape-terrain-enabled'], true) - const openDeeplinkInNewInstance = args['-n'] + const skipAuthScreen = !!args['--skip-auth-screen'] + const landscapeTerrainEnabled = !!args['--landscape-terrain-enabled'] + const openDeeplinkInNewInstance = !!args['-n'] try { const params = new URLSearchParams() params.set('realm', realm) params.set('position', position) - params.set('local-scene', localScene.toString()) - params.set('debug', debug.toString()) - params.set('hub', isHub.toString()) params.set('dclenv', dclenv) - params.set('skip-auth-screen', skipAuthScreen.toString()) - params.set('landscape-terrain-enabled', landscapeTerrainEnabled.toString()) + params.set('local-scene', 'true') + params.set('debug', 'true') + + if (isHub) { + params.set('hub', 'true') + } + if (skipAuthScreen) { + params.set('skip-auth-screen', 'true') + } + if (landscapeTerrainEnabled) { + params.set('landscape-terrain-enabled', 'true') + } if (openDeeplinkInNewInstance) { - params.set('open-deeplink-in-new-instance', openDeeplinkInNewInstance.toString()) + params.set('open-deeplink-in-new-instance', 'true') } const queryParams = params.toString() diff --git a/packages/@dcl/sdk-commands/src/commands/start/index.ts b/packages/@dcl/sdk-commands/src/commands/start/index.ts index acb7f706a..2585f9ba4 100644 --- a/packages/@dcl/sdk-commands/src/commands/start/index.ts +++ b/packages/@dcl/sdk-commands/src/commands/start/index.ts @@ -53,13 +53,13 @@ export const args = declareArgs({ '--explorer-alpha': Boolean, '--hub': Boolean, // Params related to the explorer-alpha - '--debug': String, + '--debug': Boolean, '--dclenv': String, '--realm': String, - '--local-scene': String, + '--local-scene': Boolean, '--position': String, - '--skip-auth-screen': String, - '--landscape-terrain-enabled': String, + '--skip-auth-screen': Boolean, + '--landscape-terrain-enabled': Boolean, '-n': Boolean }) diff --git a/test/sdk-commands/commands/start/explorer-alpha.spec.ts b/test/sdk-commands/commands/start/explorer-alpha.spec.ts index 8af64e0e8..2deeaf161 100644 --- a/test/sdk-commands/commands/start/explorer-alpha.spec.ts +++ b/test/sdk-commands/commands/start/explorer-alpha.spec.ts @@ -32,16 +32,13 @@ describe('explorer-alpha', () => { jest.restoreAllMocks() }) - describe('stringToBoolean function', () => { - it('should return true for "true" string', async () => { - // We need to test the internal stringToBoolean function - // Since it's not exported, we'll test it through the runExplorerAlpha function - // by checking the URL parameters + describe('boolean parameters', () => { + it('should always include local-scene and debug parameters', async () => { const args: any = { - '--local-scene': 'true', - '--debug': 'true', - '--skip-auth-screen': 'true', - '--landscape-terrain-enabled': 'true' + '--local-scene': true, + '--debug': true, + '--skip-auth-screen': true, + '--landscape-terrain-enabled': true } await runExplorerAlpha(mockComponents, { @@ -60,12 +57,12 @@ describe('explorer-alpha', () => { ) }) - it('should return false for "false" string', async () => { + it('should always include local-scene and debug even when they are false', async () => { const args: any = { - '--local-scene': 'false', - '--debug': 'false', - '--skip-auth-screen': 'false', - '--landscape-terrain-enabled': 'false' + '--local-scene': false, + '--debug': false, + '--skip-auth-screen': false, + '--landscape-terrain-enabled': false } await runExplorerAlpha(mockComponents, { @@ -79,12 +76,12 @@ describe('explorer-alpha', () => { expect(mockExec).toHaveBeenCalledWith( '/test', 'open', - expect.arrayContaining([expect.stringContaining('local-scene=false')]), + expect.arrayContaining([expect.stringContaining('local-scene=true')]), { silent: true } ) }) - it('should return default value (true) for undefined values', async () => { + it('should always include local-scene and debug even when they are undefined', async () => { const args: any = {} await runExplorerAlpha(mockComponents, { @@ -102,35 +99,6 @@ describe('explorer-alpha', () => { { silent: true } ) }) - - it('should handle case-insensitive boolean strings', async () => { - const args: any = { - '--local-scene': 'TRUE', - '--debug': 'False', - '--skip-auth-screen': 'True', - '--landscape-terrain-enabled': 'FALSE' - } - - await runExplorerAlpha(mockComponents, { - cwd: '/test', - realm: 'test-realm', - baseCoords: { x: 0, y: 0 }, - isHub: false, - args - }) - - expect(mockExec).toHaveBeenCalledWith( - '/test', - 'open', - expect.arrayContaining([ - expect.stringContaining('local-scene=true'), - expect.stringContaining('debug=false'), - expect.stringContaining('skip-auth-screen=true'), - expect.stringContaining('landscape-terrain-enabled=false') - ]), - { silent: true } - ) - }) }) describe('openDeeplinkInNewInstance parameter', () => { @@ -180,11 +148,11 @@ describe('explorer-alpha', () => { const args: any = { '--position': '10,20', '--realm': 'custom-realm', - '--local-scene': 'true', - '--debug': 'false', + '--local-scene': true, + '--debug': false, '--dclenv': 'zone', - '--skip-auth-screen': 'true', - '--landscape-terrain-enabled': 'false', + '--skip-auth-screen': true, + '--landscape-terrain-enabled': false, '-n': true } @@ -199,13 +167,23 @@ describe('explorer-alpha', () => { expect(mockExec).toHaveBeenCalledWith( '/test', 'open', - expect.arrayContaining([ - expect.stringMatching( - /decentraland:\/\/.*realm=custom-realm.*position=10%2C20.*local-scene=true.*debug=false.*hub=true.*dclenv=zone.*skip-auth-screen=true.*landscape-terrain-enabled=false.*open-deeplink-in-new-instance=true/ - ) - ]), + expect.arrayContaining([expect.stringMatching(/decentraland:\/\/".*"$/)]), { silent: true } ) + + // Check that all expected parameters are present + const callArgs = mockExec.mock.calls[0][2][0] + expect(callArgs).toContain('realm=custom-realm') + expect(callArgs).toContain('position=10%2C20') + expect(callArgs).toContain('dclenv=zone') + expect(callArgs).toContain('local-scene=true') + expect(callArgs).toContain('debug=true') + expect(callArgs).toContain('hub=true') + expect(callArgs).toContain('skip-auth-screen=true') + expect(callArgs).toContain('open-deeplink-in-new-instance=true') + + // Check that false parameters are not present + expect(callArgs).not.toContain('landscape-terrain-enabled=true') }) it('should use default values when parameters are not provided', async () => { @@ -224,7 +202,7 @@ describe('explorer-alpha', () => { 'open', expect.arrayContaining([ expect.stringMatching( - /decentraland:\/\/.*realm=default-realm.*position=5%2C10.*local-scene=true.*debug=true.*hub=false.*dclenv=org.*skip-auth-screen=true.*landscape-terrain-enabled=true/ + /decentraland:\/\/.*realm=default-realm.*position=5%2C10.*dclenv=org.*local-scene=true.*debug=true/ ) ]), { silent: true }