/opt/mawid/apps/api/src/whatsapp
Edit: /opt/mawid/apps/api/src/whatsapp/wa-window.spec.ts (860B)
import { isWithinCustomerServiceWindow } from './wa-window';
describe('isWithinCustomerServiceWindow', () => {
const now = new Date('2026-07-15T12:00:00Z');
it('is open just after an inbound message', () => {
expect(isWithinCustomerServiceWindow(new Date('2026-07-15T11:59:00Z'), now)).toBe(true);
});
it('is open 23h59m after the last inbound message', () => {
expect(isWithinCustomerServiceWindow(new Date('2026-07-14T12:01:00Z'), now)).toBe(true);
});
it('is closed exactly 24h after the last inbound message', () => {
expect(isWithinCustomerServiceWindow(new Date('2026-07-14T12:00:00Z'), now)).toBe(false);
});
it('is closed when there was never an inbound message', () => {
expect(isWithinCustomerServiceWindow(null, now)).toBe(false);
expect(isWithinCustomerServiceWindow(undefined, now)).toBe(false);
});
});