|
|
|
|
@ -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); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|