mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Sakshis/scmp test (#13904)
* Fixed a few await issues * Introduced ModelView as a class member in schemaCompareMainWindow * Added a few button tests * Fixed tests * Add a missing await
This commit is contained in:
@@ -7,7 +7,7 @@ import * as vscode from 'vscode';
|
|||||||
import { SchemaCompareMainWindow } from './schemaCompareMainWindow';
|
import { SchemaCompareMainWindow } from './schemaCompareMainWindow';
|
||||||
|
|
||||||
export async function activate(extensionContext: vscode.ExtensionContext): Promise<void> {
|
export async function activate(extensionContext: vscode.ExtensionContext): Promise<void> {
|
||||||
vscode.commands.registerCommand('schemaCompare.start', async (context: any) => { await new SchemaCompareMainWindow(undefined, extensionContext).start(context); });
|
vscode.commands.registerCommand('schemaCompare.start', async (context: any) => { await new SchemaCompareMainWindow(undefined, extensionContext, undefined).start(context); });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deactivate(): void {
|
export function deactivate(): void {
|
||||||
|
|||||||
@@ -68,7 +68,11 @@ export class SchemaCompareMainWindow {
|
|||||||
public sourceEndpointInfo: mssql.SchemaCompareEndpointInfo;
|
public sourceEndpointInfo: mssql.SchemaCompareEndpointInfo;
|
||||||
public targetEndpointInfo: mssql.SchemaCompareEndpointInfo;
|
public targetEndpointInfo: mssql.SchemaCompareEndpointInfo;
|
||||||
|
|
||||||
constructor(private schemaCompareService?: mssql.ISchemaCompareService, private extensionContext?: vscode.ExtensionContext) {
|
public promise;
|
||||||
|
|
||||||
|
public schemaCompareDialog: SchemaCompareDialog;
|
||||||
|
|
||||||
|
constructor(private schemaCompareService?: mssql.ISchemaCompareService, private extensionContext?: vscode.ExtensionContext, private view?: azdata.ModelView) {
|
||||||
this.SchemaCompareActionMap = new Map<Number, string>();
|
this.SchemaCompareActionMap = new Map<Number, string>();
|
||||||
this.SchemaCompareActionMap[mssql.SchemaUpdateAction.Delete] = loc.deleteAction;
|
this.SchemaCompareActionMap[mssql.SchemaUpdateAction.Delete] = loc.deleteAction;
|
||||||
this.SchemaCompareActionMap[mssql.SchemaUpdateAction.Change] = loc.changeAction;
|
this.SchemaCompareActionMap[mssql.SchemaUpdateAction.Change] = loc.changeAction;
|
||||||
@@ -117,52 +121,56 @@ export class SchemaCompareMainWindow {
|
|||||||
|
|
||||||
private async registerContent(): Promise<void> {
|
private async registerContent(): Promise<void> {
|
||||||
return new Promise<void>((resolve) => {
|
return new Promise<void>((resolve) => {
|
||||||
this.editor.registerContent(async view => {
|
this.editor.registerContent(async (view) => {
|
||||||
this.differencesTable = view.modelBuilder.table().withProperties({
|
if (isNullOrUndefined(this.view)) {
|
||||||
|
this.view = view;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.differencesTable = this.view.modelBuilder.table().withProperties({
|
||||||
data: [],
|
data: [],
|
||||||
title: loc.differencesTableTitle
|
title: loc.differencesTableTitle
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
this.diffEditor = view.modelBuilder.diffeditor().withProperties({
|
this.diffEditor = this.view.modelBuilder.diffeditor().withProperties({
|
||||||
contentLeft: os.EOL,
|
contentLeft: os.EOL,
|
||||||
contentRight: os.EOL,
|
contentRight: os.EOL,
|
||||||
height: 500,
|
height: 500,
|
||||||
title: loc.diffEditorTitle
|
title: loc.diffEditorTitle
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
this.splitView = view.modelBuilder.splitViewContainer().component();
|
this.splitView = this.view.modelBuilder.splitViewContainer().component();
|
||||||
|
|
||||||
let sourceTargetLabels = view.modelBuilder.flexContainer()
|
let sourceTargetLabels = this.view.modelBuilder.flexContainer()
|
||||||
.withProperties({
|
.withProperties({
|
||||||
alignItems: 'stretch',
|
alignItems: 'stretch',
|
||||||
horizontal: true
|
horizontal: true
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
this.sourceTargetFlexLayout = view.modelBuilder.flexContainer()
|
this.sourceTargetFlexLayout = this.view.modelBuilder.flexContainer()
|
||||||
.withProperties({
|
.withProperties({
|
||||||
alignItems: 'stretch',
|
alignItems: 'stretch',
|
||||||
horizontal: true
|
horizontal: true
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
this.createSwitchButton(view);
|
this.createSwitchButton();
|
||||||
this.createCompareButton(view);
|
this.createCompareButton();
|
||||||
this.createCancelButton(view);
|
this.createCancelButton();
|
||||||
this.createGenerateScriptButton(view);
|
this.createGenerateScriptButton();
|
||||||
this.createApplyButton(view);
|
this.createApplyButton();
|
||||||
this.createOptionsButton(view);
|
this.createOptionsButton();
|
||||||
this.createOpenScmpButton(view);
|
this.createOpenScmpButton();
|
||||||
this.createSaveScmpButton(view);
|
this.createSaveScmpButton();
|
||||||
this.createSourceAndTargetButtons(view);
|
this.createSourceAndTargetButtons();
|
||||||
|
|
||||||
this.sourceName = getEndpointName(this.sourceEndpointInfo);
|
this.sourceName = getEndpointName(this.sourceEndpointInfo);
|
||||||
this.targetName = ' ';
|
this.targetName = ' ';
|
||||||
this.sourceNameComponent = view.modelBuilder.inputBox().withProperties<azdata.InputBoxProperties>({
|
this.sourceNameComponent = this.view.modelBuilder.inputBox().withProperties<azdata.InputBoxProperties>({
|
||||||
value: this.sourceName,
|
value: this.sourceName,
|
||||||
title: this.sourceName,
|
title: this.sourceName,
|
||||||
enabled: false
|
enabled: false
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
this.targetNameComponent = view.modelBuilder.inputBox().withProperties<azdata.InputBoxProperties>({
|
this.targetNameComponent = this.view.modelBuilder.inputBox().withProperties<azdata.InputBoxProperties>({
|
||||||
value: this.targetName,
|
value: this.targetName,
|
||||||
title: this.targetName,
|
title: this.targetName,
|
||||||
enabled: false
|
enabled: false
|
||||||
@@ -170,7 +178,7 @@ export class SchemaCompareMainWindow {
|
|||||||
|
|
||||||
this.resetButtons(ResetButtonState.noSourceTarget);
|
this.resetButtons(ResetButtonState.noSourceTarget);
|
||||||
|
|
||||||
let toolBar = view.modelBuilder.toolbarContainer();
|
let toolBar = this.view.modelBuilder.toolbarContainer();
|
||||||
toolBar.addToolbarItems([{
|
toolBar.addToolbarItems([{
|
||||||
component: this.compareButton
|
component: this.compareButton
|
||||||
}, {
|
}, {
|
||||||
@@ -191,17 +199,17 @@ export class SchemaCompareMainWindow {
|
|||||||
component: this.saveScmpButton
|
component: this.saveScmpButton
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
let sourceLabel = view.modelBuilder.text().withProperties({
|
let sourceLabel = this.view.modelBuilder.text().withProperties({
|
||||||
value: loc.sourceTitle,
|
value: loc.sourceTitle,
|
||||||
CSSStyles: { 'margin-bottom': '0px' }
|
CSSStyles: { 'margin-bottom': '0px' }
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
let targetLabel = view.modelBuilder.text().withProperties({
|
let targetLabel = this.view.modelBuilder.text().withProperties({
|
||||||
value: loc.targetTitle,
|
value: loc.targetTitle,
|
||||||
CSSStyles: { 'margin-bottom': '0px' }
|
CSSStyles: { 'margin-bottom': '0px' }
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
let arrowLabel = view.modelBuilder.text().withProperties({
|
let arrowLabel = this.view.modelBuilder.text().withProperties({
|
||||||
value: '➔'
|
value: '➔'
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
@@ -213,20 +221,20 @@ export class SchemaCompareMainWindow {
|
|||||||
this.sourceTargetFlexLayout.addItem(this.targetNameComponent, { CSSStyles: { 'width': '40%', 'height': '25px', 'margin-top': '10px', 'margin-left': '15px', 'margin-right': '10px' } });
|
this.sourceTargetFlexLayout.addItem(this.targetNameComponent, { CSSStyles: { 'width': '40%', 'height': '25px', 'margin-top': '10px', 'margin-left': '15px', 'margin-right': '10px' } });
|
||||||
this.sourceTargetFlexLayout.addItem(this.selectTargetButton, { CSSStyles: { 'margin-top': '10px' } });
|
this.sourceTargetFlexLayout.addItem(this.selectTargetButton, { CSSStyles: { 'margin-top': '10px' } });
|
||||||
|
|
||||||
this.loader = view.modelBuilder.loadingComponent().component();
|
this.loader = this.view.modelBuilder.loadingComponent().component();
|
||||||
this.waitText = view.modelBuilder.text().withProperties({
|
this.waitText = this.view.modelBuilder.text().withProperties({
|
||||||
value: loc.waitText
|
value: loc.waitText
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
this.startText = view.modelBuilder.text().withProperties({
|
this.startText = this.view.modelBuilder.text().withProperties({
|
||||||
value: loc.startText
|
value: loc.startText
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
this.noDifferencesLabel = view.modelBuilder.text().withProperties({
|
this.noDifferencesLabel = this.view.modelBuilder.text().withProperties({
|
||||||
value: loc.noDifferencesText
|
value: loc.noDifferencesText
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
this.flexModel = view.modelBuilder.flexContainer().component();
|
this.flexModel = this.view.modelBuilder.flexContainer().component();
|
||||||
this.flexModel.addItem(toolBar.component(), { flex: 'none' });
|
this.flexModel.addItem(toolBar.component(), { flex: 'none' });
|
||||||
this.flexModel.addItem(sourceTargetLabels, { flex: 'none' });
|
this.flexModel.addItem(sourceTargetLabels, { flex: 'none' });
|
||||||
this.flexModel.addItem(this.sourceTargetFlexLayout, { flex: 'none' });
|
this.flexModel.addItem(this.sourceTargetFlexLayout, { flex: 'none' });
|
||||||
@@ -237,7 +245,7 @@ export class SchemaCompareMainWindow {
|
|||||||
height: '100%'
|
height: '100%'
|
||||||
});
|
});
|
||||||
|
|
||||||
await view.initializeModel(this.flexModel);
|
await this.view.initializeModel(this.flexModel);
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -268,13 +276,15 @@ export class SchemaCompareMainWindow {
|
|||||||
this.deploymentOptions = deploymentOptions;
|
this.deploymentOptions = deploymentOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async execute(): Promise<void> {
|
public async execute() {
|
||||||
TelemetryReporter.sendActionEvent(TelemetryViews.SchemaCompareMainWindow, 'SchemaComparisonStarted');
|
TelemetryReporter.sendActionEvent(TelemetryViews.SchemaCompareMainWindow, 'SchemaComparisonStarted');
|
||||||
const service = await this.getService();
|
const service = await this.getService();
|
||||||
|
|
||||||
if (!this.operationId) {
|
if (!this.operationId) {
|
||||||
// create once per page
|
// create once per page
|
||||||
this.operationId = generateGuid();
|
this.operationId = generateGuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.comparisonResult = await service.schemaCompare(this.operationId, this.sourceEndpointInfo, this.targetEndpointInfo, azdata.TaskExecutionMode.execute, this.deploymentOptions);
|
this.comparisonResult = await service.schemaCompare(this.operationId, this.sourceEndpointInfo, this.targetEndpointInfo, azdata.TaskExecutionMode.execute, this.deploymentOptions);
|
||||||
if (!this.comparisonResult || !this.comparisonResult.success) {
|
if (!this.comparisonResult || !this.comparisonResult.success) {
|
||||||
TelemetryReporter.createErrorEvent(TelemetryViews.SchemaCompareMainWindow, 'SchemaComparisonFailed', undefined, getTelemetryErrorType(this.comparisonResult?.errorMessage))
|
TelemetryReporter.createErrorEvent(TelemetryViews.SchemaCompareMainWindow, 'SchemaComparisonFailed', undefined, getTelemetryErrorType(this.comparisonResult?.errorMessage))
|
||||||
@@ -362,8 +372,8 @@ export class SchemaCompareMainWindow {
|
|||||||
// explicitly exclude things that were excluded in previous compare
|
// explicitly exclude things that were excluded in previous compare
|
||||||
const thingsToExclude = this.sourceTargetSwitched ? this.originalTargetExcludes : this.originalSourceExcludes;
|
const thingsToExclude = this.sourceTargetSwitched ? this.originalTargetExcludes : this.originalSourceExcludes;
|
||||||
if (thingsToExclude) {
|
if (thingsToExclude) {
|
||||||
thingsToExclude.forEach(item => {
|
thingsToExclude.forEach(async (item) => {
|
||||||
service.schemaCompareIncludeExcludeNode(this.comparisonResult.operationId, item, false, azdata.TaskExecutionMode.execute);
|
await service.schemaCompareIncludeExcludeNode(this.comparisonResult.operationId, item, false, azdata.TaskExecutionMode.execute);
|
||||||
});
|
});
|
||||||
|
|
||||||
// disable apply and generate script buttons if no changes are included
|
// disable apply and generate script buttons if no changes are included
|
||||||
@@ -586,7 +596,7 @@ export class SchemaCompareMainWindow {
|
|||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
|
||||||
public startCompare(): void {
|
public async startCompare(): Promise<void> {
|
||||||
this.flexModel.removeItem(this.splitView);
|
this.flexModel.removeItem(this.splitView);
|
||||||
this.flexModel.removeItem(this.noDifferencesLabel);
|
this.flexModel.removeItem(this.noDifferencesLabel);
|
||||||
this.flexModel.removeItem(this.startText);
|
this.flexModel.removeItem(this.startText);
|
||||||
@@ -604,11 +614,12 @@ export class SchemaCompareMainWindow {
|
|||||||
this.tablelistenersToDispose.forEach(x => x.dispose());
|
this.tablelistenersToDispose.forEach(x => x.dispose());
|
||||||
}
|
}
|
||||||
this.resetButtons(ResetButtonState.comparing);
|
this.resetButtons(ResetButtonState.comparing);
|
||||||
this.execute();
|
this.promise = this.execute();
|
||||||
|
await this.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createCompareButton(view: azdata.ModelView): void {
|
private createCompareButton(): void {
|
||||||
this.compareButton = view.modelBuilder.button().withProperties({
|
this.compareButton = this.view.modelBuilder.button().withProperties({
|
||||||
label: loc.compare,
|
label: loc.compare,
|
||||||
iconPath: {
|
iconPath: {
|
||||||
light: path.join(this.extensionContext.extensionPath, 'media', 'compare.svg'),
|
light: path.join(this.extensionContext.extensionPath, 'media', 'compare.svg'),
|
||||||
@@ -618,12 +629,12 @@ export class SchemaCompareMainWindow {
|
|||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
this.compareButton.onDidClick(async (click) => {
|
this.compareButton.onDidClick(async (click) => {
|
||||||
this.startCompare();
|
await this.startCompare();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private createCancelButton(view: azdata.ModelView): void {
|
private createCancelButton(): void {
|
||||||
this.cancelCompareButton = view.modelBuilder.button().withProperties({
|
this.cancelCompareButton = this.view.modelBuilder.button().withProperties({
|
||||||
label: loc.stop,
|
label: loc.stop,
|
||||||
iconPath: {
|
iconPath: {
|
||||||
light: path.join(this.extensionContext.extensionPath, 'media', 'stop.svg'),
|
light: path.join(this.extensionContext.extensionPath, 'media', 'stop.svg'),
|
||||||
@@ -671,8 +682,8 @@ export class SchemaCompareMainWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private createGenerateScriptButton(view: azdata.ModelView): void {
|
private createGenerateScriptButton(): void {
|
||||||
this.generateScriptButton = view.modelBuilder.button().withProperties({
|
this.generateScriptButton = this.view.modelBuilder.button().withProperties({
|
||||||
label: loc.generateScript,
|
label: loc.generateScript,
|
||||||
iconPath: {
|
iconPath: {
|
||||||
light: path.join(this.extensionContext.extensionPath, 'media', 'generate-script.svg'),
|
light: path.join(this.extensionContext.extensionPath, 'media', 'generate-script.svg'),
|
||||||
@@ -707,8 +718,8 @@ export class SchemaCompareMainWindow {
|
|||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
private createOptionsButton(view: azdata.ModelView) {
|
private createOptionsButton() {
|
||||||
this.optionsButton = view.modelBuilder.button().withProperties({
|
this.optionsButton = this.view.modelBuilder.button().withProperties({
|
||||||
label: loc.options,
|
label: loc.options,
|
||||||
iconPath: {
|
iconPath: {
|
||||||
light: path.join(this.extensionContext.extensionPath, 'media', 'options.svg'),
|
light: path.join(this.extensionContext.extensionPath, 'media', 'options.svg'),
|
||||||
@@ -725,9 +736,9 @@ export class SchemaCompareMainWindow {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private createApplyButton(view: azdata.ModelView) {
|
private createApplyButton() {
|
||||||
|
|
||||||
this.applyButton = view.modelBuilder.button().withProperties({
|
this.applyButton = this.view.modelBuilder.button().withProperties({
|
||||||
label: loc.apply,
|
label: loc.apply,
|
||||||
iconPath: {
|
iconPath: {
|
||||||
light: path.join(this.extensionContext.extensionPath, 'media', 'start.svg'),
|
light: path.join(this.extensionContext.extensionPath, 'media', 'start.svg'),
|
||||||
@@ -837,8 +848,8 @@ export class SchemaCompareMainWindow {
|
|||||||
this.flexModel.addItem(this.startText, { CSSStyles: { 'margin': 'auto' } });
|
this.flexModel.addItem(this.startText, { CSSStyles: { 'margin': 'auto' } });
|
||||||
}
|
}
|
||||||
|
|
||||||
private createSwitchButton(view: azdata.ModelView): void {
|
private createSwitchButton(): void {
|
||||||
this.switchButton = view.modelBuilder.button().withProperties({
|
this.switchButton = this.view.modelBuilder.button().withProperties({
|
||||||
label: loc.switchDirection,
|
label: loc.switchDirection,
|
||||||
iconPath: {
|
iconPath: {
|
||||||
light: path.join(this.extensionContext.extensionPath, 'media', 'switch-directions.svg'),
|
light: path.join(this.extensionContext.extensionPath, 'media', 'switch-directions.svg'),
|
||||||
@@ -868,39 +879,41 @@ export class SchemaCompareMainWindow {
|
|||||||
|
|
||||||
// only compare if both source and target are set
|
// only compare if both source and target are set
|
||||||
if (this.sourceEndpointInfo && this.targetEndpointInfo) {
|
if (this.sourceEndpointInfo && this.targetEndpointInfo) {
|
||||||
this.startCompare();
|
await this.startCompare();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private createSourceAndTargetButtons(view: azdata.ModelView): void {
|
private createSourceAndTargetButtons(): void {
|
||||||
this.selectSourceButton = view.modelBuilder.button().withProperties({
|
this.selectSourceButton = this.view.modelBuilder.button().withProperties({
|
||||||
label: '•••',
|
label: '•••',
|
||||||
title: loc.selectSource,
|
title: loc.selectSource,
|
||||||
ariaLabel: loc.selectSource
|
ariaLabel: loc.selectSource
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
this.selectSourceButton.onDidClick(() => {
|
this.selectSourceButton.onDidClick(async () => {
|
||||||
TelemetryReporter.sendActionEvent(TelemetryViews.SchemaCompareMainWindow, 'SchemaCompareSelectSource');
|
TelemetryReporter.sendActionEvent(TelemetryViews.SchemaCompareMainWindow, 'SchemaCompareSelectSource');
|
||||||
let dialog = new SchemaCompareDialog(this);
|
this.schemaCompareDialog = new SchemaCompareDialog(this);
|
||||||
dialog.openDialog();
|
this.promise = this.schemaCompareDialog.openDialog();
|
||||||
|
await this.promise;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.selectTargetButton = view.modelBuilder.button().withProperties({
|
this.selectTargetButton = this.view.modelBuilder.button().withProperties({
|
||||||
label: '•••',
|
label: '•••',
|
||||||
title: loc.selectTarget,
|
title: loc.selectTarget,
|
||||||
ariaLabel: loc.selectTarget
|
ariaLabel: loc.selectTarget
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
this.selectTargetButton.onDidClick(() => {
|
this.selectTargetButton.onDidClick(async () => {
|
||||||
TelemetryReporter.sendActionEvent(TelemetryViews.SchemaCompareMainWindow, 'SchemaCompareSelectTarget');
|
TelemetryReporter.sendActionEvent(TelemetryViews.SchemaCompareMainWindow, 'SchemaCompareSelectTarget');
|
||||||
let dialog = new SchemaCompareDialog(this);
|
this.schemaCompareDialog = new SchemaCompareDialog(this);
|
||||||
dialog.openDialog();
|
this.promise = await this.schemaCompareDialog.openDialog();
|
||||||
|
await this.promise;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private createOpenScmpButton(view: azdata.ModelView) {
|
private createOpenScmpButton() {
|
||||||
this.openScmpButton = view.modelBuilder.button().withProperties({
|
this.openScmpButton = this.view.modelBuilder.button().withProperties({
|
||||||
label: loc.openScmp,
|
label: loc.openScmp,
|
||||||
iconPath: {
|
iconPath: {
|
||||||
light: path.join(this.extensionContext.extensionPath, 'media', 'open-scmp.svg'),
|
light: path.join(this.extensionContext.extensionPath, 'media', 'open-scmp.svg'),
|
||||||
@@ -987,8 +1000,8 @@ export class SchemaCompareMainWindow {
|
|||||||
return endpointInfo;
|
return endpointInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createSaveScmpButton(view: azdata.ModelView): void {
|
private createSaveScmpButton(): void {
|
||||||
this.saveScmpButton = view.modelBuilder.button().withProperties({
|
this.saveScmpButton = this.view.modelBuilder.button().withProperties({
|
||||||
label: loc.saveScmp,
|
label: loc.saveScmp,
|
||||||
iconPath: {
|
iconPath: {
|
||||||
light: path.join(this.extensionContext.extensionPath, 'media', 'save-scmp.svg'),
|
light: path.join(this.extensionContext.extensionPath, 'media', 'save-scmp.svg'),
|
||||||
@@ -1068,7 +1081,7 @@ export class SchemaCompareMainWindow {
|
|||||||
|
|
||||||
private async getService(): Promise<mssql.ISchemaCompareService> {
|
private async getService(): Promise<mssql.ISchemaCompareService> {
|
||||||
if (this.schemaCompareService === null || this.schemaCompareService === undefined) {
|
if (this.schemaCompareService === null || this.schemaCompareService === undefined) {
|
||||||
this.schemaCompareService = (vscode.extensions.getExtension(mssql.extension.name).exports as mssql.IExtension).schemaCompare;
|
this.schemaCompareService = (await vscode.extensions.getExtension(mssql.extension.name).exports as mssql.IExtension).schemaCompare;
|
||||||
}
|
}
|
||||||
return this.schemaCompareService;
|
return this.schemaCompareService;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ describe('SchemaCompareMainWindow.start @DacFx@', function (): void {
|
|||||||
it('Should be correct when created.', async function (): Promise<void> {
|
it('Should be correct when created.', async function (): Promise<void> {
|
||||||
let sc = new SchemaCompareTestService();
|
let sc = new SchemaCompareTestService();
|
||||||
|
|
||||||
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object);
|
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object, null);
|
||||||
await result.start(undefined);
|
await result.start(undefined);
|
||||||
|
|
||||||
should(result.getComparisonResult() === undefined);
|
should(result.getComparisonResult() === undefined);
|
||||||
@@ -56,7 +56,7 @@ describe('SchemaCompareMainWindow.start @DacFx@', function (): void {
|
|||||||
it('Should start with the source as undefined', async function (): Promise<void> {
|
it('Should start with the source as undefined', async function (): Promise<void> {
|
||||||
let sc = new SchemaCompareTestService();
|
let sc = new SchemaCompareTestService();
|
||||||
|
|
||||||
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object);
|
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object, null);
|
||||||
await result.start(undefined);
|
await result.start(undefined);
|
||||||
|
|
||||||
should.equal(result.sourceEndpointInfo, undefined);
|
should.equal(result.sourceEndpointInfo, undefined);
|
||||||
@@ -66,8 +66,8 @@ describe('SchemaCompareMainWindow.start @DacFx@', function (): void {
|
|||||||
it('Should start with the source as database', async function (): Promise<void> {
|
it('Should start with the source as database', async function (): Promise<void> {
|
||||||
let sc = new SchemaCompareTestService();
|
let sc = new SchemaCompareTestService();
|
||||||
|
|
||||||
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object);
|
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object, null);
|
||||||
await result.start({ connectionProfile: mockIConnectionProfile });
|
await result.start({connectionProfile: mockIConnectionProfile});
|
||||||
|
|
||||||
should.notEqual(result.sourceEndpointInfo, undefined);
|
should.notEqual(result.sourceEndpointInfo, undefined);
|
||||||
should.equal(result.sourceEndpointInfo.endpointType, mssql.SchemaCompareEndpointType.Database);
|
should.equal(result.sourceEndpointInfo.endpointType, mssql.SchemaCompareEndpointType.Database);
|
||||||
@@ -79,7 +79,7 @@ describe('SchemaCompareMainWindow.start @DacFx@', function (): void {
|
|||||||
it('Should start with the source as dacpac.', async function (): Promise<void> {
|
it('Should start with the source as dacpac.', async function (): Promise<void> {
|
||||||
let sc = new SchemaCompareTestService();
|
let sc = new SchemaCompareTestService();
|
||||||
|
|
||||||
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object);
|
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object, null);
|
||||||
const dacpacPath = mockFilePath;
|
const dacpacPath = mockFilePath;
|
||||||
await result.start(dacpacPath);
|
await result.start(dacpacPath);
|
||||||
|
|
||||||
@@ -392,7 +392,7 @@ describe('SchemaCompareMainWindow.execute', function (): void {
|
|||||||
throw new Error(message);
|
throw new Error(message);
|
||||||
});
|
});
|
||||||
|
|
||||||
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object);
|
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object, null);
|
||||||
await result.start(undefined);
|
await result.start(undefined);
|
||||||
|
|
||||||
should(result.getComparisonResult() === undefined);
|
should(result.getComparisonResult() === undefined);
|
||||||
@@ -406,7 +406,7 @@ describe('SchemaCompareMainWindow.execute', function (): void {
|
|||||||
it('Should exit for failing Schema Compare service', async function (): Promise<void> {
|
it('Should exit for failing Schema Compare service', async function (): Promise<void> {
|
||||||
let sc = new SchemaCompareTestService(testStateScmp.FAILURE);
|
let sc = new SchemaCompareTestService(testStateScmp.FAILURE);
|
||||||
|
|
||||||
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object);
|
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object, null);
|
||||||
|
|
||||||
await result.start(undefined);
|
await result.start(undefined);
|
||||||
|
|
||||||
@@ -421,7 +421,7 @@ describe('SchemaCompareMainWindow.execute', function (): void {
|
|||||||
it('Should disable script button and apply button for Schema Compare service for dacpac', async function (): Promise<void> {
|
it('Should disable script button and apply button for Schema Compare service for dacpac', async function (): Promise<void> {
|
||||||
let sc = new SchemaCompareTestService(testStateScmp.SUCCESS_NOT_EQUAL);
|
let sc = new SchemaCompareTestService(testStateScmp.SUCCESS_NOT_EQUAL);
|
||||||
|
|
||||||
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object);
|
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object, null);
|
||||||
|
|
||||||
await result.start(undefined);
|
await result.start(undefined);
|
||||||
|
|
||||||
@@ -447,10 +447,10 @@ describe('SchemaCompareMainWindow.execute', function (): void {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should disable script button and apply button for Schema Compare service for database', async function (): Promise<void> {
|
it('Should enable script button and apply button for Schema Compare service for database', async function (): Promise<void> {
|
||||||
let sc = new SchemaCompareTestService(testStateScmp.SUCCESS_NOT_EQUAL);
|
let sc = new SchemaCompareTestService(testStateScmp.SUCCESS_NOT_EQUAL);
|
||||||
|
|
||||||
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object);
|
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object, null);
|
||||||
|
|
||||||
await result.start(undefined);
|
await result.start(undefined);
|
||||||
|
|
||||||
@@ -476,6 +476,35 @@ describe('SchemaCompareMainWindow.execute', function (): void {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should enable script button and apply button for Schema Compare service for database, using button onClick fire event', async function (): Promise<void> {
|
||||||
|
let sc = new SchemaCompareTestService(testStateScmp.SUCCESS_NOT_EQUAL);
|
||||||
|
|
||||||
|
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object, testContext.viewContext.view);
|
||||||
|
|
||||||
|
await result.start(undefined);
|
||||||
|
|
||||||
|
should(result.getComparisonResult() === undefined);
|
||||||
|
|
||||||
|
result.sourceEndpointInfo = setDacpacEndpointInfo(mocksource);
|
||||||
|
result.targetEndpointInfo = setDatabaseEndpointInfo();
|
||||||
|
|
||||||
|
testContext.viewContext.compareButtonOnClick.fire(undefined);
|
||||||
|
await result.promise;
|
||||||
|
|
||||||
|
//Generate script button and apply button should be enabled for database comparison
|
||||||
|
result.verifyButtonsState({
|
||||||
|
compareButtonState: true,
|
||||||
|
optionsButtonState: true,
|
||||||
|
switchButtonState: true,
|
||||||
|
openScmpButtonState: true,
|
||||||
|
saveScmpButtonState: true,
|
||||||
|
cancelCompareButtonState: false,
|
||||||
|
selectSourceButtonState: true,
|
||||||
|
selectTargetButtonState: true,
|
||||||
|
generateScriptButtonState: true,
|
||||||
|
applyButtonState: true} );
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('SchemaCompareMainWindow.updateSourceAndTarget', function (): void {
|
describe('SchemaCompareMainWindow.updateSourceAndTarget', function (): void {
|
||||||
@@ -489,7 +518,7 @@ describe('SchemaCompareMainWindow.updateSourceAndTarget', function (): void {
|
|||||||
let sc = new SchemaCompareTestService();
|
let sc = new SchemaCompareTestService();
|
||||||
let endpointInfo: mssql.SchemaCompareEndpointInfo;
|
let endpointInfo: mssql.SchemaCompareEndpointInfo;
|
||||||
|
|
||||||
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object);
|
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object, null);
|
||||||
|
|
||||||
await result.start(undefined);
|
await result.start(undefined);
|
||||||
|
|
||||||
@@ -518,7 +547,7 @@ describe('SchemaCompareMainWindow.updateSourceAndTarget', function (): void {
|
|||||||
let sc = new SchemaCompareTestService();
|
let sc = new SchemaCompareTestService();
|
||||||
let endpointInfo: mssql.SchemaCompareEndpointInfo;
|
let endpointInfo: mssql.SchemaCompareEndpointInfo;
|
||||||
|
|
||||||
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object);
|
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object, null);
|
||||||
|
|
||||||
await result.start(undefined);
|
await result.start(undefined);
|
||||||
|
|
||||||
@@ -545,9 +574,8 @@ describe('SchemaCompareMainWindow.updateSourceAndTarget', function (): void {
|
|||||||
|
|
||||||
it('Should set buttons appropriately when source and target endpoints are populated', async function (): Promise<void> {
|
it('Should set buttons appropriately when source and target endpoints are populated', async function (): Promise<void> {
|
||||||
let sc = new SchemaCompareTestService();
|
let sc = new SchemaCompareTestService();
|
||||||
let endpointInfo: mssql.SchemaCompareEndpointInfo;
|
|
||||||
|
|
||||||
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object);
|
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object, null);
|
||||||
|
|
||||||
await result.start(undefined);
|
await result.start(undefined);
|
||||||
|
|
||||||
@@ -573,3 +601,146 @@ describe('SchemaCompareMainWindow.updateSourceAndTarget', function (): void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('SchemaCompareMainWindow: Button clicks', function (): void {
|
||||||
|
before(() => {
|
||||||
|
mockExtensionContext = TypeMoq.Mock.ofType<vscode.ExtensionContext>();
|
||||||
|
mockExtensionContext.setup(x => x.extensionPath).returns(() => '');
|
||||||
|
testContext = createContext();
|
||||||
|
});
|
||||||
|
this.beforeEach(() => {
|
||||||
|
sinon.restore();
|
||||||
|
showErrorMessageSpy = sinon.spy(vscode.window, 'showErrorMessage');
|
||||||
|
});
|
||||||
|
this.afterEach(() => {
|
||||||
|
sinon.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('createSwitchButton click to start schema comparison', async function (): Promise<void> {
|
||||||
|
let sc = new SchemaCompareTestService();
|
||||||
|
|
||||||
|
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object, testContext.viewContext.view);
|
||||||
|
|
||||||
|
await result.start(undefined);
|
||||||
|
|
||||||
|
should(result.getComparisonResult() === undefined);
|
||||||
|
|
||||||
|
result.sourceEndpointInfo = setDacpacEndpointInfo(mocksource);
|
||||||
|
result.targetEndpointInfo = setDatabaseEndpointInfo();
|
||||||
|
|
||||||
|
testContext.viewContext.switchDirectionButtonOnClick.fire(undefined);
|
||||||
|
await result.promise;
|
||||||
|
|
||||||
|
//Verify that switch actually happened
|
||||||
|
should.notEqual(result.sourceEndpointInfo, undefined);
|
||||||
|
should.equal(result.sourceEndpointInfo.endpointType, mssql.SchemaCompareEndpointType.Database);
|
||||||
|
should.equal(result.sourceEndpointInfo.serverName, 'My Server');
|
||||||
|
should.equal(result.sourceEndpointInfo.databaseName, 'My Database');
|
||||||
|
should.notEqual(result.targetEndpointInfo, undefined);
|
||||||
|
should.equal(result.targetEndpointInfo.endpointType, mssql.SchemaCompareEndpointType.Dacpac);
|
||||||
|
should.equal(result.targetEndpointInfo.packageFilePath, 'source.dacpac');
|
||||||
|
|
||||||
|
//Generate script button and apply button should be disabled for database to dacpac comparison
|
||||||
|
result.verifyButtonsState({
|
||||||
|
compareButtonState: true,
|
||||||
|
optionsButtonState: true,
|
||||||
|
switchButtonState: true,
|
||||||
|
openScmpButtonState: true,
|
||||||
|
saveScmpButtonState: true,
|
||||||
|
cancelCompareButtonState: false,
|
||||||
|
selectSourceButtonState: true,
|
||||||
|
selectTargetButtonState: true,
|
||||||
|
generateScriptButtonState: false,
|
||||||
|
applyButtonState: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('SourceAndTarget selection should open schemaCompareDialog', async function (): Promise<void> {
|
||||||
|
let sc = new SchemaCompareTestService();
|
||||||
|
|
||||||
|
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object, testContext.viewContext.view);
|
||||||
|
|
||||||
|
await result.start(undefined);
|
||||||
|
|
||||||
|
should(result.getComparisonResult() === undefined);
|
||||||
|
|
||||||
|
result.sourceEndpointInfo = setDacpacEndpointInfo(mocksource);
|
||||||
|
result.targetEndpointInfo = setDatabaseEndpointInfo();
|
||||||
|
|
||||||
|
testContext.viewContext.selectButtonOnClick.fire(undefined);
|
||||||
|
await result.promise;
|
||||||
|
|
||||||
|
//Verify that Select button click opened a Schema Compare dialog
|
||||||
|
should.notEqual(result.schemaCompareDialog, undefined);
|
||||||
|
should.notEqual(result.schemaCompareDialog.dialog, undefined);
|
||||||
|
should(result.schemaCompareDialog.dialog.title).equal(loc.SchemaCompareLabel);
|
||||||
|
should(result.schemaCompareDialog.dialog.okButton.label).equal(loc.OkButtonText);
|
||||||
|
should(result.schemaCompareDialog.dialog.okButton.enabled).equal(false); // Should be false when open
|
||||||
|
});
|
||||||
|
|
||||||
|
it('cancelCompare click to cancel schema comparison', async function (): Promise<void> {
|
||||||
|
let sc = new SchemaCompareTestService();
|
||||||
|
|
||||||
|
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object, testContext.viewContext.view);
|
||||||
|
|
||||||
|
await result.start(undefined);
|
||||||
|
|
||||||
|
should(result.getComparisonResult() === undefined);
|
||||||
|
|
||||||
|
result.sourceEndpointInfo = setDacpacEndpointInfo(mocksource);
|
||||||
|
result.targetEndpointInfo = setDatabaseEndpointInfo();
|
||||||
|
await result.execute();
|
||||||
|
|
||||||
|
testContext.viewContext.cancelCompareButtonOnClick.fire(undefined);
|
||||||
|
|
||||||
|
//Verify no error message was thrown
|
||||||
|
should(showErrorMessageSpy.notCalled).be.true();
|
||||||
|
|
||||||
|
//Generate script button and apply button should be enabled for database comparison
|
||||||
|
result.verifyButtonsState({
|
||||||
|
compareButtonState: true,
|
||||||
|
optionsButtonState: true,
|
||||||
|
switchButtonState: true,
|
||||||
|
openScmpButtonState: true,
|
||||||
|
saveScmpButtonState: true,
|
||||||
|
cancelCompareButtonState: false,
|
||||||
|
selectSourceButtonState: true,
|
||||||
|
selectTargetButtonState: true,
|
||||||
|
generateScriptButtonState: false,
|
||||||
|
applyButtonState: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('generateScript click to generate script for schema comparison', async function (): Promise<void> {
|
||||||
|
let sc = new SchemaCompareTestService();
|
||||||
|
|
||||||
|
let result = new SchemaCompareMainWindowTest(sc, mockExtensionContext.object, testContext.viewContext.view);
|
||||||
|
|
||||||
|
await result.start(undefined);
|
||||||
|
|
||||||
|
should(result.getComparisonResult() === undefined);
|
||||||
|
|
||||||
|
result.sourceEndpointInfo = setDacpacEndpointInfo(mocksource);
|
||||||
|
result.targetEndpointInfo = setDatabaseEndpointInfo();
|
||||||
|
await result.execute();
|
||||||
|
|
||||||
|
testContext.viewContext.generateScriptButtonOnClick.fire(undefined);
|
||||||
|
|
||||||
|
//Verify no error message was thrown
|
||||||
|
should(showErrorMessageSpy.notCalled).be.true();
|
||||||
|
|
||||||
|
result.verifyButtonsState({
|
||||||
|
compareButtonState: true,
|
||||||
|
optionsButtonState: true,
|
||||||
|
switchButtonState: true,
|
||||||
|
openScmpButtonState: true,
|
||||||
|
saveScmpButtonState: true,
|
||||||
|
cancelCompareButtonState: false,
|
||||||
|
selectSourceButtonState: true,
|
||||||
|
selectTargetButtonState: true,
|
||||||
|
generateScriptButtonState: false,
|
||||||
|
applyButtonState: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ describe('SchemaCompareDialog.openDialog @DacFx@', function (): void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Simulate ok button- with both endpoints set to dacpac', async function (): Promise<void> {
|
it('Simulate ok button- with both endpoints set to dacpac', async function (): Promise<void> {
|
||||||
let schemaCompareResult = new SchemaCompareMainWindowTest(undefined, mockExtensionContext.object);
|
let schemaCompareResult = new SchemaCompareMainWindowTest(undefined, mockExtensionContext.object, undefined);
|
||||||
await schemaCompareResult.start(undefined);
|
await schemaCompareResult.start(undefined);
|
||||||
schemaCompareResult.sourceEndpointInfo = setDacpacEndpointInfo(mocksource);
|
schemaCompareResult.sourceEndpointInfo = setDacpacEndpointInfo(mocksource);
|
||||||
schemaCompareResult.targetEndpointInfo = setDacpacEndpointInfo(mocktarget);
|
schemaCompareResult.targetEndpointInfo = setDacpacEndpointInfo(mocktarget);
|
||||||
|
|||||||
@@ -3,16 +3,21 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import * as azdata from 'azdata';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import * as loc from './../localizedConstants';
|
||||||
|
|
||||||
export interface TestContext {
|
export interface TestContext {
|
||||||
context: vscode.ExtensionContext;
|
context: vscode.ExtensionContext;
|
||||||
|
viewContext: ViewTestContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createContext(): TestContext {
|
export function createContext(): TestContext {
|
||||||
let extensionPath = path.join(__dirname, '..', '..');
|
let extensionPath = path.join(__dirname, '..', '..');
|
||||||
|
|
||||||
|
let viewContext = createViewContext();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
context: {
|
context: {
|
||||||
subscriptions: [],
|
subscriptions: [],
|
||||||
@@ -36,5 +41,327 @@ export function createContext(): TestContext {
|
|||||||
logUri: undefined,
|
logUri: undefined,
|
||||||
storageUri: undefined
|
storageUri: undefined
|
||||||
},
|
},
|
||||||
|
viewContext: viewContext
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ViewTestContext {
|
||||||
|
view: azdata.ModelView;
|
||||||
|
onClick: vscode.EventEmitter<any>;
|
||||||
|
onTextChanged: vscode.EventEmitter<any>;
|
||||||
|
onValueChanged: vscode.EventEmitter<any>;
|
||||||
|
compareButtonOnClick: vscode.EventEmitter<any>;
|
||||||
|
selectButtonOnClick: vscode.EventEmitter<any>;
|
||||||
|
switchDirectionButtonOnClick: vscode.EventEmitter<any>;
|
||||||
|
cancelCompareButtonOnClick: vscode.EventEmitter<any>;
|
||||||
|
generateScriptButtonOnClick: vscode.EventEmitter<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createViewContext(): ViewTestContext {
|
||||||
|
let onClick: vscode.EventEmitter<any> = new vscode.EventEmitter<any>();
|
||||||
|
let onTextChanged: vscode.EventEmitter<any> = new vscode.EventEmitter<any>();
|
||||||
|
let onValueChanged: vscode.EventEmitter<any> = new vscode.EventEmitter<any>();
|
||||||
|
let compareButtonOnClick: vscode.EventEmitter<any> = new vscode.EventEmitter<any>();
|
||||||
|
let selectButtonOnClick: vscode.EventEmitter<any> = new vscode.EventEmitter<any>();
|
||||||
|
let switchDirectionButtonOnClick: vscode.EventEmitter<any> = new vscode.EventEmitter<any>();
|
||||||
|
let cancelCompareButtonOnClick: vscode.EventEmitter<any> = new vscode.EventEmitter<any>();
|
||||||
|
let generateScriptButtonOnClick: vscode.EventEmitter<any> = new vscode.EventEmitter<any>();
|
||||||
|
|
||||||
|
let componentBase: azdata.Component = {
|
||||||
|
id: '',
|
||||||
|
updateProperties: () => Promise.resolve(),
|
||||||
|
updateProperty: () => Promise.resolve(),
|
||||||
|
updateCssStyles: undefined!,
|
||||||
|
onValidityChanged: undefined!,
|
||||||
|
valid: true,
|
||||||
|
validate: undefined!,
|
||||||
|
focus: () => Promise.resolve()
|
||||||
|
};
|
||||||
|
|
||||||
|
let container = {
|
||||||
|
clearItems: () => { },
|
||||||
|
addItems: () => { },
|
||||||
|
addItem: () => { },
|
||||||
|
removeItem: () => true,
|
||||||
|
insertItem: () => { },
|
||||||
|
items: [] as any[],
|
||||||
|
setLayout: () => { },
|
||||||
|
setItemLayout: () => { }
|
||||||
|
};
|
||||||
|
|
||||||
|
let button = () => {
|
||||||
|
let button: azdata.ButtonComponent = Object.assign({}, componentBase, {
|
||||||
|
name: '',
|
||||||
|
label: '',
|
||||||
|
onDidClick: onClick.event
|
||||||
|
});
|
||||||
|
return button;
|
||||||
|
};
|
||||||
|
let buttonBuilder = () => {
|
||||||
|
let b = button();
|
||||||
|
let builder: azdata.ComponentBuilder<azdata.ButtonComponent, azdata.ButtonProperties> = {
|
||||||
|
component: () => b,
|
||||||
|
withProperties: (properties: any) => {
|
||||||
|
if ((properties as any).label === loc.compare) {
|
||||||
|
b.label = loc.compare;
|
||||||
|
b.onDidClick = compareButtonOnClick.event;
|
||||||
|
} else if ((properties as any).label === '•••') {
|
||||||
|
b.label = '•••';
|
||||||
|
b.onDidClick = selectButtonOnClick.event;
|
||||||
|
} else if ((properties as any).label === loc.switchDirection) {
|
||||||
|
b.label = loc.switchDirection;
|
||||||
|
b.onDidClick = switchDirectionButtonOnClick.event;
|
||||||
|
} else if ((properties as any).label === loc.stop) {
|
||||||
|
b.label = loc.stop;
|
||||||
|
b.onDidClick = cancelCompareButtonOnClick.event;
|
||||||
|
} else if ((properties as any).label === loc.generateScript) {
|
||||||
|
b.label = loc.generateScript;
|
||||||
|
b.onDidClick = generateScriptButtonOnClick.event;
|
||||||
|
}
|
||||||
|
return builder;
|
||||||
|
},
|
||||||
|
withProps: (properties) => {
|
||||||
|
if ((properties as any).label === loc.compare) {
|
||||||
|
b.label = loc.compare;
|
||||||
|
b.onDidClick = compareButtonOnClick.event;
|
||||||
|
} else if ((properties as any).label === '•••') {
|
||||||
|
b.label = '•••';
|
||||||
|
b.onDidClick = selectButtonOnClick.event;
|
||||||
|
} else if ((properties as any).label === loc.switchDirection) {
|
||||||
|
b.label = loc.switchDirection;
|
||||||
|
b.onDidClick = switchDirectionButtonOnClick.event;
|
||||||
|
} else if ((properties as any).label === loc.stop) {
|
||||||
|
b.label = loc.stop;
|
||||||
|
b.onDidClick = cancelCompareButtonOnClick.event;
|
||||||
|
} else if ((properties as any).label === loc.generateScript) {
|
||||||
|
b.label = loc.generateScript;
|
||||||
|
b.onDidClick = generateScriptButtonOnClick.event;
|
||||||
|
}
|
||||||
|
return builder;
|
||||||
|
},
|
||||||
|
withValidation: () => builder
|
||||||
|
};
|
||||||
|
return builder;
|
||||||
|
};
|
||||||
|
|
||||||
|
let radioButton: azdata.RadioButtonComponent = Object.assign({}, componentBase, {
|
||||||
|
checked: false,
|
||||||
|
onDidClick: onClick.event,
|
||||||
|
});
|
||||||
|
let radioButtonBuilder: azdata.ComponentBuilder<azdata.ButtonComponent, azdata.ButtonProperties> = {
|
||||||
|
component: () => radioButton,
|
||||||
|
withProperties: () => radioButtonBuilder,
|
||||||
|
withProps: () => radioButtonBuilder,
|
||||||
|
withValidation: () => radioButtonBuilder
|
||||||
|
};
|
||||||
|
|
||||||
|
let checkbox: azdata.CheckBoxComponent = Object.assign({}, componentBase, {
|
||||||
|
checked: true,
|
||||||
|
onChanged: onClick.event
|
||||||
|
});
|
||||||
|
let checkBoxBuilder: azdata.ComponentBuilder<azdata.CheckBoxComponent, azdata.CheckBoxProperties> = {
|
||||||
|
component: () => checkbox,
|
||||||
|
withProperties: () => checkBoxBuilder,
|
||||||
|
withProps: () => checkBoxBuilder,
|
||||||
|
withValidation: () => checkBoxBuilder
|
||||||
|
};
|
||||||
|
|
||||||
|
let form: azdata.FormContainer = Object.assign({}, componentBase, container, {
|
||||||
|
});
|
||||||
|
let formBuilder: azdata.FormBuilder = Object.assign({}, {
|
||||||
|
component: () => form,
|
||||||
|
addFormItem: () => { },
|
||||||
|
insertFormItem: () => { },
|
||||||
|
removeFormItem: () => true,
|
||||||
|
addFormItems: () => { },
|
||||||
|
withFormItems: () => formBuilder,
|
||||||
|
withProperties: () => formBuilder,
|
||||||
|
withValidation: () => formBuilder,
|
||||||
|
withItems: () => formBuilder,
|
||||||
|
withLayout: () => formBuilder,
|
||||||
|
withProps: () => formBuilder
|
||||||
|
});
|
||||||
|
|
||||||
|
let toolbar: azdata.ToolbarContainer = Object.assign({}, componentBase, container, {
|
||||||
|
});
|
||||||
|
let toolbarBuilder: azdata.ToolbarBuilder = Object.assign({}, {
|
||||||
|
component: () => toolbar,
|
||||||
|
withToolbarItems: () => toolbarBuilder,
|
||||||
|
addToolbarItems: () => { },
|
||||||
|
addToolbarItem: () => { },
|
||||||
|
withProperties: () => toolbarBuilder,
|
||||||
|
withValidation: () => toolbarBuilder,
|
||||||
|
withItems: () => toolbarBuilder,
|
||||||
|
withLayout: () => toolbarBuilder,
|
||||||
|
withProps: () => toolbarBuilder
|
||||||
|
});
|
||||||
|
|
||||||
|
let flex: azdata.FlexContainer = Object.assign({}, componentBase, container, {
|
||||||
|
});
|
||||||
|
let flexBuilder: azdata.FlexBuilder = Object.assign({}, {
|
||||||
|
component: () => flex,
|
||||||
|
withProperties: () => flexBuilder,
|
||||||
|
withValidation: () => flexBuilder,
|
||||||
|
withItems: () => flexBuilder,
|
||||||
|
withLayout: () => flexBuilder,
|
||||||
|
withProps: () => flexBuilder
|
||||||
|
});
|
||||||
|
|
||||||
|
let div: azdata.DivContainer = Object.assign({}, componentBase, container, {
|
||||||
|
onDidClick: onClick.event
|
||||||
|
});
|
||||||
|
let divBuilder: azdata.DivBuilder = Object.assign({}, {
|
||||||
|
component: () => div,
|
||||||
|
withProperties: () => divBuilder,
|
||||||
|
withValidation: () => divBuilder,
|
||||||
|
withItems: () => divBuilder,
|
||||||
|
withLayout: () => divBuilder,
|
||||||
|
withProps: () => divBuilder
|
||||||
|
});
|
||||||
|
|
||||||
|
let splitView: azdata.SplitViewContainer = Object.assign({}, componentBase, container, {
|
||||||
|
onDidClick: onClick.event
|
||||||
|
});
|
||||||
|
let splitViewBuilder: azdata.SplitViewBuilder = Object.assign({}, {
|
||||||
|
component: () => splitView,
|
||||||
|
withProperties: () => splitViewBuilder,
|
||||||
|
withValidation: () => splitViewBuilder,
|
||||||
|
withItems: () => splitViewBuilder,
|
||||||
|
withLayout: () => splitViewBuilder,
|
||||||
|
withProps: () => splitViewBuilder
|
||||||
|
});
|
||||||
|
|
||||||
|
let diffEditor: () => azdata.DiffEditorComponent = () => Object.assign({}, componentBase, {
|
||||||
|
contentLeft: '',
|
||||||
|
contentRight: '',
|
||||||
|
languageMode: '',
|
||||||
|
editorUriLeft: '',
|
||||||
|
editorUriRight: '',
|
||||||
|
onContentChanged: onClick.event,
|
||||||
|
onEditorCreated: onClick.event,
|
||||||
|
isAutoResizable: false,
|
||||||
|
minimumHeight: 0,
|
||||||
|
title: ''
|
||||||
|
});
|
||||||
|
let diffEditorBuilder: azdata.ComponentBuilder<azdata.DiffEditorComponent, azdata.DiffEditorComponent> = {
|
||||||
|
component: () => diffEditor(),
|
||||||
|
withProperties: () => diffEditorBuilder,
|
||||||
|
withValidation: () => diffEditorBuilder,
|
||||||
|
withProps: () => diffEditorBuilder
|
||||||
|
};
|
||||||
|
|
||||||
|
let inputBox: () => azdata.InputBoxComponent = () => Object.assign({}, componentBase, {
|
||||||
|
onTextChanged: onTextChanged.event,
|
||||||
|
onEnterKeyPressed: onClick.event,
|
||||||
|
value: ''
|
||||||
|
});
|
||||||
|
let inputBoxBuilder: azdata.ComponentBuilder<azdata.InputBoxComponent, azdata.InputBoxProperties> = {
|
||||||
|
component: () => {
|
||||||
|
let r = inputBox();
|
||||||
|
return r;
|
||||||
|
},
|
||||||
|
withProperties: () => inputBoxBuilder,
|
||||||
|
withProps: () => inputBoxBuilder,
|
||||||
|
withValidation: () => inputBoxBuilder
|
||||||
|
};
|
||||||
|
|
||||||
|
let dropdown: () => azdata.DropDownComponent = () => Object.assign({}, componentBase, {
|
||||||
|
onValueChanged: onValueChanged.event,
|
||||||
|
value: {
|
||||||
|
name: '',
|
||||||
|
displayName: ''
|
||||||
|
},
|
||||||
|
values: []
|
||||||
|
});
|
||||||
|
let dropdownBuilder: azdata.ComponentBuilder<azdata.DropDownComponent, azdata.DropDownProperties> = {
|
||||||
|
component: () => {
|
||||||
|
let r = dropdown();
|
||||||
|
return r;
|
||||||
|
},
|
||||||
|
withProperties: () => dropdownBuilder,
|
||||||
|
withProps: () => dropdownBuilder,
|
||||||
|
withValidation: () => dropdownBuilder
|
||||||
|
};
|
||||||
|
|
||||||
|
let table: () => azdata.TableComponent = () => Object.assign({}, componentBase, {
|
||||||
|
data: [] as any[][],
|
||||||
|
columns: [] as string[],
|
||||||
|
onRowSelected: onClick.event,
|
||||||
|
onCellAction: onClick.event,
|
||||||
|
appendData: (data: any[][]) => undefined
|
||||||
|
});
|
||||||
|
let tableBuilder: azdata.ComponentBuilder<azdata.TableComponent, azdata.TableComponentProperties> = {
|
||||||
|
component: () => table(),
|
||||||
|
withProperties: () => tableBuilder,
|
||||||
|
withProps: () => tableBuilder,
|
||||||
|
withValidation: () => tableBuilder
|
||||||
|
};
|
||||||
|
|
||||||
|
let loadingComponent: () => azdata.LoadingComponent = () => Object.assign({}, componentBase, {
|
||||||
|
loading: false,
|
||||||
|
component: undefined!
|
||||||
|
});
|
||||||
|
let loadingBuilder: azdata.LoadingComponentBuilder = {
|
||||||
|
component: () => loadingComponent(),
|
||||||
|
withProperties: () => loadingBuilder,
|
||||||
|
withProps: () => loadingBuilder,
|
||||||
|
withValidation: () => loadingBuilder,
|
||||||
|
withItem: () => loadingBuilder
|
||||||
|
};
|
||||||
|
|
||||||
|
let view: azdata.ModelView = {
|
||||||
|
onClosed: undefined!,
|
||||||
|
connection: undefined!,
|
||||||
|
serverInfo: undefined!,
|
||||||
|
valid: true,
|
||||||
|
onValidityChanged: undefined!,
|
||||||
|
validate: undefined!,
|
||||||
|
initializeModel: () => { return Promise.resolve(); },
|
||||||
|
modelBuilder: {
|
||||||
|
listView: undefined!,
|
||||||
|
radioCardGroup: undefined!,
|
||||||
|
navContainer: undefined!,
|
||||||
|
divContainer: () => divBuilder,
|
||||||
|
flexContainer: () => flexBuilder,
|
||||||
|
splitViewContainer: () => splitViewBuilder,
|
||||||
|
dom: undefined!,
|
||||||
|
card: () => undefined!,
|
||||||
|
inputBox: () => inputBoxBuilder,
|
||||||
|
checkBox: () => checkBoxBuilder!,
|
||||||
|
radioButton: () => radioButtonBuilder,
|
||||||
|
webView: undefined!,
|
||||||
|
editor: undefined!,
|
||||||
|
diffeditor: () => diffEditorBuilder,
|
||||||
|
text: () => inputBoxBuilder,
|
||||||
|
image: () => undefined!,
|
||||||
|
button: () => buttonBuilder(),
|
||||||
|
dropDown: () => dropdownBuilder,
|
||||||
|
tree: undefined!,
|
||||||
|
listBox: undefined!,
|
||||||
|
table: () => tableBuilder,
|
||||||
|
declarativeTable: () => undefined!,
|
||||||
|
dashboardWidget: undefined!,
|
||||||
|
dashboardWebview: undefined!,
|
||||||
|
formContainer: () => formBuilder,
|
||||||
|
groupContainer: () => undefined!,
|
||||||
|
toolbarContainer: () => toolbarBuilder,
|
||||||
|
loadingComponent: () => loadingBuilder,
|
||||||
|
fileBrowserTree: undefined!,
|
||||||
|
hyperlink: () => undefined!,
|
||||||
|
tabbedPanel: undefined!,
|
||||||
|
separator: undefined!,
|
||||||
|
propertiesContainer: undefined!
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
view: view,
|
||||||
|
onClick: onClick,
|
||||||
|
onTextChanged: onTextChanged,
|
||||||
|
onValueChanged: onValueChanged,
|
||||||
|
compareButtonOnClick: compareButtonOnClick,
|
||||||
|
selectButtonOnClick: selectButtonOnClick,
|
||||||
|
switchDirectionButtonOnClick: switchDirectionButtonOnClick,
|
||||||
|
cancelCompareButtonOnClick: cancelCompareButtonOnClick,
|
||||||
|
generateScriptButtonOnClick: generateScriptButtonOnClick,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import * as azdata from 'azdata';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as mssql from '../../../mssql';
|
import * as mssql from '../../../mssql';
|
||||||
import * as should from 'should';
|
import * as should from 'should';
|
||||||
@@ -24,8 +25,9 @@ export class SchemaCompareMainWindowTest extends SchemaCompareMainWindow {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
schemaCompareService: mssql.ISchemaCompareService,
|
schemaCompareService: mssql.ISchemaCompareService,
|
||||||
extensionContext: vscode.ExtensionContext) {
|
extensionContext: vscode.ExtensionContext,
|
||||||
super(schemaCompareService, extensionContext);
|
view: azdata.ModelView) {
|
||||||
|
super(schemaCompareService, extensionContext, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
// only for test
|
// only for test
|
||||||
|
|||||||
@@ -103,11 +103,39 @@ export class SchemaCompareTestService implements mssql.ISchemaCompareService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
schemaCompareGenerateScript(operationId: string, targetServerName: string, targetDatabaseName: string, taskExecutionMode: azdata.TaskExecutionMode): Thenable<azdata.ResultStatus> {
|
schemaCompareGenerateScript(operationId: string, targetServerName: string, targetDatabaseName: string, taskExecutionMode: azdata.TaskExecutionMode): Thenable<azdata.ResultStatus> {
|
||||||
return undefined;
|
let result: azdata.ResultStatus;
|
||||||
|
if (this.testState === testStateScmp.FAILURE) {
|
||||||
|
result = {
|
||||||
|
success: false,
|
||||||
|
errorMessage: 'Test failure'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result = {
|
||||||
|
success: true,
|
||||||
|
errorMessage: ''
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.resolve(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
schemaCompareCancel(operationId: string): Thenable<azdata.ResultStatus> {
|
schemaCompareCancel(operationId: string): Thenable<azdata.ResultStatus> {
|
||||||
return undefined;
|
let result: azdata.ResultStatus;
|
||||||
|
if (this.testState === testStateScmp.FAILURE) {
|
||||||
|
result = {
|
||||||
|
success: false,
|
||||||
|
errorMessage: 'Test failure'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result = {
|
||||||
|
success: true,
|
||||||
|
errorMessage: ''
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.resolve(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
handle?: number;
|
handle?: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user