diff --git a/apps/server/src/modules/board/repo/board-node.repo.spec.ts b/apps/server/src/modules/board/repo/board-node.repo.spec.ts index 3fff1732105..656d751f01d 100644 --- a/apps/server/src/modules/board/repo/board-node.repo.spec.ts +++ b/apps/server/src/modules/board/repo/board-node.repo.spec.ts @@ -1,6 +1,6 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; -// import { ColumnBoardNode } from '@shared/domain'; +import { ColumnBoardNode } from '@shared/domain'; import { MongoMemoryDatabaseModule } from '@shared/infra/database'; import { cardNodeFactory, @@ -208,7 +208,7 @@ describe('BoardNodeRepo', () => { }); }); }); - /* BC-5162 - avoid race condition due to unit of work + describe('findById', () => { describe('when boardNode exists in the database but NOT in the unit-of-work', () => { it('should return an equal object', async () => { @@ -236,5 +236,4 @@ describe('BoardNodeRepo', () => { }); }); }); - */ }); diff --git a/apps/server/src/modules/board/repo/board-node.repo.ts b/apps/server/src/modules/board/repo/board-node.repo.ts index 1f3f9b7eb03..65e57624dc9 100644 --- a/apps/server/src/modules/board/repo/board-node.repo.ts +++ b/apps/server/src/modules/board/repo/board-node.repo.ts @@ -7,7 +7,12 @@ export class BoardNodeRepo { constructor(private readonly em: EntityManager) {} async findById(id: EntityId): Promise { - const entity = await this.em.findOneOrFail(BoardNode, id); + let entity = this.em.getUnitOfWork().getById(BoardNode.name, id); + if (entity) { + return entity; + } + + entity = await this.em.findOneOrFail(BoardNode, id); return entity; }