mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 19:48:37 -05:00
* add an extension for integration tests * setup ads before running test * test setup * test cases * bash script * shorter temp folder name * code cleanup * add commented out original code * fix test error * test result path * rename results file * change file path * report smoke test results * test stablize * test stablization and configurable test servers * fix smoke test error * connection provider * simplify the integration test script * add comment * fix tslint error * address PR comments * add temp log to check whether the environment variable is already set * remove temp log * move api definition to testapi typing file * exclude integration tests extension * address comments
137 lines
3.5 KiB
TypeScript
137 lines
3.5 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { Workbench } from './areas/workbench/workbench';
|
|
import * as cp from 'child_process';
|
|
import { Code, spawn, SpawnOptions } from './vscode/code';
|
|
import { Logger } from './logger';
|
|
|
|
export enum Quality {
|
|
Dev,
|
|
Insiders,
|
|
Stable
|
|
}
|
|
|
|
export interface ApplicationOptions extends SpawnOptions {
|
|
quality: Quality;
|
|
workspacePath: string;
|
|
workspaceFilePath: string;
|
|
waitTime: number;
|
|
}
|
|
|
|
export class Application {
|
|
|
|
private _code: Code | undefined;
|
|
private _workbench: Workbench;
|
|
|
|
constructor(private options: ApplicationOptions) { }
|
|
|
|
get quality(): Quality {
|
|
return this.options.quality;
|
|
}
|
|
|
|
get code(): Code {
|
|
return this._code!;
|
|
}
|
|
|
|
get workbench(): Workbench {
|
|
return this._workbench;
|
|
}
|
|
|
|
get logger(): Logger {
|
|
return this.options.logger;
|
|
}
|
|
|
|
get workspacePath(): string {
|
|
return this.options.workspacePath;
|
|
}
|
|
|
|
get extensionsPath(): string {
|
|
return this.options.extensionsPath;
|
|
}
|
|
|
|
get userDataPath(): string {
|
|
return this.options.userDataDir;
|
|
}
|
|
|
|
get workspaceFilePath(): string {
|
|
return this.options.workspaceFilePath;
|
|
}
|
|
|
|
async start(): Promise<any> {
|
|
await this._start();
|
|
//{{SQL CARBON EDIT}}
|
|
await this.code.waitForElement('.object-explorer-view');
|
|
|
|
//Original
|
|
/*
|
|
await this.code.waitForElement('.explorer-folders-view');
|
|
await this.code.waitForActiveElement(`.editor-instance[id="workbench.editor.walkThroughPart"] > div > div[tabIndex="0"]`);
|
|
*/
|
|
//{{END}}
|
|
}
|
|
|
|
async restart(options: { workspaceOrFolder?: string, extraArgs?: string[] }): Promise<any> {
|
|
await this.stop();
|
|
await new Promise(c => setTimeout(c, 1000));
|
|
await this._start(options.workspaceOrFolder, options.extraArgs);
|
|
}
|
|
|
|
private async _start(workspaceOrFolder = this.options.workspacePath, extraArgs: string[] = []): Promise<any> {
|
|
cp.execSync('git checkout .', { cwd: this.options.workspacePath });
|
|
await this.startApplication(workspaceOrFolder, extraArgs);
|
|
await this.checkWindowReady();
|
|
}
|
|
|
|
async reload(): Promise<any> {
|
|
this.code.reload()
|
|
.catch(err => null); // ignore the connection drop errors
|
|
|
|
// needs to be enough to propagate the 'Reload Window' command
|
|
await new Promise(c => setTimeout(c, 1500));
|
|
await this.checkWindowReady();
|
|
}
|
|
|
|
async stop(): Promise<any> {
|
|
if (this._code) {
|
|
this._code.dispose();
|
|
this._code = undefined;
|
|
}
|
|
}
|
|
|
|
async capturePage(): Promise<string> {
|
|
return this.code.capturePage();
|
|
}
|
|
|
|
private async startApplication(workspaceOrFolder: string, extraArgs: string[] = []): Promise<any> {
|
|
this._code = await spawn({
|
|
codePath: this.options.codePath,
|
|
workspacePath: workspaceOrFolder,
|
|
userDataDir: this.options.userDataDir,
|
|
extensionsPath: this.options.extensionsPath,
|
|
logger: this.options.logger,
|
|
verbose: this.options.verbose,
|
|
log: this.options.log,
|
|
extraArgs,
|
|
});
|
|
|
|
this._workbench = new Workbench(this._code, this.userDataPath);
|
|
}
|
|
|
|
private async checkWindowReady(): Promise<any> {
|
|
if (!this.code) {
|
|
console.error('No code instance found');
|
|
return;
|
|
}
|
|
|
|
await this.code.waitForWindowIds(ids => ids.length > 0);
|
|
await this.code.waitForElement('.monaco-workbench');
|
|
|
|
// wait a bit, since focus might be stolen off widgets
|
|
// as soon as they open (eg quick open)
|
|
await new Promise(c => setTimeout(c, 500));
|
|
}
|
|
}
|