]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6031 Issue permalink must display source code, not the list with single result
authorStas Vilchik <vilchiks@gmail.com>
Thu, 8 Jan 2015 16:09:18 +0000 (17:09 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 8 Jan 2015 16:09:26 +0000 (17:09 +0100)
server/sonar-web/src/main/coffee/issues/controller.coffee
server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink.js
server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink/components-app.json [new file with mode: 0644]
server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink/lines.json [new file with mode: 0644]

index 4bc75e7d472babccfc3277ab6859ddc10b738e28..25ed07e0854facd35c1ea07145d21cdb50686544 100644 (file)
@@ -65,10 +65,17 @@ define [
           total: r.total
           maxResultsReached: r.p * r.ps >= r.total
         window.process.finishBackgroundProcess fetchIssuesProcess
+        if firstPage && @isIssuePermalink()
+          @showComponentViewer @options.app.list.first()
       .fail ->
         window.process.failBackgroundProcess fetchIssuesProcess
 
 
+    isIssuePermalink: ->
+      query = @options.app.state.get('query')
+      query.issues? && @options.app.list.length == 1
+
+
     fetchFilters: ->
       $.get "#{baseUrl}/api/issue_filters/app", (r) =>
         @options.app.state.set
index befc79da2cbb79f2db65a851be3f39f0656e00d5..ca9d7a51984779117e999b65aa7f28d43dca0a5d 100644 (file)
@@ -10,18 +10,22 @@ lib.changeWorkingDirectory('issues-page-should-open-issue-permalink');
 var issueKey = 'some-issue-key';
 
 
-casper.test.begin('issues-page-should-open-issue-permalink', function (test) {
+casper.test.begin('issues-page-should-open-issue-permalink', 3, function (test) {
   casper
       .start(lib.buildUrl('issues#issues=' + encodeURI(issueKey)), function () {
         lib.setDefaultViewport();
 
         lib.mockRequest('/api/l10n/index', '{}');
         lib.mockRequestFromFile('/api/issue_filters/app', 'app.json');
+        lib.mockRequest('/api/issues/search', '{}', { data: { issues: issueKey, p: 2 } });
         lib.mockRequestFromFile('/api/issues/search', 'search.json', { data: { issues: issueKey } });
+        lib.mockRequestFromFile('/api/components/app', 'components-app.json');
+        lib.mockRequestFromFile('/api/sources/lines', 'lines.json');
       })
 
       .then(function () {
-        casper.waitForSelector('.issue', function () {
+        casper.waitForSelector('.source-line', function () {
+          test.assertSelectorContains('.source-viewer', 'public void executeOn(Project project, SensorContext context');
           test.assertElementCount('.issue', 1);
           test.assertExist('.issue[data-key="' + issueKey + '"]');
         });
diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink/components-app.json b/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink/components-app.json
new file mode 100644 (file)
index 0000000..61afe8a
--- /dev/null
@@ -0,0 +1,21 @@
+{
+  "key": "org.codehaus.sonar-plugins:sonar-issues-report-plugin:src/main/java/org/sonar/issuesreport/ReportJob.java",
+  "uuid": "98662175-0f52-4f83-b0e9-1e9444320b5b",
+  "path": "src/main/java/org/sonar/issuesreport/ReportJob.java",
+  "name": "ReportJob.java",
+  "longName": "src/main/java/org/sonar/issuesreport/ReportJob.java",
+  "q": "FIL",
+  "project": "org.codehaus.sonar-plugins:sonar-issues-report-plugin",
+  "projectName": "Sonar :: Issues Report :: Plugin",
+  "fav": false,
+  "canMarkAsFavourite": true,
+  "canCreateManualIssue": true,
+  "measures": {
+    "lines": "53",
+    "coverage": "100.0%",
+    "issues": "1",
+    "debt": "5min",
+    "sqaleRating": "A",
+    "debtRatio": "0.6%"
+  }
+}
diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink/lines.json b/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink/lines.json
new file mode 100644 (file)
index 0000000..cd2053d
--- /dev/null
@@ -0,0 +1,392 @@
+{
+  "sources": [
+    {
+      "line": 1,
+      "code": "<span class=\"cppd\">/*</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 2,
+      "code": "<span class=\"cppd\"> * Sonar :: Issues Report :: Plugin</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 3,
+      "code": "<span class=\"cppd\"> * Copyright (C) 2013 SonarSource</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 4,
+      "code": "<span class=\"cppd\"> * dev@sonar.codehaus.org</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 5,
+      "code": "<span class=\"cppd\"> *</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 6,
+      "code": "<span class=\"cppd\"> * This program is free software; you can redistribute it and/or</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 7,
+      "code": "<span class=\"cppd\"> * modify it under the terms of the GNU Lesser General Public</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 8,
+      "code": "<span class=\"cppd\"> * License as published by the Free Software Foundation; either</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 9,
+      "code": "<span class=\"cppd\"> * version 3 of the License, or (at your option) any later version.</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 10,
+      "code": "<span class=\"cppd\"> *</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 11,
+      "code": "<span class=\"cppd\"> * This program is distributed in the hope that it will be useful,</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 12,
+      "code": "<span class=\"cppd\"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 13,
+      "code": "<span class=\"cppd\"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 14,
+      "code": "<span class=\"cppd\"> * Lesser General Public License for more details.</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 15,
+      "code": "<span class=\"cppd\"> *</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 16,
+      "code": "<span class=\"cppd\"> * You should have received a copy of the GNU Lesser General Public</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 17,
+      "code": "<span class=\"cppd\"> * License along with this program; if not, write to the Free Software</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 18,
+      "code": "<span class=\"cppd\"> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 19,
+      "code": "<span class=\"cppd\"> */</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 20,
+      "code": "<span class=\"k\">package</span> org.sonar.issuesreport;",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 21,
+      "code": "",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 22,
+      "code": "<span class=\"k\">import </span>org.sonar.api.batch.<span class=\"sym-1 sym\">PostJob</span>;",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 23,
+      "code": "<span class=\"k\">import </span>org.sonar.api.batch.<span class=\"sym-2 sym\">SensorContext</span>;",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 24,
+      "code": "<span class=\"k\">import </span>org.sonar.api.resources.<span class=\"sym-3 sym\">Project</span>;",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 25,
+      "code": "<span class=\"k\">import </span>org.sonar.issuesreport.printer.<span class=\"sym-4 sym\">ReportPrinter</span>;",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9",
+      "scmDate": "2013-09-19T19:06:45+0200"
+    },
+    {
+      "line": 26,
+      "code": "<span class=\"k\">import </span>org.sonar.issuesreport.report.<span class=\"sym-5 sym\">IssuesReport</span>;",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "ed1e45b9f01b4d6bc704595ff42e6ecd6fb80dbe",
+      "scmDate": "2013-02-20T17:18:48+0100"
+    },
+    {
+      "line": 27,
+      "code": "<span class=\"k\">import </span>org.sonar.issuesreport.report.<span class=\"sym-6 sym\">IssuesReportBuilder</span>;",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9",
+      "scmDate": "2013-09-19T19:06:45+0200"
+    },
+    {
+      "line": 28,
+      "code": "",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 29,
+      "code": "<span class=\"k\">public </span><span class=\"k\">class</span> <span class=\"sym-7 sym\">ReportJob</span> <span class=\"k\">implements</span> <span class=\"sym-1 sym\">PostJob</span> {",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 30,
+      "code": "",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 31,
+      "code": "  <span class=\"k\">private </span><span class=\"sym-6 sym\">IssuesReportBuilder</span> <span class=\"sym-8 sym\">builder</span>;",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9",
+      "scmDate": "2013-09-19T19:06:45+0200"
+    },
+    {
+      "line": 32,
+      "code": "  <span class=\"k\">private </span><span class=\"sym-4 sym\">ReportPrinter</span>[] <span class=\"sym-9 sym\">printers</span>;",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9",
+      "scmDate": "2013-09-19T19:06:45+0200"
+    },
+    {
+      "line": 33,
+      "code": "",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 34,
+      "code": "  <span class=\"k\">public </span><span class=\"sym-10 sym\">ReportJob</span>(<span class=\"sym-6 sym\">IssuesReportBuilder</span> <span class=\"sym-11 sym\">builder</span>, <span class=\"sym-4 sym\">ReportPrinter</span>[] <span class=\"sym-12 sym\">printers</span>) {",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9",
+      "scmDate": "2013-09-19T19:06:45+0200",
+      "lineHits": 1
+    },
+    {
+      "line": 35,
+      "code": "    <span class=\"k\">this</span>.<span class=\"sym-8 sym\">builder</span> = <span class=\"sym-11 sym\">builder</span>;",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9",
+      "scmDate": "2013-09-19T19:06:45+0200",
+      "lineHits": 1
+    },
+    {
+      "line": 36,
+      "code": "    <span class=\"k\">this</span>.<span class=\"sym-9 sym\">printers</span> = <span class=\"sym-12 sym\">printers</span>;",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9",
+      "scmDate": "2013-09-19T19:06:45+0200",
+      "lineHits": 1
+    },
+    {
+      "line": 37,
+      "code": "  }",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100",
+      "lineHits": 1
+    },
+    {
+      "line": 38,
+      "code": "",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 39,
+      "code": "  <span class=\"k\">public </span><span class=\"k\">void </span><span class=\"sym-13 sym\">executeOn</span>(<span class=\"sym-3 sym\">Project</span> <span class=\"sym-14 sym\">project</span>, <span class=\"sym-2 sym\">SensorContext</span> <span class=\"sym-15 sym\">context</span>) {",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 40,
+      "code": "    <span class=\"cppd\">// For performance only initialize IssuesReport if there is on Printer enabled</span>",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9",
+      "scmDate": "2013-09-19T19:06:45+0200"
+    },
+    {
+      "line": 41,
+      "code": "    <span class=\"sym-5 sym\">IssuesReport</span> <span class=\"sym-16 sym\">report</span> = <span class=\"k\">null</span>;",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9",
+      "scmDate": "2013-09-19T19:06:45+0200",
+      "lineHits": 1
+    },
+    {
+      "line": 42,
+      "code": "    <span class=\"k\">for</span> (<span class=\"sym-4 sym\">ReportPrinter</span> <span class=\"sym-17 sym\">printer</span> : <span class=\"sym-9 sym\">printers</span>) {",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9",
+      "scmDate": "2013-09-19T19:06:45+0200",
+      "lineHits": 1,
+      "conditions": 2,
+      "coveredConditions": 2
+    },
+    {
+      "line": 43,
+      "code": "      <span class=\"k\">if </span>(<span class=\"sym-17 sym\">printer</span>.isEnabled()) {",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9",
+      "scmDate": "2013-09-19T19:06:45+0200",
+      "lineHits": 1,
+      "conditions": 2,
+      "coveredConditions": 2
+    },
+    {
+      "line": 44,
+      "code": "        <span class=\"k\">if </span>(<span class=\"sym-16 sym\">report</span> == <span class=\"k\">null</span>) {",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "ed1e45b9f01b4d6bc704595ff42e6ecd6fb80dbe",
+      "scmDate": "2013-02-20T17:18:48+0100",
+      "lineHits": 1,
+      "conditions": 2,
+      "coveredConditions": 2
+    },
+    {
+      "line": 45,
+      "code": "          <span class=\"sym-16 sym\">report</span> = <span class=\"sym-8 sym\">builder</span>.buildReport(<span class=\"sym-14 sym\">project</span>);",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9",
+      "scmDate": "2013-09-19T19:06:45+0200",
+      "lineHits": 1
+    },
+    {
+      "line": 46,
+      "code": "        }",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "ed1e45b9f01b4d6bc704595ff42e6ecd6fb80dbe",
+      "scmDate": "2013-02-20T17:18:48+0100"
+    },
+    {
+      "line": 47,
+      "code": "        <span class=\"sym-17 sym\">printer</span>.print(<span class=\"sym-16 sym\">report</span>);",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9",
+      "scmDate": "2013-09-19T19:06:45+0200",
+      "lineHits": 1
+    },
+    {
+      "line": 48,
+      "code": "      }",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9",
+      "scmDate": "2013-09-19T19:06:45+0200"
+    },
+    {
+      "line": 49,
+      "code": "    }",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9",
+      "scmDate": "2013-09-19T19:06:45+0200"
+    },
+    {
+      "line": 50,
+      "code": "  }",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "ed1e45b9f01b4d6bc704595ff42e6ecd6fb80dbe",
+      "scmDate": "2013-02-20T17:18:48+0100",
+      "lineHits": 1
+    },
+    {
+      "line": 51,
+      "code": "",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "ed1e45b9f01b4d6bc704595ff42e6ecd6fb80dbe",
+      "scmDate": "2013-02-20T17:18:48+0100"
+    },
+    {
+      "line": 52,
+      "code": "}",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    },
+    {
+      "line": 53,
+      "code": "",
+      "scmAuthor": "julien.henry@sonarsource.com",
+      "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f",
+      "scmDate": "2013-02-19T18:45:35+0100"
+    }
+  ]
+}