@@ -63,6 +63,7 @@ describe('Notification Registry and Unified Subscription', () => {
6363
6464 // Clean up after each test
6565 afterEach ( async ( ) => {
66+ // Stop and drop registry first
6667 if ( registry ) {
6768 try {
6869 await registry . stop ( ) ;
@@ -72,6 +73,7 @@ describe('Notification Registry and Unified Subscription', () => {
7273 }
7374 }
7475
76+ // Dispose trigger manager
7577 if ( triggerManager ) {
7678 try {
7779 await triggerManager . dispose ( ) ;
@@ -81,42 +83,7 @@ describe('Notification Registry and Unified Subscription', () => {
8183 triggerManager = null ;
8284 }
8385
84- // Drop triggers manually with proper names
85- const tables = [ 'Item' , 'List' , 'uwu_table' , 'User' ] ;
86- for ( const triggerName of activeTriggerNames ) {
87- for ( const table of tables ) {
88- try {
89- await pgClient ! . unsafe (
90- `DROP TRIGGER IF EXISTS "${ triggerName } " ON "${ table } ";`
91- ) ;
92- } catch ( error ) {
93- // Ignore errors if triggers don't exist
94- }
95- }
96- }
97-
98- // Also drop any triggers that might have been created with define()
99- const commonTriggerNames = [
100- 'item_created_trigger' ,
101- 'item_status_changed_trigger' ,
102- 'item_completed_trigger' ,
103- 'trigger_one_trigger' ,
104- 'trigger_two_trigger' ,
105- 'trigger_three_trigger'
106- ] ;
107-
108- for ( const triggerName of commonTriggerNames ) {
109- for ( const table of tables ) {
110- try {
111- await pgClient ! . unsafe (
112- `DROP TRIGGER IF EXISTS "${ triggerName } " ON "${ table } ";`
113- ) ;
114- } catch ( error ) {
115- // Ignore errors if triggers don't exist
116- }
117- }
118- }
119-
86+ // Clear state
12087 activeTriggerNames = [ ] ;
12188 registry = null ;
12289 } ) ;
@@ -607,6 +574,9 @@ describe('Notification Registry and Unified Subscription', () => {
607574 // Setup and listen
608575 await registry ! . setup ( ) ;
609576 await registry ! . listen ( ) ;
577+
578+ // Wait a bit for the listeners to be ready
579+ await new Promise ( resolve => setTimeout ( resolve , 100 ) ) ;
610580
611581 // Create user and list
612582 const user = await prisma ! . user . create ( {
@@ -636,7 +606,7 @@ describe('Notification Registry and Unified Subscription', () => {
636606
637607 await waitForCondition (
638608 ( ) => receivedNotifications [ channels . created ] . length >= 1 ,
639- 2000
609+ 5000
640610 ) ;
641611 expect ( receivedNotifications [ channels . created ] . length ) . toBe ( 1 ) ;
642612 expect ( receivedNotifications [ channels . created ] [ 0 ] . data . id ) . toBe ( item . id ) ;
0 commit comments