mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-02 01:25:39 -05:00
* Merge from vscode 504f934659740e9d41501cad9f162b54d7745ad9 * delete unused folders * distro * Bump build node version * update chokidar * FIx hygiene errors * distro * Fix extension lint issues * Remove strict-vscode * Add copyright header exemptions * Bump vscode-extension-telemetry to fix webpacking issue with zone.js * distro * Fix failing tests (revert marked.js back to current one until we decide to update) * Skip searchmodel test * Fix mac build * temp debug script loading * Try disabling coverage * log error too * Revert "log error too" This reverts commit af0183e5d4ab458fdf44b88fbfab9908d090526f. * Revert "temp debug script loading" This reverts commit 3d687d541c76db2c5b55626c78ae448d3c25089c. * Add comments explaining coverage disabling * Fix ansi_up loading issue * Merge latest from ads * Use newer option * Fix compile * add debug logging warn * Always log stack * log more * undo debug * Update to use correct base path (+cleanup) * distro * fix compile errors * Remove strict-vscode * Fix sql editors not showing * Show db dropdown input & fix styling * Fix more info in gallery * Fix gallery asset requests * Delete unused workflow * Fix tapable resolutions for smoke test compile error * Fix smoke compile * Disable crash reporting * Disable interactive Co-authored-by: ADS Merger <karlb@microsoft.com>
154 lines
4.4 KiB
TypeScript
154 lines
4.4 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 * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import { Workbench } from './workbench';
|
|
import { Code, spawn, SpawnOptions } from './code';
|
|
import { Logger } from './logger';
|
|
|
|
export const enum Quality {
|
|
Dev,
|
|
Insiders,
|
|
Stable
|
|
}
|
|
|
|
export interface ApplicationOptions extends SpawnOptions {
|
|
quality: Quality;
|
|
workspacePath: string;
|
|
waitTime: number;
|
|
screenshotsPath: string | null;
|
|
}
|
|
|
|
export class Application {
|
|
|
|
private _code: Code | undefined;
|
|
private _workbench: Workbench | undefined;
|
|
|
|
constructor(private options: ApplicationOptions) {
|
|
this._userDataPath = options.userDataDir;
|
|
this._workspacePathOrFolder = options.workspacePath;
|
|
}
|
|
|
|
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 remote(): boolean {
|
|
return !!this.options.remote;
|
|
}
|
|
|
|
get web(): boolean {
|
|
return !!this.options.web;
|
|
}
|
|
|
|
private _workspacePathOrFolder: string;
|
|
get workspacePathOrFolder(): string {
|
|
return this._workspacePathOrFolder;
|
|
}
|
|
|
|
get extensionsPath(): string {
|
|
return this.options.extensionsPath;
|
|
}
|
|
|
|
private _userDataPath: string;
|
|
get userDataPath(): string {
|
|
return this._userDataPath;
|
|
}
|
|
|
|
async start(): Promise<any> {
|
|
await this._start();
|
|
await this.code.waitForElement('.object-explorer-view'); // {{SQL CARBON EDIT}} We have a different startup view
|
|
}
|
|
|
|
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.workspacePathOrFolder, extraArgs: string[] = []): Promise<any> {
|
|
this._workspacePathOrFolder = workspaceOrFolder;
|
|
await this.startApplication(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) {
|
|
await this._code.exit();
|
|
this._code.dispose();
|
|
this._code = undefined;
|
|
}
|
|
}
|
|
|
|
async captureScreenshot(name: string): Promise<void> {
|
|
if (this.options.screenshotsPath) {
|
|
const raw = await this.code.capturePage();
|
|
const buffer = Buffer.from(raw, 'base64');
|
|
const screenshotPath = path.join(this.options.screenshotsPath, `${name}.png`);
|
|
if (this.options.log) {
|
|
this.logger.log('*** Screenshot recorded:', screenshotPath);
|
|
}
|
|
fs.writeFileSync(screenshotPath, buffer);
|
|
}
|
|
}
|
|
|
|
private async startApplication(extraArgs: string[] = []): Promise<any> {
|
|
this._code = await spawn({
|
|
...this.options,
|
|
extraArgs: [...(this.options.extraArgs || []), ...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');
|
|
|
|
// {{SQL CARBON EDIT}} Wait for specified status bar items before considering the app ready - we wait for them together to avoid timing
|
|
// issues with the status bar items disappearing
|
|
const statusbarPromises: Promise<string>[] = [];
|
|
|
|
if (this.remote) {
|
|
statusbarPromises.push(this.code.waitForTextContent('.monaco-workbench .statusbar-item[id="status.host"]', ' TestResolver', undefined, 2000));
|
|
}
|
|
|
|
// Wait for SQL Tools Service to start before considering the app ready
|
|
statusbarPromises.push(this.code.waitForTextContent('.monaco-workbench .statusbar-item[id="Microsoft.mssql"]', 'SQL Tools Service Started', undefined, 30000));
|
|
await Promise.all(statusbarPromises);
|
|
|
|
// wait a bit, since focus might be stolen off widgets
|
|
// as soon as they open (e.g. quick access)
|
|
await new Promise(c => setTimeout(c, 1000));
|
|
}
|
|
}
|