feat: refs #6273 add back test
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-06-05 17:38:48 +02:00
parent 8188bdbcb0
commit 14afd8246a
2 changed files with 16 additions and 1 deletions

View File

@ -134,12 +134,14 @@ module.exports = Self => {
if (isFreelance || !client) { if (isFreelance || !client) {
const [{password}] = await models.Worker.rawSql('SELECT account.passwordGenerate() as password;'); const [{password}] = await models.Worker.rawSql('SELECT account.passwordGenerate() as password;');
const freelancer = isFreelance && await models.VnRole.findOne({fields: ['id'], where: {name: 'freelancer'}});
user = await models.VnUser.create({ user = await models.VnUser.create({
name, name,
nickname, nickname,
password, password,
email, email,
roleFk, roleFk: freelancer ? freelancer.id : roleFk,
}, myOptions); }, myOptions);
await models.Account.create({ await models.Account.create({

View File

@ -97,6 +97,19 @@ describe('Worker new', () => {
await models.Worker.destroyById(newWorker.id); await models.Worker.destroyById(newWorker.id);
} }
}); });
it('should create a new external worker', async() => {
let newWorker;
try {
newWorker = await createWorker(ctx, undefined, {isFreelance: true});
const client = await models.Client.findById(newWorker.id);
expect(newWorker.id).toBeDefined();
expect(client).toBeNull();
} finally {
await removeWorker(newWorker.id);
}
});
}); });
async function removeWorker(id) { async function removeWorker(id) {