Add info/warning/error messages for wizards and dialogs (#1696)

This commit is contained in:
Matt Irvine
2018-06-21 11:55:23 -07:00
committed by GitHub
parent 9d2b206156
commit f5b147ca4b
16 changed files with 238 additions and 30 deletions

View File

@@ -9,6 +9,7 @@ import { Mock, It, Times } from 'typemoq';
import { ExtHostModelViewDialog } from 'sql/workbench/api/node/extHostModelViewDialog';
import { MainThreadModelViewDialogShape, ExtHostModelViewShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
import { IMainContext } from 'vs/workbench/api/node/extHost.protocol';
import { MessageLevel } from 'sql/workbench/api/common/sqlExtHostTypes';
'use strict';
@@ -290,4 +291,20 @@ suite('ExtHostModelViewDialog Tests', () => {
assert.equal(validationInfo.lastPage, lastPage);
assert.equal(validationInfo.newPage, newPage);
});
test('Changing the wizard message sends the new message to the main thread', () => {
// Set up the main thread mock to record the call
mockProxy.setup(x => x.$setWizardDetails(It.isAny(), It.isAny()));
let wizard = extHostModelViewDialog.createWizard('wizard_1');
// If I update the wizard's message
let newMessage = {
level: MessageLevel.Error,
text: 'test message'
};
wizard.message = newMessage;
// Then the main thread gets notified of the new details
mockProxy.verify(x => x.$setWizardDetails(It.isAny(), It.is(x => x.message === newMessage)), Times.once());
});
});

View File

@@ -7,7 +7,7 @@ import * as assert from 'assert';
import { Mock, It, Times } from 'typemoq';
import { MainThreadModelViewDialog } from 'sql/workbench/api/node/mainThreadModelViewDialog';
import { IExtHostContext } from 'vs/workbench/api/node/extHost.protocol';
import { IModelViewButtonDetails, IModelViewTabDetails, IModelViewDialogDetails, IModelViewWizardPageDetails, IModelViewWizardDetails } from 'sql/workbench/api/common/sqlExtHostTypes';
import { IModelViewButtonDetails, IModelViewTabDetails, IModelViewDialogDetails, IModelViewWizardPageDetails, IModelViewWizardDetails, DialogMessage, MessageLevel } from 'sql/workbench/api/common/sqlExtHostTypes';
import { CustomDialogService } from 'sql/platform/dialog/customDialogService';
import { Dialog, DialogTab, Wizard } from 'sql/platform/dialog/dialogTypes';
import { ExtHostModelViewDialogShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
@@ -112,7 +112,8 @@ suite('MainThreadModelViewDialog Tests', () => {
content: [tab1Handle, tab2Handle],
okButton: okButtonHandle,
cancelButton: cancelButtonHandle,
customButtons: [button1Handle, button2Handle]
customButtons: [button1Handle, button2Handle],
message: undefined
};
// Set up the wizard details
@@ -152,7 +153,8 @@ suite('MainThreadModelViewDialog Tests', () => {
currentPage: undefined,
title: 'wizard_title',
customButtons: [],
pages: [page1Handle, page2Handle]
pages: [page1Handle, page2Handle],
message: undefined
};
// Register the buttons, tabs, and dialog
@@ -322,10 +324,27 @@ suite('MainThreadModelViewDialog Tests', () => {
mockExtHostModelViewDialog.setup(x => x.$validateNavigation(It.isAny(), It.isAny()));
// If I call validateNavigation on the wizard that gets created
let wizard: Wizard = (mainThreadModelViewDialog as any).getWizard(wizardHandle);
wizard.validateNavigation(1);
mainThreadModelViewDialog.$openWizard(wizardHandle);
openedWizard.validateNavigation(1);
// Then the call gets forwarded to the extension host
mockExtHostModelViewDialog.verify(x => x.$validateNavigation(It.is(handle => handle === wizardHandle), It.is(info => info.newPage === 1)), Times.once());
});
test('Adding a message to a wizard fires events on the created wizard', () => {
mainThreadModelViewDialog.$openWizard(wizardHandle);
let newMessage: DialogMessage;
openedWizard.onMessageChange(message => newMessage = message);
// If I change the wizard's message
wizardDetails.message = {
level: MessageLevel.Error,
text: 'test message'
};
mainThreadModelViewDialog.$setWizardDetails(wizardHandle, wizardDetails);
// Then the message gets changed on the wizard
assert.equal(newMessage, wizardDetails.message, 'New message was not included in the fired event');
assert.equal(openedWizard.message, wizardDetails.message, 'New message was not set on the wizard');
});
});