diff options
author | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-07-28 13:52:33 +0200 |
---|---|---|
committer | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-07-28 13:52:51 +0200 |
commit | 33e2ffe31acf340e1c6b307fc7e5debe64f82760 (patch) | |
tree | 21dab18e1227ce245f142137a48006cc792d0604 /server/sonar-web | |
parent | 5f055a33b0185e62e01cb097af1d11c36ef12ee0 (diff) | |
download | sonarqube-33e2ffe31acf340e1c6b307fc7e5debe64f82760.tar.gz sonarqube-33e2ffe31acf340e1c6b307fc7e5debe64f82760.zip |
SONAR-5137 Add medium tests on rule activation
Diffstat (limited to 'server/sonar-web')
5 files changed, 308 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec.js index bc7a0cb2fd6..2553a3a3033 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec.js @@ -98,6 +98,7 @@ casper.test.begin(testName('Readonly Tests'), function suite(test) { }); }); + casper.test.begin(testName('Admin Tests'), function suite(test) { var showId = null; @@ -142,6 +143,118 @@ casper.test.begin(testName('Admin Tests'), function suite(test) { }); }); + casper.run(function() { + test.done(); + }); +}); + + +casper.test.begin(testName('Activation Tests'), function suite(test) { + + var showId = null; + var activateId = null; + + casper.start(lib.buildUrl('coding-rules#rule_key=squid-xoo:x1'), function() { + lib.clearRequestMocks(); + lib.mockRequest('/api/l10n/index', '{}'); + lib.mockRequestFromFile('/api/rules/app', 'app_admin.json'); + lib.mockRequestFromFile('/api/rules/tags', 'tags.json'); + lib.mockRequestFromFile('/api/rules/search', 'search_x1.json'); + showId = lib.mockRequestFromFile('/api/rules/show', 'show_x1.json'); + }); + + + casper.waitWhileSelector("div#coding-rules-page-loader", function checkRuleActivation() { + + casper.waitForSelector('div.coding-rules-detail-quality-profiles-section', function showRuleActivation() { + test.assertExists('#coding-rules-detail-quality-profiles'); + + test.assertElementCount('.coding-rules-detail-quality-profile', 1); + + test.assertSelectorHasText('.coding-rules-detail-quality-profile-parameter', 'A nice'); + test.assertSelectorHasText('.coding-rules-detail-quality-profile-parameter', 'true'); + test.assertSelectorHasText('.coding-rules-detail-quality-profile-parameter', '0'); + }); + + + casper.then(function editActiveRule() { + casper.click('button.coding-rules-detail-quality-profile-change'); + + casper.waitForSelector('button#coding-rules-quality-profile-activation-activate', function checkActivationPopup() { + test.assertElementCount('.modal-body .property', 5 /* quality profile, severity, 3 parameters */); + + test.assertSelectorHasText('.modal-body .property textarea[name="textParameter"]', 'A nice\ntext parameter\nwith newlines.'); + test.assertSelectorHasText('.modal-body .property input[name="skipLines"]', ''); + test.assertEval(function checkPlaceHolder() { + return $j('.modal-body .property input[name="skipLines"]').attr('placeholder') === '0' + }); + test.assertEval(function checkTrueIsSelected() { + return $j('.modal-body .property select[name="acceptWhitespace"]').val() === 'true' + }); + }); + }); + + casper.then(function updateParameters() { + casper.sendKeys('textarea[name="textParameter"]', '\nUpdated'); + casper.sendKeys('input[name="skipLines"]', '5'); + casper.evaluate(function selectDefault() { + $j('select[name="acceptWhitespace"]').val('false').change(); + }); + + lib.clearRequestMock(showId); + showId = lib.mockRequestFromFile('/api/rules/show', 'update_parameters_x1.json'); + activateId = lib.mockRequest('/api/qualityprofiles/activate_rule', ''); + + casper.click('button#coding-rules-quality-profile-activation-activate'); + + casper.wait(500, function showUpdatedParameters() { + test.assertSelectorHasText('.coding-rules-detail-quality-profile-parameter', 'A nice'); + test.assertSelectorHasText('.coding-rules-detail-quality-profile-parameter', 'false'); + test.assertSelectorHasText('.coding-rules-detail-quality-profile-parameter', '5'); + }); + + }); + + casper.then(function deactivateRule() { + casper.click('button.coding-rules-detail-quality-profile-deactivate'); + + casper.waitForSelector('button[data-confirm="yes"]', function checkConfirmPopup() { + lib.clearRequestMock(showId); + showId = lib.mockRequestFromFile('/api/rules/show', 'deactivate_x1.json'); + lib.mockRequest('/api/qualityprofiles/deactivate_rule', ''); + + casper.click('button[data-confirm="yes"]'); + }); + + casper.wait(500, function showUpdatedParameters() { + test.assertElementCount('.coding-rules-detail-quality-profile', 0); + }); + }); + + casper.then(function activateRule() { + casper.click('button#coding-rules-quality-profile-activate'); + + casper.waitForSelector('button#coding-rules-quality-profile-activation-activate', function checkActivationPopup() { + + lib.clearRequestMock(showId); + showId = lib.mockRequestFromFile('/api/rules/show', 'show_x1.json'); + lib.clearRequestMock(activateId); + activateId = lib.mockRequest('/api/qualityprofiles/activate_rule', ''); + + casper.click('button#coding-rules-quality-profile-activation-activate'); + + casper.wait(500, function showUpdatedParameters() { + test.assertSelectorHasText('.coding-rules-detail-quality-profile-parameter', 'A nice'); + test.assertSelectorHasText('.coding-rules-detail-quality-profile-parameter', 'true'); + test.assertSelectorHasText('.coding-rules-detail-quality-profile-parameter', '0'); + }); + + }); + + }); + + }); + casper.run(function() { test.done(); diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec/deactivate_x1.json b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec/deactivate_x1.json new file mode 100644 index 00000000000..e1d7fcaf4bf --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec/deactivate_x1.json @@ -0,0 +1,60 @@ +{ + + "rule": { + "key": "squid-xoo:x1", + "repo": "squid-xoo", + "name": "No empty line", + "createdAt": "2014-07-23T11:17:26+0200", + "severity": "MINOR", + "status": "BETA", + "isTemplate": false, + "tags": [ ], + "sysTags": [ + "convention", + "pitfall" + ], + "lang": "xoo", + "langName": "Xoo", + "htmlDesc": "Generate an issue on <em>empty</em> lines of Xoo source files", + "mdDesc": "Generate an issue on *empty* lines of Xoo source files", + "noteLogin": "admin", + "mdNote": "As per the [Book of Xoo](http://xoo.sonarsource.com/book):\n> Xoo shall not pass!", + "htmlNote": "As per the <a href=\"http://xoo.sonarsource.com/book\" target=\"_blank\">Book of Xoo</a>:<br/><blockquote>Xoo shall not pass!<br/></blockquote>", + "defaultDebtChar": "TESTABILITY", + "defaultDebtSubChar": "INTEGRATION_TESTABILITY", + "debtChar": "TESTABILITY", + "debtSubChar": "INTEGRATION_TESTABILITY", + "debtCharName": "Testability", + "debtSubCharName": "Integration level", + "debtRemFnType": "LINEAR_OFFSET", + "debtRemFnCoeff": "1h", + "debtRemFnOffset": "30min", + "defaultDebtRemFnType": "LINEAR_OFFSET", + "defaultDebtRemFnCoeff": "1h", + "defaultDebtRemFnOffset": "30min", + "effortToFixDescription": "Effort to fix issue on one line", + "debtOverloaded": false, + "params": [ + { + "key": "acceptWhitespace", + "htmlDesc": "<h1>Accept whitespace (<code>\\s|\\t</code>) on the line\n</h1>This property is available so that a line containing only whitespace is not considered empty.<br/><h2>Example with property set to ``false``\n</h2><pre lang=\"xoo\"><code> <- One issue here\n<- And one here</code></pre><br/><br/><h2>Example with property set to ``true``\n</h2><pre lang=\"xoo\"><code> <- No issue here\n<- But one here</code></pre><br/>", + "type": "BOOLEAN", + "defaultValue": "false" + }, + { + "key": "textParameter", + "htmlDesc": "This is a parameter of type TEXT", + "type": "TEXT", + "defaultValue": "false" + }, + { + "key": "skipLines", + "htmlDesc": "Skip a number of lines at the beginning of the file", + "type": "INTEGER", + "defaultValue": "0" + } + ] + }, + "actives": [ ] + +} diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec/search_x1.json b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec/search_x1.json new file mode 100644 index 00000000000..05ba049ff3a --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec/search_x1.json @@ -0,0 +1,47 @@ +{ + + "total": 1, + "p": 1, + "ps": 25, + "rules": [ + { + "key": "squid-xoo:x1", + "name": "No empty line", + "lang": "xoo", + "status": "BETA" + } + ], + "facets": [ + { + "property": "tags", + "values": [ + { + "val": "pitfall", + "count": 1 + }, + { + "val": "convention", + "count": 1 + } + ] + }, + { + "property": "languages", + "values": [ + { + "val": "xoo", + "count": 1 + } + ] + }, + { + "property": "repositories", + "values": [ + { + "val": "squid-xoo", + "count": 1 + } + ] + } + ] +} diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec/show_x1.json b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec/show_x1.json index d360d7b4730..08dfb135df8 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec/show_x1.json +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec/show_x1.json @@ -64,6 +64,14 @@ { "key": "acceptWhitespace", "value": "true" + }, + { + "key": "textParameter", + "value": "A nice\ntext parameter\nwith newlines." + }, + { + "key": "skipLines", + "value": "0" } ] } diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec/update_parameters_x1.json b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec/update_parameters_x1.json new file mode 100644 index 00000000000..c965c4bf2af --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec/update_parameters_x1.json @@ -0,0 +1,80 @@ +{ + + "rule": { + "key": "squid-xoo:x1", + "repo": "squid-xoo", + "name": "No empty line", + "createdAt": "2014-07-23T11:17:26+0200", + "severity": "MINOR", + "status": "BETA", + "isTemplate": false, + "tags": [ ], + "sysTags": [ + "convention", + "pitfall" + ], + "lang": "xoo", + "langName": "Xoo", + "htmlDesc": "Generate an issue on <em>empty</em> lines of Xoo source files", + "mdDesc": "Generate an issue on *empty* lines of Xoo source files", + "noteLogin": "admin", + "mdNote": "As per the [Book of Xoo](http://xoo.sonarsource.com/book):\n> Xoo shall not pass!", + "htmlNote": "As per the <a href=\"http://xoo.sonarsource.com/book\" target=\"_blank\">Book of Xoo</a>:<br/><blockquote>Xoo shall not pass!<br/></blockquote>", + "defaultDebtChar": "TESTABILITY", + "defaultDebtSubChar": "INTEGRATION_TESTABILITY", + "debtChar": "TESTABILITY", + "debtSubChar": "INTEGRATION_TESTABILITY", + "debtCharName": "Testability", + "debtSubCharName": "Integration level", + "debtRemFnType": "LINEAR_OFFSET", + "debtRemFnCoeff": "1h", + "debtRemFnOffset": "30min", + "defaultDebtRemFnType": "LINEAR_OFFSET", + "defaultDebtRemFnCoeff": "1h", + "defaultDebtRemFnOffset": "30min", + "effortToFixDescription": "Effort to fix issue on one line", + "debtOverloaded": false, + "params": [ + { + "key": "acceptWhitespace", + "htmlDesc": "<h1>Accept whitespace (<code>\\s|\\t</code>) on the line\n</h1>This property is available so that a line containing only whitespace is not considered empty.<br/><h2>Example with property set to ``false``\n</h2><pre lang=\"xoo\"><code> <- One issue here\n<- And one here</code></pre><br/><br/><h2>Example with property set to ``true``\n</h2><pre lang=\"xoo\"><code> <- No issue here\n<- But one here</code></pre><br/>", + "type": "BOOLEAN", + "defaultValue": "false" + }, + { + "key": "textParameter", + "htmlDesc": "This is a parameter of type TEXT", + "type": "TEXT", + "defaultValue": "false" + }, + { + "key": "skipLines", + "htmlDesc": "Skip a number of lines at the beginning of the file", + "type": "INTEGER", + "defaultValue": "0" + } + ] + }, + "actives": [ + { + "qProfile": "xoo-sonar-way", + "inherit": "NONE", + "severity": "MAJOR", + "params": [ + { + "key": "acceptWhitespace", + "value": "false" + }, + { + "key": "textParameter", + "value": "A nice\ntext parameter\nwith newlines.\nUpdated" + }, + { + "key": "skipLines", + "value": "5" + } + ] + } + ] + +} |