diff --git a/src/modules/cards/domain/ICollectionRepository.ts b/src/modules/cards/domain/ICollectionRepository.ts index 8998d558..1f6ebf53 100644 --- a/src/modules/cards/domain/ICollectionRepository.ts +++ b/src/modules/cards/domain/ICollectionRepository.ts @@ -8,7 +8,10 @@ export interface ICollectionRepository { findById(id: CollectionId): Promise>; findByCuratorId(curatorId: CuratorId): Promise>; findByCardId(cardId: CardId): Promise>; - findByAuthorIdContainingCard(authorId: CuratorId, cardId: CardId): Promise>; + findByCuratorIdContainingCard( + authorId: CuratorId, + cardId: CardId, + ): Promise>; save(collection: Collection): Promise>; delete(collectionId: CollectionId): Promise>; } diff --git a/src/modules/cards/infrastructure/repositories/DrizzleCollectionRepository.ts b/src/modules/cards/infrastructure/repositories/DrizzleCollectionRepository.ts index 72c1feeb..ba1b21cc 100644 --- a/src/modules/cards/infrastructure/repositories/DrizzleCollectionRepository.ts +++ b/src/modules/cards/infrastructure/repositories/DrizzleCollectionRepository.ts @@ -295,7 +295,10 @@ export class DrizzleCollectionRepository implements ICollectionRepository { } } - async findByAuthorIdContainingCard(authorId: CuratorId, cardId: CardId): Promise> { + async findByCuratorIdContainingCard( + authorId: CuratorId, + cardId: CardId, + ): Promise> { try { const authorIdString = authorId.value; const cardIdString = cardId.getStringValue(); @@ -318,8 +321,8 @@ export class DrizzleCollectionRepository implements ICollectionRepository { .where( and( eq(collections.authorId, authorIdString), - eq(collectionCards.cardId, cardIdString) - ) + eq(collectionCards.cardId, cardIdString), + ), ); const domainCollections: Collection[] = []; diff --git a/src/modules/cards/tests/application/GetCollectionPageUseCase.test.ts b/src/modules/cards/tests/application/GetCollectionPageUseCase.test.ts index 6c847199..933c91c7 100644 --- a/src/modules/cards/tests/application/GetCollectionPageUseCase.test.ts +++ b/src/modules/cards/tests/application/GetCollectionPageUseCase.test.ts @@ -11,12 +11,9 @@ import { CardType, CardTypeEnum } from '../../domain/value-objects/CardType'; import { CardContent } from '../../domain/value-objects/CardContent'; import { UrlMetadata } from '../../domain/value-objects/UrlMetadata'; import { URL } from '../../domain/value-objects/URL'; -import { - CardSortField, - SortOrder, - CollectionCardQueryResultDTO, -} from '../../domain/ICardQueryRepository'; +import { CardSortField, SortOrder } from '../../domain/ICardQueryRepository'; import { UniqueEntityID } from '../../../../shared/domain/UniqueEntityID'; +import { ICollectionRepository } from '../../domain/ICollectionRepository'; describe('GetCollectionPageUseCase', () => { let useCase: GetCollectionPageUseCase; @@ -722,7 +719,7 @@ describe('GetCollectionPageUseCase', () => { it('should handle repository errors gracefully', async () => { // Create a mock collection repository that throws an error - const errorCollectionRepo = { + const errorCollectionRepo: ICollectionRepository = { findById: jest .fn() .mockRejectedValue(new Error('Database connection failed')), @@ -730,6 +727,7 @@ describe('GetCollectionPageUseCase', () => { delete: jest.fn(), findByCuratorId: jest.fn(), findByCardId: jest.fn(), + findByCuratorIdContainingCard: jest.fn(), }; const errorUseCase = new GetCollectionPageUseCase( diff --git a/src/modules/cards/tests/infrastructure/DrizzleCollectionRepository.integration.test.ts b/src/modules/cards/tests/infrastructure/DrizzleCollectionRepository.integration.test.ts index d9c649d1..4a60e1e2 100644 --- a/src/modules/cards/tests/infrastructure/DrizzleCollectionRepository.integration.test.ts +++ b/src/modules/cards/tests/infrastructure/DrizzleCollectionRepository.integration.test.ts @@ -550,10 +550,11 @@ describe('DrizzleCollectionRepository', () => { await collectionRepository.save(collection3); // Find collections by the original curator containing this card - const foundCollectionsResult = await collectionRepository.findByAuthorIdContainingCard( - curatorId, - card.cardId, - ); + const foundCollectionsResult = + await collectionRepository.findByCuratorIdContainingCard( + curatorId, + card.cardId, + ); expect(foundCollectionsResult.isOk()).toBe(true); const foundCollections = foundCollectionsResult.unwrap(); diff --git a/src/modules/cards/tests/utils/InMemoryCollectionRepository.ts b/src/modules/cards/tests/utils/InMemoryCollectionRepository.ts index 5e3845a3..718d6964 100644 --- a/src/modules/cards/tests/utils/InMemoryCollectionRepository.ts +++ b/src/modules/cards/tests/utils/InMemoryCollectionRepository.ts @@ -71,7 +71,10 @@ export class InMemoryCollectionRepository implements ICollectionRepository { } } - async findByAuthorIdContainingCard(authorId: CuratorId, cardId: CardId): Promise> { + async findByCuratorIdContainingCard( + authorId: CuratorId, + cardId: CardId, + ): Promise> { try { const collections = Array.from(this.collections.values()).filter( (collection) =>