From 4e21ed56063352cf19d5709b28545112dffe3a9d Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lievremont Date: Fri, 25 Jul 2014 15:04:38 +0200 Subject: [PATCH] Add frontend tests on rule parameters and debt info on rules page --- .../hbs/coding-rules/coding-rules-detail.hbs | 25 ---------------- .../js/tests/e2e/tests/coding-rules-spec.js | 29 +++++++++++++++++-- .../e2e/tests/coding-rules-spec/show_x1.json | 13 +++++++++ 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/server/sonar-web/src/main/hbs/coding-rules/coding-rules-detail.hbs b/server/sonar-web/src/main/hbs/coding-rules/coding-rules-detail.hbs index f839bb8963c..b64e0c037ef 100644 --- a/server/sonar-web/src/main/hbs/coding-rules/coding-rules-detail.hbs +++ b/server/sonar-web/src/main/hbs/coding-rules/coding-rules-detail.hbs @@ -49,31 +49,6 @@ {{/if}} -{{#if subcharacteristic}} -
- -
-{{/if}} -
{{{htmlDesc}}}
{{#if isEditable}} 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 e2cf097fab7..bc7a0cb2fd6 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 @@ -1,11 +1,12 @@ -var lib = require('../lib'); +var lib = require('../lib'), + testName = lib.testName('Coding Rules'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-spec'); -casper.test.begin('Coding Rules - Readonly Tests', function suite(test) { +casper.test.begin(testName('Readonly Tests'), function suite(test) { var appId = null; var showId = null; @@ -44,6 +45,7 @@ casper.test.begin('Coding Rules - Readonly Tests', function suite(test) { test.assertSelectorHasText('ol.navigator-results-list li.active', 'BETA'); }); + casper.waitForSelector('h3.coding-rules-detail-header', function showFirstRule() { test.assertSelectorHasText('h3.coding-rules-detail-header', 'No empty line'); test.assertSelectorHasText('.navigator-details .subtitle', 'squid-xoo:x1'); @@ -53,7 +55,28 @@ casper.test.begin('Coding Rules - Readonly Tests', function suite(test) { test.assertSelectorHasText('.coding-rules-detail-property:nth-child(4)', 'Testability > Integration level testability'); test.assertSelectorHasText('.coding-rules-detail-property:nth-child(6)', 'SonarQube (Xoo)'); + + casper.click('.coding-rules-subcharacteristic'); + casper.waitForSelector('.coding-rules-debt-popup', function checkDebtPopup() { + test.assertElementCount('ul.bubble-popup-list li', 3); + test.assertSelectorHasText('.bubble-popup-list li:nth-child(1)', 'LINEAR_OFFSET'); + test.assertSelectorHasText('.bubble-popup-list li:nth-child(2)', '1h'); + test.assertSelectorHasText('.bubble-popup-list li:nth-child(3)', '30min'); + }); + + test.assertDoesntExist('button#coding-rules-detail-extend-description'); + + + casper.then(function checkParameters() { + test.assertElementCount('.coding-rules-detail-parameter', 3); + test.assertVisible('.coding-rules-detail-parameter-description[data-key=acceptWhitespace]'); + test.assertSelectorHasText('.coding-rules-detail-parameter-description[data-key=acceptWhitespace]', 'Accept whitespace'); + casper.click('.coding-rules-detail-parameter:nth-child(1) .coding-rules-detail-parameter-name'); + test.assertNotVisible('.coding-rules-detail-parameter-description[data-key=acceptWhitespace]'); + casper.click('.coding-rules-detail-parameter:nth-child(1) .coding-rules-detail-parameter-name'); + test.assertVisible('.coding-rules-detail-parameter-description[data-key=acceptWhitespace]'); + }); }); }); @@ -75,7 +98,7 @@ casper.test.begin('Coding Rules - Readonly Tests', function suite(test) { }); }); -casper.test.begin('Coding Rules - Admin Tests', function suite(test) { +casper.test.begin(testName('Admin Tests'), function suite(test) { var showId = null; var updateId = null; 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 e3c47578ff2..d360d7b4730 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 @@ -38,7 +38,20 @@ { "key": "acceptWhitespace", "htmlDesc": "

Accept whitespace (\\s|\\t) on the line\n

This property is available so that a line containing only whitespace is not considered empty.

Example with property set to ``false``\n

 <- One issue here\n<- And one here


Example with property set to ``true``\n

 <- No issue here\n<- But one here

", + "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" } ] }, -- 2.39.5