summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlapentafd <francesco.lapenta@est.tech>2022-02-23 18:49:20 +0000
committerlapentafd <francesco.lapenta@est.tech>2022-02-25 10:53:50 +0000
commit62bbf4d0aa4831f6bdd461011b71a4bb94724517 (patch)
tree0b9c4069e05183905f1ed2c0f1ae022dc5f93fee
parent6e3d850c1b6efda12a70a111c8734972c99e3db5 (diff)
Code coverage apex editor
Issue-ID: POLICY-3351 Signed-off-by: lapentafd <francesco.lapenta@est.tech> Change-Id: Ib3043be521c37efe60e96b7917077db8c70b1645
-rw-r--r--gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexPolicyEditForm_State.test.js12
-rw-r--r--gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexTaskEditForm.test.js21
-rw-r--r--gui-editors/gui-editor-apex/src/main/webapp/js/__test__/fileMenu.test.js7
3 files changed, 33 insertions, 7 deletions
diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexPolicyEditForm_State.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexPolicyEditForm_State.test.js
index 8b73319..24df8d0 100644
--- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexPolicyEditForm_State.test.js
+++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexPolicyEditForm_State.test.js
@@ -62,14 +62,22 @@ const policy = {
version: 'testVersion',
uuid: 'testUUID'
},
- uuid: 'testUUID'
+ uuid: 'testUUID',
+ state: [{ key: 'testName1', value: '1'}, { key: 'testName2',value: '2'}]
}
const state = {
trigger: {
name: 'testName',
version: '0.0.1',
- }
+ },
+ defaultTask: {
+ name: 'deftestName',
+ version: '0.0.2',
+ },
+ taskReferences: [{key: { name: 'testName1',version: '1'}, key: { name: 'testName2',version: '2'}}],
+ stateOutputs : [{key: { name: 'testName1',version: '1'}, key: { name: 'testName2',version: '2'}}],
+ stateFinalizerLogicMap : [{key: {value: { logic: 'testName1', logicFlavour : '1'}}, key: {value: { logic: 'testName1', logicFlavour : '1'}}}]
}
const parentTBody = document.createElement('table');
diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexTaskEditForm.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexTaskEditForm.test.js
index e9fcc9b..159dc71 100644
--- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexTaskEditForm.test.js
+++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexTaskEditForm.test.js
@@ -37,7 +37,17 @@ const task = {
name: 'testName',
version: 'testVersion'
},
- uuid: 'testUUID'
+ uuid: 'testUUID',
+ description: 'Description of task',
+ taskLogic: {
+ logicFlavour: 'testFlav'
+ },
+ inputFields : {entry: [{key: "key1", value: {fieldSchemaKey: { name : "name2", version : "version2"}}}]},
+ outputFields : {entry: [{key: "key01", value: {fieldSchemaKey: { name : "name02", version : "version02"}}}]},
+ taskParameters: {entry: [{key: 'testKey',value: {defaultValue: 'testValue'}}]},
+ contextAlbumReference : [{name : 'contextEntry.name',version : 'contextEntry.version', displaytext : 'contextName'},
+ {name : 'contextEntry.name2',version : 'contextEntry.version2', displaytext : 'contextName2'},
+ {name : 'contextEntry.name3',version : 'contextEntry.version3', displaytext : 'contextName3'}]
};
let data = {
@@ -100,6 +110,9 @@ test('Test Edit Task Inner', () => {
$.ajax = jest.fn().mockImplementation((args) => {
args.success(data, null, jqXHR);
});
+ jest.spyOn(apexTaskTab, 'taskTab_reset').mockReturnValueOnce(null);
+ jest.spyOn(keyInformationTab_reset, 'keyInformationTab_reset').mockReturnValueOnce(null);
+ jest.spyOn(apexUtils, 'apexUtils_removeElement').mockReturnValueOnce(null);
const mock_activate = jest.fn(mod.editTaskForm_editTask_inner);
mock_activate('test', 'name', 'version', 'Edit');
expect(mock_activate).toBeCalled();
@@ -195,11 +208,13 @@ test('Test editTaskForm_submitPressed with page', () => {
'</table>' +
'</body></html>';
let documentSpy = jest.spyOn(document, 'getElementById');
- let elementMock = document.getElementById("editTaskFormInputFieldsTable");
+ let elementMock = document.createElement("editTaskFormInputFieldsTable");
elementMock.value = 'notNullValue';
- elementMock.selectedOption = {"name": "name1", "version": "version1"};
+ elementMock.selectedOption = {"name": "name1", "version": "version1", "displaytext": "t"};
elementMock.checked = {"name": "nameOpt", "version": "versionOpt"};
elementMock.setAttribute("createEditOrView", "EDIT")
+ elementMock.rows = document.getElementById("editTaskFormInputFieldsTable").rows;
+ console.log(elementMock.rows);
documentSpy.mockReturnValue(elementMock);
const mock_activate = jest.fn(mod.editTaskForm_submitPressed);
diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/fileMenu.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/fileMenu.test.js
index ffc9e2c..9f3c4b1 100644
--- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/fileMenu.test.js
+++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/fileMenu.test.js
@@ -21,11 +21,14 @@
const mod = require('../fileMenu');
test('test hideMenu', () => {
- document.documentElement.innerHTML = '<html><head></head><body><ul id="menu">Hello world!</ul></body></html>';
+ document.documentElement.innerHTML = '<html><head></head><body><ul id="menu">Hello world<li>!</li></ul></body></html>';
$ = require('jquery');
window.$ = $;
$('#menu').fileMenu();
- $('#menu').click();
+ $('li').mouseenter();
+ $('li').click();
+ $('ul').mouseenter();
+ $('ul').click();
let h1 = document.querySelector('ul');
expect(h1.textContent).toEqual('Hello world!');
});