The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/tests/end-to-end/api/14-assets.js

81 lines
2.0 KiB

import { expect } from 'chai';
import {
getCredentials,
api,
request,
credentials,
} from '../../data/api-data.js';
import { imgURL } from '../../data/interactions.js';
describe('[Assets]', function() {
this.retries(0);
before((done) => getCredentials(done));
it('giving "manage-assets" permission to user', (done) => {
request.post(api('permissions.update'))
.set(credentials)
.send({ permissions: [{ _id: 'manage-assets', roles: ['admin'] }] })
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
})
.end(done);
});
describe('[/assets.setAsset]', () => {
it('should set the "logo" asset', (done) => {
request.post(api('assets.setAsset'))
.set(credentials)
.attach('logo', imgURL)
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
})
.end(done);
});
it('should throw an error when we try set an invalid asset', (done) => {
request.post(api('assets.setAsset'))
.set(credentials)
.attach('invalidAsset', imgURL)
.expect('Content-Type', 'application/json')
.expect(400)
.expect((res) => {
expect(res.body).to.have.property('success', false);
})
.end(done);
});
});
describe('[/assets.unsetAsset]', () => {
it('should unset the "logo" asset', (done) => {
request.post(api('assets.unsetAsset'))
.set(credentials)
.send({
assetName: 'logo',
})
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
})
.end(done);
});
it('should throw an error when we try set an invalid asset', (done) => {
request.post(api('assets.unsetAsset'))
.set(credentials)
.send({
assetName: 'invalidAsset',
})
.expect('Content-Type', 'application/json')
.expect(400)
.expect((res) => {
expect(res.body).to.have.property('success', false);
})
.end(done);
});
});
});