Switch application.confirmExit in tests to never by default (#16142)

* Enabling TLS requests from self-signed-cert URLs
7.20.x
Katerina Foniok 2020-02-27 14:17:18 +01:00 committed by GitHub
parent 89fecc09c0
commit 60360aed33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 9 deletions

View File

@ -18,6 +18,7 @@ import { logging } from 'selenium-webdriver';
import { DriverHelper } from '../utils/DriverHelper';
import { ScreenCatcher } from '../utils/ScreenCatcher';
import { ITestWorkspaceUtil } from '../utils/workspace/ITestWorkspaceUtil';
import { PreferencesHandler, AskForConfirmationType } from '../utils/PreferencesHandler';
const e2eContainer = inversifyConfig.e2eContainer;
const driver: IDriver = e2eContainer.get(TYPES.Driver);
@ -26,6 +27,7 @@ const screenCatcher: ScreenCatcher = e2eContainer.get(CLASSES.ScreenCatcher);
let methodIndex: number = 0;
let deleteScreencast: boolean = true;
let testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil);
let preferencesHalder: PreferencesHandler = e2eContainer.get(CLASSES.PreferencesHandler);
class CheReporter extends mocha.reporters.Spec {
constructor(runner: mocha.Runner, options: mocha.MochaOptions) {
@ -65,6 +67,7 @@ class CheReporter extends mocha.reporters.Spec {
console.log(launchInformation);
rm.sync(TestConstants.TS_SELENIUM_REPORT_FOLDER);
preferencesHalder.setConfirmExit(AskForConfirmationType.never);
});
runner.on('test', async function (test: mocha.Test) {

View File

@ -11,7 +11,6 @@
import { CLASSES, Terminal, TopMenu, Ide, DialogWindow, DriverHelper } from '..';
import { e2eContainer } from '../inversify.config';
import Axios from 'axios';
import https from 'https';
const terminal: Terminal = e2eContainer.get(CLASSES.Terminal);
const topMenu: TopMenu = e2eContainer.get(CLASSES.TopMenu);
@ -43,8 +42,7 @@ export function runTaskWithDialogShellDjangoWorkaround(taskName: string, expecte
await dialogWindow.waitDialogDissappearance();
await driverHelper.getDriver().wait(async () => {
try {
const agent = new https.Agent({ rejectUnauthorized: false });
const res = await Axios.get(augmentedPreviewUrl, { httpsAgent: agent });
const res = await Axios.get(augmentedPreviewUrl);
if (res.status === 200) { return true; }
} catch (error) { await driverHelper.wait(1_000); }
}, timeout);

View File

@ -4,6 +4,17 @@ import { Logger } from './Logger';
import { CLASSES } from '../inversify.types';
import { CheApiRequestHandler } from './requestHandlers/CheApiRequestHandler';
export enum TerminalRendererType {
canvas = 'canvas',
dom = 'dom'
}
export enum AskForConfirmationType {
never = 'never',
ifRquired = 'ifRequired',
always = 'always'
}
@injectable()
export class PreferencesHandler {
@ -13,21 +24,34 @@ export class PreferencesHandler {
/**
* Works properly only if set before workspace startup.
*/
public async setTerminalType(type: string) {
public async setTerminalType(type: TerminalRendererType) {
Logger.debug('PreferencesHandler.setTerminalToDom');
await this.setPreference('terminal.integrated.rendererType', type);
}
/**
*
* @param askForConfirmation possible values are "never", "ifRequired" and "always"
*/
public async setConfirmExit(askForConfirmation: AskForConfirmationType) {
Logger.debug(`PreferencesHandler.setConfirmExit to ${askForConfirmation}`);
await this.setPreference(`application.confirmExit`, askForConfirmation);
}
private async setPreference(attribute: string, value: string) {
Logger.debug(`PreferencesHandler.setPreferences ${attribute} to ${value}`);
const response = await this.requestHandler.get('api/preferences');
let userPref = response.data;
const userPref = response.data;
try {
let theiaPref = JSON.parse(userPref['theia-user-preferences']);
theiaPref['terminal.integrated.rendererType'] = type;
const theiaPref = JSON.parse(userPref['theia-user-preferences']);
theiaPref[attribute] = value;
userPref['theia-user-preferences'] = JSON.stringify(theiaPref);
this.requestHandler.post('api/preferences', userPref);
} catch (e) {
// setting terminal before running a workspace, so no theia preferences are set
let theiaPref = `{ "terminal.integrated.rendererType":"${type}" }`;
const theiaPref = `{ "${attribute}":"${value}" }`;
userPref['theia-user-preferences'] = JSON.stringify(JSON.parse(theiaPref));
this.requestHandler.post('api/preferences', userPref);
}
}
}