From 85998e1f9988fd7ca1ace63bba80d970ed5849c5 Mon Sep 17 00:00:00 2001 From: Patrick Sachmann <20001160+psachmann@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:10:19 +0200 Subject: [PATCH] EW-893 fixing unit test --- .../src/modules/account/api/test/account.api.spec.ts | 10 +++++----- .../src/modules/account/testing/account.factory.ts | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/server/src/modules/account/api/test/account.api.spec.ts b/apps/server/src/modules/account/api/test/account.api.spec.ts index e5ee1b94c2..10c8157c83 100644 --- a/apps/server/src/modules/account/api/test/account.api.spec.ts +++ b/apps/server/src/modules/account/api/test/account.api.spec.ts @@ -1,10 +1,12 @@ import { EntityManager } from '@mikro-orm/mongodb'; +import { ServerTestModule } from '@modules/server/server.module'; import { INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { User } from '@shared/domain/entity'; import { Permission, RoleName } from '@shared/domain/interface'; import { TestApiClient, cleanupCollections, roleFactory, schoolEntityFactory, userFactory } from '@shared/testing'; -import { ServerTestModule } from '@modules/server/server.module'; +import { AccountEntity } from '../../domain/entity/account.entity'; +import { accountFactory } from '../../testing'; import { AccountByIdBodyParams, AccountSearchQueryParams, @@ -12,8 +14,6 @@ import { PatchMyAccountParams, PatchMyPasswordParams, } from '../dto'; -import { AccountEntity } from '../../domain/entity/account.entity'; -import { accountFactory } from '../../testing'; describe('Account Controller (API)', () => { const basePath = '/account'; @@ -495,8 +495,8 @@ describe('Account Controller (API)', () => { const studentUser = userFactory.buildWithId({ school, roles: [studentRoles] }); const superheroUser = userFactory.buildWithId({ roles: [superheroRoles] }); - const studentAccount = mapUserToAccount(studentUser); - const superheroAccount = mapUserToAccount(superheroUser); + const studentAccount = accountFactory.withUser(studentUser).build(); + const superheroAccount = accountFactory.withUser(superheroUser).build(); em.persist(school); em.persist([studentRoles, superheroRoles]); diff --git a/apps/server/src/modules/account/testing/account.factory.ts b/apps/server/src/modules/account/testing/account.factory.ts index 8c8177f1a9..0cfa746e4c 100644 --- a/apps/server/src/modules/account/testing/account.factory.ts +++ b/apps/server/src/modules/account/testing/account.factory.ts @@ -3,9 +3,9 @@ import { User } from '@shared/domain/entity'; import { EntityId } from '@shared/domain/types'; import { ObjectId } from '@mikro-orm/mongodb'; -import { DeepPartial } from 'fishery'; -import { AccountEntity, IdmAccountProperties } from '@src/modules/account/domain/entity/account.entity'; import { BaseFactory } from '@shared/testing/factory/base.factory'; +import { AccountEntity, IdmAccountProperties } from '@src/modules/account/domain/entity/account.entity'; +import { DeepPartial } from 'fishery'; export const defaultTestPassword = 'DummyPasswd!1'; export const defaultTestPasswordHash = '$2a$10$/DsztV5o6P5piW2eWJsxw.4nHovmJGBA.QNwiTmuZ/uvUc40b.Uhu'; @@ -58,7 +58,7 @@ class AccountFactory extends BaseFactory { // !!! important username should not be contain a space !!! export const accountFactory = AccountFactory.define(AccountEntity, ({ sequence }) => { return { - username: `account${sequence}`, + username: `account#${sequence}@example.tld`, password: defaultTestPasswordHash, userId: new ObjectId(), };