Merge remote-tracking branch 'origin/open254'

This commit is contained in:
Pete Richards
2016-07-18 11:35:43 -07:00
11 changed files with 212 additions and 148 deletions

View File

@@ -1,10 +1,11 @@
define([], function () {
function SaveInProgressDialog(dialogService) {
this.dialogService = dialogService;
this.dialog = undefined;
}
SaveInProgressDialog.prototype.show = function () {
this.dialogService.showBlockingMessage({
this.dialog = this.dialogService.showBlockingMessage({
title: "Saving...",
hint: "Do not navigate away from this page or close this browser tab while this message is displayed.",
unknownProgress: true,
@@ -13,7 +14,9 @@ define([], function () {
};
SaveInProgressDialog.prototype.hide = function () {
this.dialogService.dismiss();
if (this.dialog) {
this.dialog.dismiss();
}
};
return SaveInProgressDialog;

View File

@@ -70,7 +70,7 @@ define(
};
dialogService = jasmine.createSpyObj(
"dialogService",
["showBlockingMessage", "dismiss"]
["showBlockingMessage"]
);
mockDomainObject.hasCapability.andReturn(true);
@@ -111,17 +111,28 @@ define(
expect(mockActionCapability.perform).toHaveBeenCalledWith("navigate");
});
it("shows a dialog while saving", function () {
mockEditorCapability.save.andReturn(new Promise(function () {}));
action.perform();
expect(dialogService.showBlockingMessage).toHaveBeenCalled();
expect(dialogService.dismiss).not.toHaveBeenCalled();
});
describe("a blocking dialog", function () {
var mockDialogHandle;
it("hides a dialog when saving is complete", function () {
action.perform();
expect(dialogService.showBlockingMessage).toHaveBeenCalled();
expect(dialogService.dismiss).toHaveBeenCalled();
beforeEach(function () {
mockDialogHandle = jasmine.createSpyObj("dialogHandle", ["dismiss"]);
dialogService.showBlockingMessage.andReturn(mockDialogHandle);
});
it("shows a dialog while saving", function () {
mockEditorCapability.save.andReturn(new Promise(function () {
}));
action.perform();
expect(dialogService.showBlockingMessage).toHaveBeenCalled();
expect(mockDialogHandle.dismiss).not.toHaveBeenCalled();
});
it("hides a dialog when saving is complete", function () {
action.perform();
expect(dialogService.showBlockingMessage).toHaveBeenCalled();
expect(mockDialogHandle.dismiss).toHaveBeenCalled();
});
});
});

View File

@@ -101,8 +101,7 @@ define(
"dialogService",
[
"getUserInput",
"showBlockingMessage",
"dismiss"
"showBlockingMessage"
]
);
mockDialogService.getUserInput.andReturn(mockPromise(undefined));
@@ -171,25 +170,33 @@ define(
expect(mockDialogService.getUserInput).toHaveBeenCalled();
});
it("shows a blocking dialog while waiting for save", function () {
mockEditorCapability.save.andReturn(new Promise(function () {}));
action.perform();
expect(mockDialogService.showBlockingMessage).toHaveBeenCalled();
expect(mockDialogService.dismiss).not.toHaveBeenCalled();
});
describe("a blocking dialog", function () {
var mockDialogHandle;
it("hides the blocking dialog after saving", function () {
var mockCallback = jasmine.createSpy();
action.perform().then(mockCallback);
expect(mockDialogService.showBlockingMessage).toHaveBeenCalled();
waitsFor(function () {
return mockCallback.calls.length > 0;
beforeEach(function () {
mockDialogHandle = jasmine.createSpyObj("dialogHandle", ["dismiss"]);
mockDialogService.showBlockingMessage.andReturn(mockDialogHandle);
});
runs(function () {
expect(mockDialogService.dismiss).toHaveBeenCalled();
it("indicates that a save is taking place", function () {
mockEditorCapability.save.andReturn(new Promise(function () {}));
action.perform();
expect(mockDialogService.showBlockingMessage).toHaveBeenCalled();
expect(mockDialogHandle.dismiss).not.toHaveBeenCalled();
});
it("is hidden after saving", function () {
var mockCallback = jasmine.createSpy();
action.perform().then(mockCallback);
expect(mockDialogService.showBlockingMessage).toHaveBeenCalled();
waitsFor(function () {
return mockCallback.calls.length > 0;
});
runs(function () {
expect(mockDialogHandle.dismiss).toHaveBeenCalled();
});
});
});
});
}
);