Skip to content

Commit 8d571f3

Browse files
committed
fix tests and remove logs
1 parent 7e86b76 commit 8d571f3

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

src/notifications/infra/repositories/NotificationsRepository.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,12 @@ export class NotificationsRepository extends ApiRepository implements INotificat
1919
if (onlyUnread) queryParams.set('onlyUnread', 'true')
2020
if (limit !== undefined) queryParams.set('limit', limit.toString())
2121
if (offset !== undefined) queryParams.set('offset', offset.toString())
22-
console.log('Fetching notifications with params:', queryParams.toString())
23-
console.log('keys:', Array.from(queryParams.keys()))
24-
console.log('length:', Object.keys(queryParams).length)
2522
return this.doGet(
2623
this.buildApiEndpoint(this.notificationsResourceName, 'all'),
2724
true,
2825
queryParams
2926
)
3027
.then((response) => {
31-
console.log('Notifications API response:', response.data)
3228
const notifications = response.data.data.map((notification: NotificationPayload) => {
3329
const { dataverseDisplayName, dataverseAlias, ...restNotification } = notification
3430
return {

test/functional/notifications/DeleteNotification.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ describe('execute', () => {
2020

2121
const notificationsAfterDeleteSubset = await getAllNotificationsByUser.execute()
2222
const notificationsAfterDelete = notificationsAfterDeleteSubset.notifications
23-
expect(notificationsAfterDelete.length).toBe(notifications.length - 1)
23+
const deletedExists = notificationsAfterDelete.some((n) => n.id === notificationId)
24+
expect(deletedExists).toBe(false)
2425
})
2526

2627
test('should throw an error when the notification id does not exist', async () => {

test/integration/notifications/NotificationsRepository.test.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -189,22 +189,16 @@ describe('NotificationsRepository', () => {
189189
const notificationSubset: NotificationSubset = await sut.getAllNotificationsByUser(true, true)
190190

191191
expect(Array.isArray(notificationSubset.notifications)).toBe(true)
192-
const originalUnreadCount = notificationSubset.totalNotificationCount
193192
expect(notificationSubset.notifications.length).toBeGreaterThanOrEqual(0)
193+
const notificationToMarkRead = notificationSubset.notifications[0]
194+
await expect(sut.markNotificationAsRead(notificationToMarkRead.id)).resolves.toBeUndefined()
194195

195-
await expect(
196-
sut.markNotificationAsRead(notificationSubset.notifications[0].id)
197-
).resolves.toBeUndefined()
198-
199-
const updatedNotifications: NotificationSubset = await sut.getAllNotificationsByUser(
200-
true,
201-
true,
202-
10,
203-
0
196+
const updatedNotifications: NotificationSubset = await sut.getAllNotificationsByUser(true, true)
197+
const stillPresent = updatedNotifications.notifications.some(
198+
(n) => n.id === notificationToMarkRead.id
204199
)
205-
expect(updatedNotifications.totalNotificationCount).toBe(originalUnreadCount - 1)
206-
207-
const hasReadNotifications = notificationSubset.notifications.some(
200+
expect(stillPresent).toBe(false)
201+
const hasReadNotifications = updatedNotifications.notifications.some(
208202
(n) => n.displayAsRead === true
209203
)
210204
expect(hasReadNotifications).toBe(false)

0 commit comments

Comments
 (0)