regression: Room avatar upload not working (#29185)

pull/29190/head^2
gabriellsh 3 years ago committed by GitHub
parent ef901bf487
commit ced8fccd7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      apps/meteor/app/file-upload/server/lib/FileUpload.ts
  2. 68
      apps/meteor/tests/end-to-end/api/09-rooms.js

@ -393,6 +393,10 @@ export const FileUpload = {
},
async avatarsOnFinishUpload(file: IUpload) {
if (file.rid) {
return;
}
if (!file.userId) {
throw new Meteor.Error('error-not-allowed', 'Change avatar is not allowed');
}

@ -1,3 +1,6 @@
import fs from 'fs';
import path from 'path';
import { expect } from 'chai';
import { getCredentials, api, request, credentials } from '../../data/api-data.js';
@ -1511,4 +1514,69 @@ describe('[Rooms]', function () {
.end(done);
});
});
describe('/rooms.saveRoomSettings', () => {
let testChannel;
const randomString = `randomString${Date.now()}`;
before('create a channel', async () => {
const result = await createRoom({ type: 'c', name: `channel.test.${Date.now()}-${Math.random()}` });
testChannel = result.body.channel;
});
it('should update the room settings', (done) => {
const imageDataUri = `data:image/png;base64,${fs.readFileSync(path.join(process.cwd(), imgURL)).toString('base64')}`;
request
.post(api('rooms.saveRoomSettings'))
.set(credentials)
.send({
rid: testChannel._id,
roomAvatar: imageDataUri,
featured: true,
roomName: randomString,
roomTopic: randomString,
roomAnnouncement: randomString,
roomDescription: randomString,
roomType: 'p',
readOnly: true,
reactWhenReadOnly: true,
default: true,
favorite: {
favorite: true,
defaultValue: true,
},
})
.expect('Content-Type', 'application/json')
.expect(200)
.end(done);
});
it('should have reflected on rooms.info', (done) => {
request
.get(api('rooms.info'))
.set(credentials)
.query({
roomId: testChannel._id,
})
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('room').and.to.be.an('object');
expect(res.body.room).to.have.property('_id', testChannel._id);
expect(res.body.room).to.have.property('name', randomString);
expect(res.body.room).to.have.property('topic', randomString);
expect(res.body.room).to.have.property('announcement', randomString);
expect(res.body.room).to.have.property('description', randomString);
expect(res.body.room).to.have.property('t', 'p');
expect(res.body.room).to.have.property('featured', true);
expect(res.body.room).to.have.property('ro', true);
expect(res.body.room).to.have.property('default', true);
expect(res.body.room).to.have.property('favorite', true);
expect(res.body.room).to.have.property('reactWhenReadOnly', true);
})
.end(done);
});
});
});

Loading…
Cancel
Save