This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

fix build errors and tests

+73 -16
+1 -1
src/modules/cards/application/useCases/queries/GetCollectionsForUrlUseCase.ts
··· 153 153 const collectionResult = await this.collectionRepo.findById( 154 154 collectionIdResult.value, 155 155 ); 156 - if (collectionResult.isErr()) { 156 + if (collectionResult.isErr() || !collectionResult.value) { 157 157 throw new Error(`Collection not found: ${item.id}`); 158 158 } 159 159 const collection = collectionResult.value;
+2 -2
src/modules/cards/application/useCases/queries/GetUrlCardViewUseCase.ts
··· 157 157 const collectionResult = await this.collectionRepo.findById( 158 158 collectionIdResult.value, 159 159 ); 160 - if (collectionResult.isErr()) { 160 + if (collectionResult.isErr() || !collectionResult.value) { 161 161 throw new Error(`Collection not found: ${collection.id}`); 162 162 } 163 163 const fullCollection = collectionResult.value; ··· 176 176 177 177 return { 178 178 id: collection.id, 179 - uri: fullCollection.uri, 179 + uri: fullCollection.publishedRecordId?.uri, 180 180 name: collection.name, 181 181 description: fullCollection.description?.value, 182 182 author: {
+1 -1
src/modules/cards/application/useCases/queries/GetUrlStatusForMyLibraryUseCase.ts
··· 126 126 const collectionResult = await this.collectionRepo.findById( 127 127 collectionIdResult.value, 128 128 ); 129 - if (collectionResult.isErr()) { 129 + if (collectionResult.isErr() || !collectionResult.value) { 130 130 throw new Error( 131 131 `Collection not found: ${collection.id}`, 132 132 );
+1
src/modules/cards/tests/application/GetCollectionsForUrlUseCase.test.ts
··· 784 784 const errorUseCase = new GetCollectionsForUrlUseCase( 785 785 errorCollectionQueryRepository, 786 786 profileService, 787 + collectionRepository, 787 788 ); 788 789 789 790 const query = {
+17 -6
src/modules/cards/tests/application/GetLibrariesForUrlUseCase.test.ts
··· 117 117 const result = await useCase.execute(query); 118 118 119 119 // Verify the result 120 - if (result.isErr()) { 121 - console.error('Error message:', result.error.message || result.error); 122 - fail(`Use case failed: ${result.error.message || result.error}`); 123 - } 124 120 expect(result.isOk()).toBe(true); 125 121 const response = result.unwrap(); 126 122 ··· 196 192 const response = result.unwrap(); 197 193 198 194 expect(response.libraries).toHaveLength(1); 199 - expect(response.libraries[0]!.userId).toBe(curator1.value); 200 - expect(response.libraries[0]!.cardId).toBe(card1.cardId.getStringValue()); 195 + expect(response.libraries[0]!.user.id).toBe(curator1.value); 196 + expect(response.libraries[0]!.card.id).toBe(card1.cardId.getStringValue()); 201 197 }); 202 198 }); 203 199 ··· 213 209 const curator = CuratorId.create(`did:plc:curator${i}`).unwrap(); 214 210 curators.push(curator); 215 211 212 + // Add profiles for curator4 and curator5 (curator1-3 already set up in beforeEach) 213 + if (i > 3) { 214 + profileService.addProfile({ 215 + id: curator.value, 216 + name: `Curator ${i}`, 217 + handle: `curator${i}`, 218 + avatarUrl: `https://example.com/avatar${i}.jpg`, 219 + bio: `Curator ${i} bio`, 220 + }); 221 + } 222 + 216 223 const card = new CardBuilder() 217 224 .withCuratorId(curator.value) 218 225 .withType(CardTypeEnum.URL) ··· 236 243 }; 237 244 238 245 const result1 = await useCase.execute(query1); 246 + if (result1.isErr()) { 247 + throw new Error(`Use case failed: ${result1.error.message || result1.error}`); 248 + } 239 249 expect(result1.isOk()).toBe(true); 240 250 const response1 = result1.unwrap(); 241 251 ··· 355 365 356 366 const errorUseCase = new GetLibrariesForUrlUseCase( 357 367 errorCardQueryRepository, 368 + profileService, 358 369 ); 359 370 360 371 const query = {
+5 -5
src/modules/cards/tests/application/GetUrlCardViewUseCase.test.ts
··· 156 156 // Verify collections 157 157 expect(response.collections).toHaveLength(1); 158 158 expect(response.collections[0]?.name).toBe('Reading List'); 159 - expect(response.collections[0]?.authorId).toBe(curatorId.value); 159 + expect(response.collections[0]?.author.id).toBe(curatorId.value); 160 160 161 161 // Verify note 162 162 expect(response.note).toBeDefined(); ··· 166 166 expect(response.libraries).toHaveLength(1); 167 167 168 168 const testCuratorLib = response.libraries.find( 169 - (lib) => lib.userId === curatorId.value, 169 + (lib) => lib.id === curatorId.value, 170 170 ); 171 171 expect(testCuratorLib).toBeDefined(); 172 172 expect(testCuratorLib?.name).toBe('Test Curator'); ··· 479 479 getNoteCardsForUrl: jest.fn(), 480 480 }; 481 481 482 - const errorUseCase = new GetUrlCardViewUseCase(errorRepo, profileService); 482 + const errorUseCase = new GetUrlCardViewUseCase(errorRepo, profileService, collectionRepo); 483 483 484 484 const query = { 485 485 cardId: cardId, ··· 568 568 569 569 // Verify the creator is included with correct profile data 570 570 const creatorLib = response.libraries.find( 571 - (lib) => lib.userId === userIds[0], 571 + (lib) => lib.id === userIds[0], 572 572 ); 573 573 expect(creatorLib).toBeDefined(); 574 574 expect(creatorLib?.name).toBe('User 1'); ··· 656 656 657 657 // Verify all collections have the correct author 658 658 response.collections.forEach((collection) => { 659 - expect(collection.authorId).toBe(curatorId.value); 659 + expect(collection.author.id).toBe(curatorId.value); 660 660 }); 661 661 }); 662 662
+4
src/modules/cards/tests/application/GetUrlStatusForMyLibraryUseCase.test.ts
··· 528 528 const errorUseCase = new GetUrlStatusForMyLibraryUseCase( 529 529 errorCardRepository, 530 530 collectionQueryRepository, 531 + collectionRepository, 532 + profileService, 531 533 eventPublisher, 532 534 ); 533 535 ··· 580 582 const errorUseCase = new GetUrlStatusForMyLibraryUseCase( 581 583 cardRepository, 582 584 errorCollectionQueryRepository, 585 + collectionRepository, 586 + profileService, 583 587 eventPublisher, 584 588 ); 585 589
+37 -1
src/modules/cards/tests/utils/InMemoryCardQueryRepository.ts
··· 156 156 urlInLibrary, 157 157 createdAt: card.createdAt, 158 158 updatedAt: card.updatedAt, 159 + authorId: card.curatorId.value, 159 160 collections, 160 161 note, 161 162 }; ··· 307 308 urlInLibrary: card.urlInLibrary, 308 309 createdAt: card.createdAt, 309 310 updatedAt: card.updatedAt, 311 + authorId: card.authorId, 310 312 note: card.note, 311 313 }; 312 314 } ··· 374 376 // Create library entries for each card 375 377 const libraries: LibraryForUrlDTO[] = []; 376 378 for (const card of urlCards) { 379 + // Skip cards without urlContent (should not happen since we filtered for URL cards) 380 + if (!card.content.urlContent) { 381 + continue; 382 + } 383 + 377 384 for (const membership of card.libraryMemberships) { 385 + const noteCard = allCards.find( 386 + (c) => c.isNoteCard && c.parentCardId?.equals(card.cardId), 387 + ); 388 + 389 + const urlLibraryCount = this.getUrlLibraryCount(url); 390 + 378 391 libraries.push({ 379 392 userId: membership.curatorId.value, 380 - cardId: card.cardId.getStringValue(), 393 + card: { 394 + id: card.cardId.getStringValue(), 395 + url: card.content.urlContent.url.value, 396 + cardContent: { 397 + url: card.content.urlContent.url.value, 398 + title: card.content.urlContent.metadata?.title, 399 + description: card.content.urlContent.metadata?.description, 400 + author: card.content.urlContent.metadata?.author, 401 + thumbnailUrl: card.content.urlContent.metadata?.imageUrl, 402 + }, 403 + libraryCount: this.getLibraryCountForCard( 404 + card.cardId.getStringValue(), 405 + ), 406 + urlLibraryCount, 407 + urlInLibrary: true, 408 + createdAt: card.createdAt, 409 + updatedAt: card.updatedAt, 410 + note: noteCard 411 + ? { 412 + id: noteCard.cardId.getStringValue(), 413 + text: noteCard.content.noteContent?.text || '', 414 + } 415 + : undefined, 416 + }, 381 417 }); 382 418 } 383 419 }
+5
src/shared/infrastructure/http/factories/UseCaseFactory.ts
··· 154 154 getUrlCardViewUseCase: new GetUrlCardViewUseCase( 155 155 repositories.cardQueryRepository, 156 156 services.profileService, 157 + repositories.collectionRepository, 157 158 ), 158 159 getLibrariesForCardUseCase: new GetLibrariesForCardUseCase( 159 160 repositories.cardQueryRepository, ··· 190 191 getUrlStatusForMyLibraryUseCase: new GetUrlStatusForMyLibraryUseCase( 191 192 repositories.cardRepository, 192 193 repositories.collectionQueryRepository, 194 + repositories.collectionRepository, 195 + services.profileService, 193 196 services.eventPublisher, 194 197 ), 195 198 getLibrariesForUrlUseCase: new GetLibrariesForUrlUseCase( 196 199 repositories.cardQueryRepository, 200 + services.profileService, 197 201 ), 198 202 getCollectionsForUrlUseCase: new GetCollectionsForUrlUseCase( 199 203 repositories.collectionQueryRepository, 200 204 services.profileService, 205 + repositories.collectionRepository, 201 206 ), 202 207 getNoteCardsForUrlUseCase: new GetNoteCardsForUrlUseCase( 203 208 repositories.cardQueryRepository,