|  |  | @ -6,6 +6,38 @@ import { RemindersService } from '../../../src/services/reminders'; | 
			
		
	
		
		
			
				
					
					|  |  |  | import { AllowedGroups } from '../../../src/services/allowed-groups'; |  |  |  | import { AllowedGroups } from '../../../src/services/allowed-groups'; | 
			
		
	
		
		
			
				
					
					|  |  |  | import { ResponseQueue } from '../../../src/services/response-queue'; |  |  |  | import { ResponseQueue } from '../../../src/services/response-queue'; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | function seedGroup(db: Database, groupId: string) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   const cols = db.query(`PRAGMA table_info(groups)`).all() as any[]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   const values: Record<string, any> = {}; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   const nowIso = new Date().toISOString().replace('T', ' ').replace('Z', ''); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   for (const c of cols) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     const name = String(c.name); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     const type = String(c.type || '').toUpperCase(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     const notnull = Number(c.notnull || 0) === 1; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     const hasDefault = c.dflt_value != null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if (name === 'id') { values[name] = groupId; continue; } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if (name === 'name' || name === 'title' || name === 'subject') { values[name] = 'Test Group'; continue; } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if (name === 'created_by') { values[name] = 'tester'; continue; } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if (name.endsWith('_at')) { values[name] = nowIso; continue; } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if (name === 'is_active' || name === 'active') { values[name] = 1; continue; } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if (notnull && !hasDefault) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       if (type.includes('INT')) values[name] = 1; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       else if (type.includes('REAL')) values[name] = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       else values[name] = 'N/A'; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   if (!('id' in values)) values['id'] = groupId; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   const colsList = Object.keys(values); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   const placeholders = colsList.map(() => '?').join(', '); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   const sql = `INSERT OR REPLACE INTO groups (${colsList.join(', ')}) VALUES (${placeholders})`; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   db.prepare(sql).run(...colsList.map(k => values[k])); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | describe('RemindersService - gating por grupos en modo enforce', () => { |  |  |  | describe('RemindersService - gating por grupos en modo enforce', () => { | 
			
		
	
		
		
			
				
					
					|  |  |  |   const envBackup = process.env; |  |  |  |   const envBackup = process.env; | 
			
		
	
		
		
			
				
					
					|  |  |  |   let memdb: Database; |  |  |  |   let memdb: Database; | 
			
		
	
	
		
		
			
				
					|  |  | @ -45,8 +77,8 @@ describe('RemindersService - gating por grupos en modo enforce', () => { | 
			
		
	
		
		
			
				
					
					|  |  |  |     `);
 |  |  |  |     `);
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     // Sembrar grupos y estados
 |  |  |  |     // Sembrar grupos y estados
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     memdb.exec(`INSERT OR IGNORE INTO groups (id) VALUES ('ok@g.us')`); |  |  |  |     seedGroup(memdb, 'ok@g.us'); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     memdb.exec(`INSERT OR IGNORE INTO groups (id) VALUES ('na@g.us')`); |  |  |  |     seedGroup(memdb, 'na@g.us'); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     AllowedGroups.setStatus('ok@g.us', 'allowed', 'OK'); |  |  |  |     AllowedGroups.setStatus('ok@g.us', 'allowed', 'OK'); | 
			
		
	
		
		
			
				
					
					|  |  |  |     AllowedGroups.setStatus('na@g.us', 'allowed', 'NA'); // inicialmente allowed para que las tareas se creen con group_id
 |  |  |  |     AllowedGroups.setStatus('na@g.us', 'allowed', 'NA'); // inicialmente allowed para que las tareas se creen con group_id
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |