mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
fix: dont send 200 status on admin upload errors (#11707)
* fix: dont send 200 status on admin upload errors * test: update test * bring back both checks for error * test: add statusCode tests
This commit is contained in:
committed by
GitHub
parent
f2c0c18879
commit
8ca65b0c78
@@ -340,7 +340,7 @@ describe('Upload Controllers', () => {
|
||||
it('should upload site logo', (done) => {
|
||||
helpers.uploadFile(`${nconf.get('url')}/api/admin/uploadlogo`, path.join(__dirname, '../test/files/test.png'), {}, jar, csrf_token, (err, res, body) => {
|
||||
assert.ifError(err);
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.strictEqual(res.statusCode, 200);
|
||||
assert(Array.isArray(body));
|
||||
assert.equal(body[0].url, `${nconf.get('relative_path')}/assets/uploads/system/site-logo.png`);
|
||||
done();
|
||||
@@ -350,7 +350,8 @@ describe('Upload Controllers', () => {
|
||||
it('should fail to upload invalid file type', (done) => {
|
||||
helpers.uploadFile(`${nconf.get('url')}/api/admin/category/uploadpicture`, path.join(__dirname, '../test/files/503.html'), { params: JSON.stringify({ cid: cid }) }, jar, csrf_token, (err, res, body) => {
|
||||
assert.ifError(err);
|
||||
assert.equal(body.error, '[[error:invalid-image-type, image/png, image/jpeg, image/pjpeg, image/jpg, image/gif, image/svg+xml]]');
|
||||
assert.strictEqual(res.statusCode, 500);
|
||||
assert.equal(body.error, '[[error:invalid-image-type, image/png, image/jpeg, image/pjpeg, image/jpg, image/gif, image/svg+xml]]');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -358,6 +359,7 @@ describe('Upload Controllers', () => {
|
||||
it('should fail to upload category image with invalid json params', (done) => {
|
||||
helpers.uploadFile(`${nconf.get('url')}/api/admin/category/uploadpicture`, path.join(__dirname, '../test/files/test.png'), { params: 'invalid json' }, jar, csrf_token, (err, res, body) => {
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(res.statusCode, 500);
|
||||
assert.equal(body.error, '[[error:invalid-json]]');
|
||||
done();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user