alpha
Login
or
Join now
nandi.uk
/
semble
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
fix build errors and tests
author
Wesley Finck
date
9 months ago
(Oct 20, 2025, 4:59 PM -0700)
commit
678e8cd7
678e8cd70939f6deef96e113c10f60fff499a458
parent
7a5073c6
7a5073c6c78130e3d294ce44ca315bfc2b6b021e
+73
-16
9 changed files
Expand all
Collapse all
Unified
Split
src
modules
cards
application
useCases
queries
GetCollectionsForUrlUseCase.ts
GetUrlCardViewUseCase.ts
GetUrlStatusForMyLibraryUseCase.ts
tests
application
GetCollectionsForUrlUseCase.test.ts
GetLibrariesForUrlUseCase.test.ts
GetUrlCardViewUseCase.test.ts
GetUrlStatusForMyLibraryUseCase.test.ts
utils
InMemoryCardQueryRepository.ts
shared
infrastructure
http
factories
UseCaseFactory.ts
+1
-1
src/modules/cards/application/useCases/queries/GetCollectionsForUrlUseCase.ts
View file
Reviewed
···
153
153
const collectionResult = await this.collectionRepo.findById(
154
154
collectionIdResult.value,
155
155
);
156
156
-
if (collectionResult.isErr()) {
156
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
View file
Reviewed
···
157
157
const collectionResult = await this.collectionRepo.findById(
158
158
collectionIdResult.value,
159
159
);
160
160
-
if (collectionResult.isErr()) {
160
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
179
-
uri: fullCollection.uri,
179
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
View file
Reviewed
···
126
126
const collectionResult = await this.collectionRepo.findById(
127
127
collectionIdResult.value,
128
128
);
129
129
-
if (collectionResult.isErr()) {
129
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
View file
Reviewed
···
784
784
const errorUseCase = new GetCollectionsForUrlUseCase(
785
785
errorCollectionQueryRepository,
786
786
profileService,
787
787
+
collectionRepository,
787
788
);
788
789
789
790
const query = {
+17
-6
src/modules/cards/tests/application/GetLibrariesForUrlUseCase.test.ts
View file
Reviewed
···
117
117
const result = await useCase.execute(query);
118
118
119
119
// Verify the result
120
120
-
if (result.isErr()) {
121
121
-
console.error('Error message:', result.error.message || result.error);
122
122
-
fail(`Use case failed: ${result.error.message || result.error}`);
123
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
199
-
expect(response.libraries[0]!.userId).toBe(curator1.value);
200
200
-
expect(response.libraries[0]!.cardId).toBe(card1.cardId.getStringValue());
195
195
+
expect(response.libraries[0]!.user.id).toBe(curator1.value);
196
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
212
+
// Add profiles for curator4 and curator5 (curator1-3 already set up in beforeEach)
213
213
+
if (i > 3) {
214
214
+
profileService.addProfile({
215
215
+
id: curator.value,
216
216
+
name: `Curator ${i}`,
217
217
+
handle: `curator${i}`,
218
218
+
avatarUrl: `https://example.com/avatar${i}.jpg`,
219
219
+
bio: `Curator ${i} bio`,
220
220
+
});
221
221
+
}
222
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
246
+
if (result1.isErr()) {
247
247
+
throw new Error(`Use case failed: ${result1.error.message || result1.error}`);
248
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
368
+
profileService,
358
369
);
359
370
360
371
const query = {
+5
-5
src/modules/cards/tests/application/GetUrlCardViewUseCase.test.ts
View file
Reviewed
···
156
156
// Verify collections
157
157
expect(response.collections).toHaveLength(1);
158
158
expect(response.collections[0]?.name).toBe('Reading List');
159
159
-
expect(response.collections[0]?.authorId).toBe(curatorId.value);
159
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
169
-
(lib) => lib.userId === curatorId.value,
169
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
482
-
const errorUseCase = new GetUrlCardViewUseCase(errorRepo, profileService);
482
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
571
-
(lib) => lib.userId === userIds[0],
571
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
659
-
expect(collection.authorId).toBe(curatorId.value);
659
659
+
expect(collection.author.id).toBe(curatorId.value);
660
660
});
661
661
});
662
662
+4
src/modules/cards/tests/application/GetUrlStatusForMyLibraryUseCase.test.ts
View file
Reviewed
···
528
528
const errorUseCase = new GetUrlStatusForMyLibraryUseCase(
529
529
errorCardRepository,
530
530
collectionQueryRepository,
531
531
+
collectionRepository,
532
532
+
profileService,
531
533
eventPublisher,
532
534
);
533
535
···
580
582
const errorUseCase = new GetUrlStatusForMyLibraryUseCase(
581
583
cardRepository,
582
584
errorCollectionQueryRepository,
585
585
+
collectionRepository,
586
586
+
profileService,
583
587
eventPublisher,
584
588
);
585
589
+37
-1
src/modules/cards/tests/utils/InMemoryCardQueryRepository.ts
View file
Reviewed
···
156
156
urlInLibrary,
157
157
createdAt: card.createdAt,
158
158
updatedAt: card.updatedAt,
159
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
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
379
+
// Skip cards without urlContent (should not happen since we filtered for URL cards)
380
380
+
if (!card.content.urlContent) {
381
381
+
continue;
382
382
+
}
383
383
+
377
384
for (const membership of card.libraryMemberships) {
385
385
+
const noteCard = allCards.find(
386
386
+
(c) => c.isNoteCard && c.parentCardId?.equals(card.cardId),
387
387
+
);
388
388
+
389
389
+
const urlLibraryCount = this.getUrlLibraryCount(url);
390
390
+
378
391
libraries.push({
379
392
userId: membership.curatorId.value,
380
380
-
cardId: card.cardId.getStringValue(),
393
393
+
card: {
394
394
+
id: card.cardId.getStringValue(),
395
395
+
url: card.content.urlContent.url.value,
396
396
+
cardContent: {
397
397
+
url: card.content.urlContent.url.value,
398
398
+
title: card.content.urlContent.metadata?.title,
399
399
+
description: card.content.urlContent.metadata?.description,
400
400
+
author: card.content.urlContent.metadata?.author,
401
401
+
thumbnailUrl: card.content.urlContent.metadata?.imageUrl,
402
402
+
},
403
403
+
libraryCount: this.getLibraryCountForCard(
404
404
+
card.cardId.getStringValue(),
405
405
+
),
406
406
+
urlLibraryCount,
407
407
+
urlInLibrary: true,
408
408
+
createdAt: card.createdAt,
409
409
+
updatedAt: card.updatedAt,
410
410
+
note: noteCard
411
411
+
? {
412
412
+
id: noteCard.cardId.getStringValue(),
413
413
+
text: noteCard.content.noteContent?.text || '',
414
414
+
}
415
415
+
: undefined,
416
416
+
},
381
417
});
382
418
}
383
419
}
+5
src/shared/infrastructure/http/factories/UseCaseFactory.ts
View file
Reviewed
···
154
154
getUrlCardViewUseCase: new GetUrlCardViewUseCase(
155
155
repositories.cardQueryRepository,
156
156
services.profileService,
157
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
194
+
repositories.collectionRepository,
195
195
+
services.profileService,
193
196
services.eventPublisher,
194
197
),
195
198
getLibrariesForUrlUseCase: new GetLibrariesForUrlUseCase(
196
199
repositories.cardQueryRepository,
200
200
+
services.profileService,
197
201
),
198
202
getCollectionsForUrlUseCase: new GetCollectionsForUrlUseCase(
199
203
repositories.collectionQueryRepository,
200
204
services.profileService,
205
205
+
repositories.collectionRepository,
201
206
),
202
207
getNoteCardsForUrlUseCase: new GetNoteCardsForUrlUseCase(
203
208
repositories.cardQueryRepository,