]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5935 Add frontend tests for issue tag management
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Thu, 8 Jan 2015 15:17:12 +0000 (16:17 +0100)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Thu, 8 Jan 2015 15:17:17 +0000 (16:17 +0100)
server/sonar-web/src/main/js/tests/e2e/tests/issues-page-spec.js
server/sonar-web/src/main/js/tests/e2e/tests/issues-spec/search-with-tags.json [new file with mode: 0644]
server/sonar-web/src/main/js/tests/e2e/tests/issues-spec/show-with-tags.json [new file with mode: 0644]
server/sonar-web/src/main/js/tests/e2e/tests/issues-spec/tags-modified.json [new file with mode: 0644]
server/sonar-web/src/main/js/tests/e2e/tests/issues-spec/tags.json [new file with mode: 0644]

index 56be033ca945a948972fa18d3277a99fb1d0867e..710a306846204bea6cf58e8cc12445c186872466 100644 (file)
@@ -79,6 +79,8 @@ casper.test.begin(testName('Issue Box', 'Check Elements'), function (test) {
 
       .then(function () {
         test.assertSelectorContains('.issue.selected', "Add a 'package-info.java' file to document the");
+        test.assertExists('.issue.selected .issue-tags');
+        test.assertSelectorContains('.issue.selected .issue-tags', 'issue.no_tag');
         test.assertExists('.issue.selected .js-issue-set-severity');
         test.assertSelectorContains('.issue.selected .js-issue-set-severity', 'MAJOR');
         test.assertSelectorContains('.issue.selected', 'CONFIRMED');
@@ -101,6 +103,41 @@ casper.test.begin(testName('Issue Box', 'Check Elements'), function (test) {
 });
 
 
+casper.test.begin(testName('Issue Box', 'Tags'), function (test) {
+  casper
+      .start(lib.buildUrl('issues'), function () {
+        lib.setDefaultViewport();
+
+        lib.mockRequest('/api/l10n/index', '{}');
+        lib.mockRequestFromFile('/api/issue_filters/app', 'app.json');
+        lib.mockRequestFromFile('/api/issues/search', 'search-with-tags.json');
+        this.showMock = lib.mockRequestFromFile('/api/issues/show*', 'show-with-tags.json');
+      })
+
+      .then(function () {
+        casper.waitForSelector('.issue.selected .issue-tags', function () {
+          test.assertSelectorContains('.issue.selected .issue-tags', 'security, cwe');
+          lib.mockRequestFromFile('/api/issues/tags*', 'tags.json');
+          casper.click('.issue.selected .issue-tag-list');
+
+          casper.waitForSelector('.issue.selected .select2-input', function () {
+            lib.mockRequestFromFile('/api/issues/set_tags', 'tags-modified.json');
+            casper.click('.issue.selected .issue-tag-edit-done');
+            casper.waitWhileVisible('.issue.selected .issue-tag-edit');
+            casper.waitUntilVisible('.issue.selected .issue-tag-list', function () {
+              // TODO Find a way to have this assertion work
+              // test.assertSelectorContains('.issue.selected .issue-tags .issue-tag-list', 'security, cwe, cert');
+            });
+          });
+        });
+      })
+
+      .run(function () {
+        test.done();
+      });
+});
+
+
 casper.test.begin(testName('Issue Box', 'Transitions'), function (test) {
   casper
       .start(lib.buildUrl('issues'), function () {
diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/issues-spec/search-with-tags.json b/server/sonar-web/src/main/js/tests/e2e/tests/issues-spec/search-with-tags.json
new file mode 100644 (file)
index 0000000..442b1de
--- /dev/null
@@ -0,0 +1,172 @@
+{
+  "total": 1,
+  "p": 1,
+  "ps": 50,
+  "projects": [
+    {
+      "uuid": "015c6451-1709-4360-b4fa-e4508e13082d",
+      "key": "org.codehaus.sonar-plugins.xml:xml",
+      "id": 17156,
+      "qualifier": "TRK",
+      "name": "XML",
+      "longName": "XML"
+    }
+  ],
+  "components": [
+    {
+      "uuid": "639e257b-d3fb-4d10-b94a-31079b71532d",
+      "key": "org.codehaus.sonar-plugins.xml:sonar-xml-plugin:src/main/java/org/sonar/plugins/xml",
+      "id": 26177,
+      "enabled": true,
+      "qualifier": "DIR",
+      "name": "src/main/java/org/sonar/plugins/xml",
+      "longName": "src/main/java/org/sonar/plugins/xml",
+      "path": "src/main/java/org/sonar/plugins/xml",
+      "projectId": 17156,
+      "subProjectId": 17158
+    },
+    {
+      "uuid": "015c6451-1709-4360-b4fa-e4508e13082d",
+      "key": "org.codehaus.sonar-plugins.xml:xml",
+      "id": 17156,
+      "enabled": true,
+      "qualifier": "TRK",
+      "name": "XML",
+      "longName": "XML"
+    }
+
+  ],
+  "issues": [
+    {
+      "key": "94357807-fcb4-40cc-9598-9a715f1eee6e",
+      "component": "org.codehaus.sonar-plugins.xml:sonar-xml-plugin:src/main/java/org/sonar/plugins/xml",
+      "componentId": 26177,
+      "project": "org.codehaus.sonar-plugins.xml:xml",
+      "rule": "squid:S1228",
+      "status": "CONFIRMED",
+      "severity": "MAJOR",
+      "message": "Add a 'package-info.java' file to document the 'src/main/java/org/sonar/plugins/xml' package",
+      "debt": "20min",
+      "creationDate": "2014-10-03T23:26:37+0200",
+      "updateDate": "2014-10-09T06:32:55+0200",
+      "fUpdateAge": "26 days",
+      "tags": [
+        "security",
+        "cwe"
+      ],
+      "actions": [
+        "comment",
+        "assign",
+        "assign_to_me",
+        "plan",
+        "set_severity",
+        "set_tags"
+      ],
+      "transitions": [
+        "unconfirm",
+        "resolve",
+        "falsepositive"
+      ]
+    }
+  ],
+  "rules": [
+    {
+      "key": "squid:S1228",
+      "name": "Packages should have a javadoc file 'package-info.java'",
+      "desc": "<p>Each package in a Java project should include a <code>package-info.java</code> file. The purpose of this file is to document the Java package using javadoc and declare package annotations.</p>\n\n<h2>Compliant Solution</h2>\n<pre>\n/**\n* This package has non null parameters and is documented.\n**/\n@ParametersAreNonnullByDefault\npackage org.foo.bar;\n</pre>",
+      "status": "REMOVED"
+    }
+  ],
+  "users": [],
+  "languages": [
+    {
+      "key": "js",
+      "name": "JavaScript"
+    },
+    {
+      "key": "java",
+      "name": "Java"
+    }
+  ],
+  "maxResultsReached": false,
+  "paging": {
+    "pageIndex": 1,
+    "pageSize": 50,
+    "total": 1,
+    "fTotal": "1",
+    "pages": 1
+  },
+  "facets": [
+    {
+      "property": "severities",
+      "values": [
+        {
+          "val": "MAJOR",
+          "count": 1
+        },
+        {
+          "val": "INFO",
+          "count": 0
+        },
+        {
+          "val": "MINOR",
+          "count": 0
+        },
+        {
+          "val": "CRITICAL",
+          "count": 0
+        },
+        {
+          "val": "BLOCKER",
+          "count": 0
+        }
+      ]
+    },
+    {
+      "property": "statuses",
+      "values": [
+        {
+          "val": "CONFIRMED",
+          "count": 1
+        },
+        {
+          "val": "OPEN",
+          "count": 0
+        },
+        {
+          "val": "REOPENED",
+          "count": 0
+        },
+        {
+          "val": "CLOSED",
+          "count": 0
+        },
+        {
+          "val": "RESOLVED",
+          "count": 0
+        }
+      ]
+    },
+    {
+      "property": "resolutions",
+      "values": [
+        {
+          "val": "",
+          "count": 1
+        },
+        {
+          "val": "FIXED",
+          "count": 0
+        },
+        {
+          "val": "REMOVED",
+          "count": 0
+        },
+        {
+          "val": "FALSE-POSITIVE",
+          "count": 0
+        }
+      ]
+    }
+  ]
+}
diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/issues-spec/show-with-tags.json b/server/sonar-web/src/main/js/tests/e2e/tests/issues-spec/show-with-tags.json
new file mode 100644 (file)
index 0000000..6eb9475
--- /dev/null
@@ -0,0 +1,29 @@
+{
+  "issue": {
+    "key": "94357807-fcb4-40cc-9598-9a715f1eee6e",
+    "component": "org.codehaus.sonar-plugins.xml:sonar-xml-plugin:src/main/java/org/sonar/plugins/xml",
+    "componentId": 26177,
+    "project": "org.codehaus.sonar-plugins.xml:xml",
+    "rule": "squid:S1228",
+    "status": "CONFIRMED",
+    "severity": "MAJOR",
+    "message": "Add a 'package-info.java' file to document the 'src/main/java/org/sonar/plugins/xml' package",
+    "debt": "20min",
+    "creationDate": "2014-10-03T23:26:37+0200",
+    "updateDate": "2014-10-09T06:32:55+0200",
+    "fUpdateAge": "26 days",
+    "actions": [
+      "comment",
+      "assign",
+      "assign_to_me",
+      "plan",
+      "set_severity"
+    ],
+    "tags": ["security", "cwe"]
+    "transitions": [
+      "unconfirm",
+      "resolve",
+      "falsepositive"
+    ]
+  }
+}
diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/issues-spec/tags-modified.json b/server/sonar-web/src/main/js/tests/e2e/tests/issues-spec/tags-modified.json
new file mode 100644 (file)
index 0000000..d1b5389
--- /dev/null
@@ -0,0 +1,7 @@
+{
+  "tags": [
+    "security",
+    "cwe",
+    "cert"
+  ]
+}
diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/issues-spec/tags.json b/server/sonar-web/src/main/js/tests/e2e/tests/issues-spec/tags.json
new file mode 100644 (file)
index 0000000..af6bc92
--- /dev/null
@@ -0,0 +1,24 @@
+{
+  "tags": [
+    "brain-overload",
+    "bug",
+    "cert",
+    "convention",
+    "cwe",
+    "design",
+    "error-handling",
+    "misra",
+    "misra-c",
+    "misra-c++",
+    "multithreading",
+    "obsolete",
+    "owasp-top10",
+    "performance",
+    "pitfall",
+    "sans-top25",
+    "sans-top25-2011",
+    "security",
+    "sql",
+    "unused"
+  ]
+}