Skip to content

Commit

Permalink
Simplify and parametrize setting terminal type.
Browse files Browse the repository at this point in the history
  • Loading branch information
Katka92 committed Feb 5, 2020
1 parent 36ee63c commit 1d9b28e
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions tests/e2e/utils/PreferencesHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,13 @@ export class PreferencesHandler {
constructor(@inject(CLASSES.RequestHandler) private readonly requestHandler: RequestHandler) {
}

public async setTerminalToDom() {
public async setTerminalType(type: string) {
Logger.debug('PreferencesHandler.setTerminalToDom');
const response = await this.requestHandler.processRequest(RequestType.GET, `${TestConstants.TS_SELENIUM_BASE_URL}/api/preferences`);
let userPref = response.data;
try {
let theiaPref = JSON.parse(userPref['theia-user-preferences']);
let terminal = theiaPref['terminal.integrated.rendererType'];
if ( terminal === 'dom' ) {
Logger.trace('Terminal renderer type already set to dom.');
} else {
Logger.trace('Setting terminal renderer type to dom.');
theiaPref['terminal.integrated.rendererType'] = 'dom';
userPref['theia-user-preferences'] = JSON.stringify(theiaPref);
this.requestHandler.processRequest(RequestType.POST, `${TestConstants.TS_SELENIUM_BASE_URL}/api/preferences`, userPref);
}
} catch (e) {
Logger.trace('Can not set terminal renderer type.');
throw e;
}
let theiaPref = JSON.parse(userPref['theia-user-preferences']);
theiaPref['terminal.integrated.rendererType'] = type;
userPref['theia-user-preferences'] = JSON.stringify(theiaPref);
this.requestHandler.processRequest(RequestType.POST, `${TestConstants.TS_SELENIUM_BASE_URL}/api/preferences`, userPref);
}
}

0 comments on commit 1d9b28e

Please sign in to comment.