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

@@ -37,9 +37,7 @@ export class OpenExistingDialog extends DialogBase {
try {
// the selected location should be an existing directory
if (this._targetTypeRadioCardGroup?.selectedCardId === constants.Project) {
const fileExists = await fileExist(this._projectFile);
if (!fileExists) {
this.showErrorMessage(constants.FileNotExistError(constants.Project.toLowerCase(), this._projectFile));
if (!await this.validateFile(this._projectFile, constants.Project.toLowerCase())) {
return false;
}
@@ -47,9 +45,7 @@ export class OpenExistingDialog extends DialogBase {
return false;
}
} else if (this._targetTypeRadioCardGroup?.selectedCardId === constants.Workspace) {
const fileExists = await fileExist(this._workspaceFile);
if (!fileExists) {
this.showErrorMessage(constants.FileNotExistError(constants.Workspace.toLowerCase(), this._workspaceFile));
if (!await this.validateFile(this._workspaceFile, constants.Workspace.toLowerCase())) {
return false;
}
}
@@ -62,6 +58,16 @@ export class OpenExistingDialog extends DialogBase {
}
}
public async validateFile(file: string, fileType: string) {
const fileExists = await fileExist(file);
if (!fileExists) {
this.showErrorMessage(constants.FileNotExistError(fileType, file));
return false;
}
return true;
}
async onComplete(): Promise<void> {
try {
if (this._targetTypeRadioCardGroup?.selectedCardId === constants.Workspace) {