Preserve error messages if workspace validation fails in tests (#13901)

* preserving error messages if test fails

* change name of var to due scope change
This commit is contained in:
Benjin Dubishar
2021-01-11 17:50:34 -08:00
committed by GitHub
parent f37fb0b1d5
commit b69572a7c9
3 changed files with 25 additions and 17 deletions

View File

@@ -26,14 +26,18 @@ suite('Open Existing Dialog', function (): void {
await dialog.open();
dialog._targetTypeRadioCardGroup?.updateProperty( 'selectedCardId', constants.Project);
dialog._filePathTextBox!.value = '';
dialog._filePathTextBox!.value = 'nonExistentProjectFile';
dialog.workspaceInputBox!.value = 'test.code-workspace';
should.equal(await dialog.validate(), false, 'Validation fail because project file does not exist');
const validateResult = await dialog.validate();
const msg = constants.FileNotExistError('project', 'nonExistentProjectFile');
should.equal(dialog.dialogObject.message.text, msg);
should.equal(validateResult, false, 'Validation should fail because project file does not exist, but passed');
// create a project file
dialog._filePathTextBox!.value = await createProjectFile('testproj');
should.equal(await dialog.validate(), true, 'Validation pass because project file exists');
should.equal(await dialog.validate(), true, `Validation should pass because project file exists, but failed with: ${dialog.dialogObject.message.text}`);
});
test('Should validate workspace file exists', async function (): Promise<void> {
@@ -42,13 +46,18 @@ suite('Open Existing Dialog', function (): void {
await dialog.open();
dialog._targetTypeRadioCardGroup?.updateProperty( 'selectedCardId', constants.Workspace);
dialog._filePathTextBox!.value = '';
should.equal(await dialog.validate(), false, 'Validation fail because workspace file does not exist');
dialog._filePathTextBox!.value = 'nonExistentWorkspaceFile';
const validateResult = await dialog.validate();
const msg = constants.FileNotExistError('workspace', 'nonExistentWorkspaceFile');
should.equal(dialog.dialogObject.message.text, msg);
should.equal(validateResult, false, 'Validation should fail because workspace file does not exist, but passed');
// create a workspace file
dialog._filePathTextBox!.value = generateUniqueWorkspaceFilePath();
await fs.writeFile(dialog._filePathTextBox!.value , '');
should.equal(await dialog.validate(), true, 'Validation pass because workspace file exists');
should.equal(await dialog.validate(), true, `Validation should pass because workspace file exists, but failed with: ${dialog.dialogObject.message.text}`);
});