aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/js/tests/e2e/tests/quality-gates-spec.js207
-rw-r--r--sonar-server/src/main/js/tests/e2e/tests/quality-gates-spec/app.json99
-rw-r--r--sonar-server/src/main/js/tests/e2e/tests/quality-gates-spec/list.json9
-rw-r--r--sonar-server/src/main/js/tests/e2e/tests/quality-gates-spec/show.json70
4 files changed, 203 insertions, 182 deletions
diff --git a/sonar-server/src/main/js/tests/e2e/tests/quality-gates-spec.js b/sonar-server/src/main/js/tests/e2e/tests/quality-gates-spec.js
index 94f134693c3..146ecd577fe 100644
--- a/sonar-server/src/main/js/tests/e2e/tests/quality-gates-spec.js
+++ b/sonar-server/src/main/js/tests/e2e/tests/quality-gates-spec.js
@@ -8,15 +8,33 @@ casper.on('page.error', function(msg, trace) {
this.echo('Error: ' + msg, 'ERROR');
});
+var fs = require('fs');
+var utils = require('utils');
+
+// Since Casper has control, the invoked script is deep in the argument stack
+var currentFile = require('system').args[4];
+var curFilePath = fs.absolute(currentFile).split(fs.separator);
+if (curFilePath.length > 1) {
+ curFilePath.pop(); // PhantomJS does not have an equivalent path.baseName()-like method
+ curFilePath.push('quality-gates-spec');
+ fs.changeWorkingDirectory(curFilePath.join(fs.separator));
+}
casper.test.begin('App is setup correctly', function suite(test) {
+ // Load MockJax responses from FS
+ var appResponse = fs.read('app.json');
+ var listResponse = fs.read('list.json');
+ var showResponse = fs.read('show.json');
+
// Register mockjax requests on loading of requirejs
casper.options.onResourceRequested = function(instance, requestData, networkRequest) {
+
+ // Here, instance is the running instance of casperjs
if (requestData.url.indexOf('require') >= 0) {
- // Here, instance is the running instance of casperjs
- instance.page.includeJs('../js/third-party/jquery.mockjax.js', function() {
- instance.page.evaluate(function() {
+ instance.page.includeJs('../js/third-party/jquery.mockjax.js', function injectReponses() {
+ // Inject response values to page scope
+ instance.page.evaluate(function setupMockJax(appResponse, listResponse, showResponse) {
jQuery.mockjaxSettings.contentType = 'text/json';
jQuery.mockjaxSettings.responseTime = 250;
@@ -29,196 +47,21 @@ casper.test.begin('App is setup correctly', function suite(test) {
jQuery.mockjax({
url: '../api/qualitygates/app',
- responseText: JSON.stringify({
- "edit": false,
- "periods": [
- {
- "key": 1,
- "text": "since previous analysis"
- },
- {
- "key": 2,
- "text": "over 365 days"
- },
- {
- "key": 3,
- "text": "since previous version"
- },
- {
- "key": 4,
- "text": "over period 4 - defined at project level"
- },
- {
- "key": 5,
- "text": "over period 5 - defined at project level"
- }
- ],
- "metrics": [
- {
- "id": 62,
- "key": "blocker_violations",
- "name": "Blocker issues",
- "type": "INT",
- "domain": "Issues",
- "hidden": false
- },
- {
- "id": 37,
- "key": "new_coverage",
- "name": "Coverage on new code",
- "type": "PERCENT",
- "domain": "Tests",
- "hidden": false
- },
- {
- "id": 63,
- "key": "critical_violations",
- "name": "Critical issues",
- "type": "INT",
- "domain": "Issues",
- "hidden": false
- },
- {
- "id": 154,
- "key": "sqale_effort_to_grade_a",
- "name": "Effort to rating A",
- "type": "WORK_DUR",
- "domain": "SQALE",
- "hidden": false
- },
- {
- "id": 218,
- "key": "open_issues",
- "name": "Open issues",
- "type": "INT",
- "domain": "Issues",
- "hidden": false
- },
- {
- "id": 219,
- "key": "reopened_issues",
- "name": "Reopened issues",
- "type": "INT",
- "domain": "Issues",
- "hidden": false
- },
- {
- "id": 32,
- "key": "skipped_tests",
- "name": "Skipped unit tests",
- "type": "INT",
- "domain": "Tests",
- "hidden": false
- },
- {
- "id": 31,
- "key": "test_errors",
- "name": "Unit test errors",
- "type": "INT",
- "domain": "Tests",
- "hidden": false
- },
- {
- "id": 33,
- "key": "test_failures",
- "name": "Unit test failures",
- "type": "INT",
- "domain": "Tests",
- "hidden": false
- }
- ]
- })
+ responseText: appResponse
});
jQuery.mockjax({
url: "../api/qualitygates/list",
- responseText: JSON.stringify({
- "qualitygates": [
- {
- "id": 1,
- "name": "Default Gate"
- }
- ],
- "default": 1
- })
+ responseText: listResponse
});
jQuery.mockjax({
url: "../api/qualitygates/show?id=1",
- responseText: {
- "id": 1,
- "name": "Default Gate",
- "conditions": [
- {
- "id": 1,
- "metric": "blocker_violations",
- "op": "GT",
- "warning": "",
- "error": "0"
- },
- {
- "id": 2,
- "metric": "new_coverage",
- "op": "LT",
- "warning": "",
- "error": "80",
- "period": 3
- },
- {
- "id": 3,
- "metric": "critical_violations",
- "op": "GT",
- "warning": "",
- "error": "0"
- },
- {
- "id": 4,
- "metric": "sqale_effort_to_grade_a",
- "op": "GT",
- "warning": "",
- "error": "0"
- },
- {
- "id": 5,
- "metric": "open_issues",
- "op": "GT",
- "warning": "0",
- "error": ""
- },
- {
- "id": 6,
- "metric": "reopened_issues",
- "op": "GT",
- "warning": "0",
- "error": ""
- },
- {
- "id": 7,
- "metric": "skipped_tests",
- "op": "GT",
- "warning": "0",
- "error": ""
- },
- {
- "id": 8,
- "metric": "test_errors",
- "op": "GT",
- "warning": "",
- "error": "0"
- },
- {
- "id": 9,
- "metric": "test_failures",
- "op": "GT",
- "warning": "",
- "error": "0"
- }
- ]
- }
+ responseText: showResponse
});
- });
+ }, appResponse, listResponse, showResponse);
});
}
};
diff --git a/sonar-server/src/main/js/tests/e2e/tests/quality-gates-spec/app.json b/sonar-server/src/main/js/tests/e2e/tests/quality-gates-spec/app.json
new file mode 100644
index 00000000000..6a38a3ed8b5
--- /dev/null
+++ b/sonar-server/src/main/js/tests/e2e/tests/quality-gates-spec/app.json
@@ -0,0 +1,99 @@
+{
+ "edit": false,
+ "periods": [
+ {
+ "key": 1,
+ "text": "since previous analysis"
+ },
+ {
+ "key": 2,
+ "text": "over 365 days"
+ },
+ {
+ "key": 3,
+ "text": "since previous version"
+ },
+ {
+ "key": 4,
+ "text": "over period 4 - defined at project level"
+ },
+ {
+ "key": 5,
+ "text": "over period 5 - defined at project level"
+ }
+ ],
+ "metrics": [
+ {
+ "id": 62,
+ "key": "blocker_violations",
+ "name": "Blocker issues",
+ "type": "INT",
+ "domain": "Issues",
+ "hidden": false
+ },
+ {
+ "id": 37,
+ "key": "new_coverage",
+ "name": "Coverage on new code",
+ "type": "PERCENT",
+ "domain": "Tests",
+ "hidden": false
+ },
+ {
+ "id": 63,
+ "key": "critical_violations",
+ "name": "Critical issues",
+ "type": "INT",
+ "domain": "Issues",
+ "hidden": false
+ },
+ {
+ "id": 154,
+ "key": "sqale_effort_to_grade_a",
+ "name": "Effort to rating A",
+ "type": "WORK_DUR",
+ "domain": "SQALE",
+ "hidden": false
+ },
+ {
+ "id": 218,
+ "key": "open_issues",
+ "name": "Open issues",
+ "type": "INT",
+ "domain": "Issues",
+ "hidden": false
+ },
+ {
+ "id": 219,
+ "key": "reopened_issues",
+ "name": "Reopened issues",
+ "type": "INT",
+ "domain": "Issues",
+ "hidden": false
+ },
+ {
+ "id": 32,
+ "key": "skipped_tests",
+ "name": "Skipped unit tests",
+ "type": "INT",
+ "domain": "Tests",
+ "hidden": false
+ },
+ {
+ "id": 31,
+ "key": "test_errors",
+ "name": "Unit test errors",
+ "type": "INT",
+ "domain": "Tests",
+ "hidden": false
+ },
+ {
+ "id": 33,
+ "key": "test_failures",
+ "name": "Unit test failures",
+ "type": "INT",
+ "domain": "Tests",
+ "hidden": false
+ }
+ ]
+}
diff --git a/sonar-server/src/main/js/tests/e2e/tests/quality-gates-spec/list.json b/sonar-server/src/main/js/tests/e2e/tests/quality-gates-spec/list.json
new file mode 100644
index 00000000000..9d7ac911b05
--- /dev/null
+++ b/sonar-server/src/main/js/tests/e2e/tests/quality-gates-spec/list.json
@@ -0,0 +1,9 @@
+{
+ "qualitygates": [
+ {
+ "id": 1,
+ "name": "Default Gate"
+ }
+ ],
+ "default": 1
+}
diff --git a/sonar-server/src/main/js/tests/e2e/tests/quality-gates-spec/show.json b/sonar-server/src/main/js/tests/e2e/tests/quality-gates-spec/show.json
new file mode 100644
index 00000000000..bc36acb897e
--- /dev/null
+++ b/sonar-server/src/main/js/tests/e2e/tests/quality-gates-spec/show.json
@@ -0,0 +1,70 @@
+{
+ "id": 1,
+ "name": "Default Gate",
+ "conditions": [
+ {
+ "id": 1,
+ "metric": "blocker_violations",
+ "op": "GT",
+ "warning": "",
+ "error": "0"
+ },
+ {
+ "id": 2,
+ "metric": "new_coverage",
+ "op": "LT",
+ "warning": "",
+ "error": "80",
+ "period": 3
+ },
+ {
+ "id": 3,
+ "metric": "critical_violations",
+ "op": "GT",
+ "warning": "",
+ "error": "0"
+ },
+ {
+ "id": 4,
+ "metric": "sqale_effort_to_grade_a",
+ "op": "GT",
+ "warning": "",
+ "error": "0"
+ },
+ {
+ "id": 5,
+ "metric": "open_issues",
+ "op": "GT",
+ "warning": "0",
+ "error": ""
+ },
+ {
+ "id": 6,
+ "metric": "reopened_issues",
+ "op": "GT",
+ "warning": "0",
+ "error": ""
+ },
+ {
+ "id": 7,
+ "metric": "skipped_tests",
+ "op": "GT",
+ "warning": "0",
+ "error": ""
+ },
+ {
+ "id": 8,
+ "metric": "test_errors",
+ "op": "GT",
+ "warning": "",
+ "error": "0"
+ },
+ {
+ "id": 9,
+ "metric": "test_failures",
+ "op": "GT",
+ "warning": "",
+ "error": "0"
+ }
+ ]
+}