From bb4b6d25379f9c392954dd26112e2d0254975f03 Mon Sep 17 00:00:00 2001 From: Trapenok Victor Date: Thu, 1 Nov 2018 15:50:28 +1000 Subject: [PATCH 01/28] tests for gui, base tests for api paths with level <= 2 --- polemarch/static/js/common.js | 15 ++++-- polemarch/static/js/pmGuiElements.js | 0 polemarch/static/js/pmItems.js | 1 - polemarch/static/js/tests/pmDashboard.js | 8 +++ polemarch/static/js/tests/pmGroups.js | 29 +++++++++++ polemarch/static/js/tests/pmHistory.js | 7 +++ polemarch/static/js/tests/pmHook.js | 39 +++++++++++++++ polemarch/static/js/tests/pmHosts.js | 30 ++++++++++++ polemarch/static/js/tests/pmInventories.js | 29 +++++++++++ polemarch/static/js/tests/pmProjects.js | 57 ++++++++++++++++++++++ polemarch/static/js/tests/pmUnitTest.js | 10 ---- polemarch/static/js/tests/pmUsers.js | 15 ++++++ polemarch/templates/gui/gui.html | 2 +- 13 files changed, 227 insertions(+), 15 deletions(-) delete mode 100644 polemarch/static/js/pmGuiElements.js delete mode 100644 polemarch/static/js/pmItems.js create mode 100644 polemarch/static/js/tests/pmDashboard.js create mode 100644 polemarch/static/js/tests/pmGroups.js create mode 100644 polemarch/static/js/tests/pmHistory.js create mode 100644 polemarch/static/js/tests/pmHook.js create mode 100644 polemarch/static/js/tests/pmHosts.js create mode 100644 polemarch/static/js/tests/pmInventories.js create mode 100644 polemarch/static/js/tests/pmProjects.js delete mode 100644 polemarch/static/js/tests/pmUnitTest.js create mode 100644 polemarch/static/js/tests/pmUsers.js diff --git a/polemarch/static/js/common.js b/polemarch/static/js/common.js index fc26252d..dbf0f811 100644 --- a/polemarch/static/js/common.js +++ b/polemarch/static/js/common.js @@ -1,8 +1,8 @@ if(window.moment && window.moment.tz) -{ +{ window.moment.tz.setDefault(window.timeZone); } - + if(guiLocalSettings.get('hideMenu')) { if(window.innerWidth>767){ @@ -139,4 +139,13 @@ tabSignal.connect("loading.completed", function() setActiveMenuLiBase(); // Добавляем файл тестов к списку файлов для тестов гуя -window.guiTestsFiles.push(hostname + window.guiStaticPath + 'js/tests/pmUnitTest.js') + +window.guiTestsFiles.push(hostname + window.guiStaticPath + 'js/tests/pmDashboard.js') +window.guiTestsFiles.push(hostname + window.guiStaticPath + 'js/tests/pmGroups.js') +window.guiTestsFiles.push(hostname + window.guiStaticPath + 'js/tests/pmHistory.js') +window.guiTestsFiles.push(hostname + window.guiStaticPath + 'js/tests/pmHook.js') +window.guiTestsFiles.push(hostname + window.guiStaticPath + 'js/tests/pmHosts.js') +window.guiTestsFiles.push(hostname + window.guiStaticPath + 'js/tests/pmInventories.js') +window.guiTestsFiles.push(hostname + window.guiStaticPath + 'js/tests/pmProjects.js') +window.guiTestsFiles.push(hostname + window.guiStaticPath + 'js/tests/pmUsers.js') + diff --git a/polemarch/static/js/pmGuiElements.js b/polemarch/static/js/pmGuiElements.js deleted file mode 100644 index e69de29b..00000000 diff --git a/polemarch/static/js/pmItems.js b/polemarch/static/js/pmItems.js deleted file mode 100644 index 0519ecba..00000000 --- a/polemarch/static/js/pmItems.js +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/polemarch/static/js/tests/pmDashboard.js b/polemarch/static/js/tests/pmDashboard.js new file mode 100644 index 00000000..2baf64b0 --- /dev/null +++ b/polemarch/static/js/tests/pmDashboard.js @@ -0,0 +1,8 @@ + +window.qunitTestsArray['pmDashboard'] = { + test:function() + { + // Проверка того что страница открывается + guiTests.openPage("") + } +} \ No newline at end of file diff --git a/polemarch/static/js/tests/pmGroups.js b/polemarch/static/js/tests/pmGroups.js new file mode 100644 index 00000000..2cf2a595 --- /dev/null +++ b/polemarch/static/js/tests/pmGroups.js @@ -0,0 +1,29 @@ + +window.qunitTestsArray['guiPaths.group'] = { + test:function() + { + let path = '/group/' + let params = { + create:[ + { + is_valid:true, + data:{ + notes:{ + value:rundomString(6) + } + }, + }, + ], + update:[ + { + is_valid:true, + data:{ + notes : {value:rundomString(6)}, + name : {value:rundomString(6)}, + }, + }, + ] + } + guiTests.testForPath(path, params) + } +} \ No newline at end of file diff --git a/polemarch/static/js/tests/pmHistory.js b/polemarch/static/js/tests/pmHistory.js new file mode 100644 index 00000000..02f5f2de --- /dev/null +++ b/polemarch/static/js/tests/pmHistory.js @@ -0,0 +1,7 @@ + +window.qunitTestsArray['guiPaths.history'] = { + test:function() + { + guiTests.openPage("/history/") + } +} \ No newline at end of file diff --git a/polemarch/static/js/tests/pmHook.js b/polemarch/static/js/tests/pmHook.js new file mode 100644 index 00000000..3b165139 --- /dev/null +++ b/polemarch/static/js/tests/pmHook.js @@ -0,0 +1,39 @@ + +window.qunitTestsArray['guiPaths.hook'] = { + test:function() + { + let path = '/hook/' + let params = { + create:[ + { + is_valid:false, + data:{}, + }, + { + is_valid:true, + data:{ + recipients:{ + value:rundomString(6) + } + }, + }, + ], + update:[ + /*{ + is_valid:false, + data:{ + type : {value:"SCRIPT"}, + }, + },*/ + { + is_valid:true, + data:{ + type : {value:"HTTP"}, + name : {value:rundomString(6)}, + }, + }, + ] + } + guiTests.testForPath(path, params) + } +} \ No newline at end of file diff --git a/polemarch/static/js/tests/pmHosts.js b/polemarch/static/js/tests/pmHosts.js new file mode 100644 index 00000000..0ebf10c0 --- /dev/null +++ b/polemarch/static/js/tests/pmHosts.js @@ -0,0 +1,30 @@ + +window.qunitTestsArray['guiPaths.host'] = { + test:function() + { + let path = '/host/' + let params = { + create:[ + { + is_valid:true, + data:{ + notes:{ + value:rundomString(6) + } + }, + }, + ], + update:[ + { + is_valid:true, + data:{ + notes : {value:rundomString(6)}, + name : {value:rundomString(6)}, + type : {value:"RANGE"}, + }, + }, + ] + } + guiTests.testForPath(path, params) + } +} \ No newline at end of file diff --git a/polemarch/static/js/tests/pmInventories.js b/polemarch/static/js/tests/pmInventories.js new file mode 100644 index 00000000..160603f7 --- /dev/null +++ b/polemarch/static/js/tests/pmInventories.js @@ -0,0 +1,29 @@ + +window.qunitTestsArray['guiPaths.inventory'] = { + test:function() + { + let path = '/inventory/' + let params = { + create:[ + { + is_valid:true, + data:{ + notes:{ + value:rundomString(6) + } + }, + }, + ], + update:[ + { + is_valid:true, + data:{ + notes : {value:rundomString(6)}, + name : {value:rundomString(6)}, + }, + }, + ] + } + guiTests.testForPath(path, params) + } +} \ No newline at end of file diff --git a/polemarch/static/js/tests/pmProjects.js b/polemarch/static/js/tests/pmProjects.js new file mode 100644 index 00000000..f807ad11 --- /dev/null +++ b/polemarch/static/js/tests/pmProjects.js @@ -0,0 +1,57 @@ + +window.qunitTestsArray['guiPaths.project'] = { + test:function() + { + let path = '/project/' + let params = { + create:[ + { + is_valid:true, + data:{ + notes:{ + value:rundomString(6) + } + }, + }, + ], + update:[ + { + is_valid:true, + data:{ + notes : {value:rundomString(6)}, + }, + }, + ] + } + //guiTests.testForPath(path, params) + } +} + +/* +window.qunitTestsArray['guiPaths.periodic_task'] = { + test:function() + { + let path = '/periodic_task/' + let params = { + create:[ + { + is_valid:true, + data:{ + notes:{ + value:rundomString(6) + } + }, + }, + ], + update:[ + { + is_valid:true, + data:{ + notes : {value:rundomString(6)}, + }, + }, + ] + } + testForPath(path, params) + } +}*/ \ No newline at end of file diff --git a/polemarch/static/js/tests/pmUnitTest.js b/polemarch/static/js/tests/pmUnitTest.js deleted file mode 100644 index 92b10c5b..00000000 --- a/polemarch/static/js/tests/pmUnitTest.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Файл вставляемый на страницу при тестировании из phantomjs - */ - -/////////////////////////////////////////////// -// Функции тестирования -/////////////////////////////////////////////// - - - \ No newline at end of file diff --git a/polemarch/static/js/tests/pmUsers.js b/polemarch/static/js/tests/pmUsers.js new file mode 100644 index 00000000..7ad2398f --- /dev/null +++ b/polemarch/static/js/tests/pmUsers.js @@ -0,0 +1,15 @@ + +window.qunitTestsArray['guiPaths.profile/settings'] = { + test:function() + { + let path = "profile/settings" + guiTests.openPage(path) + guiTests.hasElement(1, ".btn_save", path) + guiTests.hasElement(1, ".gui-field-chartLineSettings", path) + + guiTests.hasAddButton(0, path) + + $(".btn_save").trigger('click') + + } +} \ No newline at end of file diff --git a/polemarch/templates/gui/gui.html b/polemarch/templates/gui/gui.html index 2afde8ba..758489ab 100644 --- a/polemarch/templates/gui/gui.html +++ b/polemarch/templates/gui/gui.html @@ -15,7 +15,7 @@ {% block common_sciprt %} + + + + diff --git a/polemarch/static/templates/pmTasksTemplates.html b/polemarch/static/templates/pmTasksTemplates.html index 82d5aae0..aefbe19e 100644 --- a/polemarch/static/templates/pmTasksTemplates.html +++ b/polemarch/static/templates/pmTasksTemplates.html @@ -10,3 +10,4 @@ <%] %> <%! guiElements.base %> + diff --git a/polemarch/templates/gui/gui.html b/polemarch/templates/gui/gui.html index 758489ab..c69962fd 100644 --- a/polemarch/templates/gui/gui.html +++ b/polemarch/templates/gui/gui.html @@ -16,6 +16,7 @@ {% block common_sciprt %}