defaultLabel = function (item) {
return item.val;
},
- defaultLink = function (item, property, query) {
+ defaultLink = function (item, property, query, index, items, mode) {
var criterion = {};
criterion[property] = item.val;
var r = _.extend({}, query, criterion);
+ if (mode === 'debt') {
+ r.facetMode = 'debt';
+ }
if (r.componentKey != null) {
return baseUrl + '/component_issues/index?id=' + encodeURIComponent(r.componentKey) +
'#' + getQuery(_.omit(r, 'componentKey'));
isSameDay = ending.diff(beginning, 'days') <= 1;
return beginning.format('LL') + (isSameDay ? '' : (' – ' + ending.format('LL')));
},
- link: function (item, property, query, index, items) {
+ link: function (item, property, query, index, items, mode) {
var createdAfter = moment(item.val),
endDate = query.createdBefore != null ? moment(query.createdBefore) : moment(),
createdBefore = index < items.length - 1 ? moment(items[index + 1].val).subtract(1, 'days') : endDate,
createdAfter: createdAfter.format('YYYY-MM-DD'),
createdBefore: createdBefore.format('YYYY-MM-DD')
});
+ if (mode === 'debt') {
+ r.facetMode = 'debt';
+ }
if (r.componentKey != null) {
return baseUrl + '/component_issues/index?id=' + encodeURIComponent(r.componentKey) +
'#' + getQuery(_.omit(r, 'componentKey'));
return route.join(separator);
}
- Handlebars.registerHelper('issueFilterItemLink', function (query, property, value) {
+ Handlebars.registerHelper('issueFilterItemLink', function (query, property, value, mode) {
var criterion = {};
criterion[property] = value;
var r = _.extend({}, query, criterion);
+ if (mode === 'debt') {
+ r.facetMode = 'debt';
+ }
if (r.componentKey != null) {
return baseUrl + '/component_issues/index?id=' + encodeURIComponent(r.componentKey) +
'#' + getQuery(_.omit(r, 'componentKey'));
}
});
- Handlebars.registerHelper('issueFilterTotalLink', function (query) {
+ Handlebars.registerHelper('issueFilterTotalLink', function (query, mode) {
var r = _.extend({}, query);
+ if (mode === 'debt') {
+ r.facetMode = 'debt';
+ }
if (r.componentKey != null) {
return baseUrl + '/component_issues/index?id=' + encodeURIComponent(r.componentKey) +
'#' + getQuery(_.omit(r, 'componentKey'));
}
});
+ Handlebars.registerHelper('issueFilterValue', function (value, mode) {
+ var formatter = mode === 'debt' ? 'SHORT_WORK_DUR' : 'SHORT_INT';
+ return window.formatMeasure(value, formatter);
+ });
+
return Marionette.ItemView.extend({
getTemplate: function () {
withLink: function (items) {
var link = this.conf != null && this.conf.link != null ? this.conf.link : defaultLink,
property = this.options.distributionAxis,
+ mode = this.options.displayMode,
query = this.model.get('parsedQuery');
return items.map(function (item, index) {
- return _.extend(item, { searchLink: link(item, property, query, index, items) });
+ return _.extend(item, { searchLink: link(item, property, query, index, items, mode) });
});
},
requestIssues: function () {
var that = this,
+ facetMode = this.options.displayMode,
url = baseUrl + '/api/issues/search',
options = _.extend({}, this.query, {
ps: 1,
- facets: this.options.distributionAxis
+ facets: this.options.distributionAxis,
+ facetMode: facetMode
});
if (this.options.componentUuid != null) {
_.extend(options, { componentUuids: this.options.componentUuid });
items: items,
maxResultsReached: items.length >= FACET_LIMIT,
maxResults: items.length,
- total: r.total
+ total: facetMode === 'debt' ? r.debtTotal : r.total
});
}
});
+ },
+
+ serializeData: function () {
+ return _.extend(this._super(), { displayMode: this.options.displayMode });
}
});
test.assertElementCount('tr', 6);
// check order and values
- test.assertSelectorContains('tr:nth-child(1)', '6,851');
+ test.assertSelectorContains('tr:nth-child(1)', '6.9k');
test.assertSelectorContains('tr:nth-child(2)', '1');
test.assertSelectorContains('tr:nth-child(3)', '105');
- test.assertSelectorContains('tr:nth-child(4)', '5,027');
+ test.assertSelectorContains('tr:nth-child(4)', '5k');
test.assertSelectorContains('tr:nth-child(5)', '540');
- test.assertSelectorContains('tr:nth-child(6)', '1,178');
+ test.assertSelectorContains('tr:nth-child(6)', '1.2k');
// check links
test.assertExists('tr:nth-child(1) a[href="/issues/search#resolved=false"]');
test.assertElementCount('tr', 4);
// check order and values
- test.assertSelectorContains('tr:nth-child(1)', '6,851');
+ test.assertSelectorContains('tr:nth-child(1)', '6.9k');
test.assertSelectorContains('tr:nth-child(2)', '1');
test.assertSelectorContains('tr:nth-child(3)', '105');
- test.assertSelectorContains('tr:nth-child(4)', '5,027');
+ test.assertSelectorContains('tr:nth-child(4)', '5k');
// check links
test.assertExists('tr:nth-child(1) a[href="/issues/search#resolved=false|severities=BLOCKER%2CCRITICAL%2CMAJOR"]');
test.assertElementCount('tr', 6);
// check order and values
- test.assertSelectorContains('tr:nth-child(1)', '71.6k');
+ test.assertSelectorContains('tr:nth-child(1)', '72k');
test.assertSelectorContains('tr:nth-child(2)', '238');
test.assertSelectorContains('tr:nth-child(3)', '4');
- test.assertSelectorContains('tr:nth-child(4)', '6,609');
- test.assertSelectorContains('tr:nth-child(5)', '1,307');
- test.assertSelectorContains('tr:nth-child(6)', '63.4k');
+ test.assertSelectorContains('tr:nth-child(4)', '6.6k');
+ test.assertSelectorContains('tr:nth-child(5)', '1.3k');
+ test.assertSelectorContains('tr:nth-child(6)', '63k');
// check links
test.assertExists('tr:nth-child(1) a[href="/issues/search#"]');
test.assertElementCount('tr', 4);
// check order and values
- test.assertSelectorContains('tr:nth-child(1)', '71.6k');
+ test.assertSelectorContains('tr:nth-child(1)', '72k');
test.assertSelectorContains('tr:nth-child(2)', '238');
test.assertSelectorContains('tr:nth-child(3)', '4');
- test.assertSelectorContains('tr:nth-child(4)', '6,609');
+ test.assertSelectorContains('tr:nth-child(4)', '6.6k');
// check links
test.assertExists('tr:nth-child(1) a[href="/issues/search#resolved=false"]');
test.assertElementCount('tr', 6);
// check order and values
- test.assertSelectorContains('tr:nth-child(1)', '71.6k');
- test.assertSelectorContains('tr:nth-child(2)', '6,851');
+ test.assertSelectorContains('tr:nth-child(1)', '72k');
+ test.assertSelectorContains('tr:nth-child(2)', '6.9k');
test.assertSelectorContains('tr:nth-child(3)', '752');
test.assertSelectorContains('tr:nth-child(4)', '550');
- test.assertSelectorContains('tr:nth-child(5)', '47.1k');
- test.assertSelectorContains('tr:nth-child(6)', '16.3k');
+ test.assertSelectorContains('tr:nth-child(5)', '47k');
+ test.assertSelectorContains('tr:nth-child(6)', '16k');
// check links
test.assertExists('tr:nth-child(1) a[href="/issues/search#"]');
test.assertElementCount('tr', 2);
// check order and values
- test.assertSelectorContains('tr:nth-child(1)', '6,851');
- test.assertSelectorContains('tr:nth-child(2)', '6,851');
+ test.assertSelectorContains('tr:nth-child(1)', '6.9k');
+ test.assertSelectorContains('tr:nth-child(2)', '6.9k');
// check links
test.assertExists('tr:nth-child(1) a[href="/issues/search#resolved=false"]');
test.assertElementCount('tr', 16);
// check order and values
- test.assertSelectorContains('tr:nth-child(1)', '6,851');
+ test.assertSelectorContains('tr:nth-child(1)', '6.9k');
test.assertSelectorContains('tr:nth-child(2)', '879');
test.assertSelectorContains('tr:nth-child(3)', '571');
test.assertSelectorContains('tr:nth-child(15)', '113');
test.assertElementCount('tr', 5);
// check order and values
- test.assertSelectorContains('tr:nth-child(1)', '2,598');
- test.assertSelectorContains('tr:nth-child(2)', '1,766');
+ test.assertSelectorContains('tr:nth-child(1)', '2.6k');
+ test.assertSelectorContains('tr:nth-child(2)', '1.8k');
test.assertSelectorContains('tr:nth-child(3)', '442');
test.assertSelectorContains('tr:nth-child(4)', '283');
test.assertSelectorContains('tr:nth-child(5)', '107');
test.assertElementCount('tr', 5);
// check order and values
- test.assertSelectorContains('tr:nth-child(1)', '6,851');
- test.assertSelectorContains('tr:nth-child(2)', '4,134');
+ test.assertSelectorContains('tr:nth-child(1)', '6.9k');
+ test.assertSelectorContains('tr:nth-child(2)', '4.1k');
test.assertSelectorContains('tr:nth-child(3)', '698');
test.assertSelectorContains('tr:nth-child(4)', '504');
test.assertSelectorContains('tr:nth-child(5)', '426');
test.assertElementCount('tr', 2);
// check order and values
- test.assertSelectorContains('tr:nth-child(1)', '4,134');
- test.assertSelectorContains('tr:nth-child(2)', '4,134');
+ test.assertSelectorContains('tr:nth-child(1)', '4.1k');
+ test.assertSelectorContains('tr:nth-child(2)', '4.1k');
// check links
test.assertExists('tr:nth-child(1) a[href="/issues/search#resolved=false|assigned=false"]');
test.assertElementCount('tr', 4);
// check order and values
- test.assertSelectorContains('tr:nth-child(1)', '6,851');
+ test.assertSelectorContains('tr:nth-child(1)', '6.9k');
test.assertSelectorContains('tr:nth-child(2)', '698');
test.assertSelectorContains('tr:nth-child(3)', '504');
test.assertSelectorContains('tr:nth-child(4)', '426');
test.assertElementCount('tr', 5);
// check order and values
- test.assertSelectorContains('tr:nth-child(1)', '6,851');
- test.assertSelectorContains('tr:nth-child(2)', '6,336');
+ test.assertSelectorContains('tr:nth-child(1)', '6.9k');
+ test.assertSelectorContains('tr:nth-child(2)', '6.3k');
test.assertSelectorContains('tr:nth-child(3)', '444');
test.assertSelectorContains('tr:nth-child(4)', '22');
test.assertSelectorContains('tr:nth-child(5)', '15');
test.assertElementCount('tr', 5);
// check order and values
- test.assertSelectorContains('tr:nth-child(1)', '6,851');
- test.assertSelectorContains('tr:nth-child(2)', '5,877');
+ test.assertSelectorContains('tr:nth-child(1)', '6.9k');
+ test.assertSelectorContains('tr:nth-child(2)', '5.9k');
test.assertSelectorContains('tr:nth-child(3)', '532');
test.assertSelectorContains('tr:nth-child(4)', '56');
test.assertSelectorContains('tr:nth-child(5)', '52');
test.assertElementCount('tr', 2);
// check order and values
- test.assertSelectorContains('tr:nth-child(1)', '5,877');
- test.assertSelectorContains('tr:nth-child(2)', '5,877');
+ test.assertSelectorContains('tr:nth-child(1)', '5.9k');
+ test.assertSelectorContains('tr:nth-child(2)', '5.9k');
// check links
test.assertExists('tr:nth-child(1) a[href="/issues/search#resolved=false|planned=false"]');
test.assertElementCount('tr', 6);
// check order and values
- test.assertSelectorContains('tr:nth-child(1)', '6,851');
- test.assertSelectorContains('tr:nth-child(2)', '1,724');
- test.assertSelectorContains('tr:nth-child(3)', '3,729');
- test.assertSelectorContains('tr:nth-child(4)', '1,262');
+ test.assertSelectorContains('tr:nth-child(1)', '6.9k');
+ test.assertSelectorContains('tr:nth-child(2)', '1.7k');
+ test.assertSelectorContains('tr:nth-child(3)', '3.7k');
+ test.assertSelectorContains('tr:nth-child(4)', '1.3k');
test.assertSelectorContains('tr:nth-child(5)', '64');
test.assertSelectorContains('tr:nth-child(6)', '72');
test.assertElementCount('tr', 4);
// check order and values
- test.assertSelectorContains('tr:nth-child(1)', '6,851');
+ test.assertSelectorContains('tr:nth-child(1)', '6.9k');
test.assertSelectorContains('tr:nth-child(2)', '47');
test.assertSelectorContains('tr:nth-child(3)', '48');
test.assertSelectorContains('tr:nth-child(4)', '49');
test.done();
});
});
+
+
+casper.test.begin(testName('Unresolved Issues By Severity Displaying Debt'), 13, function (test) {
+ casper
+ .start(lib.buildUrl('base'), function () {
+ lib.setDefaultViewport();
+
+ lib.mockRequestFromFile('/api/l10n/index', 'messages.json');
+ lib.mockRequestFromFile('/api/issues/search', 'unresolved-issues-by-severity-debt.json',
+ { data: { resolved: 'false' } });
+ })
+
+ .then(function () {
+ casper.evaluate(function () {
+ require(['widgets/issue-filter/widget'], function (IssueFilter) {
+ window.requestMessages().done(function () {
+ new IssueFilter({
+ el: '#content',
+ query: 'resolved=false',
+ distributionAxis: 'severities',
+ displayMode: 'debt'
+ });
+ });
+ });
+ });
+ })
+
+ .then(function () {
+ casper.waitForSelector('#content > table');
+ })
+
+ .then(function () {
+ // check count
+ test.assertElementCount('tr', 6);
+
+ // check order and values
+ test.assertSelectorContains('tr:nth-child(1)', '~ 14d');
+ test.assertSelectorContains('tr:nth-child(2)', '1min');
+ test.assertSelectorContains('tr:nth-child(3)', '~ 1h');
+ test.assertSelectorContains('tr:nth-child(4)', '~ 10d');
+ test.assertSelectorContains('tr:nth-child(5)', '~ 1d');
+ test.assertSelectorContains('tr:nth-child(6)', '~ 2d');
+
+ // check links
+ test.assertExists('tr:nth-child(1) a[href="/issues/search#resolved=false|facetMode=debt"]');
+ test.assertExists('tr:nth-child(2) a[href="/issues/search#resolved=false|severities=BLOCKER|facetMode=debt"]');
+ test.assertExists('tr:nth-child(3) a[href="/issues/search#resolved=false|severities=CRITICAL|facetMode=debt"]');
+ test.assertExists('tr:nth-child(4) a[href="/issues/search#resolved=false|severities=MAJOR|facetMode=debt"]');
+ test.assertExists('tr:nth-child(5) a[href="/issues/search#resolved=false|severities=MINOR|facetMode=debt"]');
+ test.assertExists('tr:nth-child(6) a[href="/issues/search#resolved=false|severities=INFO|facetMode=debt"]');
+ })
+
+ .then(function () {
+ lib.sendCoverage();
+ })
+
+ .run(function () {
+ test.done();
+ });
+});
+
+
+casper.test.begin(testName('Unresolved Issues By Date Displaying Debt'), 13, function (test) {
+ casper
+ .start(lib.buildUrl('base'), function () {
+ lib.setDefaultViewport();
+
+ lib.mockRequestFromFile('/api/l10n/index', 'messages.json');
+ lib.mockRequestFromFile('/api/issues/search', 'unresolved-issues-by-date-debt.json',
+ { data: { resolved: 'false' } });
+ })
+
+ .then(function () {
+ casper.evaluate(function () {
+ require(['widgets/issue-filter/widget'], function (IssueFilter) {
+ window.requestMessages().done(function () {
+ new IssueFilter({
+ el: '#content',
+ query: 'resolved=false',
+ distributionAxis: 'createdAt',
+ displayMode: 'debt'
+ });
+ });
+ });
+ });
+ })
+
+ .then(function () {
+ casper.waitForSelector('#content > table');
+ })
+
+ .then(function () {
+ // check count
+ test.assertElementCount('tr', 6);
+
+ // check order and values
+ lib.capture();
+ test.assertSelectorContains('tr:nth-child(1)', '~ 14d');
+ test.assertSelectorContains('tr:nth-child(2)', '1min');
+ test.assertSelectorContains('tr:nth-child(3)', '~ 1h');
+ test.assertSelectorContains('tr:nth-child(4)', '~ 1d');
+ test.assertSelectorContains('tr:nth-child(5)', '~ 2d');
+ test.assertSelectorContains('tr:nth-child(6)', '~ 10d');
+
+ // check links
+ test.assertExists('tr:nth-child(1) a[href="/issues/search#resolved=false|facetMode=debt"]');
+ // do not check createdBefore value, because it is set dynamically to *now*
+ test.assertExists('tr:nth-child(2) a[href^="/issues/search#resolved=false|createdAfter=2015-01-01|createdBefore="]');
+ test.assertExists('tr:nth-child(3) a[href="/issues/search#resolved=false|createdAfter=2014-01-01|createdBefore=2014-12-31|facetMode=debt"]');
+ test.assertExists('tr:nth-child(4) a[href="/issues/search#resolved=false|createdAfter=2013-01-01|createdBefore=2013-12-31|facetMode=debt"]');
+ test.assertExists('tr:nth-child(5) a[href="/issues/search#resolved=false|createdAfter=2012-01-01|createdBefore=2012-12-31|facetMode=debt"]');
+ test.assertExists('tr:nth-child(6) a[href="/issues/search#resolved=false|createdAfter=2011-01-01|createdBefore=2011-12-31|facetMode=debt"]');
+ })
+
+ .then(function () {
+ lib.sendCoverage();
+ })
+
+ .run(function () {
+ test.done();
+ });
+});