0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Added missing error messages for members uploader

fix https://linear.app/tryghost/issue/SLO-97/missing-messages-for-members-file-upload

- these were missing, so if the members importer wasn't given a file, it
  would crash with an HTTP 500 error
- also added a test to ensure we get a 422 back
This commit is contained in:
Daniel Lockyer 2024-05-06 15:00:47 +02:00 committed by Daniel Lockyer
parent 5a8145139a
commit a50bb8d79e
2 changed files with 16 additions and 0 deletions

View file

@ -24,6 +24,10 @@ const messages = {
missingFile: 'Please select a theme.',
invalidFile: 'Please select a valid zip file.'
},
members: {
missingFile: 'Please select a members CSV file.',
invalidFile: 'Please select a valid CSV file.'
},
images: {
missingFile: 'Please select an image.',
invalidFile: 'Please select a valid image.'

View file

@ -1,4 +1,5 @@
const path = require('path');
const assert = require('assert/strict');
const should = require('should');
const supertest = require('supertest');
const testUtils = require('../../utils');
@ -312,4 +313,15 @@ describe('Members Importer API', function () {
postLabelRemoveBrowseResponse.body.members.should.have.length(0);
});
it('Can handle empty body', async function () {
const res = await request
.post(localUtils.API.getApiQuery(`members/upload/`))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(422);
assert.equal(res.body.errors[0].message, 'Please select a members CSV file.');
});
});