Skip to content

Commit 40189c8

Browse files
committed
add integration tests
1 parent 967a016 commit 40189c8

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

test/environment/.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
POSTGRES_VERSION=17
22
DATAVERSE_DB_USER=dataverse
33
SOLR_VERSION=9.8.0
4-
DATAVERSE_IMAGE_REGISTRY=docker.io
5-
DATAVERSE_IMAGE_TAG=unstable
4+
DATAVERSE_IMAGE_REGISTRY=ghcr.io
5+
DATAVERSE_IMAGE_TAG=11852-notifs-api-pagination-unread
66
DATAVERSE_BOOTSTRAP_TIMEOUT=5m

test/integration/collections/CollectionsRepository.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ describe('CollectionsRepository', () => {
13811381
})
13821382

13831383
it('should return error when the dvObjectIdentifier of a file does not exist', async () => {
1384-
const invalidFileId = '99'
1384+
const invalidFileId = '99999999'
13851385
const newFeaturedItems: DvObjectFeaturedItemDTO[] = [
13861386
{
13871387
type: FeaturedItemType.FILE,

test/integration/notifications/NotificationsRepository.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,26 @@ describe('NotificationsRepository', () => {
183183
expectedError
184184
)
185185
})
186+
test('should only return unread notifications when onlyUnread is true', async () => {
187+
const notifications: Notification[] = await sut.getAllNotificationsByUser(true, true)
188+
189+
expect(Array.isArray(notifications)).toBe(true)
190+
const originalUnreadCount = notifications.length
191+
expect(notifications.length).toBeGreaterThanOrEqual(0)
192+
193+
await expect(sut.markNotificationAsRead(notifications[0].id)).resolves.toBeUndefined()
194+
195+
const updatedNotifications: Notification[] = await sut.getAllNotificationsByUser(true, true)
196+
expect(updatedNotifications.length).toBe(originalUnreadCount - 1)
197+
198+
const hasReadNotifications = notifications.some((n) => n.displayAsRead === true)
199+
expect(hasReadNotifications).toBe(false)
200+
})
201+
test('should return limited number of notifications when limit is set', async () => {
202+
const limit = 1
203+
const notifications: Notification[] = await sut.getAllNotificationsByUser(true, false, limit, 0)
204+
205+
expect(Array.isArray(notifications)).toBe(true)
206+
expect(notifications.length).toBeLessThanOrEqual(limit)
207+
})
186208
})

0 commit comments

Comments
 (0)