]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6236 do not show resolved and closed issues when query has unresolved criterion
authorStas Vilchik <vilchiks@gmail.com>
Thu, 19 Mar 2015 15:04:13 +0000 (16:04 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 19 Mar 2015 15:12:31 +0000 (16:12 +0100)
server/sonar-web/src/main/js/widgets/issue-filter.js
server/sonar-web/src/test/js/global-issue-filter-widget.js
server/sonar-web/src/test/json/global-issues-filter-widget/unresolved-issues-by-status.json [new file with mode: 0644]

index e43c28ab94637f1d5ec3a8cfd71f4323a64fe327..c1f9c4a2760f376f122770fbe3b89291d9bb818c 100644 (file)
@@ -56,6 +56,11 @@ define(['templates/widgets'], function () {
           comparator: function (item) {
             var order = ['OPEN', 'REOPENED', 'CONFIRMED', 'RESOLVED', 'CLOSED'];
             return order.indexOf(item.val);
+          },
+          filter: function (item) {
+            var unresolvedQuery = '' + this.query.resolved === 'false',
+                resolvedStatus = item.val === 'RESOLVED' || item.val === 'CLOSED';
+            return !(unresolvedQuery && resolvedStatus);
           }
         },
         'resolutions': {
index 90f7c808bc89ab52f7a5eb17bfd6c94d4e7d59fc..705e894861113439e56937fec1d80bf2a747f4f8 100644 (file)
@@ -196,6 +196,61 @@ casper.test.begin(testName('All Issues By Status'), 9, function (test) {
 });
 
 
+casper.test.begin(testName('Unresolved Issues By Status'), 9, function (test) {
+  casper
+      .start(lib.buildUrl('issue-filter-widget'), function () {
+        lib.setDefaultViewport();
+
+
+        lib.mockRequestFromFile('/api/issues/search', 'unresolved-issues-by-status.json',
+            { data: { resolved: 'false' } });
+      })
+
+      .then(function () {
+        casper.evaluate(function () {
+          require(['/js/widgets/issue-filter.js'], function (IssueFilter) {
+            window.requestMessages().done(function () {
+              new IssueFilter({
+                el: '#issue-filter-widget',
+                query: 'resolved=false',
+                distributionAxis: 'statuses'
+              });
+            });
+          });
+        });
+      })
+
+      .then(function () {
+        casper.waitForSelector('#issue-filter-widget > table');
+      })
+
+      .then(function () {
+        // check count
+        test.assertElementCount('tr', 4);
+
+        // check order and values
+        test.assertSelectorContains('tr:nth-child(1)', '71571');
+        test.assertSelectorContains('tr:nth-child(2)', '238');
+        test.assertSelectorContains('tr:nth-child(3)', '4');
+        test.assertSelectorContains('tr:nth-child(4)', '6609');
+
+        // check links
+        test.assertExists('tr:nth-child(1) a[href="/issues/search#resolved=false"]');
+        test.assertExists('tr:nth-child(2) a[href="/issues/search#resolved=false|statuses=OPEN"]');
+        test.assertExists('tr:nth-child(3) a[href="/issues/search#resolved=false|statuses=REOPENED"]');
+        test.assertExists('tr:nth-child(4) a[href="/issues/search#resolved=false|statuses=CONFIRMED"]');
+      })
+
+      .then(function () {
+        lib.sendCoverage();
+      })
+
+      .run(function () {
+        test.done();
+      });
+});
+
+
 casper.test.begin(testName('All Issues By Resolution'), 10, function (test) {
   casper
       .start(lib.buildUrl('issue-filter-widget'), function () {
diff --git a/server/sonar-web/src/test/json/global-issues-filter-widget/unresolved-issues-by-status.json b/server/sonar-web/src/test/json/global-issues-filter-widget/unresolved-issues-by-status.json
new file mode 100644 (file)
index 0000000..97babc0
--- /dev/null
@@ -0,0 +1,32 @@
+{
+  "total": 71571,
+  "p": 1,
+  "ps": 1,
+  "facets": [
+    {
+      "property": "statuses",
+      "values": [
+        {
+          "val": "CLOSED",
+          "count": 0
+        },
+        {
+          "val": "CONFIRMED",
+          "count": 6609
+        },
+        {
+          "val": "RESOLVED",
+          "count": 0
+        },
+        {
+          "val": "OPEN",
+          "count": 238
+        },
+        {
+          "val": "REOPENED",
+          "count": 4
+        }
+      ]
+    }
+  ]
+}