Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions apps/meteor/tests/end-to-end/api/06-outgoing-integrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getCredentials, api, request, credentials } from '../../data/api-data.j
import { createIntegration, removeIntegration } from '../../data/integration.helper';
import { updatePermission } from '../../data/permissions.helper';
import { password } from '../../data/user';
import { createUser, login } from '../../data/users.helper';
import { createUser, deleteUser, login } from '../../data/users.helper';

describe('[Outgoing Integrations]', function () {
this.retries(0);
Expand All @@ -16,22 +16,24 @@ describe('[Outgoing Integrations]', function () {
let userCredentials;

before((done) => getCredentials(done));

before((done) => {
updatePermission('manage-incoming-integrations', [])
.then(() => updatePermission('manage-own-incoming-integrations', []))
.then(() => updatePermission('manage-own-outgoing-integrations', []))
.then(() => updatePermission('manage-outgoing-integrations', []))
.then(done);
before(async () => {
await Promise.all([
updatePermission('manage-incoming-integrations', []),
updatePermission('manage-own-incoming-integrations', []),
updatePermission('manage-own-outgoing-integrations', []),
updatePermission('manage-outgoing-integrations', []),
]);
});

after((done) => {
updatePermission('manage-incoming-integrations', ['admin'])
.then(() => updatePermission('manage-own-incoming-integrations', ['admin']))
.then(() => updatePermission('manage-own-outgoing-integrations', ['admin']))
.then(() => updatePermission('manage-outgoing-integrations', ['admin']))
.then(done);
});
after(async () =>
Promise.all([
updatePermission('manage-incoming-integrations', ['admin']),
updatePermission('manage-own-incoming-integrations', ['admin']),
updatePermission('manage-own-outgoing-integrations', ['admin']),
updatePermission('manage-outgoing-integrations', ['admin']),
deleteUser(user),
Comment thread
MarcosSpessatto marked this conversation as resolved.
]),
);

describe('[/integrations.create]', () => {
it('should return an error when the user DOES NOT have the permission "manage-outgoing-integrations" to add an outgoing integration', (done) => {
Expand Down Expand Up @@ -183,6 +185,7 @@ describe('[Outgoing Integrations]', function () {
});

it('should create an outgoing integration successfully', (done) => {
let integrationId;
request
.post(api('integrations.create'))
.set(credentials)
Expand All @@ -204,14 +207,14 @@ describe('[Outgoing Integrations]', function () {
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
integration._id = res.body.integration._id;
expect(res.body).to.have.nested.property('integration.name', 'Guggy');
expect(res.body).to.have.nested.property('integration.type', 'webhook-outgoing');
expect(res.body).to.have.nested.property('integration.enabled', true);
expect(res.body).to.have.nested.property('integration.username', 'rocket.cat');
expect(res.body).to.have.nested.property('integration.event', 'sendMessage');
integrationId = res.body.integration._id;
})
.end(done);
.end(() => removeIntegration(integrationId, 'outgoing').then(done));
});
});

Expand Down