-var lib = require('../lib');
+var lib = require('../lib'),
+ testName = lib.testName('Component Viewer');
lib.initMessages();
lib.changeWorkingDirectory('component-viewer-spec');
-casper.test.begin('Component Viewer Base Tests', function (test) {
+casper.test.begin(testName('Base'), function (test) {
casper
.start(lib.buildUrl('component-viewer#component=component'), function () {
lib.setDefaultViewport();
lib.mockRequest('/api/l10n/index', '{}');
lib.mockRequestFromFile('/api/components/app', 'app.json');
lib.mockRequestFromFile('/api/sources/show', 'source.json');
- lib.mockRequestFromFile('/api/issues/search', 'issues.json');
- lib.mockRequestFromFile('/api/coverage/show', 'coverage.json');
- lib.mockRequestFromFile('/api/duplications/show', 'duplications.json');
- lib.mockRequestFromFile('/api/sources/scm', 'scm.json');
lib.mockRequest('*', '{}'); // Trick to see all ajax requests
})
casper.waitForSelector('.component-viewer-source .row', function () {
// Check header elements
- test.assertElementCount('.component-viewer-header', 1);
+ test.assertExists('.component-viewer-header');
test.assertSelectorContains('.component-viewer-header-component-project', 'SonarQube');
test.assertSelectorContains('.component-viewer-header-component-project', 'SonarQube :: Batch');
test.assertSelectorContains('.component-viewer-header-component-name',
'src/main/java/org/sonar/batch/index/Cache.java');
- test.assertElementCount('.component-viewer-header-favorite', 1);
- test.assertElementCount('.component-viewer-header-actions', 1);
+ test.assertExists('.component-viewer-header-favorite');
+ test.assertExists('.component-viewer-header-actions');
// Check main measures
test.assertSelectorContains('.js-header-tab-basic', '379');
test.assertSelectorContains('.js-header-tab-issues', '3h 30min');
test.assertSelectorContains('.js-header-tab-issues', '6');
test.assertSelectorContains('.js-header-tab-coverage', '74.3%');
- test.assertElementCount('.js-header-tab-scm', 1);
+ test.assertExists('.js-header-tab-scm');
// Check source
test.assertElementCount('.component-viewer-source .row', 520);
test.assertSelectorContains('.component-viewer-source', 'public class Cache');
// Check workspace
- test.assertElementCount('.component-viewer-workspace', 1);
+ test.assertExists('.component-viewer-workspace');
});
})
+ .run(function () {
+ test.done();
+ });
+});
+
+
+
+casper.test.begin(testName('Decoration'), function (test) {
+ casper
+ .start(lib.buildUrl('component-viewer#component=component'), function () {
+ lib.setDefaultViewport();
+
+ lib.mockRequest('/api/l10n/index', '{}');
+ lib.mockRequestFromFile('/api/components/app', 'app.json');
+ lib.mockRequestFromFile('/api/sources/show', 'source.json');
+ lib.mockRequestFromFile('/api/issues/search', 'issues.json');
+ lib.mockRequestFromFile('/api/coverage/show', 'coverage.json');
+ lib.mockRequestFromFile('/api/duplications/show', 'duplications.json');
+ lib.mockRequestFromFile('/api/sources/scm', 'scm.json');
+ lib.mockRequest('*', '{}'); // Trick to see all ajax requests
+ })
+
+ .then(function () {
+ casper.waitForSelector('.component-viewer-source .row');
+ })
+
.then(function() {
// Check issues decoration
casper.click('.js-toggle-issues');
casper.click('.js-toggle-issues');
casper.waitWhileSelector('.code-issue', function () {
- test.assertElementCount('.code-issue', 0);
+ test.assertDoesntExist('.code-issue');
});
});
})
casper.click('.js-toggle-coverage');
casper.waitWhileSelector('.coverage-green', function () {
- test.assertElementCount('.coverage-green', 0);
+ test.assertDoesntExist('.coverage-green');
});
});
})
casper.click('.js-toggle-duplications');
casper.waitWhileSelector('.duplication-exists', function () {
- test.assertElementCount('.duplication-exists', 0);
+ test.assertDoesntExist('.duplication-exists');
});
});
})
casper.click('.js-toggle-scm');
casper.waitWhileSelector('.scm-author', function () {
- test.assertElementCount('.scm-author', 0);
- test.assertElementCount('.scm-date', 0);
+ test.assertDoesntExist('.scm-author');
+ test.assertDoesntExist('.scm-date');
+ });
+ });
+ })
+
+ .run(function () {
+ test.done();
+ });
+});
+
+
+casper.test.begin(testName('Header'), function (test) {
+ casper
+ .start(lib.buildUrl('component-viewer#component=component'), function () {
+ lib.setDefaultViewport();
+
+ lib.mockRequest('/api/l10n/index', '{}');
+ lib.mockRequestFromFile('/api/components/app', 'app.json');
+ lib.mockRequestFromFile('/api/sources/show', 'source.json');
+ lib.mockRequestFromFile('/api/resources', 'resources.json');
+ lib.mockRequest('*', '{}'); // Trick to see all ajax requests
+ })
+
+ .then(function () {
+ casper.waitForSelector('.component-viewer-source .row');
+ })
+
+ .then(function () {
+ // Check issues header and filters
+ casper.click('.js-header-tab-issues');
+ casper.waitForSelector('.js-filter-unresolved-issues', function () {
+ test.assertExists('.js-filter-open-issues');
+ test.assertExists('.js-filter-fixed-issues');
+ test.assertExists('.js-filter-false-positive-issues');
+ test.assertSelectorContains('.js-filter-MAJOR-issues', '1');
+ test.assertSelectorContains('.js-filter-MINOR-issues', '1');
+ test.assertSelectorContains('.js-filter-INFO-issues', '4');
+ test.assertSelectorContains('.js-filter-rule[data-rule="common-java:DuplicatedBlocks"]', '1');
+ test.assertSelectorContains('.js-filter-rule[data-rule="squid:S1192"]', '1');
+ test.assertSelectorContains('.js-filter-rule[data-rule="squid:S1135"]', '4');
+ test.assertExists('.js-issues-time-changes');
+
+ casper.click('.js-header-tab-issues');
+ casper.waitWhileSelector('.js-filter-unresolved-issues', function () {
+ test.assertDoesntExist('.js-filter-open-issues');
+ test.assertDoesntExist('.js-filter-MAJOR-issues');
+ test.assertDoesntExist('.js-filter-rule');
+ });
+ });
+ })
+
+ .then(function () {
+ // Check coverage header and filters
+ casper.click('.js-header-tab-coverage');
+ casper.waitForSelector('.js-filter-lines-to-cover', function () {
+ test.assertExists('.js-filter-uncovered-lines');
+ test.assertExists('.js-filter-branches-to-cover');
+ test.assertExists('.js-filter-uncovered-branches');
+ test.assertSelectorContains('[data-metric="coverage"]', '74.3%');
+ test.assertSelectorContains('[data-metric="line_coverage"]', '74.2%');
+ test.assertSelectorContains('[data-metric="lines_to_cover"]', '194');
+ test.assertSelectorContains('[data-metric="uncovered_lines"]', '50');
+ test.assertSelectorContains('[data-metric="branch_coverage"]', '75.0%');
+ test.assertSelectorContains('[data-metric="conditions_to_cover"]', '16');
+ test.assertSelectorContains('[data-metric="uncovered_conditions"]', '4');
+ test.assertExists('.js-coverage-time-changes');
+
+ casper.click('.js-header-tab-coverage');
+ casper.waitWhileSelector('.js-filter-lines-to-cover', function () {
+ test.assertDoesntExist('.js-filter-uncovered-lines');
+ test.assertDoesntExist('[data-metric="coverage"]');
+ test.assertDoesntExist('[data-metric="branch_coverage"]');
+ });
+ });
+ })
+
+ .then(function () {
+ // Check duplications header and filters
+ casper.click('.js-header-tab-duplications');
+ casper.waitForSelector('.js-filter-duplications', function () {
+ test.assertSelectorContains('[data-metric="duplicated_blocks"]', '2');
+ test.assertSelectorContains('[data-metric="duplicated_lines"]', '30');
+
+ casper.click('.js-header-tab-duplications');
+ casper.waitWhileSelector('.js-filter-duplications', function () {
+ test.assertDoesntExist('[data-metric="duplicated_blocks"]');
+ test.assertDoesntExist('[data-metric="duplicated_lines"]');
+ });
+ });
+ })
+
+ .then(function () {
+ // Check scm header and filters
+ casper.click('.js-header-tab-scm');
+ casper.waitForSelector('.js-filter-modified-lines', function () {
+ test.assertExists('.js-scm-time-changes');
+
+ casper.click('.js-header-tab-scm');
+ casper.waitWhileSelector('.js-filter-modified-lines', function () {
+ test.assertDoesntExist('.js-scm-time-changes');
});
});
})
--- /dev/null
+[
+ {
+ "id": 19983,
+ "key": "org.codehaus.sonar:sonar-batch:src/main/java/org/sonar/batch/index/Cache.java",
+ "name": "Cache.java",
+ "scope": "FIL",
+ "qualifier": "FIL",
+ "date": "2014-07-21T23:18:51+0200",
+ "creationDate": "2013-04-17T04:06:45+0200",
+ "lname": "src/main/java/org/sonar/batch/index/Cache.java",
+ "lang": "java",
+ "msr": [
+ {
+ "key": "lines",
+ "val": 519.0,
+ "frmt_val": "519"
+ },
+ {
+ "key": "ncloc",
+ "val": 379.0,
+ "frmt_val": "379"
+ },
+ {
+ "key": "classes",
+ "val": 6.0,
+ "frmt_val": "6"
+ },
+ {
+ "key": "functions",
+ "val": 56.0,
+ "frmt_val": "56"
+ },
+ {
+ "key": "accessors",
+ "val": 0.0,
+ "frmt_val": "0"
+ },
+ {
+ "key": "statements",
+ "val": 174.0,
+ "frmt_val": "174"
+ },
+ {
+ "key": "public_api",
+ "val": 33.0,
+ "frmt_val": "33"
+ },
+ {
+ "key": "comment_lines",
+ "val": 23.0,
+ "frmt_val": "23"
+ },
+ {
+ "key": "comment_lines_density",
+ "val": 5.7,
+ "frmt_val": "5.7%"
+ },
+ {
+ "key": "public_documented_api_density",
+ "val": 36.4,
+ "frmt_val": "36.4%"
+ },
+ {
+ "key": "public_undocumented_api",
+ "val": 21.0,
+ "frmt_val": "21"
+ },
+ {
+ "key": "complexity",
+ "val": 116.0,
+ "frmt_val": "116"
+ },
+ {
+ "key": "function_complexity",
+ "val": 2.1,
+ "frmt_val": "2.1"
+ },
+ {
+ "key": "coverage",
+ "val": 74.3,
+ "frmt_val": "74.3%"
+ },
+ {
+ "key": "lines_to_cover",
+ "val": 194.0,
+ "frmt_val": "194"
+ },
+ {
+ "key": "uncovered_lines",
+ "val": 50.0,
+ "frmt_val": "50"
+ },
+ {
+ "key": "line_coverage",
+ "val": 74.2,
+ "frmt_val": "74.2%"
+ },
+ {
+ "key": "conditions_to_cover",
+ "val": 16.0,
+ "frmt_val": "16"
+ },
+ {
+ "key": "uncovered_conditions",
+ "val": 4.0,
+ "frmt_val": "4"
+ },
+ {
+ "key": "branch_coverage",
+ "val": 75.0,
+ "frmt_val": "75.0%"
+ },
+ {
+ "key": "duplicated_lines",
+ "val": 30.0,
+ "frmt_val": "30"
+ },
+ {
+ "key": "duplicated_blocks",
+ "val": 2.0,
+ "frmt_val": "2"
+ },
+ {
+ "key": "duplicated_files",
+ "val": 1.0,
+ "frmt_val": "1"
+ },
+ {
+ "key": "duplicated_lines_density",
+ "val": 5.8,
+ "frmt_val": "5.8%"
+ },
+ {
+ "key": "major_violations",
+ "val": 1.0,
+ "frmt_val": "1"
+ },
+ {
+ "key": "minor_violations",
+ "val": 1.0,
+ "frmt_val": "1"
+ },
+ {
+ "key": "info_violations",
+ "val": 4.0,
+ "frmt_val": "4"
+ },
+ {
+ "key": "ncloc_data",
+ "data": "1=0;2=0;3=0;4=0;5=0;6=0;7=0;8=0;9=0;10=0;11=0;12=0;13=0;14=0;15=0;17=0;16=0;19=0;18=0;21=0;20=1;23=1;22=1;25=1;24=1;27=1;26=1;29=1;28=0;31=1;30=0;34=1;35=0;32=1;33=1;38=0;39=0;36=0;37=0;42=0;43=1;40=0;41=1;46=1;47=1;44=1;45=0;51=1;50=0;49=1;48=1;55=0;54=1;53=1;52=1;59=1;58=1;57=1;56=1;63=1;62=1;61=1;60=0;68=1;69=1;70=0;71=1;64=1;65=0;66=1;67=1;76=1;77=1;78=1;79=1;72=1;73=1;74=1;75=1;85=1;84=1;87=1;86=1;81=0;80=0;83=0;82=0;93=1;92=1;95=1;94=1;89=0;88=0;91=0;90=0;102=1;103=1;100=0;101=1;98=0;99=0;96=1;97=0;110=1;111=1;108=0;109=0;106=0;107=0;104=1;105=1;119=1;118=1;117=1;116=1;115=0;114=1;113=1;112=1;127=1;126=0;125=1;124=1;123=1;122=1;121=1;120=1;137=1;136=1;139=1;138=1;141=1;140=0;143=1;142=1;129=1;128=1;131=1;130=0;133=1;132=1;135=0;134=1;152=1;153=1;154=1;155=1;156=0;157=1;158=1;159=1;144=1;145=0;146=1;147=1;148=1;149=1;150=0;151=1;171=1;170=0;169=1;168=1;175=0;174=1;173=1;172=1;163=1;162=1;161=1;160=0;167=1;166=1;165=0;164=1;186=1;187=1;184=1;185=0;190=0;191=0;188=1;189=0;178=1;179=1;176=1;177=1;182=1;183=1;180=0;181=1;205=1;204=0;207=1;206=1;201=1;200=1;203=1;202=1;197=1;196=1;199=0;198=1;193=0;192=0;195=1;194=0;220=1;221=1;222=1;223=1;216=1;217=1;218=1;219=1;212=1;213=1;214=0;215=1;208=1;209=0;210=1;211=1;239=0;238=0;237=0;236=1;235=1;234=1;233=1;232=1;231=1;230=1;229=1;228=0;227=0;226=0;225=0;224=1;254=1;255=1;252=1;253=1;250=1;251=1;248=1;249=1;246=1;247=1;244=0;245=1;242=0;243=0;240=0;241=0;275=1;274=1;273=1;272=1;279=0;278=1;277=1;276=1;283=0;282=0;281=0;280=0;287=1;286=1;285=1;284=0;258=1;259=1;256=1;257=1;262=1;263=1;260=1;261=0;266=1;267=1;264=1;265=1;270=1;271=1;268=1;269=1;305=1;304=1;307=1;306=1;309=1;308=1;311=1;310=1;313=1;312=1;315=1;314=0;317=1;316=1;319=0;318=0;288=1;289=1;290=1;291=1;292=1;293=1;294=1;295=1;296=1;297=1;298=1;299=0;300=0;301=0;302=0;303=1;343=1;342=1;341=1;340=1;339=1;338=1;337=1;336=0;351=1;350=1;349=1;348=1;347=0;346=1;345=1;344=1;326=1;327=1;324=1;325=1;322=1;323=1;320=0;321=0;334=0;335=0;332=1;333=0;330=1;331=1;328=1;329=1;373=1;372=1;375=1;374=0;369=0;368=1;371=1;370=1;381=0;380=1;383=0;382=0;377=1;376=1;379=1;378=1;356=1;357=1;358=1;359=0;352=1;353=0;354=1;355=1;364=0;365=1;366=1;367=1;360=1;361=1;362=1;363=1;410=1;411=1;408=1;409=1;414=1;415=1;412=1;413=1;402=0;403=1;400=1;401=1;406=1;407=0;404=1;405=1;395=1;394=1;393=1;392=0;399=1;398=0;397=1;396=1;387=1;386=1;385=0;384=0;391=1;390=1;389=1;388=0;440=1;441=1;442=1;443=0;444=1;445=1;446=1;447=1;432=1;433=1;434=1;435=1;436=0;437=1;438=1;439=0;425=1;424=1;427=1;426=1;429=1;428=1;431=1;430=0;417=1;416=0;419=1;418=1;421=1;420=1;423=1;422=1;478=1;479=1;476=1;477=1;474=1;475=1;472=1;473=1;470=1;471=1;468=1;469=1;466=1;467=0;464=1;465=1;463=1;462=1;461=1;460=1;459=1;458=0;457=1;456=1;455=1;454=1;453=0;452=1;451=1;450=1;449=0;448=1;508=1;509=1;510=1;511=0;504=1;505=1;506=0;507=1;500=1;501=1;502=0;503=1;496=1;497=0;498=1;499=1;493=0;492=1;495=1;494=1;489=1;488=1;491=1;490=1;485=1;484=1;487=0;486=1;481=1;480=1;483=1;482=1;516=1;517=0;518=1;512=1;513=1;514=1;515=1"
+ }
+ ]
+ }
+]