[Edit Mode] Fixed issue with save dialog not being displayed for new objects after mutation. Fixes 1080

This commit is contained in:
Henry
2016-09-21 16:12:09 -07:00
parent e0b6986851
commit 3548cde9c4
5 changed files with 69 additions and 23 deletions

View File

@ -32,7 +32,9 @@ define(
mockQ,
mockDomainObject,
mockPolicyService,
mockNavigatedObject,
mockWindow,
capabilities,
action;
function mockPromise(value) {
@ -44,6 +46,29 @@ define(
}
beforeEach(function () {
capabilities = {};
mockQ = { when: mockPromise };
mockNavigatedObject = jasmine.createSpyObj(
"domainObject",
[
"getId",
"getModel",
"hasCapability",
"getCapability"
]
);
capabilities.editor = jasmine.createSpyObj("editorCapability", [
"isEditContextRoot",
"cancel"
]);
mockNavigatedObject.getCapability.andCallFake(function (capability) {
return capabilities[capability];
});
mockNavigatedObject.hasCapability.andReturn(false);
mockNavigationService = jasmine.createSpyObj(
"navigationService",
[
@ -51,11 +76,14 @@ define(
"getNavigation"
]
);
mockNavigationService.getNavigation.andReturn({});
mockQ = { when: mockPromise };
mockNavigationService.getNavigation.andReturn(mockNavigatedObject);
mockDomainObject = jasmine.createSpyObj(
"domainObject",
["getId", "getModel", "getCapability"]
[
"getId",
"getModel"
]
);
mockPolicyService = jasmine.createSpyObj("policyService",
@ -112,6 +140,21 @@ define(
});
});
describe("in edit more", function () {
beforeEach(function () {
mockNavigatedObject.hasCapability.andCallFake(function (capability) {
return capability === "editor";
});
capabilities.editor.isEditContextRoot.andReturn(true);
});
it("cancels editing if in edit mode", function () {
action.perform();
expect(capabilities.editor.cancel)
.toHaveBeenCalled();
});
});
it("is only applicable when a domain object is in context", function () {
expect(NavigateAction.appliesTo({})).toBeFalsy();
expect(NavigateAction.appliesTo({