Skip to content

Commit

Permalink
Add more smoke tests and abstract more code (#10799)
Browse files Browse the repository at this point in the history
* add more smoke tests and abstract more code

* fix missing imports
  • Loading branch information
Anthony Dresser authored Jun 10, 2020
1 parent 187667f commit d849ed9
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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)]);
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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();
}
Expand Down
6 changes: 5 additions & 1 deletion test/automation/src/sql/queryEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
31 changes: 10 additions & 21 deletions test/automation/src/sql/queryEditors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
2 changes: 1 addition & 1 deletion test/automation/src/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 17 additions & 1 deletion test/smoke/src/sql/areas/queryEditor/queryEditor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
}

0 comments on commit d849ed9

Please sign in to comment.