mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Add info/warning/error messages for wizards and dialogs (#1696)
This commit is contained in:
@@ -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());
|
||||
});
|
||||
});
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user