From 51b0c6c9b06d97d007d99cdcd8651a97b0b792df Mon Sep 17 00:00:00 2001 From: waynedunican Date: Mon, 21 Sep 2020 09:19:42 +0100 Subject: JS Testing added for apex-editor Last apex-editor/pom.xml change to exclude the /dist folder Issue-ID: POLICY-2783 Change-Id: I076aac4e503c7e5f2ea39fa9291153be4b119808 Signed-off-by: waynedunican --- .../src/main/resources/webapp/js/ApexAjax.js | 9 +- .../webapp/js/ApexContextAlbumEditForm.js | 39 ++++-- .../resources/webapp/js/ApexContextAlbumTab.js | 15 +- .../webapp/js/ApexContextSchemaEditForm.js | 31 +++-- .../resources/webapp/js/ApexContextSchemaTab.js | 22 ++- .../main/resources/webapp/js/ApexEventEditForm.js | 40 +++++- .../src/main/resources/webapp/js/ApexEventTab.js | 20 ++- .../src/main/resources/webapp/js/ApexFiles.js | 16 ++- .../src/main/resources/webapp/js/ApexFormUtils.js | 2 +- .../resources/webapp/js/ApexKeyInformationTab.js | 13 +- .../src/main/resources/webapp/js/ApexMain.js | 23 ++-- .../main/resources/webapp/js/ApexModelHandling.js | 14 +- .../main/resources/webapp/js/ApexNewModelForm.js | 22 ++- .../main/resources/webapp/js/ApexPageControl.js | 29 +++- .../main/resources/webapp/js/ApexPolicyEditForm.js | 54 ++++++-- .../webapp/js/ApexPolicyEditForm_State.js | 19 +++ .../src/main/resources/webapp/js/ApexPolicyTab.js | 21 ++- .../src/main/resources/webapp/js/ApexResultForm.js | 6 + .../src/main/resources/webapp/js/ApexTable.js | 2 +- .../main/resources/webapp/js/ApexTaskEditForm.js | 45 ++++-- .../src/main/resources/webapp/js/ApexTaskTab.js | 29 +++- .../src/main/resources/webapp/js/ApexUtils.js | 12 +- .../resources/webapp/js/__test__/ApexAjax.test.js | 153 ++++++++++++++++----- .../js/__test__/ApexContextAlbumEditForm.test.js | 44 ++++++ .../webapp/js/__test__/ApexContextAlbumTab.test.js | 15 +- .../js/__test__/ApexContextSchemaEditForm.test.js | 36 +++++ .../js/__test__/ApexContextSchemaTab.test.js | 33 +++++ .../webapp/js/__test__/ApexEventEditForm.test.js | 73 ++++++++++ .../webapp/js/__test__/ApexEventTab.test.js | 33 +++++ .../resources/webapp/js/__test__/ApexFiles.test.js | 46 +++---- .../webapp/js/__test__/ApexFormUtils.test.js | 5 +- .../webapp/js/__test__/ApexModelHandling.test.js | 37 +++++ .../webapp/js/__test__/ApexNewModelForm.test.js | 46 +++++++ .../webapp/js/__test__/ApexPageControl.test.js | 30 ---- .../webapp/js/__test__/ApexPolicyEditForm.test.js | 55 ++++++++ .../js/__test__/ApexPolicyEditForm_State.test.js | 122 ++++++++++++++++ .../webapp/js/__test__/ApexPolicyTab.test.js | 26 ++++ .../webapp/js/__test__/ApexResultForm.test.js | 37 +++++ .../webapp/js/__test__/ApexTaskEditForm.test.js | 50 +++++++ .../webapp/js/__test__/ApexTaskTab.test.js | 33 +++++ .../src/main/resources/webapp/js/contextMenu.js | 36 +++++ .../src/main/resources/webapp/js/dropdownList.js | 11 ++ .../main/resources/webapp/js/showhideTextarea.js | 7 + 43 files changed, 1226 insertions(+), 185 deletions(-) create mode 100644 gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexContextAlbumEditForm.test.js create mode 100644 gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexContextSchemaEditForm.test.js create mode 100644 gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexContextSchemaTab.test.js create mode 100644 gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexEventEditForm.test.js create mode 100644 gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexEventTab.test.js create mode 100644 gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexModelHandling.test.js create mode 100644 gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexNewModelForm.test.js delete mode 100644 gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPageControl.test.js create mode 100644 gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPolicyEditForm.test.js create mode 100644 gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPolicyEditForm_State.test.js create mode 100644 gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPolicyTab.test.js create mode 100644 gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexResultForm.test.js create mode 100644 gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexTaskEditForm.test.js create mode 100644 gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexTaskTab.test.js (limited to 'gui-editors/gui-editor-apex/src/main/resources/webapp/js') diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexAjax.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexAjax.js index 2a75b72..79a4ac8 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexAjax.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexAjax.js @@ -19,6 +19,11 @@ * ============LICENSE_END========================================================= */ +const { + pageControl_restError, pageControl_status, + pageControl_successStatus +} = require("./ApexPageControl"); + function ajax_get(requestURL, callback) { $.ajax({ type : 'GET', @@ -36,7 +41,7 @@ function ajax_get(requestURL, callback) { function ajax_getWithKeyInfo(requestURL, objectType, callback, keyNam) { let keyName = keyNam || "key"; - let keyInfoURL = restRootURL + "/KeyInformation/Get?name=&version="; + let keyInfoURL = window.restRootURL + "/KeyInformation/Get?name=&version="; ajax_get(keyInfoURL, function(dataKeyInfos) { ajax_get(requestURL, function(data) { var keyInfos = []; @@ -122,4 +127,4 @@ function ajax_delete(requestURL, callback) { }); } -module.exports = {ajax_get, ajax_delete, ajax_post, ajax_put, ajax_getOKOrFail, ajax_getWithKeyInfo}; \ No newline at end of file +export {ajax_get, ajax_delete, ajax_post, ajax_put, ajax_getOKOrFail, ajax_getWithKeyInfo}; \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextAlbumEditForm.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextAlbumEditForm.js index 602fa49..c09e625 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextAlbumEditForm.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextAlbumEditForm.js @@ -19,9 +19,15 @@ * ============LICENSE_END========================================================= */ +const {ajax_delete, ajax_getWithKeyInfo, ajax_get} = require("./ApexAjax"); +const {contextAlbumTab_reset} = require("./ApexContextAlbumTab"); +const {apexUtils_removeElement, apexUtils_emptyElement, scrollToTop, apexUtils_areYouSure} = require("./ApexUtils"); +const {dropdownList} = require("./dropdownList"); +const { formUtils_generateDescription, formUtils_generateUUID } = require("./ApexFormUtils"); + function editContextAlbumForm_createContextAlbum(formParent) { // Get all contextSchemas too for album item schema - var requestURL = restRootURL + "/ContextSchema/Get?name=&version="; + var requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; var contextSchemas = new Array(); ajax_get(requestURL, function(data2) { for (var i = 0; i < data2.messages.message.length; i++) { @@ -40,7 +46,7 @@ function editContextAlbumForm_createContextAlbum(formParent) { function editContextAlbumForm_deleteContextAlbum(parent, name, version) { var message = "Are you sure you want to delete ContextAlbum \"" + name + ":" + version + "\"?"; if (apexUtils_areYouSure(message)) { - var requestURL = restRootURL + "/ContextAlbum/Delete?name=" + name + "&version=" + version; + var requestURL = window.restRootURL + "/ContextAlbum/Delete?name=" + name + "&version=" + version; ajax_delete(requestURL, function(data) { apexUtils_removeElement("editContextAlbumFormDiv"); contextAlbumTab_reset(); @@ -50,10 +56,10 @@ function editContextAlbumForm_deleteContextAlbum(parent, name, version) { } function editContextAlbumForm_viewContextAlbum(parent, name, version) { - var requestURL = restRootURL + "/ContextAlbum/Get?name=" + name + "&version=" + version; + var requestURL = window.restRootURL + "/ContextAlbum/Get?name=" + name + "&version=" + version; ajax_getWithKeyInfo(requestURL, "apexContextAlbum", function(contextAlbum) { // Get all contextSchemas too for album item schema - var requestURL = restRootURL + "/ContextSchema/Get?name=&version="; + var requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; var contextSchemas = new Array(); ajax_get(requestURL, function(data2) { for (var i = 0; i < data2.messages.message.length; i++) { @@ -71,10 +77,10 @@ function editContextAlbumForm_viewContextAlbum(parent, name, version) { } function editContextAlbumForm_editContextAlbum(formParent, name, version) { - var requestURL = restRootURL + "/ContextAlbum/Get?name=" + name + "&version=" + version; + var requestURL = window.restRootURL + "/ContextAlbum/Get?name=" + name + "&version=" + version; ajax_getWithKeyInfo(requestURL, "apexContextAlbum", function(contextAlbum) { // Get all contextSchemas too for album item schema - var requestURL = restRootURL + "/ContextSchema/Get?name=&version="; + var requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; var contextSchemas = new Array(); ajax_get(requestURL, function(data2) { for (var i = 0; i < data2.messages.message.length; i++) { @@ -94,6 +100,11 @@ function editContextAlbumForm_editContextAlbum(formParent, name, version) { function editContextAlbumForm_activate(parent, operation, contextAlbum, contextSchemas) { apexUtils_removeElement("editContextAlbumFormDiv"); var formParent = document.getElementById(parent); + + //Test Purposes + if(formParent === null){ + formParent = document.createElement(parent); + } apexUtils_emptyElement(parent); var isedit = false; @@ -457,14 +468,14 @@ function editContextAlbumForm_submitPressed() { }); if (createEditOrView == "CREATE") { - var requestURL = restRootURL + "/ContextAlbum/Create"; + var requestURL = window.restRootURL + "/ContextAlbum/Create"; ajax_post(requestURL, jsonString, function(resultData) { apexUtils_removeElement("editContextAlbumFormDiv"); contextAlbumTab_reset(); keyInformationTab_reset() }); } else if (createEditOrView == "EDIT") { - var requestURL = restRootURL + "/ContextAlbum/Update"; + var requestURL = window.restRootURL + "/ContextAlbum/Update"; ajax_put(requestURL, jsonString, function(resultData) { apexUtils_removeElement("editContextAlbumFormDiv"); contextAlbumTab_reset(); @@ -473,3 +484,15 @@ function editContextAlbumForm_submitPressed() { } } + +export { + editContextAlbumForm_viewContextAlbum, + editContextAlbumForm_generateUUIDPressed, + editContextAlbumForm_generateDescriptionPressed, + editContextAlbumForm_editContextAlbum, + editContextAlbumForm_deleteContextAlbum, + editContextAlbumForm_createContextAlbum, + editContextAlbumForm_cancelPressed, + editContextAlbumForm_activate, + editContextAlbumForm_submitPressed +} diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextAlbumTab.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextAlbumTab.js index f0af49f..2b1a5e8 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextAlbumTab.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextAlbumTab.js @@ -19,6 +19,11 @@ * ============LICENSE_END========================================================= */ +import {rightClickMenu_scopePreserver} from './contextMenu'; +import {createTable} from './ApexTable'; +import {ajax_get} from './ApexAjax'; +import {apexUtils_removeElement} from "./ApexUtils"; + function contextAlbumTab_reset() { contextAlbumTab_deactivate(); contextAlbumTab_activate(); @@ -27,7 +32,7 @@ function contextAlbumTab_reset() { function contextAlbumTab_activate() { contextAlbumTab_create(); - var requestURL = restRootURL + "/ContextAlbum/Get?name=&version="; + var requestURL = window.restRootURL + "/ContextAlbum/Get?name=&version="; ajax_get(requestURL, function(data) { $("#contextAlbumTableBody").find("tr:gt(0)").remove(); @@ -69,6 +74,11 @@ function contextAlbumTab_deactivate() { function contextAlbumTab_create() { var contextAlbumTab = document.getElementById("contextAlbumsTab"); + //Testing purposes + if(contextAlbumTab === null){ + contextAlbumTab = document.createElement('contextAlbumsTab'); + } + var contextAlbumTabContent = document.getElementById("contextAlbumTabContent"); if (contextAlbumTabContent != null) { return @@ -115,4 +125,5 @@ function contextAlbumTab_create() { contextAlbumTable.setAttribute("id", "contextAlbumTableBody"); } -module.exports = {contextAlbumTab_reset, contextAlbumTab_create, contextAlbumTab_activate, contextAlbumTab_deactivate}; \ No newline at end of file +//Testing purposes +export { contextAlbumTab_reset, contextAlbumTab_create, contextAlbumTab_activate, contextAlbumTab_deactivate }; \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextSchemaEditForm.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextSchemaEditForm.js index 7eecb72..197b58b 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextSchemaEditForm.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextSchemaEditForm.js @@ -19,6 +19,14 @@ * ============LICENSE_END========================================================= */ +import {ajax_delete, ajax_getWithKeyInfo, ajax_post, ajax_put} from "./ApexAjax"; +import {apexUtils_removeElement, apexUtils_emptyElement, scrollToTop, apexUtils_areYouSure} from "./ApexUtils"; +import { + formUtils_generateDescription, + formUtils_generateUUID +} from "./ApexFormUtils"; +import {contextSchemaTab_reset} from "./ApexContextSchemaTab"; + function editContextSchemaForm_createContextSchema(formParent) { return editContextSchemaForm_activate(formParent, "CREATE", null); } @@ -26,7 +34,7 @@ function editContextSchemaForm_createContextSchema(formParent) { function editContextSchemaForm_deleteContextSchema(parent, name, version) { var message = "Are you sure you want to delete ContextSchema \"" + name + ":" + version + "\"?"; if (apexUtils_areYouSure(message)) { - var requestURL = restRootURL + "/ContextSchema/Delete?name=" + name + "&version=" + version; + var requestURL = window.restRootURL + "/ContextSchema/Delete?name=" + name + "&version=" + version; ajax_delete(requestURL, function(data) { apexUtils_removeElement("editContextSchemaFormDiv"); contextSchemaTab_reset(); @@ -36,14 +44,14 @@ function editContextSchemaForm_deleteContextSchema(parent, name, version) { } function editContextSchemaForm_viewContextSchema(parent, name, version) { - var requestURL = restRootURL + "/ContextSchema/Get?name=" + name + "&version=" + version; + var requestURL = window.restRootURL + "/ContextSchema/Get?name=" + name + "&version=" + version; ajax_getWithKeyInfo(requestURL, "apexContextSchema", function(contextSchema) { editContextSchemaForm_activate(parent, "VIEW", contextSchema); }); } function editContextSchemaForm_editContextSchema(formParent, name, version) { - var requestURL = restRootURL + "/ContextSchema/Get?name=" + name + "&version=" + version; + var requestURL = window.restRootURL + "/ContextSchema/Get?name=" + name + "&version=" + version; ajax_getWithKeyInfo(requestURL, "apexContextSchema", function(contextSchema) { editContextSchemaForm_activate(formParent, "EDIT", contextSchema); }); @@ -52,6 +60,11 @@ function editContextSchemaForm_editContextSchema(formParent, name, version) { function editContextSchemaForm_activate(parent, operation, contextSchema) { apexUtils_removeElement("editContextSchemaFormDiv"); var formParent = document.getElementById(parent); + + //Testing purposes + if(formParent === null){ + formParent = document.createElement("formParentTest") + } apexUtils_emptyElement(parent); var isedit = false; @@ -351,14 +364,14 @@ function editContextSchemaForm_submitPressed() { }); if (createEditOrView == "CREATE") { - var requestURL = restRootURL + "/ContextSchema/Create"; + var requestURL = window.restRootURL + "/ContextSchema/Create"; ajax_post(requestURL, jsonString, function(resultData) { apexUtils_removeElement("editContextSchemaFormDiv"); contextSchemaTab_reset(); keyInformationTab_reset() }); } else if (createEditOrView == "EDIT") { - var requestURL = restRootURL + "/ContextSchema/Update"; + var requestURL = window.restRootURL + "/ContextSchema/Update"; ajax_put(requestURL, jsonString, function(resultData) { apexUtils_removeElement("editContextSchemaFormDiv"); contextSchemaTab_reset(); @@ -368,6 +381,8 @@ function editContextSchemaForm_submitPressed() { } -module.exports = {editContextSchemaForm_activate, editContextSchemaForm_cancelPressed, editContextSchemaForm_createContextSchema, - editContextSchemaForm_deleteContextSchema, editContextSchemaForm_editContextSchema, editContextSchemaForm_generateDescriptionPressed, - editContextSchemaForm_generateUUIDPressed, editContextSchemaForm_submitPressed, editContextSchemaForm_viewContextSchema}; +export { + editContextSchemaForm_activate, editContextSchemaForm_cancelPressed, editContextSchemaForm_createContextSchema, + editContextSchemaForm_deleteContextSchema, editContextSchemaForm_editContextSchema, editContextSchemaForm_generateDescriptionPressed, + editContextSchemaForm_generateUUIDPressed, editContextSchemaForm_submitPressed, editContextSchemaForm_viewContextSchema +}; diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextSchemaTab.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextSchemaTab.js index 1c8b85e..4474f5d 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextSchemaTab.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexContextSchemaTab.js @@ -19,6 +19,11 @@ * ============LICENSE_END========================================================= */ +const {ajax_get} = require("./ApexAjax"); +const {createTable} = require('./ApexTable'); +const {rightClickMenu_scopePreserver} = require('./contextMenu'); +const {apexUtils_removeElement} = require('./ApexUtils'); + function contextSchemaTab_reset() { contextSchemaTab_deactivate(); contextSchemaTab_activate(); @@ -26,7 +31,7 @@ function contextSchemaTab_reset() { function contextSchemaTab_activate() { contextSchemaTab_create(); - var requestURL = restRootURL + "/ContextSchema/Get?name=&version="; + var requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; ajax_get(requestURL, function(data) { $("#contextSchemaTableBody").find("tr:gt(0)").remove(); @@ -63,6 +68,11 @@ function contextSchemaTab_deactivate() { function contextSchemaTab_create() { var contextSchemaTab = document.getElementById("contextSchemasTab"); + //Testing purposes + if(contextSchemaTab === null){ + contextSchemaTab = document.createElement('contextSchemasTab'); + } + var contextSchemaTabContent = document.getElementById("contextSchemaTabContent"); if (contextSchemaTabContent != null) { return @@ -102,4 +112,12 @@ function contextSchemaTab_create() { var contextSchemaTableBody = document.createElement("tbody"); contextSchemaTable.appendChild(contextSchemaTableBody); contextSchemaTable.setAttribute("id", "contextSchemaTableBody"); -} \ No newline at end of file +} + +//Testing purposes +export { + contextSchemaTab_activate, + contextSchemaTab_deactivate, + contextSchemaTab_reset, + contextSchemaTab_create +} diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexEventEditForm.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexEventEditForm.js index 51408e3..58c9b26 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexEventEditForm.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexEventEditForm.js @@ -19,10 +19,17 @@ * ============LICENSE_END========================================================= */ +import { formUtils_generateDescription, formUtils_generateUUID } from "./ApexFormUtils"; +import {dropdownList} from "./dropdownList"; +import {ajax_post, ajax_put, ajax_delete, ajax_get, ajax_getWithKeyInfo} from "./ApexAjax"; +import {eventTab_reset} from "./ApexEventTab"; +import {apexUtils_areYouSure, apexUtils_removeElement, apexUtils_emptyElement, createAddFormButton, scrollToTop} from './ApexUtils'; +import {keyInformationTab_reset} from "./ApexKeyInformationTab"; + function editEventForm_deleteEvent(parent, name, version) { var message = "Are you sure you want to delete Event \"" + name + ":" + version + "\"?"; if (apexUtils_areYouSure(message)) { - var requestURL = restRootURL + "/Event/Delete?name=" + name + "&version=" + version; + var requestURL = window.restRootURL + "/Event/Delete?name=" + name + "&version=" + version; ajax_delete(requestURL, function(data) { apexUtils_removeElement("editEventFormDiv"); eventTab_reset(); @@ -41,7 +48,7 @@ function editEventForm_editEvent(formParent, name, version) { function editEventForm_createEvent(formParent) { // Get all contextSchemas too for event params - var requestURL = restRootURL + "/ContextSchema/Get?name=&version="; + var requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; var contextSchemas = new Array(); ajax_get(requestURL, function(data2) { for (var i = 0; i < data2.messages.message.length; i++) { @@ -59,10 +66,10 @@ function editEventForm_createEvent(formParent) { } function editEventForm_editEvent_inner(formParent, name, version, viewOrEdit) { - var requestURL = restRootURL + "/Event/Get?name=" + name + "&version=" + version; + var requestURL = window.restRootURL + "/Event/Get?name=" + name + "&version=" + version; ajax_getWithKeyInfo(requestURL, "apexEvent", function(event) { // Get all contextSchemas too for event params - var requestURL = restRootURL + "/ContextSchema/Get?name=&version="; + var requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; var contextSchemas = new Array(); ajax_get(requestURL, function(data2) { for (var i = 0; i < data2.messages.message.length; i++) { @@ -82,6 +89,11 @@ function editEventForm_editEvent_inner(formParent, name, version, viewOrEdit) { function editEventForm_activate(parent, operation, event, contextSchemas) { apexUtils_removeElement("editEventFormDiv"); var formParent = document.getElementById(parent); + + //Testing purposes + if(formParent === null){ + formParent = document.createElement('testFormParent'); + } apexUtils_emptyElement(parent); var isedit = false; @@ -302,7 +314,7 @@ function editEventForm_activate(parent, operation, event, contextSchemas) { // for // delete // button - paramstable_head_th = document.createElement("th"); + var paramstable_head_th = document.createElement("th"); paramstable_head_tr.appendChild(paramstable_head_th); paramstable_head_th.innerHTML = "Parameter Name: "; paramstable_head_th.setAttribute("class", "table-eventparam-heading form-heading"); @@ -548,14 +560,14 @@ function editEventForm_submitPressed() { var jsonString = JSON.stringify(eventbean); if (createEditOrView == "CREATE") { - var requestURL = restRootURL + "/Event/Create"; + var requestURL = window.restRootURL + "/Event/Create"; ajax_post(requestURL, jsonString, function(resultData) { apexUtils_removeElement("editEventFormDiv"); eventTab_reset(); keyInformationTab_reset() }); } else if (createEditOrView == "EDIT") { - var requestURL = restRootURL + "/Event/Update"; + var requestURL = window.restRootURL + "/Event/Update"; ajax_put(requestURL, jsonString, function(resultData) { apexUtils_removeElement("editEventFormDiv"); eventTab_reset(); @@ -564,3 +576,17 @@ function editEventForm_submitPressed() { } } + +export { + editEventForm_activate, + editEventForm_addEventParam, + editEventForm_cancelPressed, + editEventForm_createEvent, + editEventForm_deleteEvent, + editEventForm_editEvent, + editEventForm_editEvent_inner, + editEventForm_generateDescriptionPressed, + editEventForm_generateUUIDPressed, + editEventForm_submitPressed, + editEventForm_viewEvent +} diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexEventTab.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexEventTab.js index 699f460..56886fb 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexEventTab.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexEventTab.js @@ -19,6 +19,12 @@ * ============LICENSE_END========================================================= */ + +import {ajax_get} from "./ApexAjax"; +import {rightClickMenu_scopePreserver} from "./contextMenu"; +import {createTable} from "./ApexTable"; +import {apexUtils_removeElement} from "./ApexUtils"; + function eventTab_reset() { eventTab_deactivate(); eventTab_activate(); @@ -27,7 +33,7 @@ function eventTab_reset() { function eventTab_activate() { eventTab_create(); - var requestURL = restRootURL + "/Event/Get?name=&version="; + var requestURL = window.restRootURL + "/Event/Get?name=&version="; ajax_get(requestURL, function(data) { $("#eventTableBody").find("tr:gt(0)").remove(); @@ -87,6 +93,11 @@ function eventTab_deactivate() { function eventTab_create() { var eventTab = document.getElementById("eventsTab"); + //Testing purposes + if(eventTab === null){ + eventTab = document.createElement('eventsTab'); + } + var eventTabContent = document.getElementById("eventTabContent"); if (eventTabContent != null) { return @@ -138,4 +149,9 @@ function eventTab_create() { eventTable.setAttribute("id", "eventTableBody"); } -exports = {eventTab_reset, eventTab_activate, eventTab_deactivate, eventTab_create} +export { + eventTab_reset, + eventTab_activate, + eventTab_deactivate, + eventTab_create +} diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexFiles.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexFiles.js index 93b1183..ade1eb3 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexFiles.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexFiles.js @@ -19,6 +19,12 @@ * ============LICENSE_END========================================================= */ +import {resultForm_activate} from "./ApexResultForm"; + +const {ajax_put, ajax_get, ajax_getOKOrFail} = require("./ApexAjax"); +const {pageControl_modelMode} = require("./ApexPageControl"); +const {modelFileName} = require("./ApexNewModelForm"); + function files_fileOpen() { $('').on('change', function() { var reader = new FileReader(); @@ -26,10 +32,10 @@ function files_fileOpen() { reader.readAsText(this.files[0]); reader.onload = function(event) { - var requestURL = restRootURL + "/Model/Load"; + var requestURL = window.restRootURL + "/Model/Load"; ajax_put(requestURL, event.target.result, function(resultData) { localStorage.setItem("apex_model_loaded", true); - var requestURL = restRootURL + "/Model/GetKey"; + var requestURL = window.restRootURL + "/Model/GetKey"; ajax_get(requestURL, function(data) { var modelKey = JSON.parse(data.messages.message[0]).apexArtifactKey; pageControl_modelMode(modelKey.name, modelKey.version, modelFileName); @@ -40,7 +46,7 @@ function files_fileOpen() { } function files_fileDownload() { - var requestURL = restRootURL + "/Model/Download"; + var requestURL = window.restRootURL + "/Model/Download"; var downloadLink = document.createElement("a"); document.body.appendChild(downloadLink); @@ -51,7 +57,7 @@ function files_fileDownload() { } function files_fileUpload() { - var requestURL = restRootURL + "/Model/Upload?userId=" + new URLSearchParams(window.location.search).get('userId'); + var requestURL = window.restRootURL + "/Model/Upload?userId=" + new URLSearchParams(window.location.search).get('userId'); ajax_getOKOrFail(requestURL, function(data) { var uploadResultString = ""; @@ -62,4 +68,4 @@ function files_fileUpload() { }); } -module.exports = {files_fileUpload, files_fileDownload, files_fileOpen}; +export {files_fileUpload, files_fileDownload, files_fileOpen}; diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexFormUtils.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexFormUtils.js index 93f0f68..9476e58 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexFormUtils.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexFormUtils.js @@ -47,4 +47,4 @@ function formUtils_generateDescription(name, version, uuid) { return description; } -module.exports = {formUtils_generateDescription, formUtils_generateUUID}; +export {formUtils_generateDescription, formUtils_generateUUID}; diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexKeyInformationTab.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexKeyInformationTab.js index 3ba1e17..9442ddd 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexKeyInformationTab.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexKeyInformationTab.js @@ -19,6 +19,10 @@ * ============LICENSE_END========================================================= */ +import {ajax_get} from "./ApexAjax"; +import {apexUtils_escapeHtml, apexUtils_removeElement} from "./ApexUtils"; +import {createTable} from "./ApexTable"; + function keyInformationTab_reset() { keyInformationTab_deactivate(); keyInformationTab_activate(); @@ -27,7 +31,7 @@ function keyInformationTab_reset() { function keyInformationTab_activate() { keyInformationTab_create(); - var requestURL = restRootURL + "/KeyInformation/Get?name=&version="; + var requestURL = window.restRootURL + "/KeyInformation/Get?name=&version="; ajax_get(requestURL, function(data) { $("#keyInformationTableBody").find("tr:gt(0)").remove(); @@ -103,3 +107,10 @@ function keyInformationTab_create() { keyInformationTable.appendChild(keyInformationTableBody); keyInformationTable.setAttribute("id", "keyInformationTableBody"); } + +export { + keyInformationTab_activate, + keyInformationTab_create, + keyInformationTab_deactivate, + keyInformationTab_reset +} diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexMain.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexMain.js index 9dea9b5..d7019d3 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexMain.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexMain.js @@ -19,16 +19,22 @@ * ============LICENSE_END========================================================= */ +import {pageControl_noModelMode, pageControl_modelMode} from "./ApexPageControl"; +import {newModelForm_activate} from "./ApexNewModelForm"; +import {files_fileDownload, files_fileOpen, files_fileUpload} from "./ApexFiles"; +import {ajax_delete, ajax_get} from "./ApexAjax"; +import {modelHandling_analyse, modelHandling_validate} from "./ApexModelHandling"; + var restRootURL = null; var modelFileName = null; -$("#menu").fileMenu({ - slideSpeed : 200 -}); - $(document).ready(function() { + $("#menu").fileMenu({ + slideSpeed : 200 + }); pageControl_noModelMode(); main_getRestRootURL(); + $(".content").fadeIn(); }); $("#menu li").not(".emptyMessage").click(function() { @@ -114,6 +120,7 @@ function main_getRestRootURL() { var restContext = "apexservices/editor/"; if (localStorage.getItem("apex_session")) { restRootURL = href + restContext + localStorage.getItem("apex_session"); + window.restRootURL = href + restContext + localStorage.getItem("apex_session"); var requestURL = restRootURL + "/Model/GetKey"; ajax_get(requestURL, function(data) { $("#statusMessageTable").append(" REST root URL set to: " + restRootURL + ""); @@ -166,8 +173,6 @@ $(".ebInlineMessage").mouseleave(function(e) { }, 200); }); -$(document).ready(function() { - $(".content").fadeIn(); -}); - -exports.restRootURL = { restRootURL }; +export { + clearLocalStorage +} diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexModelHandling.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexModelHandling.js index d6af0c9..9c04102 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexModelHandling.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexModelHandling.js @@ -19,8 +19,11 @@ * ============LICENSE_END========================================================= */ +import {ajax_getOKOrFail, ajax_get} from "./ApexAjax"; +import {resultForm_activate} from "./ApexResultForm"; + function modelHandling_analyse() { - var requestURL = restRootURL + "/Model/Analyse"; + var requestURL = window.restRootURL + "/Model/Analyse"; ajax_get(requestURL, function(data) { resultForm_activate(document.getElementById("mainArea"), "Model Analysis Result", data.messages.message[0]); @@ -28,7 +31,7 @@ function modelHandling_analyse() { } function modelHandling_validate() { - var requestURL = restRootURL + "/Model/Validate"; + var requestURL = window.restRootURL + "/Model/Validate"; ajax_getOKOrFail(requestURL, function(data) { var validationResultString = ""; @@ -37,4 +40,9 @@ function modelHandling_validate() { } resultForm_activate(document.getElementById("mainArea"), "Model Validation Result", validationResultString); }); -} \ No newline at end of file +} + +export { + modelHandling_analyse, + modelHandling_validate +} diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexNewModelForm.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexNewModelForm.js index bf0e016..65b39d9 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexNewModelForm.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexNewModelForm.js @@ -19,6 +19,12 @@ * ============LICENSE_END========================================================= */ +import { formUtils_generateDescription, formUtils_generateUUID } from "./ApexFormUtils"; +import {apexUtils_removeElement} from "./ApexUtils"; +import {pageControl_modelMode} from "./ApexPageControl"; +import {ajax_post, ajax_get} from "./ApexAjax"; +import {keyInformationTab_reset} from "./ApexKeyInformationTab"; + function newModelForm_activate(formParent) { apexUtils_removeElement("newModelFormDiv"); @@ -203,25 +209,33 @@ function newModelForm_cancelPressed() { } function newModelForm_submitPressed() { - jsonString = JSON.stringify({ + var jsonString = JSON.stringify({ "name" : $('#newModelFormNameInput').val(), "version" : $('#newModelFormVersionInput').val(), "uuid" : $('#newModelFormUuidInput').val(), "description" : $('#newModelFormDescriptionTextArea').val() }); - var requestURL = restRootURL + "/Model/Create"; + var requestURL = window.restRootURL + "/Model/Create"; ajax_post(requestURL, jsonString, function(resultData) { apexUtils_removeElement("newModelDivBackground"); - var requestURL = restRootURL + "/Model/GetKey"; + var requestURL = window.restRootURL + "/Model/GetKey"; ajax_get(requestURL, function(data) { var modelKey = JSON.parse(data.messages.message[0]).apexArtifactKey; - modelFileName = modelKey.name + ".json"; + var modelFileName = modelKey.name + ".json"; pageControl_modelMode(modelKey.name, modelKey.version, modelFileName); }); keyInformationTab_reset() }); } + +export { + newModelForm_activate, + newModelForm_cancelPressed, + newModelForm_generateDescriptionPressed, + newModelForm_generateUUIDPressed, + newModelForm_submitPressed +} diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPageControl.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPageControl.js index 133f511..e1a553e 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPageControl.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPageControl.js @@ -19,6 +19,23 @@ * ============LICENSE_END========================================================= */ +import { + contextSchemaTab_activate, + contextSchemaTab_deactivate +} from "./ApexContextSchemaTab"; +import {eventTab_activate, eventTab_deactivate} from "./ApexEventTab"; +import { + contextAlbumTab_activate, + contextAlbumTab_deactivate +} from "./ApexContextAlbumTab"; +import {taskTab_activate, taskTab_deactivate} from "./ApexTaskTab"; +import {policyTab_activate, policyTab_deactivate} from "./ApexPolicyTab"; +import { + keyInformationTab_activate, + keyInformationTab_deactivate +} from "./ApexKeyInformationTab"; +import {clearLocalStorage} from "./ApexMain"; + function pageControl_modelMode(name, version, fileName) { $('#modelName').html(name); $('#modelVersion').html(version); @@ -254,4 +271,14 @@ function showPlaceholder(show) { } } -module.exports = {showPlaceholder, pageControl_busyMode, pageControl_modelMode, pageControl_noModelMode, pageControl_readyMode, pageControl_recursiveDisable, pageControl_restError, pageControl_status, pageControl_successStatus} +export { + showPlaceholder, + pageControl_busyMode, + pageControl_modelMode, + pageControl_noModelMode, + pageControl_readyMode, + pageControl_recursiveDisable, + pageControl_restError, + pageControl_status, + pageControl_successStatus +} diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm.js index 93c672c..116cfa4 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm.js @@ -19,6 +19,14 @@ * ============LICENSE_END========================================================= */ +import {apexUtils_removeElement, apexUtils_emptyElement, apexUtils_areYouSure, scrollToTop} from "./ApexUtils"; +import {dropdownList, dropdownList_ChangeOptions} from "./dropdownList"; +import {ajax_get, ajax_delete, ajax_getWithKeyInfo, ajax_post, ajax_put} from "./ApexAjax"; +import {policyTab_reset} from "./ApexPolicyTab"; +import { editPolicyForm_State_generateStateDiv, editPolicyForm_State_getStateBean } from "./ApexPolicyEditForm_State"; +import { formUtils_generateDescription, formUtils_generateUUID } from "./ApexFormUtils"; +import {keyInformationTab_reset} from "./ApexKeyInformationTab"; + function editPolicyForm_createPolicy(formParent) { editPolicyForm_editPolicy_inner(formParent, null, "CREATE"); } @@ -37,7 +45,7 @@ function editPolicyForm_deletePolicy(parent, name, version) { function editPolicyForm_viewPolicy(formParent, name, version) { // get the policy - var requestURL = restRootURL + "/Policy/Get?name=" + name + "&version=" + version; + var requestURL = window.restRootURL + "/Policy/Get?name=" + name + "&version=" + version; ajax_getWithKeyInfo(requestURL, "apexPolicy", function(policy) { editPolicyForm_editPolicy_inner(formParent, policy, "VIEW"); }, "policyKey"); @@ -45,7 +53,7 @@ function editPolicyForm_viewPolicy(formParent, name, version) { function editPolicyForm_editPolicy(formParent, name, version) { // get the policy - var requestURL = restRootURL + "/Policy/Get?name=" + name + "&version=" + version; + var requestURL = window.restRootURL + "/Policy/Get?name=" + name + "&version=" + version; ajax_getWithKeyInfo(requestURL, "apexPolicy", function(policy) { editPolicyForm_editPolicy_inner(formParent, policy, "EDIT"); }, "policyKey"); @@ -53,7 +61,7 @@ function editPolicyForm_editPolicy(formParent, name, version) { function editPolicyForm_editPolicy_inner(formParent, policy, viewOrEdit) { // Get all contextSchemas too - requestURL = restRootURL + "/ContextSchema/Get?name=&version="; + var requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; var contextSchemas = new Array(); ajax_get(requestURL, function(data2) { for (var i = 0; i < data2.messages.message.length; i++) { @@ -66,7 +74,7 @@ function editPolicyForm_editPolicy_inner(formParent, policy, viewOrEdit) { }); } // Get all tasks - requestURL = restRootURL + "/Task/Get?name=&version="; + requestURL = window.restRootURL + "/Task/Get?name=&version="; var tasks = new Array(); ajax_get(requestURL, function(data3) { for (var j = 0; j < data3.messages.message.length; j++) { @@ -79,7 +87,7 @@ function editPolicyForm_editPolicy_inner(formParent, policy, viewOrEdit) { }); } // Get all ContextAlbums - requestURL = restRootURL + "/ContextAlbum/Get?name=&version="; + requestURL = window.restRootURL + "/ContextAlbum/Get?name=&version="; var albums = new Array(); ajax_get(requestURL, function(data4) { for (var k = 0; k < data4.messages.message.length; k++) { @@ -92,7 +100,7 @@ function editPolicyForm_editPolicy_inner(formParent, policy, viewOrEdit) { }); } // Get all Events - requestURL = restRootURL + "/Event/Get?name=&version="; + requestURL = window.restRootURL + "/Event/Get?name=&version="; var events = new Array(); ajax_get(requestURL, function(data5) { for (var m = 0; m < data5.messages.message.length; m++) { @@ -114,6 +122,11 @@ function editPolicyForm_editPolicy_inner(formParent, policy, viewOrEdit) { function editPolicyForm_activate(parent, operation, policy, tasks, events, contextAlbums, contextItemSchemas) { apexUtils_removeElement("editPolicyFormDiv"); var formParent = document.getElementById(parent); + + //Testing purposes + if(formParent === null) { + formParent = document.createElement("testFormParent"); + } apexUtils_emptyElement(parent); var isedit = false; @@ -407,7 +420,7 @@ function editPolicyForm_activate(parent, operation, policy, tasks, events, conte triggerLI.appendChild(triggerPeriodicEventCheckbox); - triggerPeriodicEventLabel = document.createElement("label"); + var triggerPeriodicEventLabel = document.createElement("label"); triggerPeriodicEventLabel.setAttribute("class", "periodic-events-label"); triggerPeriodicEventLabel.innerHTML = "is Periodic Event"; triggerLI.appendChild(triggerPeriodicEventLabel); @@ -433,7 +446,7 @@ function editPolicyForm_activate(parent, operation, policy, tasks, events, conte } } for (i = 0; i < policy.state.entry.length; i++) { - stateEntry = policy.state.entry[i]; + var stateEntry = policy.state.entry[i]; var statename = stateEntry.key; var state = stateEntry.value; var stateLI = editPolicyForm_addState(statename, state, createEditOrView, policy, tasks, events, @@ -720,7 +733,7 @@ function editPolicyForm_submitPressed() { var jsonString = JSON.stringify(policybean); if (createEditOrView == "CREATE") { - var requestURL = restRootURL + "/Policy/Create"; + var requestURL = window.restRootURL + "/Policy/Create"; ajax_post(requestURL, jsonString, function(resultData) { apexUtils_removeElement("editPolicyFormDiv"); policyTab_reset(); @@ -728,7 +741,7 @@ function editPolicyForm_submitPressed() { }); } else if (createEditOrView == "EDIT") { var firstStatePeriodic = $("#periodicEventsCheckbox").is(":checked") - var requestURL = restRootURL + "/Policy/Update?firstStatePeriodic=" + firstStatePeriodic; + var requestURL = window.restRootURL + "/Policy/Update?firstStatePeriodic=" + firstStatePeriodic; ajax_put(requestURL, jsonString, function(resultData) { apexUtils_removeElement("editPolicyFormDiv"); policyTab_reset(); @@ -800,3 +813,24 @@ function editPolicyForm_getPolicyBean() { }; return policybean; } + +export { + editPolicyForm_activate, + editPolicyForm_editPolicy_inner, + editPolicyForm_State_getStateBean, + editPolicyForm_addNewState, + editPolicyForm_addState, + editPolicyForm_cancelPressed, + editPolicyForm_createPolicy, + editPolicyForm_deletePolicy, + editPolicyForm_editPolicy, + editPolicyForm_generateDescriptionPressed, + editPolicyForm_generateUUIDPressed, + editPolicyForm_getNextStateOptions, + editPolicyForm_getPolicyBean, + editPolicyForm_getStateOptions, + editPolicyForm_State_generateStateDiv, + editPolicyForm_submitPressed, + editPolicyForm_updateTriggerEventOptions, + editPolicyForm_viewPolicy +} diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm_State.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm_State.js index 77e8814..e9d1118 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm_State.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm_State.js @@ -19,6 +19,12 @@ * ============LICENSE_END========================================================= */ +import { dropdownList } from "./dropdownList"; +import { createAddFormButton } from "./ApexUtils"; +import { showHideTextarea } from "./showhideTextarea"; +import { formUtils_generateUUID } from "./ApexFormUtils"; +import {editPolicyForm_getNextStateOptions, editPolicyForm_updateTriggerEventOptions} from "./ApexPolicyEditForm"; + function editPolicyForm_State_generateStateDiv(createEditOrView, policy, statename, state, tasks, events, contextAlbums, contextItemSchemas) { var retDiv = document.createElement("div"); @@ -799,6 +805,7 @@ function editPolicyForm_State_addPolicyTask(parentTBody, disabled, isdefault, st function editPolicyForm_State_getLogicOutputMappingOptions(statename) { var outputoptions = new Array(); var finalizerstablerows = document.getElementById("editPolicyFormLogicOutputsTable_" + statename).rows; + if (finalizerstablerows && finalizerstablerows.length > 2) { // has head // so just // ignore @@ -856,6 +863,7 @@ function editPolicyForm_State_getStateBean(statename) { return null; } var div = document.getElementById("editPolicyFormStateDiv_" + statename); + if (div == null) { console.error("State information requested for state " + statename + ", but that state does not exist!") alert("State information requested for state " + statename + ", but that state does not exist!"); @@ -1127,3 +1135,14 @@ function editPolicyForm_State_getStateBean(statename) { return ret; } + +export { + editPolicyForm_State_generateStateDiv, + editPolicyForm_State_addPolicyContext, + editPolicyForm_State_addPolicyTask, + editPolicyForm_State_addStateDirectOutput, + editPolicyForm_State_addStateLogicOutput, + editPolicyForm_State_getDirectOutputMappingOptions, + editPolicyForm_State_getStateBean, + editPolicyForm_State_getLogicOutputMappingOptions +} diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyTab.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyTab.js index 8d9788e..e3a1765 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyTab.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyTab.js @@ -19,6 +19,11 @@ * ============LICENSE_END========================================================= */ +import {rightClickMenu_scopePreserver} from "./contextMenu"; +import {createTable} from "./ApexTable"; +import {ajax_get} from "./ApexAjax"; +import {apexUtils_removeElement} from "./ApexUtils"; + function policyTab_reset() { policyTab_deactivate(); policyTab_activate(); @@ -27,7 +32,7 @@ function policyTab_reset() { function policyTab_activate() { policyTab_create(); - var requestURL = restRootURL + "/Policy/Get?name=&version="; + var requestURL = window.restRootURL + "/Policy/Get?name=&version="; ajax_get(requestURL, function(data) { $("#policyTableBody").find("tr:gt(0)").remove(); @@ -164,6 +169,11 @@ function policyTab_deactivate() { function policyTab_create() { var policyTab = document.getElementById("policiesTab"); + //Testing purposes + if(policyTab === null) { + policyTab = document.createElement("policiesTab"); + } + var policyTabContent = document.getElementById("policyTabContent"); if (policyTabContent != null) { return @@ -208,4 +218,11 @@ function policyTab_create() { var policyTableBody = document.createElement("tbody"); policyTable.appendChild(policyTableBody); policyTable.setAttribute("id", "policyTableBody"); -} \ No newline at end of file +} + +export { + policyTab_activate, + policyTab_create, + policyTab_deactivate, + policyTab_reset +} diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexResultForm.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexResultForm.js index b254c38..0838ce8 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexResultForm.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexResultForm.js @@ -19,6 +19,8 @@ * ============LICENSE_END========================================================= */ +import {apexUtils_removeElement} from "./ApexUtils"; + function resultForm_activate(formParent, formHeading, formText) { apexUtils_removeElement("newModelDivBackground"); @@ -87,3 +89,7 @@ function resultForm_activate(formParent, formHeading, formText) { function resultForm_okPressed() { apexUtils_removeElement("newModelDivBackground"); } + +export { + resultForm_activate, resultForm_okPressed +} diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexTable.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexTable.js index 3e9fe3d..0283fb7 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexTable.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexTable.js @@ -36,4 +36,4 @@ function setRowHover(rowElement) { }; } -module.exports = {createTable, setRowHover}; \ No newline at end of file +export { createTable, setRowHover }; \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexTaskEditForm.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexTaskEditForm.js index d4021c0..56ba578 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexTaskEditForm.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexTaskEditForm.js @@ -19,9 +19,16 @@ * ============LICENSE_END========================================================= */ +import {taskTab_reset} from "./ApexTaskTab"; +import {dropdownList} from "./dropdownList"; +import { ajax_delete, ajax_getWithKeyInfo, ajax_post, ajax_put, ajax_get } from "./ApexAjax"; +import { formUtils_generateDescription, formUtils_generateUUID } from "./ApexFormUtils"; +import { apexUtils_removeElement, apexUtils_emptyElement, apexUtils_areYouSure, createAddFormButton, scrollToTop } from "./ApexUtils"; +import { showHideTextarea } from "./showhideTextarea"; + function editTaskForm_createTask(formParent) { // Get all contextSchemas too for task input/outputfields - var requestURL = restRootURL + "/ContextSchema/Get?name=&version="; + var requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; var contextSchemas = new Array(); ajax_get(requestURL, function(data2) { for (var i = 0; i < data2.messages.message.length; i++) { @@ -35,7 +42,7 @@ function editTaskForm_createTask(formParent) { contextSchemas.push(dt); } // Get all contextAlbums too for task context album references - var requestURL = restRootURL + "/ContextAlbum/Get?name=&version="; + var requestURL = window.restRootURL + "/ContextAlbum/Get?name=&version="; var contextAlbums = new Array(); ajax_get(requestURL, function(data3) { for (var i = 0; i < data3.messages.message.length; i++) { @@ -56,7 +63,7 @@ function editTaskForm_createTask(formParent) { function editTaskForm_deleteTask(parent, name, version) { var message = "Are you sure you want to delete Task \"" + name + ":" + version + "\"?"; if (apexUtils_areYouSure(message)) { - var requestURL = restRootURL + "/Task/Delete?name=" + name + "&version=" + version; + var requestURL = window.restRootURL + "/Task/Delete?name=" + name + "&version=" + version; ajax_delete(requestURL, function(data) { apexUtils_removeElement("editTaskFormDiv"); taskTab_reset(); @@ -74,10 +81,10 @@ function editTaskForm_editTask(formParent, name, version) { } function editTaskForm_editTask_inner(formParent, name, version, viewOrEdit) { - var requestURL = restRootURL + "/Task/Get?name=" + name + "&version=" + version; + var requestURL = window.restRootURL + "/Task/Get?name=" + name + "&version=" + version; ajax_getWithKeyInfo(requestURL, "apexTask", function(task) { // Get all contextSchemas too for task inputfields - var requestURL = restRootURL + "/ContextSchema/Get?name=&version="; + var requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; var contextSchemas = new Array(); ajax_get(requestURL, function(data2) { for (var i = 0; i < data2.messages.message.length; i++) { @@ -90,7 +97,7 @@ function editTaskForm_editTask_inner(formParent, name, version, viewOrEdit) { }); } // Get all contextAlbums too for task context album references - var requestURL = restRootURL + "/ContextAlbum/Get?name=&version="; + var requestURL = window.restRootURL + "/ContextAlbum/Get?name=&version="; var contextAlbums = new Array(); ajax_get(requestURL, function(data3) { for (var i = 0; i < data3.messages.message.length; i++) { @@ -112,6 +119,11 @@ function editTaskForm_editTask_inner(formParent, name, version, viewOrEdit) { function editTaskForm_activate(parent, operation, task, contextSchemas, contextAlbums) { apexUtils_removeElement("editTaskFormDiv"); var formParent = document.getElementById(parent); + + //Testing purposes + if(formParent === null) { + formParent = document.createElement('testFormParent'); + } apexUtils_emptyElement(parent); var isedit = false; @@ -985,14 +997,14 @@ function editTaskForm_submitPressed() { var jsonString = JSON.stringify(taskbean); if (createEditOrView == "CREATE") { - var requestURL = restRootURL + "/Task/Create"; + var requestURL = window.restRootURL + "/Task/Create"; ajax_post(requestURL, jsonString, function(resultData) { apexUtils_removeElement("editTaskFormDiv"); taskTab_reset(); keyInformationTab_reset() }); } else if (createEditOrView == "EDIT") { - var requestURL = restRootURL + "/Task/Update"; + var requestURL = window.restRootURL + "/Task/Update"; ajax_put(requestURL, jsonString, function(resultData) { apexUtils_removeElement("editTaskFormDiv"); taskTab_reset(); @@ -1001,3 +1013,20 @@ function editTaskForm_submitPressed() { } } + +export { + editTaskForm_activate, + editTaskForm_addTaskContext, + editTaskForm_addTaskInputField, + editTaskForm_addTaskOutputField, + editTaskForm_addTaskParameter, + editTaskForm_cancelPressed, + editTaskForm_createTask, + editTaskForm_deleteTask, + editTaskForm_editTask, + editTaskForm_editTask_inner, + editTaskForm_generateDescriptionPressed, + editTaskForm_generateUUIDPressed, + editTaskForm_submitPressed, + editTaskForm_viewTask +} diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexTaskTab.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexTaskTab.js index 632882b..cb442be 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexTaskTab.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexTaskTab.js @@ -19,6 +19,11 @@ * ============LICENSE_END========================================================= */ +import {createTable} from "./ApexTable"; +import {ajax_get} from "./ApexAjax"; +import {rightClickMenu_scopePreserver} from "./contextMenu"; +import {apexUtils_removeElement} from "./ApexUtils"; + function taskTab_reset() { taskTab_deactivate(); taskTab_activate(); @@ -27,16 +32,16 @@ function taskTab_reset() { function taskTab_activate() { taskTab_create(); - var requestURL = restRootURL + "/Task/Get?name=&version="; + const requestURL = window.restRootURL + "/Task/Get?name=&version="; ajax_get(requestURL, function(data) { $("#taskTableBody").find("tr:gt(0)").remove(); - for (var i = 0; i < data.messages.message.length; i++) { - var task = JSON.parse(data.messages.message[i]).apexTask; + for (let i = 0; i < data.messages.message.length; i++) { + const task = JSON.parse(data.messages.message[i]).apexTask; - var taskRow_tr = document.createElement("tr"); - var taskid = task.key.name + ":" + task.key.version; + const taskRow_tr = document.createElement("tr"); + const taskid = task.key.name + ":" + task.key.version; var taskTableRow = "" + @@ -119,6 +124,11 @@ function taskTab_deactivate() { function taskTab_create() { var taskTab = document.getElementById("tasksTab"); + //Testing purposes + if(taskTab === null) { + taskTab = document.createElement("tasksTab"); + } + var taskTabContent = document.getElementById("taskTabContent"); if (taskTabContent != null) { return @@ -173,4 +183,11 @@ function taskTab_create() { var taskTableBody = document.createElement("tbody"); taskTable.appendChild(taskTableBody); taskTable.setAttribute("id", "taskTableBody"); -} \ No newline at end of file +} + +export { + taskTab_create, + taskTab_reset, + taskTab_activate, + taskTab_deactivate +}; diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexUtils.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexUtils.js index 33abdeb..b1ff792 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexUtils.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexUtils.js @@ -124,4 +124,14 @@ function getHomepageURL() { + (location.pathname.endsWith("/editor/") ? location.pathname.substring(0, location.pathname .indexOf("editor/")) : location.pathname); location.href = homepageURL; -} \ No newline at end of file +} + +export { + apexUtils_removeElement, + apexUtils_emptyElement, + scrollToTop, + apexUtils_areYouSure, + createAddFormButton, + apexUtils_escapeHtml, + apexUtils_deleteTableRow +} diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexAjax.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexAjax.test.js index ebf79c9..34640c3 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexAjax.test.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexAjax.test.js @@ -19,51 +19,130 @@ const mod = require('../ApexAjax'); -test('Test ajax_get', () => { - const mockGet = jest.fn(mod.ajax_get).mockImplementation(() => { - const val = { - type : 'GET', - url : 'requestURL', - dataType : "json", // data type of response - success : function(data) { - return 'Success' - }, - error : function(jqXHR, textStatus, errorThrown) { - return 'Error' - } - } +const requestURL = "http://localhost:7979"; +const data = { + useHttps: 'useHttps', + hostname: 'hostname', + port: 'port', + username: 'username', + password: 'password', + messages: { + message: '' + }, + content: ['01', '02'], + result: 'ok', + ok: true +} + +test('Test ajax_get error', () => { + const callback = jest.fn(); + $.ajax = jest.fn().mockImplementation((args) => { + args.error(data, null, null); + }); + const mock_get_error = jest.fn(mod.ajax_get(requestURL, callback)); + mock_get_error(); + expect(mock_get_error).toHaveBeenCalled(); +}); + +test('Test ajax_get success', () => { + const callback = jest.fn(); + const jqXHR = { status: 200, responseText: "" }; + $.ajax = jest.fn().mockImplementation((args) => { + args.success(data, null, jqXHR); }); - mockGet('Called'); - expect(mockGet).toBeCalledTimes(1); - expect(mockGet).toHaveBeenCalledWith('Called'); + const mock_get_success = jest.fn(mod.ajax_get(requestURL, callback)); + mock_get_success(); + expect(mock_get_success).toHaveBeenCalled(); }); -test('Test ajax_delete', () => { - const mockDelete = jest.fn(mod.ajax_delete); - mockDelete(); - expect(mockDelete).toBeCalledTimes(1); +test('Test ajax_delete error', () => { + const callback = jest.fn(); + const jqXHR = { status: 500, responseText: "" }; + $.ajax = jest.fn().mockImplementation((args) => { + args.error(jqXHR, null, null); + }); + const mock_delete_error = jest.fn(mod.ajax_delete(requestURL, callback)); + mock_delete_error(); + expect(mock_delete_error).toHaveBeenCalled(); }); -test('Test ajax_post', () => { - const mockAjaxPost = jest.fn(mod.ajax_post); - mockAjaxPost(); - expect(mockAjaxPost).toBeCalledTimes(1); +test('Test ajax_delete success', () => { + const callback = jest.fn(); + const jqXHR = { status: 200, responseText: "" }; + $.ajax = jest.fn().mockImplementation((args) => { + args.success(data, null, jqXHR); + }); + const mock_delete_success = jest.fn(mod.ajax_delete(requestURL, callback)); + mock_delete_success(); + expect(mock_delete_success).toHaveBeenCalled(); }); -test('Test ajax_put', () => { - const mockAjaxPut = jest.fn(mod.ajax_put); - mockAjaxPut(); - expect(mockAjaxPut).toBeCalledTimes(1); +test('Test ajax_post error', () => { + const callback = jest.fn(); + const jqXHR = { status: 500, responseText: "" }; + $.ajax = jest.fn().mockImplementation((args) => { + args.error(jqXHR, null, null); + }); + const mock_post_error = jest.fn(mod.ajax_post(requestURL, data, callback)); + mock_post_error(); + expect(mock_post_error).toHaveBeenCalled(); }); -test('Test ajax_getOKOrFail', () => { - const mockAjaxGetOkOrFail = jest.fn(mod.ajax_getOKOrFail); - mockAjaxGetOkOrFail(); - expect(mockAjaxGetOkOrFail).toBeCalledTimes(1); +test('Test ajax_post success', () => { + const callback = jest.fn(); + const jqXHR = { status: 200, responseText: "" }; + $.ajax = jest.fn().mockImplementation((args) => { + args.success(data, null, jqXHR); + }); + const mock_post_success = jest.fn(mod.ajax_post(requestURL, data, callback)); + mock_post_success(); + expect(mock_post_success).toHaveBeenCalled(); +}); + +test('Test ajax_put error', () => { + const callback = jest.fn(); + const jqXHR = { status: 500, responseText: "" }; + $.ajax = jest.fn().mockImplementation((args) => { + args.error(jqXHR, null, null); + }); + const mock_put_error = jest.fn(mod.ajax_put(requestURL, callback)); + mock_put_error(); + expect(mock_put_error).toHaveBeenCalled(); +}); + +test('Test ajax_put success', () => { + const callback = jest.fn(); + const jqXHR = { status: 200, responseText: "" }; + + $.ajax = jest.fn().mockImplementation((args) => { + args.success(data, null, jqXHR); + }); + const mock_put_success = jest.fn(mod.ajax_put(requestURL, data, callback)); + mock_put_success(); + expect(mock_put_success).toHaveBeenCalled(); +}); + +test('Test ajax_getOKOrFail error', () => { + const callback = jest.fn(); + const jqXHR = { status: 500, responseText: "" }; + $.ajax = jest.fn().mockImplementation((args) => { + args.error(jqXHR, null, null); + }); + const mock_getOKOrFail_error = jest.fn(mod.ajax_getOKOrFail(requestURL, callback)); + mock_getOKOrFail_error(); + expect(mock_getOKOrFail_error).toHaveBeenCalled(); +}); + +test('Test ajax_getOKOrFail success', () => { + const callback = jest.fn(); + const jqXHR = { status: 200, responseText: "" }; + + $.ajax = jest.fn().mockImplementation((args) => { + args.success(data, null, jqXHR); + }); + const mock_getOKOrFail_success = jest.fn(mod.ajax_getOKOrFail(requestURL, callback)); + mock_getOKOrFail_success(); + expect(mock_getOKOrFail_success).toHaveBeenCalled(); }); -test('Test ajax_getWithKeyInfo', () => { - const mockGetWKey = jest.fn(mod.ajax_getWithKeyInfo); - const kName = mod.ajax_getWithKeyInfo.keyName; - expect(kName).not.toBe(null); -}); \ No newline at end of file +test.todo('Test ajax_getWithKeyInfo'); diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexContextAlbumEditForm.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexContextAlbumEditForm.test.js new file mode 100644 index 0000000..728accd --- /dev/null +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexContextAlbumEditForm.test.js @@ -0,0 +1,44 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +const mod = require('../ApexContextAlbumEditForm'); + +test('Test mock_editContextAlbumForm_activate', () => { + const mock_editContextAlbumForm_activate = jest.fn(mod.editContextAlbumForm_activate); + + const contextAlbum = { + name: 'testName', + version: '0.0.1', + scope: 'test', + uuid: 'testUUID', + description: 'testDesc', + writeable: true + }; + const contextSchema = { + name: 'testName', + version: '0.0.1', + schemaFlavour: 'testFlav', + schemaDefinition: 'testDef', + uuid: 'testUUID', + description: 'testDesc' + } + + mock_editContextAlbumForm_activate('parentTest', 'CREATE', contextAlbum, contextSchema); + expect(mock_editContextAlbumForm_activate).toHaveBeenCalledTimes(1); +}); \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexContextAlbumTab.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexContextAlbumTab.test.js index 5932a6d..e109174 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexContextAlbumTab.test.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexContextAlbumTab.test.js @@ -18,15 +18,10 @@ */ const mod = require('../ApexContextAlbumTab'); +const utils = require('../ApexUtils'); -test('call deactivate', () => { - const deactivate = jest.fn(mod.contextAlbumTab_deactivate).mockReturnValueOnce('success'); - deactivate(); - expect(deactivate).toHaveBeenCalledTimes(1); +test('Test contextAlbumTab_create', () => { + const mock_activate = jest.fn(mod.contextAlbumTab_activate); + mock_activate(); + expect(mock_activate).toBeCalled(); }); - -test('call create', () => { - const create = jest.fn(mod.contextAlbumTab_create).mockReturnValueOnce('success'); - create(); - expect(create).toHaveBeenCalledTimes(1); -}) \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexContextSchemaEditForm.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexContextSchemaEditForm.test.js new file mode 100644 index 0000000..69505bb --- /dev/null +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexContextSchemaEditForm.test.js @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +const mod = require('../ApexContextSchemaEditForm'); + +test('Test editContextSchemaForm_createContextSchema', () => { + const contextSchema = { + name: 'testName', + version: '0.0.1', + schemaFlavour: 'testFlav', + schemaDefinition: 'testDef', + uuid: 'testUUID', + description: 'testDesc' + } + + const mock_editContextSchemaForm_createContextSchema = jest.fn(mod.editContextSchemaForm_createContextSchema); + mock_editContextSchemaForm_createContextSchema('parentTest', 'CREATE', contextSchema); + expect(mock_editContextSchemaForm_createContextSchema).toBeCalled(); +}); \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexContextSchemaTab.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexContextSchemaTab.test.js new file mode 100644 index 0000000..552eb85 --- /dev/null +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexContextSchemaTab.test.js @@ -0,0 +1,33 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +const mod = require('../ApexContextSchemaTab'); + +test('Test activateContextSchema', () => { + const mock_activate = jest.fn(mod.contextSchemaTab_activate); + mock_activate(); + expect(mock_activate).toBeCalled(); +}); + +test('Test deactivate', () => { + const mock_deactivate = jest.fn(mod.contextSchemaTab_deactivate); + mock_deactivate(); + expect(mock_deactivate).toBeCalledWith(); +}); \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexEventEditForm.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexEventEditForm.test.js new file mode 100644 index 0000000..6363ae6 --- /dev/null +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexEventEditForm.test.js @@ -0,0 +1,73 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +const mod = require('../ApexEventEditForm'); +const contextSchema = { + name: 'testName', + version: '0.0.1', + schemaFlavour: 'testFlav', + schemaDefinition: 'testDef', + uuid: 'testUUID', + description: 'testDesc' +} + +test('Test Activate', () => { + const mock_activate = jest.fn(mod.editEventForm_activate); + mock_activate(null, 'CREATE', null, contextSchema); + expect(mock_activate).toBeCalled(); +}); + +test('Test Activate Edit', () => { + + const event = { + key: { + name: 'testName', + version: '0.0.1', + }, + nameSpace: 'test', + source: 'test', + target: 'test', + uuid: 'test', + description: 'test', + } + + const mock_activate = jest.fn(mod.editEventForm_activate); + mock_activate(null, 'EDIT', event, contextSchema); + expect(mock_activate).toBeCalled(); +}); + +test('Test Activate !=Create/Edit', () => { + + const event = { + key: { + name: 'testName', + version: '0.0.1', + }, + nameSpace: 'test', + source: 'test', + target: 'test', + uuid: 'test', + description: 'test', + } + + const mock_activate = jest.fn(mod.editEventForm_activate); + mock_activate(null, 'TEST', event, contextSchema); + expect(mock_activate).toBeCalled(); +}); \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexEventTab.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexEventTab.test.js new file mode 100644 index 0000000..23f4edc --- /dev/null +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexEventTab.test.js @@ -0,0 +1,33 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +const mod = require('../ApexEventTab'); + +test('Test activate', () => { + const mock_activate = jest.fn(mod.eventTab_activate); + mock_activate() + expect(mock_activate).toBeCalled(); +}); + +// These are being tested indirectly +// But could be tested individually here if needed +test.todo('Test create'); +test.todo('Test deactivate'); +test.todo('Test reset'); \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexFiles.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexFiles.test.js index d6d3c40..6fcaa4d 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexFiles.test.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexFiles.test.js @@ -1,20 +1,21 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix Foundation - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * http://www.apache.org/licenses/LICENSE-2.0 * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= */ const mod = require('../ApexFiles'); @@ -23,19 +24,16 @@ test('test files_open', () => { const open = jest.fn(mod.files_fileOpen); open(); expect(open).toBeCalledTimes(1); -}) +}); test('test files_download', () => { - const download = jest.fn(mod.files_fileDownload).mockImplementation(() => { - var requestURL = "/Model/Download"; - - var downloadLink = document.createElement("a"); - document.body.appendChild(downloadLink); - downloadLink.download = 'modelFileName'; - downloadLink.href = requestURL; - downloadLink.click(); - document.body.removeChild(downloadLink); - }); + const download = jest.fn(mod.files_fileDownload); download(); expect(download).toHaveBeenCalledTimes(1); -}) \ No newline at end of file +}); + +test('Test files_upload', () => { + const upload = jest.fn(mod.files_fileUpload); + upload(); + expect(upload).toBeCalled(); +}); \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexFormUtils.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexFormUtils.test.js index 046c43e..0df839d 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexFormUtils.test.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexFormUtils.test.js @@ -28,5 +28,8 @@ test('test generate', () => { test('test edit', () => { const mock = jest.fn(mod.formUtils_generateDescription); mock(); - expect(mock).toBeCalledTimes(1); + expect(mock(null, null, null)).toBe("Generated description for a concept called \"null\" with version \"null\" and UUID \"null\""); + expect(mock).toBeCalledTimes(2); + + }) \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexModelHandling.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexModelHandling.test.js new file mode 100644 index 0000000..b9315c2 --- /dev/null +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexModelHandling.test.js @@ -0,0 +1,37 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +const mod = require('../ApexModelHandling'); + +test('Test modelHandling_analyse', () => { + const mock_modelHandling_analyse = jest.fn(mod.modelHandling_analyse); + mock_modelHandling_analyse(); + expect(mock_modelHandling_analyse).toHaveBeenCalledWith(); +}); + +test('Test modelHandling_validate', () => { + const mock_modelHandling_validate_ajaxget = jest.fn(mod.modelHandling_validate.ajax_get); + mock_modelHandling_validate_ajaxget('test', jest.fn()); + expect(mock_modelHandling_validate_ajaxget).toHaveBeenCalledTimes(1); + + const mock_modelHandling_validate = jest.fn(mod.modelHandling_validate); + mock_modelHandling_validate(); + expect(mock_modelHandling_validate).toHaveBeenCalled(); +}); \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexNewModelForm.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexNewModelForm.test.js new file mode 100644 index 0000000..5088988 --- /dev/null +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexNewModelForm.test.js @@ -0,0 +1,46 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +const mod = require('../ApexNewModelForm'); + +test('test activate', () => { + document.innerHTML = + '
' + + '
' + + '
' + + '
'; + + const mock_activate = jest.fn(mod.newModelForm_activate); + mock_activate(document.createElement("elementTest")); + expect(mock_activate).toBeCalled(); +}); + +test('Test generateUUIDPressed', () => { + document.innerHTML = + '
'; + + const mock_generateUuid = jest.fn(mod.newModelForm_generateUUIDPressed); + mock_generateUuid.mockImplementation(() => { + document.createElement("newModelFormUuidInput"); + document.getElementsByTagName("newModelFormUuidInput").value = 'test'; + }); + mock_generateUuid(); + expect(mock_generateUuid).toBeCalled(); +}); \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPageControl.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPageControl.test.js deleted file mode 100644 index abdb1a9..0000000 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPageControl.test.js +++ /dev/null @@ -1,30 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -const mod = require('../ApexPageControl'); - -test('test show placeholder', () => { - const mock = jest.fn(mod.showPlaceholder); - mock(); - expect(mock).toBeCalledTimes(1); -}) - -test('test busyMode', () => { - -}) \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPolicyEditForm.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPolicyEditForm.test.js new file mode 100644 index 0000000..f438305 --- /dev/null +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPolicyEditForm.test.js @@ -0,0 +1,55 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +const mod = require('../ApexPolicyEditForm'); +const policy = { + policyKey: { + name: 'testName', + version: 'testVersion', + uuid: 'testUUID' + }, + uuid: 'testUUID' +} + +test('Test activate CREATE', () => { + const mock_activate = jest.fn(mod.editPolicyForm_activate); + + mock_activate('test', 'CREATE', policy, 'tasks', 'events', 'contextS', 'contextI'); + expect(mock_activate).toBeCalled(); +}); + +test('Test activate EDIT', () => { + const mock_activate = jest.fn(mod.editPolicyForm_activate); + + mock_activate('test', 'EDIT', policy, 'tasks', 'events', 'contextS', 'contextI'); + expect(mock_activate).toBeCalled(); +}); + +test('Test activate !CREATE/EDIT', () => { + const mock_activate = jest.fn(mod.editPolicyForm_activate); + + mock_activate('test', 'TEST', policy, 'tasks', 'events', 'contextS', 'contextI'); + expect(mock_activate).toBeCalled(); +}); + +test('Test editPolicyForm_editPolicy_inner', () => { + const mock_editPolicyForm_editPolicy_inner = jest.fn(mod.editPolicyForm_editPolicy_inner); + mock_editPolicyForm_editPolicy_inner('formParent', policy, 'VIEW'); + expect(mock_editPolicyForm_editPolicy_inner).toBeCalled(); +}) \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPolicyEditForm_State.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPolicyEditForm_State.test.js new file mode 100644 index 0000000..1f1767a --- /dev/null +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPolicyEditForm_State.test.js @@ -0,0 +1,122 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +const mod = require('../ApexPolicyEditForm_State'); + +const contextAlbum = { + name: 'testName', + version: '0.0.1', + scope: 'test', + uuid: 'testUUID', + description: 'testDesc', + writeable: true +}; +const contextSchema = { + name: 'testName', + version: '0.0.1', + schemaFlavour: 'testFlav', + schemaDefinition: 'testDef', + uuid: 'testUUID', + description: 'testDesc' +} + +const task = { + key: { + name: 'testName', + version: 'testVersion' + }, + uuid: 'testUUID' +}; + +const event = { + key: { + name: 'testName', + version: '0.0.1', + }, + nameSpace: 'test', + source: 'test', + target: 'test', + uuid: 'test', + description: 'test', +} + +const policy = { + policyKey: { + name: 'testName', + version: 'testVersion', + uuid: 'testUUID' + }, + uuid: 'testUUID' +} + +const state = { + trigger: { + name: 'testName', + version: '0.0.1', + } +} + +const parentTBody = document.createElement('table'); + +test('Test editPolicyForm_State_generateStateDiv CREATE', () => { + const mock_editPolicyForm_State_generateStateDiv = jest.fn(mod.editPolicyForm_State_generateStateDiv); + mock_editPolicyForm_State_generateStateDiv('CREATE', policy, 'stateName', state, task, event, contextAlbum, contextSchema); + expect(mock_editPolicyForm_State_generateStateDiv).toBeCalledWith('CREATE', policy, 'stateName', state, task, event, contextAlbum, contextSchema); +}); + +test('Test editPolicyForm_State_generateStateDiv VIEW', () => { + const mock_editPolicyForm_State_generateStateDiv = jest.fn(mod.editPolicyForm_State_generateStateDiv); + mock_editPolicyForm_State_generateStateDiv('VIEW', policy, 'stateName', state, task, event, contextAlbum, contextSchema); + expect(mock_editPolicyForm_State_generateStateDiv).toBeCalledWith('VIEW', policy, 'stateName', state, task, event, contextAlbum, contextSchema); +}); + +test('Test editPolicyForm_State_generateStateDiv EDIT', () => { + const mock_editPolicyForm_State_generateStateDiv = jest.fn(mod.editPolicyForm_State_generateStateDiv); + mock_editPolicyForm_State_generateStateDiv('EDIT', policy, 'stateName', state, task, event, contextAlbum, contextSchema); + expect(mock_editPolicyForm_State_generateStateDiv).toBeCalledWith('EDIT', policy, 'stateName', state, task, event, contextAlbum, contextSchema); +}); + +test('Test editPolicyForm_State_addStateLogicOutput', () => { + const mock_editPolicyForm_State_addStateLogicOutput = jest.fn(mod.editPolicyForm_State_addStateLogicOutput); + mock_editPolicyForm_State_addStateLogicOutput(parentTBody, false, 'stateName', state, 'outputName', 'logic', 'flavour'); + expect(mock_editPolicyForm_State_addStateLogicOutput).toBeCalledWith(parentTBody, false, 'stateName', state, 'outputName', 'logic', 'flavour'); +}); + +test('Test editPolicyForm_State_addStateDirectOutput', () => { + const mock_editPolicyForm_State_addStateDirectOutput = jest.fn(mod.editPolicyForm_State_addStateDirectOutput); + mock_editPolicyForm_State_addStateDirectOutput(parentTBody, false, 'stateName', state, 'outputName', state, event, 'options', event); + expect(mock_editPolicyForm_State_addStateDirectOutput).toBeCalledWith(parentTBody, false, 'stateName', state, 'outputName', state, event, 'options', event); +}); + +test('Test editPolicyForm_State_addPolicyContext', () => { + const mock_editPolicyForm_State_addPolicyContext = jest.fn(mod.editPolicyForm_State_addPolicyContext); + mock_editPolicyForm_State_addPolicyContext(parentTBody, false, 'stateName', 'contextName', 'ref', contextAlbum); + expect(mock_editPolicyForm_State_addPolicyContext).toBeCalledWith(parentTBody, false, 'stateName', 'contextName', 'ref', contextAlbum); +}); + +test('Test editPolicyForm_State_addPolicyTask', () => { + const mock_editPolicyForm_State_addPolicyTask = jest.fn(mod.editPolicyForm_State_addPolicyTask); + mock_editPolicyForm_State_addPolicyTask(parentTBody, false, false, state, 'stateName', 'ref', task, 'options'); + expect(mock_editPolicyForm_State_addPolicyTask).toBeCalledWith(parentTBody, false, false, state, 'stateName', 'ref', task, 'options'); + +}); + +test.todo('Test editPolicyForm_State_getDirectOutputMappingOptions'); +test.todo('Test editPolicyForm_State_getStateBean'); +test.todo('Test editPolicyForm_State_getLogicOutputMappingOptions'); \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPolicyTab.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPolicyTab.test.js new file mode 100644 index 0000000..47f00ef --- /dev/null +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexPolicyTab.test.js @@ -0,0 +1,26 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +const mod = require('../ApexPolicyTab'); + +test('Test policyTab_activate', () => { + const mock_activate = jest.fn(mod.policyTab_activate); + mock_activate(); + expect(mock_activate).toBeCalled(); +}); \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexResultForm.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexResultForm.test.js new file mode 100644 index 0000000..a219ac9 --- /dev/null +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexResultForm.test.js @@ -0,0 +1,37 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +const mod = require('../ApexResultForm'); + +test('resultForm test', () => { + document.innerHTML = + '
' + + '
' + + '
' + + '
'; + + const content = document.getElementById("elementTest"); + const mock_activate = jest.fn(mod.resultForm_activate); + mock_activate(document.createElement("elementTest"), 'heading', 'text'); + expect(mock_activate).toBeCalled(); + + const mock_pressedOK = jest.fn(mod.resultForm_okPressed); + mock_pressedOK(); +}); \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexTaskEditForm.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexTaskEditForm.test.js new file mode 100644 index 0000000..f914645 --- /dev/null +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexTaskEditForm.test.js @@ -0,0 +1,50 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +const mod = require('../ApexTaskEditForm'); + +const contextSchema = { + name: 'testName', + version: '0.0.1', + schemaFlavour: 'testFlav', + schemaDefinition: 'testDef', + uuid: 'testUUID', + description: 'testDesc' +}; + +const task = { + key: { + name: 'testName', + version: 'testVersion' + }, + uuid: 'testUUID' +}; + +test('Test editTaskForm_activate CREATE', () => { + const mock_activate = jest.fn(mod.editTaskForm_activate); + mock_activate('test', 'CREATE', 'task', contextSchema, 'album'); + expect(mock_activate).toBeCalled(); +}); + +test('Test editTaskForm_activate EDIT', () => { + const mock_activate = jest.fn(mod.editTaskForm_activate); + mock_activate('test', 'EDIT', task, contextSchema, 'album'); + expect(mock_activate).toBeCalled(); +}); diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexTaskTab.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexTaskTab.test.js new file mode 100644 index 0000000..784c644 --- /dev/null +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexTaskTab.test.js @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +const mod = require('../ApexTaskTab'); + +test('test dom : taskTab_activate', () => { + const activate_mock = jest.fn(mod.taskTab_activate); + activate_mock(); + expect(activate_mock).toBeCalled(); +}); + +test('test reset', () => { + const reset_mock = jest.fn(mod.taskTab_reset); + reset_mock(); + expect(reset_mock).toBeCalled(); +}); \ No newline at end of file diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/contextMenu.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/contextMenu.js index 925a522..1235cf1 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/contextMenu.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/contextMenu.js @@ -20,6 +20,38 @@ */ //hide the context menu, if it's shown, anytime the user clicks anywhere. +import {apexUtils_emptyElement} from "./ApexUtils"; +import { + editContextSchemaForm_createContextSchema, + editContextSchemaForm_deleteContextSchema, + editContextSchemaForm_editContextSchema, + editContextSchemaForm_viewContextSchema +} from "./ApexContextSchemaEditForm"; +import { + editEventForm_createEvent, + editEventForm_deleteEvent, + editEventForm_editEvent, + editEventForm_viewEvent +} from "./ApexEventEditForm"; +import { + editTaskForm_createTask, + editTaskForm_deleteTask, + editTaskForm_editTask, + editTaskForm_viewTask +} from "./ApexTaskEditForm"; +import { + editPolicyForm_createPolicy, + editPolicyForm_deletePolicy, + editPolicyForm_editPolicy, + editPolicyForm_viewPolicy +} from "./ApexPolicyEditForm"; +import { + editContextAlbumForm_createContextAlbum, + editContextAlbumForm_deleteContextAlbum, + editContextAlbumForm_editContextAlbum, + editContextAlbumForm_viewContextAlbum +} from "./ApexContextAlbumEditForm"; + $(document).on("click", function(event) { if (document.getElementById("rightClickMenu")) document.getElementById("rightClickMenu").className = "ebContextMenu-body_visible_false"; @@ -197,3 +229,7 @@ function mouseY(evt) { return null; } } + +export { + rightClickMenu_scopePreserver +} diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/dropdownList.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/dropdownList.js index a64b823..497bd68 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/dropdownList.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/dropdownList.js @@ -199,3 +199,14 @@ function dropdownList_ChangeOptions(dropdownListDIV, options, selected, disabled } return retdiv; } + +export { + dropdownList, + dropdownList_ChangeOptions, + dropdownList_display_click, + dropdownList_display_hide, + dropdownList_filter, + dropdownList_filter_scopePreserver, + dropdownList_option_select, + dropdownList_option_select_scopePreserver +} diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/showhideTextarea.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/showhideTextarea.js index e1ac0e7..353b4e9 100644 --- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/showhideTextarea.js +++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/showhideTextarea.js @@ -124,3 +124,10 @@ function showHideTextarea(id_prefix, content, _initialshow, _editable, _disabled return retdiv; }; +export { + showHideTextarea, + showHideTextarea_display_hide, + showHideTextarea_display_show, + _showHideTextarea_display_hide, + _showHideTextarea_display_show +} -- cgit 1.2.3-korg