define(['templates/widgets'], function () {
var $ = jQuery,
+ FACET_LIMIT = 15,
defaultComparator = function (item) {
return -item.count;
},
}
}
},
+ 'reporters': {
+ label: function (item, r) {
+ if (_.isArray(r.users)) {
+ var reporter = _.findWhere(r.users, { login: item.val });
+ if (reporter != null) {
+ return reporter.name;
+ }
+ }
+ }
+ },
'actionPlans': {
template: 'widget-issue-filter-action-plans',
label: function (item, r) {
},
'createdAt': {
comparator: function (item) {
- return moment(item.val).toDate();
+ return -moment(item.val).unix();
},
label: function (item, r, items, index, query) {
var beginning = moment(item.val),
if (_.isArray(r.facets) && r.facets.length === 1) {
// save response object, but do not trigger repaint
that.model.set({ rawResponse: r }, { silent: true });
+ var items = that.sortItems(that.withLabels(that.withLink(that.filterItems(r.facets[0].values))));
that.model.set({
- items: that.sortItems(that.withLabels(that.withLink(that.filterItems(r.facets[0].values)))),
+ items: items,
+ maxResultsReached: r.facets[0].values.length >= FACET_LIMIT,
+ maxResults: items.length,
total: r.total
});
}
});
+casper.test.begin(testName('Unresolved Issues By Reporter'), 12, function (test) {
+ casper
+ .start(lib.buildUrl('issue-filter-widget'), function () {
+ lib.setDefaultViewport();
+
+ lib.mockRequest('/api/l10n/index', '{}');
+ lib.mockRequestFromFile('/api/issues/search', 'unresolved-issues-by-reporter.json',
+ { data: { resolved: 'false' } });
+ })
+
+ .then(function () {
+ casper.evaluate(function () {
+ require(['/js/widgets/issue-filter.js'], function (IssueFilter) {
+ window.requestMessages().done(function () {
+ new IssueFilter({
+ el: '#issue-filter-widget',
+ query: 'resolved=false',
+ distributionAxis: 'reporters'
+ });
+ });
+ });
+ });
+ })
+
+ .then(function () {
+ casper.waitForSelector('#issue-filter-widget > table');
+ })
+
+ .then(function () {
+ // check count
+ test.assertElementCount('tr', 4);
+
+ // check order and values
+ test.assertSelectorContains('tr:nth-child(1)', '6851');
+ test.assertSelectorContains('tr:nth-child(2)', '698');
+ test.assertSelectorContains('tr:nth-child(3)', '504');
+ test.assertSelectorContains('tr:nth-child(4)', '426');
+
+ // check links
+ test.assertExists('tr:nth-child(1) a[href="/issues/search#resolved=false"]');
+ test.assertExists('tr:nth-child(2) a[href="/issues/search#resolved=false|reporters=first.user"]');
+ test.assertExists('tr:nth-child(3) a[href="/issues/search#resolved=false|reporters=second.user"]');
+ test.assertExists('tr:nth-child(4) a[href="/issues/search#resolved=false|reporters=third.user"]');
+
+ // check labels
+ test.assertSelectorContains('tr:nth-child(2)', 'First User');
+ test.assertSelectorContains('tr:nth-child(3)', 'Second User');
+ test.assertSelectorContains('tr:nth-child(4)', 'Third User');
+ })
+
+ .then(function () {
+ lib.sendCoverage();
+ })
+
+ .run(function () {
+ test.done();
+ });
+});
+
+
casper.test.begin(testName('Unresolved Issues By Language'), 15, function (test) {
casper
.start(lib.buildUrl('issue-filter-widget'), function () {
// check order and values
test.assertSelectorContains('tr:nth-child(1)', '6851');
- test.assertSelectorContains('tr:nth-child(2)', '72');
- test.assertSelectorContains('tr:nth-child(3)', '64');
+ test.assertSelectorContains('tr:nth-child(2)', '1724');
+ test.assertSelectorContains('tr:nth-child(3)', '3729');
test.assertSelectorContains('tr:nth-child(4)', '1262');
- test.assertSelectorContains('tr:nth-child(5)', '3729');
- test.assertSelectorContains('tr:nth-child(6)', '1724');
+ test.assertSelectorContains('tr:nth-child(5)', '64');
+ test.assertSelectorContains('tr:nth-child(6)', '72');
// check links
test.assertExists('tr:nth-child(1) a[href="/issues/search#resolved=false"]');
- test.assertExists('tr:nth-child(2) a[href="/issues/search#resolved=false|createdAfter=2011-01-01|createdBefore=2011-12-31"]');
- test.assertExists('tr:nth-child(3) a[href="/issues/search#resolved=false|createdAfter=2012-01-01|createdBefore=2012-12-31"]');
- test.assertExists('tr:nth-child(4) a[href="/issues/search#resolved=false|createdAfter=2013-01-01|createdBefore=2013-12-31"]');
- test.assertExists('tr:nth-child(5) a[href="/issues/search#resolved=false|createdAfter=2014-01-01|createdBefore=2014-12-31"]');
// do not check createdBefore value, because it is set dynamically to *now*
- test.assertExists('tr:nth-child(6) a[href^="/issues/search#resolved=false|createdAfter=2015-01-01|createdBefore="]');
+ 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"]');
+ test.assertExists('tr:nth-child(4) a[href="/issues/search#resolved=false|createdAfter=2013-01-01|createdBefore=2013-12-31"]');
+ test.assertExists('tr:nth-child(5) a[href="/issues/search#resolved=false|createdAfter=2012-01-01|createdBefore=2012-12-31"]');
+ test.assertExists('tr:nth-child(6) a[href="/issues/search#resolved=false|createdAfter=2011-01-01|createdBefore=2011-12-31"]');
// check labels
- test.assertSelectorContains('tr:nth-child(2)', 'January 1 2011 – December 31 2011');
- test.assertSelectorContains('tr:nth-child(3)', 'January 1 2012 – December 31 2012');
- test.assertSelectorContains('tr:nth-child(4)', 'January 1 2013 – December 31 2013');
- test.assertSelectorContains('tr:nth-child(5)', 'January 1 2014 – December 31 2014');
// do not check label fully, because it is set dynamically using *now*
- test.assertSelectorContains('tr:nth-child(6)', 'January 1 2015 – ');
+ test.assertSelectorContains('tr:nth-child(2)', 'January 1 2015 – ');
+ test.assertSelectorContains('tr:nth-child(3)', 'January 1 2014 – December 31 2014');
+ test.assertSelectorContains('tr:nth-child(4)', 'January 1 2013 – December 31 2013');
+ test.assertSelectorContains('tr:nth-child(5)', 'January 1 2012 – December 31 2012');
+ test.assertSelectorContains('tr:nth-child(6)', 'January 1 2011 – December 31 2011');
})
.then(function () {
// check order and values
test.assertSelectorContains('tr:nth-child(1)', '6851');
- test.assertSelectorContains('tr:nth-child(2)', '49');
+ test.assertSelectorContains('tr:nth-child(2)', '47');
test.assertSelectorContains('tr:nth-child(3)', '48');
- test.assertSelectorContains('tr:nth-child(4)', '47');
+ test.assertSelectorContains('tr:nth-child(4)', '49');
// check links
test.assertExists('tr:nth-child(1) a[href="/issues/search#resolved=false|createdAfter=2015-02-16|createdBefore=2015-02-18"]');
- test.assertExists('tr:nth-child(2) a[href="/issues/search#resolved=false|createdAfter=2015-02-16|createdBefore=2015-02-17"]');
+ test.assertExists('tr:nth-child(2) a[href="/issues/search#resolved=false|createdAfter=2015-02-18|createdBefore=2015-02-19"]');
test.assertExists('tr:nth-child(3) a[href="/issues/search#resolved=false|createdAfter=2015-02-17|createdBefore=2015-02-18"]');
- test.assertExists('tr:nth-child(4) a[href="/issues/search#resolved=false|createdAfter=2015-02-18|createdBefore=2015-02-19"]');
+ test.assertExists('tr:nth-child(4) a[href="/issues/search#resolved=false|createdAfter=2015-02-16|createdBefore=2015-02-17"]');
// check labels
- test.assertSelectorContains('tr:nth-child(2)', 'February 16 2015');
+ test.assertSelectorContains('tr:nth-child(2)', 'February 18 2015');
test.assertSelectorContains('tr:nth-child(3)', 'February 17 2015');
- test.assertSelectorContains('tr:nth-child(4)', 'February 18 2015');
+ test.assertSelectorContains('tr:nth-child(4)', 'February 16 2015');
})
.then(function () {
// check order and values
test.assertSelectorContains('tr:nth-child(1)', '6851');
- test.assertSelectorContains('tr:nth-child(2)', '72');
- test.assertSelectorContains('tr:nth-child(3)', '64');
+ test.assertSelectorContains('tr:nth-child(2)', '1724');
+ test.assertSelectorContains('tr:nth-child(3)', '3729');
test.assertSelectorContains('tr:nth-child(4)', '1262');
- test.assertSelectorContains('tr:nth-child(5)', '3729');
- test.assertSelectorContains('tr:nth-child(6)', '1724');
+ test.assertSelectorContains('tr:nth-child(5)', '64');
+ test.assertSelectorContains('tr:nth-child(6)', '72');
// check links
test.assertExists('tr:nth-child(1) a[href="/component_issues/index?id=org.codehaus.sonar%3Asonar#resolved=false"]');
- test.assertExists('tr:nth-child(2) a[href="/component_issues/index?id=org.codehaus.sonar%3Asonar#resolved=false|createdAfter=2011-01-01|createdBefore=2011-12-31"]');
- test.assertExists('tr:nth-child(3) a[href="/component_issues/index?id=org.codehaus.sonar%3Asonar#resolved=false|createdAfter=2012-01-01|createdBefore=2012-12-31"]');
- test.assertExists('tr:nth-child(4) a[href="/component_issues/index?id=org.codehaus.sonar%3Asonar#resolved=false|createdAfter=2013-01-01|createdBefore=2013-12-31"]');
- test.assertExists('tr:nth-child(5) a[href="/component_issues/index?id=org.codehaus.sonar%3Asonar#resolved=false|createdAfter=2014-01-01|createdBefore=2014-12-31"]');
// do not check createdBefore value, because it is set dynamically to *now*
- test.assertExists('tr:nth-child(6) a[href^="/component_issues/index?id=org.codehaus.sonar%3Asonar#resolved=false|createdAfter=2015-01-01|createdBefore="]');
+ test.assertExists('tr:nth-child(2) a[href^="/component_issues/index?id=org.codehaus.sonar%3Asonar#resolved=false|createdAfter=2015-01-01|createdBefore="]');
+ test.assertExists('tr:nth-child(3) a[href="/component_issues/index?id=org.codehaus.sonar%3Asonar#resolved=false|createdAfter=2014-01-01|createdBefore=2014-12-31"]');
+ test.assertExists('tr:nth-child(4) a[href="/component_issues/index?id=org.codehaus.sonar%3Asonar#resolved=false|createdAfter=2013-01-01|createdBefore=2013-12-31"]');
+ test.assertExists('tr:nth-child(5) a[href="/component_issues/index?id=org.codehaus.sonar%3Asonar#resolved=false|createdAfter=2012-01-01|createdBefore=2012-12-31"]');
+ test.assertExists('tr:nth-child(6) a[href="/component_issues/index?id=org.codehaus.sonar%3Asonar#resolved=false|createdAfter=2011-01-01|createdBefore=2011-12-31"]');
// check labels
- test.assertSelectorContains('tr:nth-child(2)', 'January 1 2011 – December 31 2011');
- test.assertSelectorContains('tr:nth-child(3)', 'January 1 2012 – December 31 2012');
- test.assertSelectorContains('tr:nth-child(4)', 'January 1 2013 – December 31 2013');
- test.assertSelectorContains('tr:nth-child(5)', 'January 1 2014 – December 31 2014');
// do not check label fully, because it is set dynamically using *now*
- test.assertSelectorContains('tr:nth-child(6)', 'January 1 2015 – ');
+ test.assertSelectorContains('tr:nth-child(2)', 'January 1 2015 – ');
+ test.assertSelectorContains('tr:nth-child(3)', 'January 1 2014 – December 31 2014');
+ test.assertSelectorContains('tr:nth-child(4)', 'January 1 2013 – December 31 2013');
+ test.assertSelectorContains('tr:nth-child(5)', 'January 1 2012 – December 31 2012');
+ test.assertSelectorContains('tr:nth-child(6)', 'January 1 2011 – December 31 2011');
})
.then(function () {