Skip to content

Commit

Permalink
test: add cleanup to users tests (#30654)
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego authored and debdutdeb committed Oct 26, 2023
1 parent 1525935 commit c2151e8
Show file tree
Hide file tree
Showing 5 changed files with 275 additions and 247 deletions.
9 changes: 4 additions & 5 deletions apps/meteor/tests/data/api-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export function wait(cb, time) {
return () => setTimeout(cb, time);
}

export const apiUsername = `api${username}`;
export const apiEmail = `api${email}`;
export const apiPublicChannelName = `api${publicChannelName}`;
export const apiPrivateChannelName = `api${privateChannelName}`;
export const apiUsername = `api${username}-${Date.now()}`;
export const apiEmail = `api${email}-${Date.now()}`;
export const apiPublicChannelName = `api${publicChannelName}-${Date.now()}`;
export const apiPrivateChannelName = `api${privateChannelName}-${Date.now()}`;

export const apiRoleNameUsers = `api${roleNameUsers}`;
export const apiRoleNameSubscriptions = `api${roleNameSubscriptions}`;
Expand All @@ -25,7 +25,6 @@ export const apiRoleScopeSubscriptions = `${roleScopeSubscriptions}`;
export const apiRoleDescription = `api${roleDescription}`;
export const reservedWords = ['admin', 'administrator', 'system', 'user'];

export const targetUser = {};
export const channel = {};
export const group = {};
export const message = {};
Expand Down
18 changes: 6 additions & 12 deletions apps/meteor/tests/data/custom-fields.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCredentials, request, api, credentials } from './api-data.js';
import { credentials, request, api } from './api-data.js';

export const customFieldText = {
type: 'text',
Expand All @@ -7,18 +7,12 @@ export const customFieldText = {
maxLength: 10,
};

export function setCustomFields(customFields, done) {
getCredentials((error) => {
if (error) {
return done(error);
}
export function setCustomFields(customFields) {
const stringified = customFields ? JSON.stringify(customFields) : '';

const stringified = customFields ? JSON.stringify(customFields) : '';

request.post(api('settings/Accounts_CustomFields')).set(credentials).send({ value: stringified }).expect(200).end(done);
});
return request.post(api('settings/Accounts_CustomFields')).set(credentials).send({ value: stringified }).expect(200);
}

export function clearCustomFields(done = () => {}) {
setCustomFields(null, done);
export function clearCustomFields() {
return setCustomFields(null);
}
17 changes: 7 additions & 10 deletions apps/meteor/tests/data/users.helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,13 @@ export const login = (username, password) =>
});
});

export const deleteUser = (user) =>
new Promise((resolve) => {
request
.post(api('users.delete'))
.set(credentials)
.send({
userId: user._id,
})
.end(resolve);
});
export const deleteUser = async (user) =>
request
.post(api('users.delete'))
.set(credentials)
.send({
userId: user._id,
});

export const getUserByUsername = (username) =>
new Promise((resolve) => {
Expand Down
Loading

0 comments on commit c2151e8

Please sign in to comment.