smoke - properly create screenshots and stop instances (#137220)

This commit is contained in:
Benjamin Pasero 2021-11-15 12:15:25 +01:00 committed by GitHub
parent c33965ab75
commit bacf6ed2c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 24 deletions

View file

@ -6,11 +6,17 @@
import { Application, ApplicationOptions, Quality } from '../../../../automation';
import { join } from 'path';
import { ParsedArgs } from 'minimist';
import { timeout } from '../../utils';
import { afterSuite, timeout } from '../../utils';
export function setup(opts: ParsedArgs, testDataPath: string) {
describe('Datamigration', () => {
let insidersApp: Application | undefined = undefined;
let stableApp: Application | undefined = undefined;
afterSuite(opts, () => insidersApp, async () => stableApp?.stop());
it(`verifies opened editors are restored`, async function () {
const stableCodePath = opts['stable-build'];
if (!stableCodePath) {
@ -31,7 +37,7 @@ export function setup(opts: ParsedArgs, testDataPath: string) {
stableOptions.userDataDir = userDataDir;
stableOptions.quality = Quality.Stable;
const stableApp = new Application(stableOptions);
stableApp = new Application(stableOptions);
await stableApp.start();
// Open 3 editors and pin 2 of them
@ -44,11 +50,12 @@ export function setup(opts: ParsedArgs, testDataPath: string) {
await stableApp.workbench.editors.newUntitledFile();
await stableApp.stop();
stableApp = undefined;
const insiderOptions: ApplicationOptions = Object.assign({}, this.defaultOptions);
insiderOptions.userDataDir = userDataDir;
const insidersApp = new Application(insiderOptions);
insidersApp = new Application(insiderOptions);
await insidersApp.start();
// Verify 3 editors are open
@ -57,6 +64,7 @@ export function setup(opts: ParsedArgs, testDataPath: string) {
await insidersApp.workbench.editors.selectTab('www');
await insidersApp.stop();
insidersApp = undefined;
});
it(`verifies that 'hot exit' works for dirty files`, async function () {
@ -72,7 +80,7 @@ export function setup(opts: ParsedArgs, testDataPath: string) {
stableOptions.userDataDir = userDataDir;
stableOptions.quality = Quality.Stable;
const stableApp = new Application(stableOptions);
stableApp = new Application(stableOptions);
await stableApp.start();
await stableApp.workbench.editors.newUntitledFile();
@ -89,11 +97,12 @@ export function setup(opts: ParsedArgs, testDataPath: string) {
await timeout(2000); // give time to store the backup before stopping the app
await stableApp.stop();
stableApp = undefined;
const insiderOptions: ApplicationOptions = Object.assign({}, this.defaultOptions);
insiderOptions.userDataDir = userDataDir;
const insidersApp = new Application(insiderOptions);
insidersApp = new Application(insiderOptions);
await insidersApp.start();
await insidersApp.workbench.editors.waitForTab(readmeMd, true);
@ -105,6 +114,7 @@ export function setup(opts: ParsedArgs, testDataPath: string) {
await insidersApp.workbench.editor.waitForEditorContents(untitled, c => c.indexOf(textToTypeInUntitled) > -1);
await insidersApp.stop();
insidersApp = undefined;
});
});
}

View file

@ -3,29 +3,18 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import minimist = require('minimist');
import * as path from 'path';
import { Application, ApplicationOptions } from '../../../../automation';
import { afterSuite } from '../../utils';
export function setup() {
export function setup(opts: minimist.ParsedArgs) {
describe('Launch', () => {
let app: Application;
after(async function () {
if (app) {
await app.stop();
}
});
afterEach(async function () {
if (app) {
if (this.currentTest!.state === 'failed') {
const name = this.currentTest!.fullTitle().replace(/[^a-z0-9\-]/ig, '_');
await app.captureScreenshot(name);
}
}
});
afterSuite(opts, () => app);
it(`verifies that application launches when user data directory has non-ascii characters`, async function () {
const defaultOptions = this.defaultOptions as ApplicationOptions;
@ -33,6 +22,5 @@ export function setup() {
app = new Application(options);
await app.start();
});
});
}

View file

@ -356,7 +356,7 @@ describe(`VSCode Smoke Tests (${opts.web ? 'Web' : 'Electron'})`, () => {
setupExtensionTests(opts);
if (!opts.web) { setupMultirootTests(opts); }
if (!opts.web) { setupLocalizationTests(opts); }
if (!opts.web) { setupLaunchTests(); }
if (!opts.web) { setupLaunchTests(opts); }
// TODO: Enable terminal tests for non-web
if (opts.web) { setupTerminalProfileTests(opts); }

View file

@ -42,9 +42,9 @@ export function beforeSuite(opts: minimist.ParsedArgs, optionsTransform?: (opts:
});
}
export function afterSuite(opts: minimist.ParsedArgs) {
export function afterSuite(opts: minimist.ParsedArgs, appFn?: () => Application | undefined, joinFn?: () => Promise<unknown>) {
after(async function () {
const app = this.app as Application;
const app: Application = appFn?.() ?? this.app;
if (this.currentTest?.state === 'failed' && opts.screenshots) {
const name = this.currentTest!.fullTitle().replace(/[^a-z0-9\-]/ig, '_');
@ -58,6 +58,10 @@ export function afterSuite(opts: minimist.ParsedArgs) {
if (app) {
await app.stop();
}
if (joinFn) {
await joinFn();
}
});
}