From a4f193fea58aa43d1fedb1ba4b5ddf1a19e63af6 Mon Sep 17 00:00:00 2001 From: Marcos Spessatto Defendi Date: Wed, 7 Feb 2024 17:04:59 -0300 Subject: [PATCH] test: make incoming integration fully independent (#31657) --- .../api/07-incoming-integrations.js | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/apps/meteor/tests/end-to-end/api/07-incoming-integrations.js b/apps/meteor/tests/end-to-end/api/07-incoming-integrations.js index b6eff60393e5..37ce98ade6c5 100644 --- a/apps/meteor/tests/end-to-end/api/07-incoming-integrations.js +++ b/apps/meteor/tests/end-to-end/api/07-incoming-integrations.js @@ -4,9 +4,9 @@ import { after, before, describe, it } from 'mocha'; import { getCredentials, api, request, credentials } from '../../data/api-data.js'; import { createIntegration, removeIntegration } from '../../data/integration.helper'; import { updatePermission } from '../../data/permissions.helper'; -import { createRoom } from '../../data/rooms.helper.js'; +import { createRoom, deleteRoom } from '../../data/rooms.helper.js'; import { password } from '../../data/user'; -import { createUser, login } from '../../data/users.helper'; +import { createUser, deleteUser, login } from '../../data/users.helper'; describe('[Incoming Integrations]', function () { this.retries(0); @@ -20,27 +20,28 @@ describe('[Incoming Integrations]', function () { 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', [])); + before(async () => { + await Promise.all([ + updatePermission('manage-incoming-integrations', []), + updatePermission('manage-own-incoming-integrations', []), + updatePermission('manage-own-outgoing-integrations', []), + updatePermission('manage-outgoing-integrations', []), + ]); testChannelName = `channel.test.${Date.now()}-${Math.random()}`; - createRoom({ type: 'c', name: testChannelName }).end((err, res) => { - channel = res.body.channel; - - return done(); - }); + channel = (await createRoom({ type: 'c', name: testChannelName })).body.channel; }); - 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 () => { + await Promise.all([ + updatePermission('manage-incoming-integrations', ['admin']), + updatePermission('manage-own-incoming-integrations', ['admin']), + updatePermission('manage-own-outgoing-integrations', ['admin']), + updatePermission('manage-outgoing-integrations', ['admin']), + deleteRoom({ type: 'c', roomId: channel._id }), + deleteUser(user), + ]); }); describe('[/integrations.create]', () => {