Compatibility results only show errors (bug 658161), also shows passing tests.
This commit is contained in:
Родитель
3b266501b4
Коммит
4db424ef5c
|
@ -262,7 +262,7 @@ var compatibilityFixtures = {
|
|||
|
||||
module('Validator: Compatibility', compatibilityFixtures);
|
||||
|
||||
asyncTest('Test passing', function() {
|
||||
asyncTest('Test basic', function() {
|
||||
var $suite = $('.addon-validator-suite', this.sandbox),
|
||||
tiers=[], results=[];
|
||||
|
||||
|
@ -287,7 +287,7 @@ asyncTest('Test passing', function() {
|
|||
"tier": 1,
|
||||
"for_appversions": null,
|
||||
"message": "Flagged file extension found",
|
||||
"type": "warning",
|
||||
"type": "error",
|
||||
"line": null,
|
||||
"uid": "bb0b38812d8f450a85fa90a2e7e6693b"
|
||||
},
|
||||
|
@ -363,30 +363,62 @@ asyncTest('Test passing', function() {
|
|||
|
||||
tests.waitFor(function() {
|
||||
// Wait until last app/version section was created.
|
||||
return $('#suite-results-tier-ec8030f7-c20a-464f-9b0e-13a3a9e97384-40b1', $suite).length;
|
||||
return $('#suite-results-tier-ec8030f7-c20a-464f-9b0e-13a3a9e97384-40b3', $suite).length;
|
||||
}).thenDo(function() {
|
||||
equals($('#suite-results-tier-errors', $suite).length, 0);
|
||||
equals($('.result-header h4:visible', $suite).eq(0).text(),
|
||||
'General Tests');
|
||||
equals($('.result-header h4:visible', $suite).eq(1).text(),
|
||||
'Firefox 4.0b3 Tests');
|
||||
equals($('.result-header h4:visible', $suite).eq(2).text(),
|
||||
'Firefox 4.0b1 Tests');
|
||||
equals($('#v-msg-2a96f7faee7a41cca4d6ead26dddc6b3 p:eq(0)', $suite).text(),
|
||||
'Warning: A dangerous or banned global...');
|
||||
equals($('#v-msg-9a07163bb74e476c96a2bd467a2bbe52 p:eq(0)', $suite).text(),
|
||||
'Error: To prevent vulnerabilities...');
|
||||
equals($('#v-msg-92a0be84024a464e87046b04e26232c4 p:eq(0)', $suite).text(),
|
||||
'Error: The add-on doesn\'t have...');
|
||||
equals($('#v-msg-dd96f7faee7a41cca4d6ead26dddc6c2 p:eq(0)', $suite).text(),
|
||||
'Error: some other error...');
|
||||
ok($('#v-msg-bb0b38812d8f450a85fa90a2e7e6693b', $suite).length == 1,
|
||||
'Non-compatibility message should be shown');
|
||||
equals($('#suite-results-tier-ec8030f7-c20a-464f-9b0e-13a3a9e97384-40b3 .result-summary', $suite).text(),
|
||||
'1 error, 1 warning');
|
||||
'1 error');
|
||||
equals($('#suite-results-tier-ec8030f7-c20a-464f-9b0e-13a3a9e97384-40b3 .version-change-link').attr('href'),
|
||||
'/firefox-4-changes');
|
||||
equals($('#suite-results-tier-ec8030f7-c20a-464f-9b0e-13a3a9e97384-40b1 .version-change-link').length, 0);
|
||||
equals($('#suite-results-tier-1 .result-summary', $suite).text(),
|
||||
'0 errors, 1 warning');
|
||||
'1 error');
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest('Test all passing', function() {
|
||||
var $suite = $('.addon-validator-suite', this.sandbox);
|
||||
|
||||
$.mockjax({
|
||||
url: '/validate',
|
||||
responseText: {
|
||||
"url": "/upload/d5d993a5a2fa4b759ae2fa3b2eda2a38/json",
|
||||
"full_report_url": "/upload/d5d993a5a2fa4b759ae2fa3b2eda2a38",
|
||||
"upload": "d5d993a5a2fa4b759ae2fa3b2eda2a38",
|
||||
"error": null,
|
||||
"validation": {
|
||||
"errors": 0,
|
||||
"success": true,
|
||||
"warnings": 5,
|
||||
"ending_tier": 5,
|
||||
"messages": [],
|
||||
"detected_type": "extension",
|
||||
"notices": 2,
|
||||
"message_tree": {},
|
||||
"metadata": {}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$suite.trigger('validate');
|
||||
|
||||
tests.waitFor(function() {
|
||||
// Wait until last app/version section was created.
|
||||
return $('#suite-results-tier-1:visible', $suite).length;
|
||||
}).thenDo(function() {
|
||||
equals($('.result-header h4:visible', $suite).eq(0).text(),
|
||||
'Compatibility Tests');
|
||||
tests.hasClass($('#suite-results-tier-1 .tier-results', $suite),
|
||||
'tests-passed');
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
@ -420,8 +452,7 @@ asyncTest('Test task error', function() {
|
|||
});
|
||||
|
||||
asyncTest('Test no tests section', function() {
|
||||
var $suite = $('.addon-validator-suite', this.sandbox),
|
||||
tiers=[], results=[];
|
||||
var $suite = $('.addon-validator-suite', this.sandbox);
|
||||
|
||||
$.mockjax({
|
||||
url: '/validate',
|
||||
|
@ -446,7 +477,7 @@ asyncTest('Test no tests section', function() {
|
|||
"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}": ["4.0b3"]
|
||||
},
|
||||
"message": "Dangerous Global Object",
|
||||
"type": "warning",
|
||||
"type": "error",
|
||||
"line": 533,
|
||||
"uid": "2a96f7faee7a41cca4d6ead26dddc6b3"
|
||||
}],
|
||||
|
@ -464,7 +495,10 @@ asyncTest('Test no tests section', function() {
|
|||
// Wait until last app/version section was created.
|
||||
return $('#suite-results-tier-ec8030f7-c20a-464f-9b0e-13a3a9e97384-40b3', $suite).length;
|
||||
}).thenDo(function() {
|
||||
equals($('#suite-results-tier-non_compat:visible', $suite).length, 0);
|
||||
equals($('#suite-results-tier-1:visible', $suite).length, 0);
|
||||
equals($('#suite-results-tier-2:visible', $suite).length, 0);
|
||||
equals($('#suite-results-tier-3:visible', $suite).length, 0);
|
||||
equals($('#suite-results-tier-4:visible', $suite).length, 0);
|
||||
equals($('#suite-results-tier-ec8030f7-c20a-464f-9b0e-13a3a9e97384-40b3 .msg', $suite).length, 1);
|
||||
start();
|
||||
});
|
||||
|
@ -598,7 +632,7 @@ asyncTest('Test single tier', function() {
|
|||
"ending_tier": 5,
|
||||
"messages": [{
|
||||
"context": null,
|
||||
"compatibility_type": "notice",
|
||||
"compatibility_type": "error",
|
||||
"uid": "bc73cbff60534798b46ed5840d1544c6",
|
||||
"column": null,
|
||||
"line": null,
|
||||
|
@ -608,7 +642,7 @@ asyncTest('Test single tier', function() {
|
|||
"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}": ["4.2a1pre", "5.0a2", "6.0a1", "4.0.*"]
|
||||
},
|
||||
"message": "Firefox 5 Compatibility Detected",
|
||||
"type": "notice",
|
||||
"type": "error",
|
||||
"id": ["testcases_compatibility", "firefox_5_test", "fx5_notice"],
|
||||
"description": "Potential compatibility for FX5 was detected."
|
||||
}],
|
||||
|
@ -687,6 +721,103 @@ asyncTest('Test no compat tests', function() {
|
|||
});
|
||||
});
|
||||
|
||||
asyncTest('Test compat ignores warnings and notices', function() {
|
||||
var $suite = $('.addon-validator-suite', this.sandbox);
|
||||
|
||||
$.mockjax({
|
||||
url: '/validate',
|
||||
responseText: {
|
||||
"url": "/upload/d5d993a5a2fa4b759ae2fa3b2eda2a38/json",
|
||||
"full_report_url": "/upload/d5d993a5a2fa4b759ae2fa3b2eda2a38",
|
||||
"upload": "d5d993a5a2fa4b759ae2fa3b2eda2a38",
|
||||
"error": null,
|
||||
"validation": {
|
||||
"errors": 0,
|
||||
"compatibility_summary": {"errors": 1},
|
||||
"success": false,
|
||||
"warnings": 1,
|
||||
"ending_tier": 5,
|
||||
"messages": [{
|
||||
"context": ["<code>"],
|
||||
"description": ["A dangerous or banned global..."],
|
||||
"column": 23,
|
||||
"id": [],
|
||||
"file": "chrome/content/youtune.js",
|
||||
"tier": 3,
|
||||
"for_appversions": {
|
||||
"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}": ["4.0b3"]
|
||||
},
|
||||
"message": "Dangerous Global Object",
|
||||
"type": "warning",
|
||||
"compatibility_type": "error",
|
||||
"line": 533,
|
||||
"uid": "2a96f7faee7a41cca4d6ead26dddc6b3"
|
||||
}, {
|
||||
"context": ["<code>"],
|
||||
"description": ["Some warning..."],
|
||||
"column": 23,
|
||||
"id": [],
|
||||
"file": "chrome/content/youtune.js",
|
||||
"tier": 3,
|
||||
"for_appversions": null,
|
||||
"message": "Some warning",
|
||||
"type": "warning",
|
||||
"compatibility_type": null,
|
||||
"line": 533,
|
||||
"uid": "1dc6f7faee7a41cca4d6ead26dddceed"
|
||||
}, {
|
||||
"context": ["<code>"],
|
||||
"description": ["Some notice..."],
|
||||
"column": 23,
|
||||
"id": [],
|
||||
"file": "chrome/content/youtune.js",
|
||||
"tier": 3,
|
||||
"for_appversions": null,
|
||||
"message": "Some notice",
|
||||
"type": "notice",
|
||||
"compatibility_type": null,
|
||||
"line": 533,
|
||||
"uid": "dce6f7faee7a41cca4d6ead26dddc2c1"
|
||||
}, {
|
||||
"context": ["<code>"],
|
||||
"description": ["Some error..."],
|
||||
"column": 23,
|
||||
"id": [],
|
||||
"file": "chrome/content/youtune.js",
|
||||
"tier": 3,
|
||||
"for_appversions": null,
|
||||
"message": "Some error",
|
||||
"type": "error",
|
||||
"compatibility_type": null,
|
||||
"line": 533,
|
||||
"uid": "6cd6f7faee7a41cca4d6ead26dddca4c"
|
||||
}],
|
||||
"detected_type": "extension",
|
||||
"notices": 0,
|
||||
"message_tree": {},
|
||||
"metadata": {}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$suite.trigger('validate');
|
||||
|
||||
tests.waitFor(function() {
|
||||
return $('#suite-results-tier-ec8030f7-c20a-464f-9b0e-13a3a9e97384-40b3', $suite).length;
|
||||
}).thenDo(function() {
|
||||
// Compat error:
|
||||
equals($('#v-msg-2a96f7faee7a41cca4d6ead26dddc6b3', $suite).length, 1);
|
||||
// Regular notice:
|
||||
equals($('#v-msg-1dc6f7faee7a41cca4d6ead26dddceed', $suite).length, 0);
|
||||
equals($('#v-msg-dce6f7faee7a41cca4d6ead26dddc2c1', $suite).length, 0);
|
||||
// Regular error
|
||||
equals($('#v-msg-6cd6f7faee7a41cca4d6ead26dddca4c', $suite).length, 1);
|
||||
equals($('#suite-results-tier-3 .result-summary', $suite).text(),
|
||||
'1 error');
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
module('Validator: Incomplete', validatorFixtures);
|
||||
|
||||
|
|
|
@ -30,9 +30,12 @@ function initValidator() {
|
|||
options.app = null;
|
||||
if (typeof options.testsWereRun === 'undefined')
|
||||
options.testsWereRun = true;
|
||||
if (typeof options.showWarnings === 'undefined')
|
||||
options.showWarnings = true;
|
||||
this.$results = $('.results', $suite);
|
||||
this.app = options.app;
|
||||
this.testsWereRun = options.testsWereRun;
|
||||
this.showWarnings = options.showWarnings;
|
||||
this.counts = {error: 0, warning: 0};
|
||||
this.tierId = tierId;
|
||||
this.$suite = $suite;
|
||||
|
@ -57,7 +60,8 @@ function initValidator() {
|
|||
}
|
||||
|
||||
ResultsTier.prototype.summarize = function() {
|
||||
var sm = resultSummary(this.counts.error, this.counts.warning),
|
||||
var sm = resultSummary(this.counts.error, this.counts.warning,
|
||||
{showWarnings: this.showWarnings}),
|
||||
resultClass, summaryMsg;
|
||||
$('.result-summary', this.$dom).css('visibility', 'visible')
|
||||
.empty().text(sm);
|
||||
|
@ -83,12 +87,14 @@ function initValidator() {
|
|||
.addClass(resultClass);
|
||||
if ($('.test-tier', this.$suite).length)
|
||||
this.topSummary();
|
||||
return this.counts;
|
||||
};
|
||||
|
||||
ResultsTier.prototype.topSummary = function() {
|
||||
var $top = $('[class~="test-tier"]' +
|
||||
'[data-tier="' + this.tierId + '"]', this.$suite),
|
||||
summaryMsg = resultSummary(this.counts.error, this.counts.warning);
|
||||
summaryMsg = resultSummary(this.counts.error, this.counts.warning,
|
||||
{showWarnings: this.showWarnings});
|
||||
|
||||
$('.tier-summary', $top).text(summaryMsg);
|
||||
$top.removeClass('ajax-loading', 'tests-failed', 'tests-passed',
|
||||
|
@ -140,14 +146,12 @@ function initValidator() {
|
|||
this.tiers = {};
|
||||
this.appTrans = null;
|
||||
this.versionChangeLinks = null;
|
||||
this.allCounts = {error: 0, warning: 0};
|
||||
}
|
||||
|
||||
MsgVisitor.prototype.createTier = function(tierId, options) {
|
||||
if (options && options.app) {
|
||||
options.app.trans = this.appTrans;
|
||||
options.app.versionChangeLinks = this.versionChangeLinks;
|
||||
}
|
||||
var tier = new ResultsTier(this.$suite, tierId, options);
|
||||
var tier = new ResultsTier(this.$suite, tierId,
|
||||
this.tierOptions(options));
|
||||
return tier;
|
||||
};
|
||||
|
||||
|
@ -160,7 +164,9 @@ function initValidator() {
|
|||
}
|
||||
});
|
||||
$.each(this.tiers, function(tierId, tier) {
|
||||
tier.summarize();
|
||||
var tierSum = tier.summarize();
|
||||
self.allCounts.error += tierSum.error;
|
||||
self.allCounts.warning += tierSum.warning;
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -240,6 +246,14 @@ function initValidator() {
|
|||
return ctxDiv;
|
||||
};
|
||||
|
||||
MsgVisitor.prototype.tierOptions = function(options) {
|
||||
if (options && options.app) {
|
||||
options.app.trans = this.appTrans;
|
||||
options.app.versionChangeLinks = this.versionChangeLinks;
|
||||
}
|
||||
return options;
|
||||
};
|
||||
|
||||
var CompatMsgVisitor = inherit(MsgVisitor, function(suite, data) {
|
||||
this.appTrans = JSON.parse(this.$results.attr('data-app-trans'));
|
||||
this.versionChangeLinks = JSON.parse(this.$results.attr('data-version-change-links'));
|
||||
|
@ -253,6 +267,10 @@ function initValidator() {
|
|||
if (!$('.msg', res).length)
|
||||
$(res).hide();
|
||||
});
|
||||
if (this.allCounts.error == 0) {
|
||||
$('#suite-results-tier-1').show();
|
||||
$('#suite-results-tier-1 h4').text(gettext('Compatibility Tests'));
|
||||
}
|
||||
};
|
||||
|
||||
CompatMsgVisitor.prototype.getMsgType = function(msg) {
|
||||
|
@ -261,6 +279,9 @@ function initValidator() {
|
|||
|
||||
CompatMsgVisitor.prototype.message = function(msg) {
|
||||
var self = this;
|
||||
if (this.getMsgType(msg) !== 'error')
|
||||
// Compatibility results only need to display/tally errors.
|
||||
return;
|
||||
if (msg.for_appversions) {
|
||||
eachAppVer(msg.for_appversions, function(guid, version, id) {
|
||||
var app = {guid: guid, version: version, id: id};
|
||||
|
@ -272,6 +293,12 @@ function initValidator() {
|
|||
}
|
||||
};
|
||||
|
||||
CompatMsgVisitor.prototype.tierOptions = function(options) {
|
||||
options = MsgVisitor.prototype.tierOptions.apply(this, arguments);
|
||||
options.showWarnings = false; // compat results only show errors
|
||||
return options;
|
||||
};
|
||||
|
||||
function buildResults(suite, data) {
|
||||
var vis,
|
||||
validation = data.validation,
|
||||
|
@ -314,13 +341,23 @@ function initValidator() {
|
|||
}
|
||||
}
|
||||
|
||||
function resultSummary(numErrors, numWarnings) {
|
||||
function resultSummary(numErrors, numWarnings, options) {
|
||||
// e.g. '1 error, 3 warnings'
|
||||
if (typeof options === 'undefined')
|
||||
options = {};
|
||||
if (typeof options.showWarnings === 'undefined')
|
||||
options.showWarnings = true;
|
||||
var errors = format(ngettext('{0} error', '{0} errors', numErrors),
|
||||
[numErrors]),
|
||||
warnings;
|
||||
|
||||
if (options.showWarnings) {
|
||||
warnings = format(ngettext('{0} warning', '{0} warnings', numWarnings),
|
||||
[numWarnings]);
|
||||
return format('{0}, {1}', errors, warnings);
|
||||
return format('{0}, {1}', errors, warnings);
|
||||
} else {
|
||||
return errors;
|
||||
}
|
||||
}
|
||||
|
||||
function joinPaths(parts) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче