Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add cleanup to users tests #30654

Merged
merged 4 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading