-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #493 from aarranz/feature/duplicate-workspace
Feature/duplicate workspace
- Loading branch information
Showing
10 changed files
with
304 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
src/setup.cfg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
198 changes: 198 additions & 0 deletions
198
src/js_tests/wirecloud/ui/NewWorkspaceWindowMenuSpec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
/* | ||
* Copyright (c) 2020 Future Internet Consulting and Development Solutions S.L. | ||
* | ||
* This file is part of Wirecloud Platform. | ||
* | ||
* Wirecloud Platform is free software: you can redistribute it and/or | ||
* modify it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* Wirecloud is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Wirecloud Platform. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
/* globals StyledElements, Wirecloud */ | ||
|
||
(function (ns, se) { | ||
|
||
"use strict"; | ||
|
||
describe("NewWorkspaceWindowMenu", () => { | ||
|
||
beforeAll(() => { | ||
Wirecloud.ui.InputInterfaceFactory = new StyledElements.InputInterfaceFactory(); | ||
Wirecloud.ui.InputInterfaceFactory.addFieldType("mac", StyledElements.TextInputInterface); | ||
|
||
Wirecloud.contextManager = { | ||
"get": jasmine.createSpy("get").and.callFake((name) => { | ||
switch (name) { | ||
case "username": | ||
return "currentuser"; | ||
}; | ||
}) | ||
}; | ||
}); | ||
|
||
beforeEach(() => { | ||
spyOn(Wirecloud.UserInterfaceManager, "monitorTask"); | ||
spyOn(Wirecloud, "createWorkspace"); | ||
spyOn(Wirecloud, "changeActiveWorkspace"); | ||
Wirecloud.ui.MissingDependenciesWindowMenu = jasmine.createSpy("MissingDependenciesWindowMenu"); | ||
Wirecloud.ui.MessageWindowMenu = jasmine.createSpy("MessageWindowMenu"); | ||
}); | ||
|
||
afterAll(() => { | ||
delete Wirecloud.ui.InputInterfaceFactory; | ||
delete Wirecloud.contextManager; | ||
delete Wirecloud.ui.MissingDependenciesWindowMenu; | ||
delete Wirecloud.ui.MessageWindowMenu; | ||
}); | ||
|
||
describe("new Wirecloud.ui.NewWorkspaceWindowMenu(options)", () => { | ||
|
||
it("should work without providing any option", () => { | ||
const dialog = new ns.NewWorkspaceWindowMenu(); | ||
|
||
expect(dialog.form.fields.workspace).toBe(undefined); | ||
expect(dialog.form.fields.mashup).not.toBe(undefined); | ||
expect(dialog.form.fields.title).not.toBe(undefined); | ||
}); | ||
|
||
it("should allow to pass an initial title by using the title option", () => { | ||
const dialog = new ns.NewWorkspaceWindowMenu({"title": "New workspace"}); | ||
|
||
expect(dialog.form.fields.workspace).toBe(undefined); | ||
expect(dialog.form.fields.mashup).not.toBe(undefined); | ||
expect(dialog.form.fields.title.initialValue).toBe("New workspace"); | ||
}); | ||
|
||
it("should allow to duplicate workspaces by using the workspace option", () => { | ||
const dialog = new ns.NewWorkspaceWindowMenu({"workspace": "4"}); | ||
|
||
expect(dialog.form.fields.mashup).toBe(undefined); | ||
expect(dialog.form.fields.workspace.initialValue).toBe("4"); | ||
}); | ||
|
||
}); | ||
|
||
describe("executeOperation(data)", () => { | ||
|
||
it("should work when the title is empty", () => { | ||
const dialog = new ns.NewWorkspaceWindowMenu(); | ||
const workspace = {}; | ||
Wirecloud.createWorkspace.and.returnValue( | ||
new Wirecloud.Task("Sending request", (resolve) => {resolve(workspace);}) | ||
); | ||
|
||
dialog.executeOperation({ | ||
title: "", | ||
mashup: null | ||
}); | ||
expect(Wirecloud.changeActiveWorkspace).toHaveBeenCalledWith(workspace); | ||
}); | ||
|
||
it("should work when a title is provided", () => { | ||
const dialog = new ns.NewWorkspaceWindowMenu(); | ||
const workspace = {}; | ||
Wirecloud.createWorkspace.and.returnValue( | ||
new Wirecloud.Task("Sending request", (resolve) => {resolve(workspace);}) | ||
); | ||
|
||
dialog.executeOperation({ | ||
title: "New Workspace", | ||
mashup: null | ||
}); | ||
expect(Wirecloud.changeActiveWorkspace).toHaveBeenCalledWith(workspace); | ||
}); | ||
|
||
it("should manage generic errors", () => { | ||
const dialog = new ns.NewWorkspaceWindowMenu(); | ||
Wirecloud.createWorkspace.and.returnValue( | ||
new Wirecloud.Task("Sending request", (resolve, reject) => {reject({});}) | ||
); | ||
|
||
dialog.executeOperation({ | ||
title: "New Workspace", | ||
mashup: null | ||
}); | ||
expect(Wirecloud.changeActiveWorkspace).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it("should manage missingDependencies error", () => { | ||
const dialog = new ns.NewWorkspaceWindowMenu(); | ||
Wirecloud.createWorkspace.and.returnValue( | ||
new Wirecloud.Task("Sending request", (resolve, reject) => {reject({details: {missingDependencies: []}});}) | ||
); | ||
|
||
dialog.executeOperation({ | ||
title: "My Marketplace", | ||
mashup: "CoNWeT/bae-marketplace/0.1.1" | ||
}); | ||
|
||
expect(Wirecloud.changeActiveWorkspace).not.toHaveBeenCalled(); | ||
expect(Wirecloud.ui.MessageWindowMenu).not.toHaveBeenCalled(); | ||
expect(Wirecloud.ui.MissingDependenciesWindowMenu).toHaveBeenCalled(); | ||
}); | ||
|
||
it("should manage missingDependencies error (retry - success)", () => { | ||
const dialog = new ns.NewWorkspaceWindowMenu(); | ||
Wirecloud.createWorkspace.and.returnValue( | ||
new Wirecloud.Task("Sending request", (resolve, reject) => {reject({details: {missingDependencies: []}});}) | ||
); | ||
|
||
dialog.executeOperation({ | ||
title: "", | ||
mashup: "CoNWeT/bae-marketplace/0.1.1" | ||
}); | ||
expect(Wirecloud.ui.MissingDependenciesWindowMenu).toHaveBeenCalled(); | ||
|
||
const retry = Wirecloud.ui.MissingDependenciesWindowMenu.calls.argsFor(0)[0]; | ||
|
||
const workspace = {}; | ||
Wirecloud.createWorkspace.and.returnValue( | ||
new Wirecloud.Task("Sending request", (resolve) => {resolve(workspace);}) | ||
); | ||
|
||
retry(); | ||
|
||
expect(Wirecloud.ui.MessageWindowMenu).not.toHaveBeenCalled(); | ||
expect(Wirecloud.changeActiveWorkspace).toHaveBeenCalledWith(workspace); | ||
}); | ||
|
||
it("should manage missingDependencies error (retry - error)", () => { | ||
// Error retry | ||
const dialog = new ns.NewWorkspaceWindowMenu(); | ||
Wirecloud.createWorkspace.and.returnValue( | ||
new Wirecloud.Task("Sending request", (resolve, reject) => {reject({details: {missingDependencies: []}});}) | ||
); | ||
|
||
dialog.executeOperation({ | ||
title: "", | ||
mashup: "CoNWeT/bae-marketplace/0.1.1" | ||
}); | ||
expect(Wirecloud.ui.MissingDependenciesWindowMenu).toHaveBeenCalled(); | ||
|
||
const retry = Wirecloud.ui.MissingDependenciesWindowMenu.calls.argsFor(0)[0]; | ||
Wirecloud.createWorkspace.and.returnValue( | ||
new Wirecloud.Task("Sending request", (resolve, reject) => {reject({});}) | ||
); | ||
|
||
retry(); | ||
|
||
expect(Wirecloud.changeActiveWorkspace).not.toHaveBeenCalled(); | ||
expect(Wirecloud.ui.MessageWindowMenu).toHaveBeenCalled(); | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
})(Wirecloud.ui, StyledElements); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.