| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- import { test } from 'node:test';
- import assert from 'node:assert/strict';
- import { applyTestConfig } from './helpers/testConfig.js';
- import { formatTicketNumber, isTicketMode } from '../src/domain/ticketService.js';
- test('ticket numbers use the EKS-YYYYMMDD-<conversationId> format', () => {
- applyTestConfig();
- const n = formatTicketNumber(1311, new Date(Date.UTC(2026, 7, 20, 9, 0, 0)));
- assert.equal(n, 'EKS-20260820-1311');
- });
- test('the ticket prefix is configurable', () => {
- applyTestConfig({ TICKET_NUMBER_PREFIX: 'SUP' });
- assert.equal(formatTicketNumber(7, new Date(Date.UTC(2026, 0, 2))), 'SUP-20260102-7');
- });
- test('the ticket label puts a conversation in manual mode', () => {
- applyTestConfig();
- assert.equal(isTicketMode({ labels: ['ticket'] }), true);
- assert.equal(isTicketMode({ labels: ['vip'] }), false);
- });
- test('handoff=true puts a conversation in manual mode', () => {
- applyTestConfig();
- assert.equal(isTicketMode({ custom_attributes: { handoff: true } }), true);
- assert.equal(isTicketMode({ custom_attributes: { handoff: 'true' } }), true);
- assert.equal(isTicketMode({ custom_attributes: { handoff: false } }), false);
- });
- test('a real ticket_number puts a conversation in manual mode, "0" does not', () => {
- applyTestConfig();
- assert.equal(isTicketMode({ custom_attributes: { ticket_number: 'EKS-20260820-1311' } }), true);
- assert.equal(isTicketMode({ custom_attributes: { ticket_number: '0' } }), false);
- assert.equal(isTicketMode({ custom_attributes: { ticket_number: '' } }), false);
- });
- test('an empty conversation is not in manual mode', () => {
- applyTestConfig();
- assert.equal(isTicketMode({}), false);
- });
|