add explicit unset for the image routes

the initial motivation was to fix up the profile avatar rule which
had a mix of json or multipart. this style does not work well with
express 5
This commit is contained in:
Girish Ramakrishnan
2025-06-06 18:36:58 +02:00
parent 4ffff84540
commit 344782099f
7 changed files with 142 additions and 22 deletions
+39
View File
@@ -373,6 +373,45 @@ describe('Profile API', function () {
});
});
describe('background', function () {
it('no default', async function () {
const response = await superagent.get(`${serverUrl}/api/v1/profile/background_image`)
.query({ access_token: user.token })
.ok(() => true);
expect(response.status).to.be(404);
});
it('can set custom background', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/profile/background_image`)
.query({ access_token: user.token })
.attach('backgroundImage', './logo.png');
expect(response.status).to.be(200);
});
it('did set custom background', async function () {
const response2 = await superagent.get(`${serverUrl}/api/v1/profile/background_image`)
.query({ access_token: user.token })
.ok(() => true);
const customAvatarSize = require('fs').readFileSync('./logo.png').length;
expect(parseInt(response2.headers['content-length'])).to.equal(customAvatarSize);
expect(response2.status).to.equal(200);
});
it('can unset background', async function () {
const response = await superagent.del(`${serverUrl}/api/v1/profile/background_image`)
.query({ access_token: user.token });
expect(response.status).to.be(200);
const response2 = await superagent.get(`${serverUrl}/api/v1/profile/background_image`)
.query({ access_token: user.token })
.ok(() => true);
expect(response2.status).to.be(404);
});
});
describe('language', function () {
it('fails to set unknown language', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/profile/language`)