From: Stas Vilchik Date: Tue, 27 May 2014 07:54:19 +0000 (+0600) Subject: SONAR-5209 Show tests that cover a line X-Git-Tag: 4.4-RC1~820 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=379e815c5aedbb29fbc87e0747b9e6f5a098567c;p=sonarqube.git SONAR-5209 Show tests that cover a line --- diff --git a/sonar-server/src/main/coffee/component-viewer/coverage-popup.coffee b/sonar-server/src/main/coffee/component-viewer/coverage-popup.coffee index 63d38c8b702..b4dcd2a703a 100644 --- a/sonar-server/src/main/coffee/component-viewer/coverage-popup.coffee +++ b/sonar-server/src/main/coffee/component-viewer/coverage-popup.coffee @@ -21,29 +21,13 @@ define [ goToFile: (e) -> key = $(e.currentTarget).data 'key' - test = $(e.currentTarget).data 'test' - @options.main.addTransition key, 'coverage', [ - { - key: 'org.codehaus.sonar:sonar-plugin-api:src/test/java/org/sonar/api/resources/ResourceTypeTreeTest.java' - name: 'forbidDuplicatedType' - subname: 'ResourceTypeTreeTest.java' - active: test == 'forbidDuplicatedType' - } - { - key: 'org.codehaus.sonar:sonar-plugin-api:src/test/java/org/sonar/api/resources/ResourceTypeTreeTest.java' - name: 'forbidNullRelation' - subname: 'ResourceTypeTreeTest.java' - active: test == 'forbidNullRelation' - } - { - key: 'org.codehaus.sonar:sonar-plugin-api:src/test/java/org/sonar/api/resources/ResourceTypeTest.java' - name: 'fail_on_duplicated_qualifier' - subname: 'ResourceTypeTest.java' - active: test == 'fail_on_duplicated_qualifier' - } - ], [ - { - key: key, - name: test - } - ] + @options.main.addTransition key, 'coverage' + + + serializeData: -> + files = @model.get 'files' + tests = _.groupBy @model.get('tests'), '_ref' + testFiles = _.map tests, (testSet, fileRef) -> + file: files[fileRef] + tests: testSet + testFiles: testFiles \ No newline at end of file diff --git a/sonar-server/src/main/coffee/component-viewer/source.coffee b/sonar-server/src/main/coffee/component-viewer/source.coffee index a69c2db557c..fee9b6f419e 100644 --- a/sonar-server/src/main/coffee/component-viewer/source.coffee +++ b/sonar-server/src/main/coffee/component-viewer/source.coffee @@ -19,6 +19,8 @@ define [ $ = jQuery + API_COVERAGE_TESTS = "#{baseUrl}/api/tests/testable" + class SourceView extends Marionette.ItemView template: Templates['source'] @@ -117,10 +119,13 @@ define [ showCoveragePopup: (e) -> e.stopPropagation() $('body').click() - popup = new CoveragePopupView - triggerEl: $(e.currentTarget) - main: @options.main - popup.render() + line = $(e.currentTarget).closest('.row').data 'line-number' + $.get API_COVERAGE_TESTS, key: @options.main.component.get('key'), line: line, (data) => + popup = new CoveragePopupView + model: new Backbone.Model data + triggerEl: $(e.currentTarget) + main: @options.main + popup.render() showDuplicationPopup: (e) -> diff --git a/sonar-server/src/main/hbs/component-viewer/coveragePopup.hbs b/sonar-server/src/main/hbs/component-viewer/coveragePopup.hbs index e6058cb6abd..cddc28fd1e9 100644 --- a/sonar-server/src/main/hbs/component-viewer/coveragePopup.hbs +++ b/sonar-server/src/main/hbs/component-viewer/coveragePopup.hbs @@ -1,44 +1,18 @@ -
-
- ResourceTypeTreeTest.java +{{#each testFiles}} +
+ + {{file.longName}} + +
    + {{#each tests}} +
  • + + {{name}} + {{durationInMs}}ms +
  • + {{/each}} +
- -
- -
-
- ResourceTypesTest.java -
- -
+{{/each}}
\ No newline at end of file diff --git a/sonar-server/src/main/hbs/component-viewer/source.hbs b/sonar-server/src/main/hbs/component-viewer/source.hbs index 8260193e0e5..7842b324c2a 100644 --- a/sonar-server/src/main/hbs/component-viewer/source.hbs +++ b/sonar-server/src/main/hbs/component-viewer/source.hbs @@ -37,16 +37,18 @@ {{/if}} {{#if ../../settings.coverage}} - + {{#if coverage}} - {{coverage.testCases}} + + {{coverage.testCases}} + {{/if}} - + {{#if coverage}} {{#if coverage.branches}} - + {{coverage.coveredBranches}}/{{coverage.branches}} {{/if}} diff --git a/sonar-server/src/main/hbs/component-viewer/workspace.hbs b/sonar-server/src/main/hbs/component-viewer/workspace.hbs index f409ed28d5e..3b9e7a2b863 100644 --- a/sonar-server/src/main/hbs/component-viewer/workspace.hbs +++ b/sonar-server/src/main/hbs/component-viewer/workspace.hbs @@ -1,26 +1,27 @@ - - - -
    - {{#eachReverse workspace}} -
  • - {{qualifierIcon component.qualifier}} {{component.name}} - {{#if options}} -
      - {{#each options}} -
    • - {{name}} - {{#if subname}}
      {{subname}}
      {{/if}} -
    • - {{/each}} -
    - {{/if}} -
  • - {{/eachReverse}} -
\ No newline at end of file +
    + {{#eachReverse workspace}} +
  • + {{qualifierIcon component.q}} {{component.name}} + {{#if options}} +
      + {{#each options}} +
    • + {{name}} + {{#if subname}}
      {{subname}}
      {{/if}} +
    • + {{/each}} +
    + {{/if}} +
  • + {{/eachReverse}} +
+
\ No newline at end of file diff --git a/sonar-server/src/main/js/common/handlebars-extensions.js b/sonar-server/src/main/js/common/handlebars-extensions.js index 59ca2b3d9a1..26ab8daf9f4 100644 --- a/sonar-server/src/main/js/common/handlebars-extensions.js +++ b/sonar-server/src/main/js/common/handlebars-extensions.js @@ -25,6 +25,10 @@ define(['handlebars', 'moment'], function (Handlebars, moment) { var defaultActions = ['comment', 'assign', 'assign_to_me', 'plan', 'set_severity']; + Handlebars.registerHelper('log', function(variable) { + console.log(variable); + }); + Handlebars.registerHelper('capitalize', function(string) { return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); }); @@ -41,6 +45,12 @@ define(['handlebars', 'moment'], function (Handlebars, moment) { ); }); + Handlebars.registerHelper('alertIconClass', function(alert) { + return new Handlebars.SafeString( + 'icon-alert-' + alert.toLowerCase() + ); + }); + Handlebars.registerHelper('qualifierIcon', function(qualifier) { return new Handlebars.SafeString( qualifier ? '': '' diff --git a/sonar-server/src/main/less/component-viewer.less b/sonar-server/src/main/less/component-viewer.less index dbd06913cd2..8b15965f168 100644 --- a/sonar-server/src/main/less/component-viewer.less +++ b/sonar-server/src/main/less/component-viewer.less @@ -38,6 +38,8 @@ a:hover { text-decoration: underline; } } +.component-viewer-workspace-container { position: relative; } + .component-viewer-workspace-list { display: none; width: @workspaceWidth; @@ -77,7 +79,7 @@ .component-viewer-workspace-toggle { position: absolute; - top: 0; right: 0; + top: 0; right: -30px; .size(30px, 30px); .trans; @@ -565,13 +567,15 @@ } } -.component-viewer-popup-section + .component-viewer-popup-section { - margin-top: 10px; +.component-viewer-popup-section { + width: 300px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } -.component-viewer-popup-section-title { - color: #777; - font-size: @smallFontSize; +.component-viewer-popup-section + .component-viewer-popup-section { + margin-top: 10px; } .component-viewer-popup-list { @@ -593,26 +597,26 @@ .component-viewer-popup-test { position: relative; display: block; - height: 24px; - line-height: 24px; + height: 16px; + line-height: 16px; +} - &:hover { - .component-viewer-popup-test-name { text-decoration: underline; } - } +.component-viewer-popup-test-file { } .component-viewer-popup-test-name { display: block; - width: 240px; border-left: 20px solid transparent; border-right: 44px solid transparent; .box-sizing(border-box); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .component-viewer-popup-test-status { position: absolute; - top: 0; left: 0; - line-height: 24px; + top: 0; left: 0 } .component-viewer-popup-test-duration {