Add unit tests and provide better message
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
parent
6c9ea61758
commit
faef05730a
|
@ -112,10 +112,10 @@
|
||||||
var afterCall = function(xhr) {
|
var afterCall = function(xhr) {
|
||||||
var messages = [];
|
var messages = [];
|
||||||
if (expectedStatus.indexOf(xhr.status) === -1) {
|
if (expectedStatus.indexOf(xhr.status) === -1) {
|
||||||
var docUrl = placeholderUrl.replace('PLACEHOLDER', 'admin-setup-well-known-URL');
|
var docUrl = placeholderUrl.replace('PLACEHOLDER', 'admin-nginx');
|
||||||
messages.push({
|
messages.push({
|
||||||
msg: t('core', 'Your web server is not properly set up to resolve "{url}". Further information can be found in the <a target="_blank" rel="noreferrer noopener" href="{docLink}">documentation</a>.', { docLink: docUrl, url: url }),
|
msg: t('core', 'Your web server is not properly set up to resolve "{url}". This is most likely related to a web server configuration that was not updated to deliver this folder directly. Please compare your configuration against the shipped rewrite rules in ".htaccess" for Apache or the provided one in the documentation for Nginx at it\'s <a target="_blank" rel="noreferrer noopener" href="{docLink}">documentation page</a>. On Nginx those are typically the lines starting with "location ~" that need an update.', { docLink: docUrl, url: url }),
|
||||||
type: OC.SetupChecks.MESSAGE_TYPE_INFO
|
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
deferred.resolve(messages);
|
deferred.resolve(messages);
|
||||||
|
|
|
@ -107,6 +107,42 @@ describe('OC.SetupChecks tests', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('checkProviderUrl', function() {
|
||||||
|
it('should fail with another response status code than the expected one', function(done) {
|
||||||
|
var async = OC.SetupChecks.checkProviderUrl('/ocm-provider/', 'http://example.org/PLACEHOLDER', true);
|
||||||
|
|
||||||
|
suite.server.requests[0].respond(302);
|
||||||
|
|
||||||
|
async.done(function( data, s, x ){
|
||||||
|
expect(data).toEqual([{
|
||||||
|
msg: 'Your web server is not properly set up to resolve "/ocm-provider/". This is most likely related to a web server configuration that was not updated to deliver this folder directly. Please compare your configuration against the shipped rewrite rules in ".htaccess" for Apache or the provided one in the documentation for Nginx at it\'s <a href="http://example.org/admin-nginx" rel="noreferrer noopener">documentation page</a>. On Nginx those are typically the lines starting with "location ~" that need an update.',
|
||||||
|
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
|
||||||
|
}]);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return no error with the expected response status code', function(done) {
|
||||||
|
var async = OC.SetupChecks.checkProviderUrl('/ocm-provider/', 'http://example.org/PLACEHOLDER', true);
|
||||||
|
|
||||||
|
suite.server.requests[0].respond(200);
|
||||||
|
|
||||||
|
async.done(function( data, s, x ){
|
||||||
|
expect(data).toEqual([]);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return no error when no check should be run', function(done) {
|
||||||
|
var async = OC.SetupChecks.checkProviderUrl('/ocm-provider/', 'http://example.org/PLACEHOLDER', false);
|
||||||
|
|
||||||
|
async.done(function( data, s, x ){
|
||||||
|
expect(data).toEqual([]);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('checkWOFF2Loading', function() {
|
describe('checkWOFF2Loading', function() {
|
||||||
it('should fail with another response status code than the expected one', function(done) {
|
it('should fail with another response status code than the expected one', function(done) {
|
||||||
var async = OC.SetupChecks.checkWOFF2Loading(OC.filePath('core', '', 'fonts/Nunito-Regular.woff2'), 'http://example.org/PLACEHOLDER');
|
var async = OC.SetupChecks.checkWOFF2Loading(OC.filePath('core', '', 'fonts/Nunito-Regular.woff2'), 'http://example.org/PLACEHOLDER');
|
||||||
|
|
|
@ -257,8 +257,8 @@ $(document).ready(function(){
|
||||||
OC.SetupChecks.checkGeneric(),
|
OC.SetupChecks.checkGeneric(),
|
||||||
OC.SetupChecks.checkWOFF2Loading(OC.filePath('core', '', 'fonts/Nunito-Regular.woff2'), oc_defaults.docPlaceholderUrl),
|
OC.SetupChecks.checkWOFF2Loading(OC.filePath('core', '', 'fonts/Nunito-Regular.woff2'), oc_defaults.docPlaceholderUrl),
|
||||||
OC.SetupChecks.checkDataProtected()
|
OC.SetupChecks.checkDataProtected()
|
||||||
).then(function (check1, check2, check3, check4, check5, check6, check7, check8) {
|
).then(function (check1, check2, check3, check4, check5, check6, check7, check8, check9, check10) {
|
||||||
var messages = [].concat(check1, check2, check3, check4, check5, check6, check7, check8);
|
var messages = [].concat(check1, check2, check3, check4, check5, check6, check7, check8, check9, check10);
|
||||||
var $el = $('#postsetupchecks');
|
var $el = $('#postsetupchecks');
|
||||||
$('#security-warning-state-loading').addClass('hidden');
|
$('#security-warning-state-loading').addClass('hidden');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue