aboutsummaryrefslogtreecommitdiffstats
path: root/gui-pdp-monitoring/src/webapp/js/__test__
diff options
context:
space:
mode:
authorbrunomilitzer <bruno.militzer@est.tech>2022-01-21 09:52:42 +0000
committerbrunomilitzer <bruno.militzer@est.tech>2022-01-21 09:52:48 +0000
commit7be95544827a95524a9b683d946ee7473e6854f9 (patch)
treedecabe3a248564ca0391d63dc33f4b88e4545a7c /gui-pdp-monitoring/src/webapp/js/__test__
parent1ef0fcce1314a8c3cccf207e271014bb2f1f4c22 (diff)
Removed PDP Monitoring from GUI
Issue-ID: POLICY-3888 Change-Id: If59a7b7ad3074e718772051e2a13134eadb54997 Signed-off-by: brunomilitzer <bruno.militzer@est.tech>
Diffstat (limited to 'gui-pdp-monitoring/src/webapp/js/__test__')
-rw-r--r--gui-pdp-monitoring/src/webapp/js/__test__/MonitoringChart.test.js40
-rw-r--r--gui-pdp-monitoring/src/webapp/js/__test__/MonitoringMain.test.js60
-rw-r--r--gui-pdp-monitoring/src/webapp/js/__test__/MonitoringTable.test.js33
-rw-r--r--gui-pdp-monitoring/src/webapp/js/__test__/MonitoringUtils.test.js109
-rw-r--r--gui-pdp-monitoring/src/webapp/js/__test__/PdpEngineWorkerStatus.test.js37
-rw-r--r--gui-pdp-monitoring/src/webapp/js/__test__/PdpInformation.test.js31
-rw-r--r--gui-pdp-monitoring/src/webapp/js/__test__/PdpListView.test.js63
-rw-r--r--gui-pdp-monitoring/src/webapp/js/__test__/PdpStatisticsSummary.test.js38
8 files changed, 0 insertions, 411 deletions
diff --git a/gui-pdp-monitoring/src/webapp/js/__test__/MonitoringChart.test.js b/gui-pdp-monitoring/src/webapp/js/__test__/MonitoringChart.test.js
deleted file mode 100644
index 6fa0e05..0000000
--- a/gui-pdp-monitoring/src/webapp/js/__test__/MonitoringChart.test.js
+++ /dev/null
@@ -1,40 +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=========================================================
- */
-
-import * as MonitoringChart from "../MonitoringChart";
-
-const data = MonitoringChart.generateRandomData();
-const container = null;
-const title = null;
-const unit = null;
-const lineStroke = "";
-const nodeColour = "";
-
-test("test create chart is available", () => {
- MonitoringChart.createChart(data, container, title, unit, lineStroke, nodeColour);
- expect(data.length).toBe(30);
-});
-
-test("update Chart", () => {
- MonitoringChart.initTooltip;
- expect(data.length).toBe(30);
-});
-
-
diff --git a/gui-pdp-monitoring/src/webapp/js/__test__/MonitoringMain.test.js b/gui-pdp-monitoring/src/webapp/js/__test__/MonitoringMain.test.js
deleted file mode 100644
index cfbfaf6..0000000
--- a/gui-pdp-monitoring/src/webapp/js/__test__/MonitoringMain.test.js
+++ /dev/null
@@ -1,60 +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=========================================================
- */
-
-import * as sut from "../MonitoringMain";
-
-import * as MonitoringChart from "../MonitoringChart";
-import * as MonitoringUtils from "../MonitoringUtils";
-import * as PdpInformation from "../PdpInformation";
-import * as PdpStatisticsSummary from "../PdpStatisticsSummary";
-import * as PdpEngineWorkerStatus from "../PdpEngineWorkerStatus";
-
-test("test ready", () => {
- MonitoringChart.initTooltip = jest.fn();
- MonitoringUtils.setUpPage = jest.fn();
- MonitoringUtils.getEngineURL = jest.fn();
- sut.readyCallback();
- expect(MonitoringChart.initTooltip).toHaveBeenCalled();
- expect(MonitoringUtils.setUpPage).toHaveBeenCalled();
- expect(MonitoringUtils.getEngineURL).toHaveBeenCalled();
-});
-
-test("test service callback", () => {
- const storedData = {
- useHttps: "http",
- hostname: "localhost",
- port: 7979,
- username: "username",
- password: "password",
- };
-
- const data = {
- server: "localhost",
- port: 7979,
- }
- window.localStorage.setItem("pap-monitor-services", JSON.stringify(storedData));
- PdpInformation.setEngineServiceData = jest.fn();
- PdpStatisticsSummary.setEngineSummaryData = jest.fn();
- PdpEngineWorkerStatus.setEngineStatusData = jest.fn();
- sut.servicesCallback(data);
- expect(PdpInformation.setEngineServiceData).toHaveBeenCalled();
- expect(PdpStatisticsSummary.setEngineSummaryData).toHaveBeenCalled();
- expect(PdpEngineWorkerStatus.setEngineStatusData).toHaveBeenCalled();
-}); \ No newline at end of file
diff --git a/gui-pdp-monitoring/src/webapp/js/__test__/MonitoringTable.test.js b/gui-pdp-monitoring/src/webapp/js/__test__/MonitoringTable.test.js
deleted file mode 100644
index 2f67925..0000000
--- a/gui-pdp-monitoring/src/webapp/js/__test__/MonitoringTable.test.js
+++ /dev/null
@@ -1,33 +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=========================================================
- */
-
-import $ from 'jquery';
-import * as MonitoringTable from "../MonitoringTable"
-
-var wrapper = document.createElement("example")
-wrapper.setAttribute("id", "engineSummary_wrapper");
-wrapper.setAttribute("class", "wrapper_borderless");
-
-test("create necessary engine table", () => {
- MonitoringTable.createEngineTable($(wrapper), null, null);
- expect(document.getElementById("engineTableBody")).toBeDefined();
- expect(document.getElementById("engineTableHeader")).toBeDefined();
- expect(document.getElementById("engineTableHeaderRow")).toBeDefined();
- }); \ No newline at end of file
diff --git a/gui-pdp-monitoring/src/webapp/js/__test__/MonitoringUtils.test.js b/gui-pdp-monitoring/src/webapp/js/__test__/MonitoringUtils.test.js
deleted file mode 100644
index 35eb297..0000000
--- a/gui-pdp-monitoring/src/webapp/js/__test__/MonitoringUtils.test.js
+++ /dev/null
@@ -1,109 +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=========================================================
- */
-
-import $ from 'jquery';
-import * as sut from "../MonitoringUtils";
-import * as PdpInformation from "../PdpInformation";
-import * as PdpStatisticsSummary from "../PdpStatisticsSummary";
-import * as PdpListView from '../PdpListView';
-
-const requestURL = "http://localhost:7979";
-
-const serviceData = {
- useHttps: "http",
- hostname: "localhost",
- port: 7979,
- username: "username",
- password: "password",
-};
-
-test('ajax_get ok', () => {
- const callback = jest.fn();
- $.ajax = jest.fn().mockImplementation((args) => { args.success(); });
- sut.ajax_get(requestURL, callback, serviceData.useHttps, serviceData.hostname, serviceData.port,
- serviceData.username, serviceData.password, {}, null);
- expect(callback).toHaveBeenCalled();
-});
-
-test('ajax_get error', () => {
- const errorCallback = jest.fn();
- const jqXHR = { status: 500, responseText: "" };
- $.ajax = jest.fn().mockImplementation(
- args => {
- args.error(jqXHR, null, null);
- }
- );
- sut.ajax_get(requestURL, null, serviceData.useHttps, serviceData.hostname, serviceData.port,
- serviceData.username, serviceData.password, {}, errorCallback);
- expect(errorCallback).toHaveBeenCalled();
-});
-
-test('ajax_get_statistics ok', () => {
- const callback = jest.fn();
- $.ajax = jest.fn().mockImplementation((args) => { args.success(); });
- sut.ajax_get_statistics(requestURL, callback, serviceData.useHttps, serviceData.hostname, serviceData.port,
- serviceData.username, serviceData.password, "", {}, null);
- expect(callback).toHaveBeenCalled();
-});
-
-test('ajax_get_statistics error', () => {
- const errorCallback = jest.fn();
- const jqXHR = { status: 500, responseText: "" };
- $.ajax = jest.fn().mockImplementation(
- args => {
- args.error(jqXHR, null, null);
- }
- );
- PdpInformation.createEngineServiceTable = jest.fn();
- PdpStatisticsSummary.createEngineSummaryTable = jest.fn();
- sut.ajax_get_statistics(requestURL, null, serviceData.useHttps, serviceData.hostname, serviceData.port,
- serviceData.username, serviceData.password, "", {}, errorCallback);
-
- expect(errorCallback).toHaveBeenCalled();
- expect(PdpInformation.createEngineServiceTable).toHaveBeenCalled();
- expect(PdpStatisticsSummary.createEngineSummaryTable).toHaveBeenCalled();
-});
-
-test('getEngineURL popup dialog', () => {
- window.localStorage.clear();
- sut.getEngineURL("message");
- $('#submit').click();
- expect($("papDialogDiv")).toHaveLength(1);
-});
-
-test('getEngineURL read from localStorage', () => {
- window.localStorage.setItem("pap-monitor-services", JSON.stringify(serviceData));
- const data = {
- groups: [{
- pdpSubgroups: [{
- pdpType: "apex",
- pdpInstances: [{
- instanceId: "apex-pdp1",
- }],
- }]
- }
- ],
- };
-
- $.ajax = jest.fn().mockImplementation((args) => { args.success(data); });
- PdpListView.RenderPdpList = jest.fn();
- sut.getEngineURL("message");
- expect(PdpListView.RenderPdpList.mock.calls[0][0]).toHaveLength(1);
-});
diff --git a/gui-pdp-monitoring/src/webapp/js/__test__/PdpEngineWorkerStatus.test.js b/gui-pdp-monitoring/src/webapp/js/__test__/PdpEngineWorkerStatus.test.js
deleted file mode 100644
index 39b74f5..0000000
--- a/gui-pdp-monitoring/src/webapp/js/__test__/PdpEngineWorkerStatus.test.js
+++ /dev/null
@@ -1,37 +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=========================================================
- */
-
-import * as PdpEngineWorkerStatus from "../PdpEngineWorkerStatus";
-import * as MonitoringChart from "../MonitoringChart";
-
-test("set engine status data", () => {
- var temp = MonitoringChart.generateRandomData();
- var engineStatusData = [{id : 1, lastPolicyDuration : 1, averagePolicyDuration: 1}];
- var changed = jest.fn(() => {
- return false;
- });
-
- engineStatusData[0].lastPolicyDuration = temp;
- engineStatusData[0].averagePolicyDuration = temp;
- window.engineStatusTables = [];
- PdpEngineWorkerStatus.setEngineStatusData(engineStatusData, changed);
-
- expect(window.engineStatusTables[0]).toBeDefined();
-}); \ No newline at end of file
diff --git a/gui-pdp-monitoring/src/webapp/js/__test__/PdpInformation.test.js b/gui-pdp-monitoring/src/webapp/js/__test__/PdpInformation.test.js
deleted file mode 100644
index 993eb54..0000000
--- a/gui-pdp-monitoring/src/webapp/js/__test__/PdpInformation.test.js
+++ /dev/null
@@ -1,31 +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=========================================================
- */
-
-import * as PdpInformation from "../PdpInformation"
-
-test("create engine service table", () => {
- PdpInformation.createEngineServiceTable();
- expect(document.getElementById("string")).toBeDefined();
-})
-
-test("ser engine service data", () => {
- PdpInformation.setEngineServiceData("testing", "testing", "testing", "testing", "testing", null, null);
- expect(document.getElementById("testing")).toBeDefined();
-}) \ No newline at end of file
diff --git a/gui-pdp-monitoring/src/webapp/js/__test__/PdpListView.test.js b/gui-pdp-monitoring/src/webapp/js/__test__/PdpListView.test.js
deleted file mode 100644
index 3d38be9..0000000
--- a/gui-pdp-monitoring/src/webapp/js/__test__/PdpListView.test.js
+++ /dev/null
@@ -1,63 +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=========================================================
- */
-
-import * as PdpListView from "../PdpListView";
-const pdpArray = [];
-
-test("render pdp list", () => {
- const data = {
- groups: [{
- pdpSubgroups: [{
- pdpType: "apex",
- pdpInstances: [{
- instanceId: "apex-pdp1",
- }],
- }]
- }
- ],
- };
-
- for (let i = 0; i < data.groups.length; i++) {
- var map = {};
- map.title = data.groups[i].name;
- map.children = [];
- (data.groups[i].pdpSubgroups).forEach((pdpSubgroup, index) => {
- map.children[index] = {};
- map.children[index].title = pdpSubgroup.pdpType;
- const instanceId = [];
- pdpSubgroup.pdpInstances.forEach(pdpInstance => {
- var instanceIdMap = {};
- instanceIdMap.title = pdpInstance.instanceId;
- instanceId.push(instanceIdMap)
- });
- map.children[index].children = instanceId;
- });
- pdpArray.push(map);
- };
-
- document.body.innerHTML = '<ul class="pdps__list"></ul>';
- PdpListView.RenderPdpList(pdpArray, "pdps__list");
- expect(document.querySelector('a.' + 'pdps__link').innerHTML).toBe("apex-pdp1");
-});
-
-test("high light selected", () => {
- PdpListView.highlightSelected(1);
- expect(document.querySelector(`.pdps__link[href*="${1}"]`)).toBeDefined();
-}) \ No newline at end of file
diff --git a/gui-pdp-monitoring/src/webapp/js/__test__/PdpStatisticsSummary.test.js b/gui-pdp-monitoring/src/webapp/js/__test__/PdpStatisticsSummary.test.js
deleted file mode 100644
index 03404b7..0000000
--- a/gui-pdp-monitoring/src/webapp/js/__test__/PdpStatisticsSummary.test.js
+++ /dev/null
@@ -1,38 +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=========================================================
- */
-
-import * as PdpEngineSummary from "../PdpStatisticsSummary";
-
-var data = [{averagePolicyDuration : [
- { timestamp: 1584979433034, value: 95 },
- { timestamp: 1584979428034, value: 78 },
- { timestamp: 1584979423034, value: 71 },
- { timestamp: 1584979418034, value: 79 },
- { timestamp: 1584979413034, value: 21 }]}]
-
-test("create engine summary table", () => {
- PdpEngineSummary.createEngineSummaryTable();
- expect(document.getElementById("string")).toBeDefined();
-})
-
-test("set engine service data", () => {
- PdpEngineSummary.setEngineSummaryData(data, null, 1, 2, 3, 1, 2, 3)
- expect(document.getElementById("engineSummaryTable")).toBeDefined();
-}) \ No newline at end of file