From 143668196e123c844299c9a6239bbf4a67a2d372 Mon Sep 17 00:00:00 2001 From: Marius456 Date: Wed, 13 Mar 2024 10:03:40 +0200 Subject: [PATCH 01/10] add fail sdk test --- .../src/__tests__/deviceManager.test.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 packages/sdk-webos/src/__tests__/deviceManager.test.ts diff --git a/packages/sdk-webos/src/__tests__/deviceManager.test.ts b/packages/sdk-webos/src/__tests__/deviceManager.test.ts new file mode 100644 index 000000000..914ca95f2 --- /dev/null +++ b/packages/sdk-webos/src/__tests__/deviceManager.test.ts @@ -0,0 +1,28 @@ +import { createRnvContext, getContext, getRealPath } from '@rnv/core'; +import { launchWebOSimulator } from '../deviceManager'; + +jest.mock('@rnv/core'); +jest.mock('path'); + +beforeEach(() => { + createRnvContext(); +}); + +afterEach(() => { + jest.resetAllMocks(); +}); + +describe('launchWebOSimulator', () => { + it('should fail if webos SDK path is not defined', async () => { + //GIVEN + const ctx = getContext(); + const target = true; + const errorMessage = `c.buildConfig.sdks.WEBOS_SDK undefined`; + + //WHEN + jest.mocked(getRealPath).mockReturnValue(undefined); + + //THEN + await expect(launchWebOSimulator(ctx, target)).rejects.toBe(errorMessage); + }); +}); From ad634a60eb256bfaf4f7f50d423b811b816c8a80 Mon Sep 17 00:00:00 2001 From: Marius456 Date: Tue, 19 Mar 2024 09:14:42 +0200 Subject: [PATCH 02/10] add success test --- .../src/__tests__/deviceManager.test.ts | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/sdk-webos/src/__tests__/deviceManager.test.ts b/packages/sdk-webos/src/__tests__/deviceManager.test.ts index 914ca95f2..f340ed3da 100644 --- a/packages/sdk-webos/src/__tests__/deviceManager.test.ts +++ b/packages/sdk-webos/src/__tests__/deviceManager.test.ts @@ -1,4 +1,4 @@ -import { createRnvContext, getContext, getRealPath } from '@rnv/core'; +import { createRnvContext, fsExistsSync, getContext, getDirectories, getRealPath, inquirerPrompt } from '@rnv/core'; import { launchWebOSimulator } from '../deviceManager'; jest.mock('@rnv/core'); @@ -25,4 +25,25 @@ describe('launchWebOSimulator', () => { //THEN await expect(launchWebOSimulator(ctx, target)).rejects.toBe(errorMessage); }); + + it('should ask to select sims if no target is specified and run it [macos]', async () => { + //GIVEN + const ctx = getContext(); + const target = true; + + //WHEN + jest.mocked(getRealPath).mockReturnValue('mock_webos_SDK_path'); + jest.mocked(getDirectories).mockReturnValue(['mock_sim_1', 'mock_sim_2']); + + jest.mocked(inquirerPrompt).mockResolvedValue({ selectedSimulator: 'mock_sim_1' }); + + // path.join.mockReturnValue('false'); + jest.mocked(fsExistsSync).mockReturnValue(true); + + jest.mock('@rnv/core', () => ({ isSystemWin: false, isSystemLinux: false })); + + //THEN + const result = await launchWebOSimulator(ctx, target); + expect(result).toEqual(true); + }); }); From 51ac1c4c69628df69577a80410bcb81b3fcad966 Mon Sep 17 00:00:00 2001 From: Marius456 Date: Tue, 19 Mar 2024 16:15:31 +0200 Subject: [PATCH 03/10] update tests --- .../src/__tests__/deviceManager.test.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/sdk-webos/src/__tests__/deviceManager.test.ts b/packages/sdk-webos/src/__tests__/deviceManager.test.ts index f340ed3da..f0b6237f4 100644 --- a/packages/sdk-webos/src/__tests__/deviceManager.test.ts +++ b/packages/sdk-webos/src/__tests__/deviceManager.test.ts @@ -19,10 +19,9 @@ describe('launchWebOSimulator', () => { const target = true; const errorMessage = `c.buildConfig.sdks.WEBOS_SDK undefined`; - //WHEN jest.mocked(getRealPath).mockReturnValue(undefined); - //THEN + //WHEN & THEN await expect(launchWebOSimulator(ctx, target)).rejects.toBe(errorMessage); }); @@ -30,20 +29,23 @@ describe('launchWebOSimulator', () => { //GIVEN const ctx = getContext(); const target = true; - - //WHEN jest.mocked(getRealPath).mockReturnValue('mock_webos_SDK_path'); jest.mocked(getDirectories).mockReturnValue(['mock_sim_1', 'mock_sim_2']); jest.mocked(inquirerPrompt).mockResolvedValue({ selectedSimulator: 'mock_sim_1' }); - // path.join.mockReturnValue('false'); jest.mocked(fsExistsSync).mockReturnValue(true); - jest.mock('@rnv/core', () => ({ isSystemWin: false, isSystemLinux: false })); + jest.mock('@rnv/core', () => ({ + ...jest.requireActual('@rnv/core'), + isSystemWin: false, + isSystemLinux: false, + })); - //THEN + //WHEN const result = await launchWebOSimulator(ctx, target); + + //THEN expect(result).toEqual(true); }); }); From 223f6b0523c67fbccb449d98b9b5a837ea18b527 Mon Sep 17 00:00:00 2001 From: Marius456 Date: Tue, 19 Mar 2024 19:17:32 +0200 Subject: [PATCH 04/10] add variations of test --- .../src/__tests__/deviceManager.test.ts | 53 +++++++++++++++++-- packages/sdk-webos/src/deviceManager.ts | 5 +- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/packages/sdk-webos/src/__tests__/deviceManager.test.ts b/packages/sdk-webos/src/__tests__/deviceManager.test.ts index f0b6237f4..018ee93b3 100644 --- a/packages/sdk-webos/src/__tests__/deviceManager.test.ts +++ b/packages/sdk-webos/src/__tests__/deviceManager.test.ts @@ -1,5 +1,6 @@ import { createRnvContext, fsExistsSync, getContext, getDirectories, getRealPath, inquirerPrompt } from '@rnv/core'; import { launchWebOSimulator } from '../deviceManager'; +import * as RnvCore from '@rnv/core'; jest.mock('@rnv/core'); jest.mock('path'); @@ -36,11 +37,53 @@ describe('launchWebOSimulator', () => { jest.mocked(fsExistsSync).mockReturnValue(true); - jest.mock('@rnv/core', () => ({ - ...jest.requireActual('@rnv/core'), - isSystemWin: false, - isSystemLinux: false, - })); + RnvCore.isSystemMac = true; + RnvCore.isSystemWin = false; + RnvCore.isSystemLinux = false; + + //WHEN + const result = await launchWebOSimulator(ctx, target); + + //THEN + expect(result).toEqual(true); + }); + + it('should ask to select sims if no target is specified and run it [linux]', async () => { + //GIVEN + const ctx = getContext(); + const target = true; + jest.mocked(getRealPath).mockReturnValue('mock_webos_SDK_path'); + jest.mocked(getDirectories).mockReturnValue(['mock_sim_1', 'mock_sim_2']); + + jest.mocked(inquirerPrompt).mockResolvedValue({ selectedSimulator: 'mock_sim_1' }); + + jest.mocked(fsExistsSync).mockReturnValue(true); + + RnvCore.isSystemMac = false; + RnvCore.isSystemWin = false; + RnvCore.isSystemLinux = true; + + //WHEN + const result = await launchWebOSimulator(ctx, target); + + //THEN + expect(result).toEqual(true); + }); + + it('should ask to select sims if no target is specified and run it [windows]', async () => { + //GIVEN + const ctx = getContext(); + const target = true; + jest.mocked(getRealPath).mockReturnValue('mock_webos_SDK_path'); + jest.mocked(getDirectories).mockReturnValue(['mock_sim_1', 'mock_sim_2']); + + jest.mocked(inquirerPrompt).mockResolvedValue({ selectedSimulator: 'mock_sim_1' }); + + jest.mocked(fsExistsSync).mockReturnValue(true); + + RnvCore.isSystemMac = false; + RnvCore.isSystemWin = true; + RnvCore.isSystemLinux = false; //WHEN const result = await launchWebOSimulator(ctx, target); diff --git a/packages/sdk-webos/src/deviceManager.ts b/packages/sdk-webos/src/deviceManager.ts index 4fc08e911..d49a39f03 100644 --- a/packages/sdk-webos/src/deviceManager.ts +++ b/packages/sdk-webos/src/deviceManager.ts @@ -72,8 +72,11 @@ export const launchWebOSimulator = async (c: RnvContext, target: string | boolea if (!fsExistsSync(ePath)) { return Promise.reject(`Can't find simulator at path: ${ePath}`); } + if (isSystemWin || isSystemLinux) { - return executeAsync(c, ePath, ExecOptionsPresets.SPINNER_FULL_ERROR_SUMMARY); + await executeAsync(c, ePath, ExecOptionsPresets.SPINNER_FULL_ERROR_SUMMARY); + logSuccess(`Succesfully launched ${target}`); + return true; } await executeAsync(c, `${openCommand} ${ePath}`, ExecOptionsPresets.FIRE_AND_FORGET); From aab7c89e10e16692ce42a8d3b61e6f0cf7fa459c Mon Sep 17 00:00:00 2001 From: Marius456 Date: Wed, 20 Mar 2024 09:31:48 +0200 Subject: [PATCH 05/10] update test --- .../src/__tests__/deviceManager.test.ts | 45 ++++++++++++------- packages/sdk-webos/src/deviceManager.ts | 11 +---- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/packages/sdk-webos/src/__tests__/deviceManager.test.ts b/packages/sdk-webos/src/__tests__/deviceManager.test.ts index 018ee93b3..86532456b 100644 --- a/packages/sdk-webos/src/__tests__/deviceManager.test.ts +++ b/packages/sdk-webos/src/__tests__/deviceManager.test.ts @@ -1,4 +1,4 @@ -import { createRnvContext, fsExistsSync, getContext, getDirectories, getRealPath, inquirerPrompt } from '@rnv/core'; +import { createRnvContext, getContext, getDirectories, getRealPath, inquirerPrompt } from '@rnv/core'; import { launchWebOSimulator } from '../deviceManager'; import * as RnvCore from '@rnv/core'; @@ -26,20 +26,36 @@ describe('launchWebOSimulator', () => { await expect(launchWebOSimulator(ctx, target)).rejects.toBe(errorMessage); }); + it('should give log warning if target not found and resolve', async () => { + //GIVEN + const ctx = getContext(); + const target = ''; + jest.mocked(getRealPath).mockReturnValue('mock_webos_SDK_path'); + jest.mocked(getDirectories).mockReturnValue(['mock_sim_1', 'mock_sim_2']); + + jest.mocked(launchWebOSimulator).mockResolvedValue(true); + + //WHEN + const result = await launchWebOSimulator(ctx, target); + + //THEN + + expect(RnvCore.logWarning).toHaveBeenCalled(); + expect(result).toEqual(true); + }); + it('should ask to select sims if no target is specified and run it [macos]', async () => { //GIVEN const ctx = getContext(); + ctx.isSystemWin = false; const target = true; jest.mocked(getRealPath).mockReturnValue('mock_webos_SDK_path'); jest.mocked(getDirectories).mockReturnValue(['mock_sim_1', 'mock_sim_2']); jest.mocked(inquirerPrompt).mockResolvedValue({ selectedSimulator: 'mock_sim_1' }); - jest.mocked(fsExistsSync).mockReturnValue(true); - - RnvCore.isSystemMac = true; - RnvCore.isSystemWin = false; - RnvCore.isSystemLinux = false; + jest.mocked(RnvCore).isSystemMac = true; + jest.mocked(RnvCore).isSystemLinux = false; //WHEN const result = await launchWebOSimulator(ctx, target); @@ -51,17 +67,15 @@ describe('launchWebOSimulator', () => { it('should ask to select sims if no target is specified and run it [linux]', async () => { //GIVEN const ctx = getContext(); + ctx.isSystemWin = false; const target = true; jest.mocked(getRealPath).mockReturnValue('mock_webos_SDK_path'); jest.mocked(getDirectories).mockReturnValue(['mock_sim_1', 'mock_sim_2']); jest.mocked(inquirerPrompt).mockResolvedValue({ selectedSimulator: 'mock_sim_1' }); - jest.mocked(fsExistsSync).mockReturnValue(true); - - RnvCore.isSystemMac = false; - RnvCore.isSystemWin = false; - RnvCore.isSystemLinux = true; + jest.mocked(RnvCore).isSystemMac = false; + jest.mocked(RnvCore).isSystemLinux = true; //WHEN const result = await launchWebOSimulator(ctx, target); @@ -74,16 +88,15 @@ describe('launchWebOSimulator', () => { //GIVEN const ctx = getContext(); const target = true; + ctx.isSystemWin = true; + jest.mocked(getRealPath).mockReturnValue('mock_webos_SDK_path'); jest.mocked(getDirectories).mockReturnValue(['mock_sim_1', 'mock_sim_2']); jest.mocked(inquirerPrompt).mockResolvedValue({ selectedSimulator: 'mock_sim_1' }); - jest.mocked(fsExistsSync).mockReturnValue(true); - - RnvCore.isSystemMac = false; - RnvCore.isSystemWin = true; - RnvCore.isSystemLinux = false; + jest.mocked(RnvCore).isSystemMac = false; + jest.mocked(RnvCore).isSystemLinux = false; //WHEN const result = await launchWebOSimulator(ctx, target); diff --git a/packages/sdk-webos/src/deviceManager.ts b/packages/sdk-webos/src/deviceManager.ts index d49a39f03..ee5c00dd0 100644 --- a/packages/sdk-webos/src/deviceManager.ts +++ b/packages/sdk-webos/src/deviceManager.ts @@ -1,6 +1,5 @@ import path from 'path'; import { - fsExistsSync, getRealPath, fsReadFileSync, getDirectories, @@ -14,7 +13,6 @@ import { logInfo, logTask, logWarning, - isSystemWin, RnvContext, inquirerPrompt, ExecOptionsPresets, @@ -66,14 +64,9 @@ export const launchWebOSimulator = async (c: RnvContext, target: string | boolea const ePath = path.join( webosSdkPath, - `Simulator/${target}/${target}${isSystemWin ? '.exe' : isSystemLinux ? '.appimage' : '.app'}` + `Simulator/${target}/${target}${c.isSystemWin ? '.exe' : isSystemLinux ? '.appimage' : '.app'}` ); - - if (!fsExistsSync(ePath)) { - return Promise.reject(`Can't find simulator at path: ${ePath}`); - } - - if (isSystemWin || isSystemLinux) { + if (c.isSystemWin || isSystemLinux) { await executeAsync(c, ePath, ExecOptionsPresets.SPINNER_FULL_ERROR_SUMMARY); logSuccess(`Succesfully launched ${target}`); return true; From 9a6c9cdf038eebd613af6a5673b4acccbc3ca9d5 Mon Sep 17 00:00:00 2001 From: Marius456 Date: Wed, 20 Mar 2024 13:32:32 +0200 Subject: [PATCH 06/10] fix target not found test --- packages/sdk-webos/src/__tests__/deviceManager.test.ts | 7 ++++--- packages/sdk-webos/src/deviceManager.ts | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/sdk-webos/src/__tests__/deviceManager.test.ts b/packages/sdk-webos/src/__tests__/deviceManager.test.ts index 86532456b..3b5da7229 100644 --- a/packages/sdk-webos/src/__tests__/deviceManager.test.ts +++ b/packages/sdk-webos/src/__tests__/deviceManager.test.ts @@ -30,16 +30,17 @@ describe('launchWebOSimulator', () => { //GIVEN const ctx = getContext(); const target = ''; + ctx.isSystemWin = false; + jest.mocked(RnvCore).isSystemMac = true; + jest.mocked(RnvCore).isSystemLinux = false; jest.mocked(getRealPath).mockReturnValue('mock_webos_SDK_path'); jest.mocked(getDirectories).mockReturnValue(['mock_sim_1', 'mock_sim_2']); - - jest.mocked(launchWebOSimulator).mockResolvedValue(true); + jest.mocked(inquirerPrompt).mockResolvedValue({ selectedSimulator: 'mock_sim_1' }); //WHEN const result = await launchWebOSimulator(ctx, target); //THEN - expect(RnvCore.logWarning).toHaveBeenCalled(); expect(result).toEqual(true); }); diff --git a/packages/sdk-webos/src/deviceManager.ts b/packages/sdk-webos/src/deviceManager.ts index ee5c00dd0..31a5dbfbf 100644 --- a/packages/sdk-webos/src/deviceManager.ts +++ b/packages/sdk-webos/src/deviceManager.ts @@ -71,7 +71,6 @@ export const launchWebOSimulator = async (c: RnvContext, target: string | boolea logSuccess(`Succesfully launched ${target}`); return true; } - await executeAsync(c, `${openCommand} ${ePath}`, ExecOptionsPresets.FIRE_AND_FORGET); logSuccess(`Succesfully launched ${target}`); return true; From b64c92bb203f4b68306aa39024e23092f8f49174 Mon Sep 17 00:00:00 2001 From: Marius456 Date: Wed, 20 Mar 2024 14:01:40 +0200 Subject: [PATCH 07/10] add isSystem to context --- .../core/src/context/__tests__/index.test.ts | 2 ++ packages/core/src/context/defaults.ts | 2 ++ packages/core/src/context/index.ts | 4 +++- packages/core/src/context/types.ts | 2 ++ .../src/__tests__/deviceManager.test.ts | 19 ++++++++----------- packages/sdk-webos/src/deviceManager.ts | 8 +++----- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/packages/core/src/context/__tests__/index.test.ts b/packages/core/src/context/__tests__/index.test.ts index b60b18375..57601e326 100644 --- a/packages/core/src/context/__tests__/index.test.ts +++ b/packages/core/src/context/__tests__/index.test.ts @@ -31,6 +31,8 @@ describe('Context tests', () => { 'injectableConfigProps', 'isBuildHooksReady', 'isDefault', + 'isSystemLinux', + 'isSystemMac', 'isSystemWin', 'logMessages', 'paths', diff --git a/packages/core/src/context/defaults.ts b/packages/core/src/context/defaults.ts index 22af30dfe..ae56c9529 100644 --- a/packages/core/src/context/defaults.ts +++ b/packages/core/src/context/defaults.ts @@ -61,6 +61,8 @@ const runtime: RnvContext['runtime'] = { export const generateContextDefaults = (): RnvContext => ({ isDefault: true, isSystemWin: false, + isSystemLinux: false, + isSystemMac: false, logMessages: [], timeEnd: new Date(), timeStart: new Date(), diff --git a/packages/core/src/context/index.ts b/packages/core/src/context/index.ts index 7383ba4c2..9cedfd0f8 100644 --- a/packages/core/src/context/index.ts +++ b/packages/core/src/context/index.ts @@ -62,7 +62,9 @@ Make sure all your rnv dependencies are of same version and you are executing wi c.process = ctx?.process || c.process; c.command = ctx?.cmd || c.command; c.subCommand = ctx?.subCmd || c.subCommand; - c.isSystemWin = isSystemWin; + c.isSystemWin = process.platform === 'win32'; + c.isSystemLinux = process.platform === 'linux'; + c.isSystemMac = process.platform === 'darwin'; c.paths.rnv.dir = ctx?.RNV_HOME_DIR || c.paths.rnv.dir; diff --git a/packages/core/src/context/types.ts b/packages/core/src/context/types.ts index c3e85b938..b48fe6259 100644 --- a/packages/core/src/context/types.ts +++ b/packages/core/src/context/types.ts @@ -59,6 +59,8 @@ export type RnvContext = { runningProcesses: ExecaChildProcess[]; rnvVersion: string; isSystemWin: boolean; + isSystemLinux: boolean; + isSystemMac: boolean; _currentTask?: string; systemPropsInjects: OverridesOptions; _requiresNpmInstall?: boolean; diff --git a/packages/sdk-webos/src/__tests__/deviceManager.test.ts b/packages/sdk-webos/src/__tests__/deviceManager.test.ts index 3b5da7229..17ac0d204 100644 --- a/packages/sdk-webos/src/__tests__/deviceManager.test.ts +++ b/packages/sdk-webos/src/__tests__/deviceManager.test.ts @@ -31,8 +31,8 @@ describe('launchWebOSimulator', () => { const ctx = getContext(); const target = ''; ctx.isSystemWin = false; - jest.mocked(RnvCore).isSystemMac = true; - jest.mocked(RnvCore).isSystemLinux = false; + ctx.isSystemMac = true; + ctx.isSystemLinux = false; jest.mocked(getRealPath).mockReturnValue('mock_webos_SDK_path'); jest.mocked(getDirectories).mockReturnValue(['mock_sim_1', 'mock_sim_2']); jest.mocked(inquirerPrompt).mockResolvedValue({ selectedSimulator: 'mock_sim_1' }); @@ -49,15 +49,14 @@ describe('launchWebOSimulator', () => { //GIVEN const ctx = getContext(); ctx.isSystemWin = false; + ctx.isSystemMac = true; + ctx.isSystemLinux = false; const target = true; jest.mocked(getRealPath).mockReturnValue('mock_webos_SDK_path'); jest.mocked(getDirectories).mockReturnValue(['mock_sim_1', 'mock_sim_2']); jest.mocked(inquirerPrompt).mockResolvedValue({ selectedSimulator: 'mock_sim_1' }); - jest.mocked(RnvCore).isSystemMac = true; - jest.mocked(RnvCore).isSystemLinux = false; - //WHEN const result = await launchWebOSimulator(ctx, target); @@ -69,15 +68,14 @@ describe('launchWebOSimulator', () => { //GIVEN const ctx = getContext(); ctx.isSystemWin = false; + ctx.isSystemMac = false; + ctx.isSystemLinux = true; const target = true; jest.mocked(getRealPath).mockReturnValue('mock_webos_SDK_path'); jest.mocked(getDirectories).mockReturnValue(['mock_sim_1', 'mock_sim_2']); jest.mocked(inquirerPrompt).mockResolvedValue({ selectedSimulator: 'mock_sim_1' }); - jest.mocked(RnvCore).isSystemMac = false; - jest.mocked(RnvCore).isSystemLinux = true; - //WHEN const result = await launchWebOSimulator(ctx, target); @@ -90,15 +88,14 @@ describe('launchWebOSimulator', () => { const ctx = getContext(); const target = true; ctx.isSystemWin = true; + ctx.isSystemMac = false; + ctx.isSystemLinux = false; jest.mocked(getRealPath).mockReturnValue('mock_webos_SDK_path'); jest.mocked(getDirectories).mockReturnValue(['mock_sim_1', 'mock_sim_2']); jest.mocked(inquirerPrompt).mockResolvedValue({ selectedSimulator: 'mock_sim_1' }); - jest.mocked(RnvCore).isSystemMac = false; - jest.mocked(RnvCore).isSystemLinux = false; - //WHEN const result = await launchWebOSimulator(ctx, target); diff --git a/packages/sdk-webos/src/deviceManager.ts b/packages/sdk-webos/src/deviceManager.ts index 31a5dbfbf..1dc14959f 100644 --- a/packages/sdk-webos/src/deviceManager.ts +++ b/packages/sdk-webos/src/deviceManager.ts @@ -16,8 +16,6 @@ import { RnvContext, inquirerPrompt, ExecOptionsPresets, - isSystemLinux, - isSystemMac, logError, logSuccess, getConfigProp, @@ -64,9 +62,9 @@ export const launchWebOSimulator = async (c: RnvContext, target: string | boolea const ePath = path.join( webosSdkPath, - `Simulator/${target}/${target}${c.isSystemWin ? '.exe' : isSystemLinux ? '.appimage' : '.app'}` + `Simulator/${target}/${target}${c.isSystemWin ? '.exe' : c.isSystemLinux ? '.appimage' : '.app'}` ); - if (c.isSystemWin || isSystemLinux) { + if (c.isSystemWin || c.isSystemLinux) { await executeAsync(c, ePath, ExecOptionsPresets.SPINNER_FULL_ERROR_SUMMARY); logSuccess(`Succesfully launched ${target}`); return true; @@ -160,7 +158,7 @@ const launchAppOnSimulator = async (c: RnvContext, appPath: string) => { const regex = /\d+(\.\d+)?/g; const version = selectedOption.match(regex)[0]; - if (isSystemMac) { + if (c.isSystemMac) { logInfo( `If you encounter damaged simulator error, run this command line: xattr -c ${simulatorDirPath}/${selectedOption}/${selectedOption}.app` ); From 33bfd3d1456e30189f1422110a71e277026243fd Mon Sep 17 00:00:00 2001 From: Marius456 Date: Wed, 20 Mar 2024 14:16:13 +0200 Subject: [PATCH 08/10] small fix --- packages/sdk-webos/src/deviceManager.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/sdk-webos/src/deviceManager.ts b/packages/sdk-webos/src/deviceManager.ts index 339c59bbc..e83db71fc 100644 --- a/packages/sdk-webos/src/deviceManager.ts +++ b/packages/sdk-webos/src/deviceManager.ts @@ -66,14 +66,14 @@ export const launchWebOSimulator = async (target: string | boolean) => { webosSdkPath, `Simulator/${target}/${target}${c.isSystemWin ? '.exe' : c.isSystemLinux ? '.appimage' : '.app'}` ); - + if (c.isSystemWin || c.isSystemLinux) { - await executeAsync(c, ePath, ExecOptionsPresets.SPINNER_FULL_ERROR_SUMMARY); + await executeAsync(ePath, ExecOptionsPresets.SPINNER_FULL_ERROR_SUMMARY); logSuccess(`Succesfully launched ${target}`); return true; } - - await executeAsync(c, `${openCommand} ${ePath}`, ExecOptionsPresets.FIRE_AND_FORGET); + + await executeAsync(`${openCommand} ${ePath}`, ExecOptionsPresets.FIRE_AND_FORGET); logSuccess(`Succesfully launched ${target}`); return true; }; From 930c080d824eda77edbc00a24a4be5b6e10c3b0c Mon Sep 17 00:00:00 2001 From: Marius456 Date: Wed, 20 Mar 2024 15:06:24 +0200 Subject: [PATCH 09/10] fix UT due to migration to getContext DI --- .../sdk-webos/src/__tests__/deviceManager.test.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/sdk-webos/src/__tests__/deviceManager.test.ts b/packages/sdk-webos/src/__tests__/deviceManager.test.ts index 17ac0d204..669594a5b 100644 --- a/packages/sdk-webos/src/__tests__/deviceManager.test.ts +++ b/packages/sdk-webos/src/__tests__/deviceManager.test.ts @@ -16,14 +16,13 @@ afterEach(() => { describe('launchWebOSimulator', () => { it('should fail if webos SDK path is not defined', async () => { //GIVEN - const ctx = getContext(); const target = true; const errorMessage = `c.buildConfig.sdks.WEBOS_SDK undefined`; jest.mocked(getRealPath).mockReturnValue(undefined); //WHEN & THEN - await expect(launchWebOSimulator(ctx, target)).rejects.toBe(errorMessage); + await expect(launchWebOSimulator(target)).rejects.toBe(errorMessage); }); it('should give log warning if target not found and resolve', async () => { @@ -38,7 +37,7 @@ describe('launchWebOSimulator', () => { jest.mocked(inquirerPrompt).mockResolvedValue({ selectedSimulator: 'mock_sim_1' }); //WHEN - const result = await launchWebOSimulator(ctx, target); + const result = await launchWebOSimulator(target); //THEN expect(RnvCore.logWarning).toHaveBeenCalled(); @@ -58,7 +57,7 @@ describe('launchWebOSimulator', () => { jest.mocked(inquirerPrompt).mockResolvedValue({ selectedSimulator: 'mock_sim_1' }); //WHEN - const result = await launchWebOSimulator(ctx, target); + const result = await launchWebOSimulator(target); //THEN expect(result).toEqual(true); @@ -77,7 +76,7 @@ describe('launchWebOSimulator', () => { jest.mocked(inquirerPrompt).mockResolvedValue({ selectedSimulator: 'mock_sim_1' }); //WHEN - const result = await launchWebOSimulator(ctx, target); + const result = await launchWebOSimulator(target); //THEN expect(result).toEqual(true); @@ -97,7 +96,7 @@ describe('launchWebOSimulator', () => { jest.mocked(inquirerPrompt).mockResolvedValue({ selectedSimulator: 'mock_sim_1' }); //WHEN - const result = await launchWebOSimulator(ctx, target); + const result = await launchWebOSimulator(target); //THEN expect(result).toEqual(true); From b21332028e564e4c831276459636ec8d30dc361d Mon Sep 17 00:00:00 2001 From: Marius456 Date: Tue, 26 Mar 2024 10:43:00 +0200 Subject: [PATCH 10/10] fix android e2e --- packages/app-harness/src/app/index.tsx | 2 +- packages/app-harness/test/specs/e2e.cjs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/app-harness/src/app/index.tsx b/packages/app-harness/src/app/index.tsx index 85193e0a1..428f1387c 100644 --- a/packages/app-harness/src/app/index.tsx +++ b/packages/app-harness/src/app/index.tsx @@ -52,7 +52,7 @@ const AppContent = () => { ReNative Harness diff --git a/packages/app-harness/test/specs/e2e.cjs b/packages/app-harness/test/specs/e2e.cjs index d1fa07c02..04d4e695a 100644 --- a/packages/app-harness/test/specs/e2e.cjs +++ b/packages/app-harness/test/specs/e2e.cjs @@ -5,7 +5,7 @@ describe('Test App Harness', () => { FlexnRunner.launchApp(); }); - it('--> check if element has correct text in Home Page', async () => { - await FlexnRunner.expectToHaveTextById('app-harness-home-screen-intro-text', 'ReNative Harness'); + it('--> check if ReNative logo is displayed in Home Page', async () => { + await FlexnRunner.expectToBeDisplayedById('app-harness-home-screen-renative-image'); }); });