aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2014-07-31 15:11:41 +0200
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2014-07-31 15:11:52 +0200
commitfc2fd04714f95ac269806bd2806e045b39a93a98 (patch)
treec03b7cb128216d7c6e7792b218355dfd807eb589 /server/sonar-web
parenta62ea5d4b00352588f883e15bbaaae6d64b60b59 (diff)
downloadsonarqube-fc2fd04714f95ac269806bd2806e045b39a93a98.tar.gz
sonarqube-fc2fd04714f95ac269806bd2806e045b39a93a98.zip
SONAR-4812 Add MT for availability of "Value" in metric filter
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/src/main/js/tests/e2e/tests/metric-filter-spec.js69
-rw-r--r--server/sonar-web/src/main/js/tests/e2e/views/metric-filter.jade134
2 files changed, 203 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/metric-filter-spec.js b/server/sonar-web/src/main/js/tests/e2e/tests/metric-filter-spec.js
new file mode 100644
index 00000000000..40b1a2417aa
--- /dev/null
+++ b/server/sonar-web/src/main/js/tests/e2e/tests/metric-filter-spec.js
@@ -0,0 +1,69 @@
+var lib = require('../lib'),
+ testName = lib.testName('Metric Filter');
+
+
+lib.initMessages();
+
+
+casper.test.begin(testName('Basic Tests'), function suite(test) {
+
+ casper.start(lib.buildUrl('metric-filter'));
+
+
+ casper.waitForSelector(".navigator-filter-label", function checkMetricFilter() {
+
+ test.assertSelectorHasText('.navigator-filter-label', 'Metric');
+ test.assertSelectorHasText('.navigator-filter-value', 'Not set');
+
+ casper.click('.navigator-filter-label');
+ casper.waitUntilVisible('.navigator-filters', function checkFields() {
+ test.assertElementCount('[name="metric"] [label="Issues"] option', 2);
+ test.assertElementCount('[name="metric"] [label="Size"] option', 1);
+
+ test.assertElementCount('[name="period"] option', 4);
+ });
+
+ casper.waitUntilVisible('.select2-results:nth-child(2) .select2-result-sub', function checkMetricField() {
+ test.assertElementCount('.select2-result-sub .select2-match', 3);
+ test.assertElementCount('.select2-results-dept-0:nth-child(1) .select2-result', 2);
+ test.assertElementCount('.select2-results-dept-0:nth-child(2) .select2-result', 1);
+
+ casper.mouseEvent('mousedown', '.select2-results-dept-0:nth-child(1) .select2-result:nth-child(2) span');
+ casper.mouseEvent('mouseup', '.select2-results-dept-0:nth-child(1) .select2-result:nth-child(2) span');
+ });
+
+ casper.then(function checkPeriodsForDifferentialMetric() {
+ casper.click('.select2-container:nth-child(3) .select2-choice');
+
+ casper.waitUntilVisible('.select2-results', function checkPeriods() {
+ // 'New issues' is selected => 'Value' disappears
+ test.assertElementCount('[name="period"] option', 3);
+ });
+ });
+
+ casper.then(function comeBackToNonDifferentialMetric() {
+ casper.click('.select2-container:nth-child(1) .select2-choice');
+
+ casper.waitUntilVisible('.select2-results:nth-child(2) .select2-result-sub', function checkMetricField() {
+ test.assertElementCount('.select2-result-sub .select2-match', 3);
+ test.assertElementCount('.select2-results-dept-0:nth-child(1) .select2-result', 2);
+ test.assertElementCount('.select2-results-dept-0:nth-child(2) .select2-result', 1);
+
+ casper.mouseEvent('mousedown', '.select2-results-dept-0:nth-child(1) .select2-result:nth-child(1) span');
+ casper.mouseEvent('mouseup', '.select2-results-dept-0:nth-child(1) .select2-result:nth-child(1) span');
+ });
+ });
+
+ casper.then(function checkPeriodsForDifferentialMetric() {
+ casper.click('.select2-container:nth-child(3) .select2-choice');
+
+ casper.waitUntilVisible('.select2-results');
+ // 'Issues' is selected => 'Value' is back
+ test.assertElementCount('[name="period"] option', 4);
+ });
+ });
+
+ casper.run(function() {
+ test.done();
+ });
+});
diff --git a/server/sonar-web/src/main/js/tests/e2e/views/metric-filter.jade b/server/sonar-web/src/main/js/tests/e2e/views/metric-filter.jade
new file mode 100644
index 00000000000..b298140ded8
--- /dev/null
+++ b/server/sonar-web/src/main/js/tests/e2e/views/metric-filter.jade
@@ -0,0 +1,134 @@
+extends ./layouts/main
+
+block header
+ script(src='../js/require.js')
+ script.
+ jQuery('html').addClass('navigator-page measures-page');
+ window.SS = typeof window.SS === 'object' ? window.SS : {};
+ _.extend(window.SS, {
+ metrics: [
+ {"metric":{"best_value":0.0,"delete_historical_data":false,"description":"Issues","direction":-1,"domain":"Issues","enabled":true,"hidden":false,"id":61,"name":"violations","optimized_best_value":true,"origin":"JAV","qualitative":true,"short_name":"Issues","user_managed":false,"val_type":"INT","worst_value":null}},
+ {"metric":{"best_value":0.0,"delete_historical_data":true,"description":"New issues","direction":-1,"domain":"Issues","enabled":true,"hidden":false,"id":67,"name":"new_violations","optimized_best_value":true,"origin":"JAV","qualitative":true,"short_name":"New issues","user_managed":false,"val_type":"INT","worst_value":null}},
+ {"metric":{"best_value":null,"delete_historical_data":false,"description":"Lines of code","direction":-1,"domain":"Size","enabled":true,"hidden":false,"id":3,"name":"ncloc","optimized_best_value":false,"origin":"JAV","qualitative":false,"short_name":"Lines of code","user_managed":false,"val_type":"INT","worst_value":null}}
+ ],
+ metricPeriods: {
+ '1': 'since previous analysis',
+ '2': 'over 365 days',
+ '3': 'since previous version'
+ },
+ phrases: {
+ 'any': 'Any',
+ 'anytime': 'Anytime',
+ 'all': 'All',
+ 'manage': 'Manate',
+ 'to': 'To',
+ 'value': 'Value',
+ 'components': 'Components',
+ 'age': 'Age',
+ 'alert': 'Alert',
+ 'componentsOf': 'Components of',
+ 'date': 'Date',
+ 'favoritesOnly': 'Favorites only',
+ 'keyContains': 'Key contains',
+ 'lastAnalysis': 'Last analysis',
+ 'metric': 'Metric',
+ 'notSet': 'Not set',
+ 'nameContains': 'Name contains',
+ 'moreCriteria': '+ More',
+ 'error': 'Error',
+ 'warning': 'Warning',
+ 'ok': 'OK',
+ 'days': 'days',
+ 'filtersList': 'Measures Filters',
+
+ 'work_duration': {
+ 'x_days': '{0}d',
+ 'x_hours': '{0}h',
+ 'x_minutes': '{0}min'
+ }
+ }
+ });
+
+block body
+ div.navigator
+ div.navigator-filters
+
+ script(id='filter-bar-template' type='text/x-handlebars-template').
+ <form method="get" action="../measures/search">
+ <div class="navigator-filters-list"></div>
+ <button class="navigator-filter-submit">Search</button>
+ </form>
+
+
+ script.
+ requirejs.config({
+ baseUrl: '../js',
+
+ paths: {
+ 'backbone': 'third-party/backbone',
+ 'backbone.marionette': 'third-party/backbone.marionette',
+ 'handlebars': 'third-party/handlebars'
+ },
+
+ shim: {
+ 'backbone.marionette': {
+ deps: ['backbone'],
+ exports: 'Marionette'
+ },
+ 'backbone': {
+ exports: 'Backbone'
+ },
+ 'handlebars': {
+ exports: 'Handlebars'
+ }
+ }
+
+ });
+
+ requirejs(
+ [
+ 'backbone', 'backbone.marionette',
+ 'measures/measures-filter-bar',
+ 'navigator/filters/base-filters',
+ 'navigator/filters/metric-filters'
+ ],
+ function (Backbone, Marionette, FilterBar, BaseFilters, MetricFilterView) {
+
+ var NavigatorApp = new Marionette.Application();
+
+ NavigatorApp.addRegions({
+ filtersRegion: '.navigator-filters'
+ });
+
+
+ NavigatorApp.addInitializer(function () {
+ this.filters = new BaseFilters.Filters();
+
+ this.filters.add([
+ new BaseFilters.Filter({
+ name: window.SS.phrases.metric,
+ property: 'metric',
+ type: MetricFilterView,
+ metrics: window.SS.metrics,
+ periods: window.SS.metricPeriods,
+ operations: { 'eq': '=', 'lt': '<', 'lte': '≤', 'gt': '>', 'gte': '≥' },
+ enabled: true,
+ optional: false
+ })
+ ]);
+
+
+ this.filterBarView = new FilterBar({
+ collection: this.filters,
+ extra: {
+ sort: '',
+ asc: false
+ }
+ });
+
+
+ this.filtersRegion.show(this.filterBarView);
+ });
+
+ NavigatorApp.start();
+ });