@@ -9,11 +9,7 @@ import {
99 NotificationType
1010} from '../../../src/notifications/domain/models/Notification'
1111import { createDataset , CreatedDatasetIdentifiers } from '../../../src/datasets'
12- import {
13- publishDatasetViaApi ,
14- waitForNoLocks ,
15- deletePublishedDatasetViaApi
16- } from '../../testHelpers/datasets/datasetHelper'
12+ import { publishDatasetViaApi , waitForNoLocks } from '../../testHelpers/datasets/datasetHelper'
1713import { WriteError } from '../../../src'
1814import { createCollection } from '../../../src/collections'
1915import {
@@ -99,24 +95,7 @@ describe('NotificationsRepository', () => {
9995 expect ( notification ) . toHaveProperty ( 'displayAsRead' )
10096 } )
10197
102- test ( 'should return only unread notifications when onlyUnread is true (if any exist)' , async ( ) => {
103- const notifications : Notification [ ] = await sut . getAllNotificationsByUser ( true , true )
104-
105- expect ( Array . isArray ( notifications ) ) . toBe ( true )
106- expect ( Array . isArray ( notifications ) ) . toBe ( true )
107- expect ( notifications . every ( ( n ) => n . displayAsRead === false ) ) . toBe ( true )
108- } )
109-
110- test ( 'should paginate results using limit and offset' , async ( ) => {
111- const limit = 1
112- const page1 : Notification [ ] = await sut . getAllNotificationsByUser ( true , undefined , limit , 0 )
113- const page2 : Notification [ ] = await sut . getAllNotificationsByUser ( true , undefined , limit , 1 )
114-
115- expect ( page1 . length ) . toBeLessThanOrEqual ( limit )
116- expect ( page2 . length ) . toBeLessThanOrEqual ( limit )
117-
118- // Always run the assertion, but only if both pages have one notification each
119- expect ( page1 . length !== 1 || page2 . length !== 1 || page1 [ 0 ] . id !== page2 [ 0 ] . id ) . toBe ( true )
98+ test ( 'should find notification with ASSIGNROLE type that has not been deleted' , async ( ) => {
12099 const notifications : Notification [ ] = await sut . getAllNotificationsByUser ( true )
121100
122101 const assignRoleNotification = notifications . find (
@@ -137,46 +116,6 @@ describe('NotificationsRepository', () => {
137116 expect ( assignRoleNotification ?. roleAssignments ?. [ 0 ] ) . toHaveProperty ( 'definitionPointId' )
138117 } )
139118
140- test ( 'should generate 5+ notifications and verify pagination across pages' , async ( ) => {
141- const createdDatasets : CreatedDatasetIdentifiers [ ] = [ ]
142- try {
143- const howMany = 5
144- for ( let i = 0 ; i < howMany ; i ++ ) {
145- const ids = await createDataset . execute ( TestConstants . TEST_NEW_DATASET_DTO )
146- createdDatasets . push ( ids )
147- await publishDatasetViaApi ( ids . numericId )
148- await waitForNoLocks ( ids . numericId , 10 )
149- }
150-
151- const limit = 5
152- const page1 : Notification [ ] = await sut . getAllNotificationsByUser ( true , undefined , limit , 0 )
153- const page2 : Notification [ ] = await sut . getAllNotificationsByUser ( true , undefined , limit , 5 )
154- const page3 : Notification [ ] = await sut . getAllNotificationsByUser ( true , undefined , limit , 10 )
155- expect ( page1 . length ) . toBeLessThanOrEqual ( limit )
156- expect ( page2 . length ) . toBeLessThanOrEqual ( limit )
157- expect ( page3 . length ) . toBeLessThanOrEqual ( limit )
158-
159- const ids1 = new Set ( page1 . map ( ( n ) => n . id ) )
160- const ids2 = new Set ( page2 . map ( ( n ) => n . id ) )
161- const ids3 = new Set ( page3 . map ( ( n ) => n . id ) )
162-
163- const intersects = ( a : Set < number > , b : Set < number > ) : boolean => {
164- for ( const x of a ) {
165- if ( b . has ( x ) ) return true
166- }
167- return false
168- }
169-
170- expect ( page1 . length === 0 || page2 . length === 0 || ! intersects ( ids1 , ids2 ) ) . toBe ( true )
171- expect ( page1 . length === 0 || page3 . length === 0 || ! intersects ( ids1 , ids3 ) ) . toBe ( true )
172- expect ( page2 . length === 0 || page3 . length === 0 || ! intersects ( ids2 , ids3 ) ) . toBe ( true )
173- } finally {
174- for ( const d of createdDatasets ) {
175- await deletePublishedDatasetViaApi ( d . persistentId )
176- }
177- }
178- } )
179-
180119 test ( 'should create a collection and find the notification with CREATEDV type' , async ( ) => {
181120 const testCollectionAlias = 'test-notification-collection'
182121 const createdCollectionId = await createCollection . execute (
0 commit comments