mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Add more smoke tests and abstract more code (#10799)
* add more smoke tests and abstract more code * fix missing imports
This commit is contained in:
@@ -17,6 +17,7 @@ import { IExtensionGalleryService } from 'vs/platform/extensionManagement/common
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
|
||||
export abstract class AbstractTelemetryOptOut implements IWorkbenchContribution {
|
||||
|
||||
@@ -33,10 +34,11 @@ export abstract class AbstractTelemetryOptOut implements IWorkbenchContribution
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@IExtensionGalleryService private readonly galleryService: IExtensionGalleryService,
|
||||
@IProductService private readonly productService: IProductService,
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService // {{SQL CARBON EDIT}} add service
|
||||
) { }
|
||||
|
||||
protected async handleTelemetryOptOut(): Promise<void> {
|
||||
if (this.productService.telemetryOptOutUrl && !this.storageService.get(AbstractTelemetryOptOut.TELEMETRY_OPT_OUT_SHOWN, StorageScope.GLOBAL)) {
|
||||
if (!this.environmentService.disableTelemetry && this.productService.telemetryOptOutUrl && !this.storageService.get(AbstractTelemetryOptOut.TELEMETRY_OPT_OUT_SHOWN, StorageScope.GLOBAL)) { // {{SQL CARBON EDIT}} add disableTelemetry check
|
||||
const experimentId = 'telemetryOptOut';
|
||||
|
||||
const [count, experimentState] = await Promise.all([this.getWindowCount(), this.experimentService.getExperimentById(experimentId)]);
|
||||
@@ -164,9 +166,10 @@ export class BrowserTelemetryOptOut extends AbstractTelemetryOptOut {
|
||||
@IExperimentService experimentService: IExperimentService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IExtensionGalleryService galleryService: IExtensionGalleryService,
|
||||
@IProductService productService: IProductService
|
||||
@IProductService productService: IProductService,
|
||||
@IEnvironmentService environmentService: IEnvironmentService // {{SQL CARBON EDIT}} add service
|
||||
) {
|
||||
super(storageService, openerService, notificationService, hostService, telemetryService, experimentService, configurationService, galleryService, productService);
|
||||
super(storageService, openerService, notificationService, hostService, telemetryService, experimentService, configurationService, galleryService, productService, environmentService);
|
||||
|
||||
this.handleTelemetryOptOut();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { AbstractTelemetryOptOut } from 'vs/workbench/contrib/welcome/telemetryOptOut/browser/telemetryOptOut';
|
||||
import { IElectronService } from 'vs/platform/electron/electron-sandbox/electron';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
|
||||
export class NativeTelemetryOptOut extends AbstractTelemetryOptOut {
|
||||
|
||||
@@ -27,9 +28,10 @@ export class NativeTelemetryOptOut extends AbstractTelemetryOptOut {
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IExtensionGalleryService galleryService: IExtensionGalleryService,
|
||||
@IProductService productService: IProductService,
|
||||
@IElectronService private readonly electronService: IElectronService
|
||||
@IEnvironmentService environmentService: IEnvironmentService, // {{SQL CARBON EDIT}} add service
|
||||
@IElectronService private readonly electronService: IElectronService,
|
||||
) {
|
||||
super(storageService, openerService, notificationService, hostService, telemetryService, experimentService, configurationService, galleryService, productService);
|
||||
super(storageService, openerService, notificationService, hostService, telemetryService, experimentService, configurationService, galleryService, productService, environmentService);
|
||||
|
||||
this.handleTelemetryOptOut();
|
||||
}
|
||||
|
||||
@@ -9,10 +9,14 @@ export class QueryEditor {
|
||||
|
||||
public readonly commandBar: CommandBar;
|
||||
|
||||
constructor(code: Code) {
|
||||
constructor(private code: Code) {
|
||||
this.commandBar = new CommandBar(code);
|
||||
}
|
||||
|
||||
private static readonly RESULT_SELECTOR = '.query-editor-view .monaco-table';
|
||||
public async waitForResults(): Promise<void> {
|
||||
await this.code.waitForElement(QueryEditor.RESULT_SELECTOR);
|
||||
}
|
||||
}
|
||||
|
||||
export class CommandBar {
|
||||
|
||||
@@ -6,32 +6,21 @@
|
||||
import { Editors } from '../editors';
|
||||
import { Code } from '../code';
|
||||
|
||||
export class QueryEditors extends Editors {
|
||||
export class QueryEditors {
|
||||
|
||||
constructor(
|
||||
private vsCode: Code
|
||||
private readonly code: Code,
|
||||
private readonly editors: Editors
|
||||
) {
|
||||
super(vsCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for an active SQL Query Editor tab for the specified file. This is a modification of the editors.waitForActiveTab that
|
||||
* takes into account the connected status displayed in the title of Query Editors.
|
||||
* @param fileName The name of the file opened in the editor
|
||||
* @param isDirty Whether the file is dirty or not
|
||||
*/
|
||||
async waitForActiveTab(fileName: string, isDirty: boolean = false): Promise<void> {
|
||||
// For now assume all opened tabs are disconnected until we have a need to open connected tabs
|
||||
await this.vsCode.waitForElement(`.tabs-container div.tab.active${isDirty ? '.dirty' : ''}[aria-selected="true"][aria-label="${fileName} - disconnected, tab"]`);
|
||||
}
|
||||
async newUntitledQuery(): Promise<void> {
|
||||
if (process.platform === 'darwin') {
|
||||
await this.code.dispatchKeybinding('cmd+n');
|
||||
} else {
|
||||
await this.code.dispatchKeybinding('ctrl+n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for an active Query Editor for the specified file to have focus. This is a modification of the editors.waitForEditorFocus
|
||||
* that takes into account the connected status displayed in the title of Query Editors.
|
||||
* @param fileName The name of the file opened in the editor
|
||||
*/
|
||||
async waitForEditorFocus(fileName: string): Promise<void> {
|
||||
await this.waitForActiveTab(fileName);
|
||||
await super.waitForActiveEditor(fileName);
|
||||
await this.editors.waitForEditorFocus('SQLQuery_1');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ export class Workbench {
|
||||
// {{SQL CARBON EDIT}}
|
||||
this.connectionDialog = new ConnectionDialog(code);
|
||||
this.profiler = new Profiler(code, this.quickaccess);
|
||||
this.queryEditors = new QueryEditors(code);
|
||||
this.queryEditors = new QueryEditors(code, this.editors);
|
||||
this.queryEditor = new QueryEditor(code);
|
||||
// {{END}}
|
||||
this.notebook = new Notebook(this.quickaccess, code);
|
||||
|
||||
@@ -17,7 +17,23 @@ export function setup() {
|
||||
await app.workbench.connectionDialog.setTarget('File', 'chinook.db');
|
||||
await app.workbench.connectionDialog.connect();
|
||||
await app.workbench.queryEditor.commandBar.clickButton(1);
|
||||
await app.code.waitForElement('.query-editor-view .monaco-table');
|
||||
await app.workbench.queryEditor.waitForResults();
|
||||
await app.workbench.quickaccess.runCommand('workbench.action.closeActiveEditor');
|
||||
});
|
||||
|
||||
it('can new file, connect and execute', async function () {
|
||||
const app = this.app as Application;
|
||||
await app.workbench.queryEditors.newUntitledQuery();
|
||||
const untitled = 'SQLQuery_1';
|
||||
await app.workbench.editor.waitForTypeInEditor(untitled, 'select * from employees');
|
||||
await app.workbench.queryEditor.commandBar.clickButton(3);
|
||||
await app.workbench.connectionDialog.waitForConnectionDialog();
|
||||
await app.workbench.connectionDialog.setProvider('Sqlite');
|
||||
await app.workbench.connectionDialog.setTarget('File', 'chinook.db');
|
||||
await app.workbench.connectionDialog.connect();
|
||||
await app.workbench.queryEditor.commandBar.clickButton(1);
|
||||
await app.workbench.queryEditor.waitForResults();
|
||||
await app.workbench.quickaccess.runCommand('workbench.action.closeActiveEditor');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user