|
|
|
@ -444,7 +444,7 @@ describe('WebhookServer', () => {
|
|
|
|
|
|
|
|
|
|
|
|
await WebhookServer.handleRequest(createTestRequest(payload));
|
|
|
|
await WebhookServer.handleRequest(createTestRequest(payload));
|
|
|
|
|
|
|
|
|
|
|
|
expect(SimulatedResponseQueue.getQueue().length).toBeGreaterThan(0);
|
|
|
|
expect(SimulatedResponseQueue.get().length).toBeGreaterThan(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test('should handle multiple past dates correctly', async () => {
|
|
|
|
test('should handle multiple past dates correctly', async () => {
|
|
|
|
@ -464,7 +464,7 @@ describe('WebhookServer', () => {
|
|
|
|
|
|
|
|
|
|
|
|
await WebhookServer.handleRequest(createTestRequest(payload));
|
|
|
|
await WebhookServer.handleRequest(createTestRequest(payload));
|
|
|
|
|
|
|
|
|
|
|
|
expect(SimulatedResponseQueue.getQueue().length).toBeGreaterThan(0);
|
|
|
|
expect(SimulatedResponseQueue.get().length).toBeGreaterThan(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test('should handle mixed valid and invalid date formats', async () => {
|
|
|
|
test('should handle mixed valid and invalid date formats', async () => {
|
|
|
|
@ -483,7 +483,7 @@ describe('WebhookServer', () => {
|
|
|
|
|
|
|
|
|
|
|
|
await WebhookServer.handleRequest(createTestRequest(payload));
|
|
|
|
await WebhookServer.handleRequest(createTestRequest(payload));
|
|
|
|
|
|
|
|
|
|
|
|
expect(SimulatedResponseQueue.getQueue().length).toBeGreaterThan(0);
|
|
|
|
expect(SimulatedResponseQueue.get().length).toBeGreaterThan(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test('should normalize sender ID before processing', async () => {
|
|
|
|
test('should normalize sender ID before processing', async () => {
|
|
|
|
@ -501,7 +501,7 @@ describe('WebhookServer', () => {
|
|
|
|
const request = createTestRequest(payload);
|
|
|
|
const request = createTestRequest(payload);
|
|
|
|
const response = await WebhookServer.handleRequest(request);
|
|
|
|
const response = await WebhookServer.handleRequest(request);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
expect(SimulatedResponseQueue.getQueue().length).toBeGreaterThan(0);
|
|
|
|
expect(SimulatedResponseQueue.get().length).toBeGreaterThan(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test('should ignore messages with invalid sender ID', async () => {
|
|
|
|
test('should ignore messages with invalid sender ID', async () => {
|
|
|
|
@ -519,7 +519,7 @@ describe('WebhookServer', () => {
|
|
|
|
const request = createTestRequest(payload);
|
|
|
|
const request = createTestRequest(payload);
|
|
|
|
const response = await WebhookServer.handleRequest(request);
|
|
|
|
const response = await WebhookServer.handleRequest(request);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
expect(SimulatedResponseQueue.getQueue().length).toBe(0);
|
|
|
|
expect(SimulatedResponseQueue.get().length).toBe(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test('should ensure user exists and use normalized ID', async () => {
|
|
|
|
test('should ensure user exists and use normalized ID', async () => {
|
|
|
|
@ -537,7 +537,7 @@ describe('WebhookServer', () => {
|
|
|
|
const request = createTestRequest(payload);
|
|
|
|
const request = createTestRequest(payload);
|
|
|
|
const response = await WebhookServer.handleRequest(request);
|
|
|
|
const response = await WebhookServer.handleRequest(request);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
expect(SimulatedResponseQueue.getQueue().length).toBeGreaterThan(0);
|
|
|
|
expect(SimulatedResponseQueue.get().length).toBeGreaterThan(0);
|
|
|
|
|
|
|
|
|
|
|
|
// Verify user was created in real database
|
|
|
|
// Verify user was created in real database
|
|
|
|
const user = testDb.query("SELECT * FROM users WHERE id = ?").get('1234567890');
|
|
|
|
const user = testDb.query("SELECT * FROM users WHERE id = ?").get('1234567890');
|
|
|
|
@ -560,7 +560,7 @@ describe('WebhookServer', () => {
|
|
|
|
const request = createTestRequest(payload);
|
|
|
|
const request = createTestRequest(payload);
|
|
|
|
const response = await WebhookServer.handleRequest(request);
|
|
|
|
const response = await WebhookServer.handleRequest(request);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
expect(SimulatedResponseQueue.getQueue().length).toBe(0);
|
|
|
|
expect(SimulatedResponseQueue.get().length).toBe(0);
|
|
|
|
|
|
|
|
|
|
|
|
// Verify no user was created
|
|
|
|
// Verify no user was created
|
|
|
|
const userCount = testDb.query("SELECT COUNT(*) as count FROM users").get();
|
|
|
|
const userCount = testDb.query("SELECT COUNT(*) as count FROM users").get();
|
|
|
|
@ -732,7 +732,7 @@ describe('WebhookServer', () => {
|
|
|
|
const request = createTestRequest(payload);
|
|
|
|
const request = createTestRequest(payload);
|
|
|
|
const response = await WebhookServer.handleRequest(request);
|
|
|
|
const response = await WebhookServer.handleRequest(request);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
expect(SimulatedResponseQueue.getQueue().length).toBe(0);
|
|
|
|
expect(SimulatedResponseQueue.get().length).toBe(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test('should proceed with messages from active groups', async () => {
|
|
|
|
test('should proceed with messages from active groups', async () => {
|
|
|
|
@ -750,7 +750,7 @@ describe('WebhookServer', () => {
|
|
|
|
const request = createTestRequest(payload);
|
|
|
|
const request = createTestRequest(payload);
|
|
|
|
const response = await WebhookServer.handleRequest(request);
|
|
|
|
const response = await WebhookServer.handleRequest(request);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
expect(SimulatedResponseQueue.getQueue().length).toBeGreaterThan(0);
|
|
|
|
expect(SimulatedResponseQueue.get().length).toBeGreaterThan(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test('should accept /t alias and process command', async () => {
|
|
|
|
test('should accept /t alias and process command', async () => {
|
|
|
|
@ -768,7 +768,7 @@ describe('WebhookServer', () => {
|
|
|
|
const request = createTestRequest(payload);
|
|
|
|
const request = createTestRequest(payload);
|
|
|
|
const response = await WebhookServer.handleRequest(request);
|
|
|
|
const response = await WebhookServer.handleRequest(request);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
expect(SimulatedResponseQueue.getQueue().length).toBeGreaterThan(0);
|
|
|
|
expect(SimulatedResponseQueue.get().length).toBeGreaterThan(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test('should never send responses to the group (DM only policy)', async () => {
|
|
|
|
test('should never send responses to the group (DM only policy)', async () => {
|
|
|
|
@ -858,7 +858,7 @@ describe('WebhookServer', () => {
|
|
|
|
const response = await WebhookServer.handleRequest(createTestRequest(payload));
|
|
|
|
const response = await WebhookServer.handleRequest(createTestRequest(payload));
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
|
|
|
|
|
|
|
|
const out = SimulatedResponseQueue.getQueue();
|
|
|
|
const out = SimulatedResponseQueue.get();
|
|
|
|
expect(out.length).toBeGreaterThan(0);
|
|
|
|
expect(out.length).toBeGreaterThan(0);
|
|
|
|
const msg = out.map(x => x.message).join('\n');
|
|
|
|
const msg = out.map(x => x.message).join('\n');
|
|
|
|
expect(msg).toContain('No tienes tareas pendientes.');
|
|
|
|
expect(msg).toContain('No tienes tareas pendientes.');
|
|
|
|
@ -904,7 +904,7 @@ describe('WebhookServer', () => {
|
|
|
|
const response = await WebhookServer.handleRequest(createTestRequest(payload));
|
|
|
|
const response = await WebhookServer.handleRequest(createTestRequest(payload));
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
|
|
|
|
|
|
|
|
const out = SimulatedResponseQueue.getQueue();
|
|
|
|
const out = SimulatedResponseQueue.get();
|
|
|
|
expect(out.length).toBeGreaterThan(0);
|
|
|
|
expect(out.length).toBeGreaterThan(0);
|
|
|
|
const msg = out.map(x => x.message).join('\n');
|
|
|
|
const msg = out.map(x => x.message).join('\n');
|
|
|
|
expect(msg).toContain('No respondo en grupos.');
|
|
|
|
expect(msg).toContain('No respondo en grupos.');
|
|
|
|
@ -932,7 +932,7 @@ describe('WebhookServer', () => {
|
|
|
|
const response = await WebhookServer.handleRequest(createTestRequest(payload));
|
|
|
|
const response = await WebhookServer.handleRequest(createTestRequest(payload));
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
|
|
|
|
|
|
|
|
const out = SimulatedResponseQueue.getQueue();
|
|
|
|
const out = SimulatedResponseQueue.get();
|
|
|
|
expect(out.length).toBeGreaterThan(0);
|
|
|
|
expect(out.length).toBeGreaterThan(0);
|
|
|
|
const msg = out.map(x => x.message).join('\n');
|
|
|
|
const msg = out.map(x => x.message).join('\n');
|
|
|
|
expect(msg).toContain('Tus tareas');
|
|
|
|
expect(msg).toContain('Tus tareas');
|
|
|
|
|