From 80ce9c47fc03e62a6049a23a1078bc7a3017d26a Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 8 Jan 2015 17:09:18 +0100 Subject: [PATCH] SONAR-6031 Issue permalink must display source code, not the list with single result --- .../src/main/coffee/issues/controller.coffee | 7 + ...issues-page-should-open-issue-permalink.js | 8 +- .../components-app.json | 21 + .../lines.json | 392 ++++++++++++++++++ 4 files changed, 426 insertions(+), 2 deletions(-) create mode 100644 server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink/components-app.json create mode 100644 server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink/lines.json diff --git a/server/sonar-web/src/main/coffee/issues/controller.coffee b/server/sonar-web/src/main/coffee/issues/controller.coffee index 4bc75e7d472..25ed07e0854 100644 --- a/server/sonar-web/src/main/coffee/issues/controller.coffee +++ b/server/sonar-web/src/main/coffee/issues/controller.coffee @@ -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 diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink.js b/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink.js index befc79da2cb..ca9d7a51984 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink.js @@ -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 index 00000000000..61afe8a34c8 --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink/components-app.json @@ -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 index 00000000000..cd2053d91d6 --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink/lines.json @@ -0,0 +1,392 @@ +{ + "sources": [ + { + "line": 1, + "code": "/*", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 2, + "code": " * Sonar :: Issues Report :: Plugin", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 3, + "code": " * Copyright (C) 2013 SonarSource", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 4, + "code": " * dev@sonar.codehaus.org", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 5, + "code": " *", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 6, + "code": " * This program is free software; you can redistribute it and/or", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 7, + "code": " * modify it under the terms of the GNU Lesser General Public", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 8, + "code": " * License as published by the Free Software Foundation; either", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 9, + "code": " * version 3 of the License, or (at your option) any later version.", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 10, + "code": " *", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 11, + "code": " * This program is distributed in the hope that it will be useful,", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 12, + "code": " * but WITHOUT ANY WARRANTY; without even the implied warranty of", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 13, + "code": " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 14, + "code": " * Lesser General Public License for more details.", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 15, + "code": " *", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 16, + "code": " * You should have received a copy of the GNU Lesser General Public", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 17, + "code": " * License along with this program; if not, write to the Free Software", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 18, + "code": " * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 19, + "code": " */", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 20, + "code": "package 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": "import org.sonar.api.batch.PostJob;", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 23, + "code": "import org.sonar.api.batch.SensorContext;", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 24, + "code": "import org.sonar.api.resources.Project;", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 25, + "code": "import org.sonar.issuesreport.printer.ReportPrinter;", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9", + "scmDate": "2013-09-19T19:06:45+0200" + }, + { + "line": 26, + "code": "import org.sonar.issuesreport.report.IssuesReport;", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "ed1e45b9f01b4d6bc704595ff42e6ecd6fb80dbe", + "scmDate": "2013-02-20T17:18:48+0100" + }, + { + "line": 27, + "code": "import org.sonar.issuesreport.report.IssuesReportBuilder;", + "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": "public class ReportJob implements PostJob {", + "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": " private IssuesReportBuilder builder;", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9", + "scmDate": "2013-09-19T19:06:45+0200" + }, + { + "line": 32, + "code": " private ReportPrinter[] printers;", + "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": " public ReportJob(IssuesReportBuilder builder, ReportPrinter[] printers) {", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9", + "scmDate": "2013-09-19T19:06:45+0200", + "lineHits": 1 + }, + { + "line": 35, + "code": " this.builder = builder;", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9", + "scmDate": "2013-09-19T19:06:45+0200", + "lineHits": 1 + }, + { + "line": 36, + "code": " this.printers = printers;", + "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": " public void executeOn(Project project, SensorContext context) {", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "a0c83c815b2deeec585de6894a0b882db635410f", + "scmDate": "2013-02-19T18:45:35+0100" + }, + { + "line": 40, + "code": " // For performance only initialize IssuesReport if there is on Printer enabled", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9", + "scmDate": "2013-09-19T19:06:45+0200" + }, + { + "line": 41, + "code": " IssuesReport report = null;", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9", + "scmDate": "2013-09-19T19:06:45+0200", + "lineHits": 1 + }, + { + "line": 42, + "code": " for (ReportPrinter printer : printers) {", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9", + "scmDate": "2013-09-19T19:06:45+0200", + "lineHits": 1, + "conditions": 2, + "coveredConditions": 2 + }, + { + "line": 43, + "code": " if (printer.isEnabled()) {", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "bbbf5a70655725bd960e41626bcda3b0f85c82d9", + "scmDate": "2013-09-19T19:06:45+0200", + "lineHits": 1, + "conditions": 2, + "coveredConditions": 2 + }, + { + "line": 44, + "code": " if (report == null) {", + "scmAuthor": "julien.henry@sonarsource.com", + "scmRevision": "ed1e45b9f01b4d6bc704595ff42e6ecd6fb80dbe", + "scmDate": "2013-02-20T17:18:48+0100", + "lineHits": 1, + "conditions": 2, + "coveredConditions": 2 + }, + { + "line": 45, + "code": " report = builder.buildReport(project);", + "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": " printer.print(report);", + "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" + } + ] +} -- 2.39.5