2022-09-19 17:49:46 +00:00
|
|
|
import { apiCallProperties } from './apiauth';
|
|
|
|
import { ensureSomethingDoesntExist, ensureSomethingExists } from './ensure';
|
2022-04-28 10:35:02 +00:00
|
|
|
|
|
|
|
export function ensureHumanUserExists(api: apiCallProperties, username: string): Cypress.Chainable<number> {
|
2022-09-19 17:49:46 +00:00
|
|
|
return ensureSomethingExists(api, 'users/_search', (user: any) => user.userName === username, 'users/human', {
|
|
|
|
user_name: username,
|
|
|
|
profile: {
|
|
|
|
first_name: 'e2efirstName',
|
|
|
|
last_name: 'e2elastName',
|
|
|
|
},
|
|
|
|
email: {
|
|
|
|
email: 'e2e@email.ch',
|
|
|
|
},
|
|
|
|
phone: {
|
|
|
|
phone: '+41 123456789',
|
|
|
|
},
|
|
|
|
});
|
2022-04-28 10:35:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function ensureMachineUserExists(api: apiCallProperties, username: string): Cypress.Chainable<number> {
|
2022-09-19 17:49:46 +00:00
|
|
|
return ensureSomethingExists(api, 'users/_search', (user: any) => user.userName === username, 'users/machine', {
|
|
|
|
user_name: username,
|
|
|
|
name: 'e2emachinename',
|
|
|
|
description: 'e2emachinedescription',
|
|
|
|
});
|
2022-04-28 10:35:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function ensureUserDoesntExist(api: apiCallProperties, username: string): Cypress.Chainable<null> {
|
2022-09-19 17:49:46 +00:00
|
|
|
return ensureSomethingDoesntExist(
|
|
|
|
api,
|
|
|
|
'users/_search',
|
|
|
|
(user: any) => user.userName === username,
|
|
|
|
(user) => `users/${user.id}`,
|
|
|
|
);
|
2022-04-28 10:35:02 +00:00
|
|
|
}
|