RTC-14795 Abort launching of c9shell if network is offline (#2074)

* Abort launching of c9shell if network is offline

* invert

* unit test mocking

* mock
This commit is contained in:
Swapna Sundar Biswal 2024-01-16 10:18:46 +01:00 committed by GitHub
parent 0bb3f1449e
commit e1b97221c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 0 deletions

View File

@ -37,6 +37,12 @@ describe('C9 shell handler', () => {
};
});
jest.mock('../src/app/window-handler', () => {
return {
windowHandler: { isOnline: true },
};
});
beforeEach(() => {
jest.clearAllMocks().resetModules().resetAllMocks();
mockSpawnEvents.clear();

View File

@ -26,6 +26,12 @@ jest.mock('../src/common/logger', () => {
};
});
jest.mock('../src/app/window-handler', () => {
return {
windowHandler: { isOnline: true },
};
});
describe('config', () => {
const configFileName: string = 'Symphony.config';
let userConfigDir: string;

View File

@ -5,6 +5,7 @@ import { isDevEnv, isWindowsOS } from '../common/env';
import { ChildProcess, spawn } from 'child_process';
import * as path from 'path';
import { getCommandLineArgs, getGuid } from '../common/utils';
import { windowHandler } from './window-handler';
/**
* Current state of the C9 shell process.
@ -162,6 +163,13 @@ class C9ShellHandler {
* Launches the correct c9shell process
*/
private async _launchC9Shell(): Promise<ChildProcess | undefined> {
if (!windowHandler.isOnline) {
logger.info(
'c9-shell: launching of shell aborted due to network unavailability.',
);
return;
}
this._curStatus = undefined;
const uniquePipeName = getGuid();