Fix unstable data-workspace tests (#13824)

* stub file existing validation

* add error message

* change back to calling dialog.validate()

* move tests to separate dialogbase file and add more error message validation
This commit is contained in:
Kim Santiago
2020-12-17 10:28:42 -08:00
committed by GitHub
parent f88e17a294
commit e3e1ae92b2
5 changed files with 92 additions and 68 deletions

View File

@@ -36,9 +36,7 @@ export abstract class DialogBase {
protected abstract initialize(view: azdata.ModelView): Promise<void>;
protected async validate(): Promise<boolean> {
return Promise.resolve(true);
}
abstract validate(): Promise<boolean>;
public async open(): Promise<void> {
const tab = azdata.window.createTab('');
@@ -77,6 +75,10 @@ export abstract class DialogBase {
};
}
public getErrorMessage(): azdata.window.DialogMessage {
return this._dialogObject.message;
}
protected createHorizontalContainer(view: azdata.ModelView, items: azdata.Component[]): azdata.FlexContainer {
return view.modelBuilder.flexContainer().withItems(items, { CSSStyles: { 'margin-right': '5px', 'margin-bottom': '10px' } }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();
}
@@ -159,7 +161,7 @@ export abstract class DialogBase {
}
}
protected async validateNewWorkspace(sameFolderAsNewProject: boolean): Promise<boolean> {
public async validateNewWorkspace(sameFolderAsNewProject: boolean): Promise<boolean> {
// workspace file should end in .code-workspace
const workspaceValid = this.workspaceInputBox!.value!.endsWith(constants.WorkspaceFileExtension);
if (!workspaceValid) {
@@ -171,7 +173,7 @@ export abstract class DialogBase {
if (!sameFolderAsNewProject) {
const workspaceParentDirectoryExists = await directoryExist(path.dirname(this.workspaceInputBox!.value!));
if (!workspaceParentDirectoryExists) {
this.showErrorMessage(constants.WorkspaceParentDirectoryNotExistError(this.workspaceInputBox!.value!));
this.showErrorMessage(constants.WorkspaceParentDirectoryNotExistError(path.dirname(this.workspaceInputBox!.value!)));
return false;
}
}