feat: onboard service desk as second CASAN project

This commit is contained in:
thanhnv
2026-07-10 17:00:35 +09:00
parent 040af64191
commit f8215cd2eb
20 changed files with 208 additions and 13 deletions
+16
View File
@@ -0,0 +1,16 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { assignTicket, createTicket, isSlaBreached, resolveTicket } from '../src/ticket.js';
const opened = () => createTicket({ id: 'INC-100', summary: 'VPN access fails', priority: 'HIGH', requestedAt: '2026-07-10T00:00:00Z' });
test('creates a traceable open ticket', () => assert.equal(opened().status, 'OPEN'));
test('assigns then resolves ticket through valid state transition', () => assert.equal(resolveTicket(assignTicket(opened(), 'ops-a'), '2026-07-10T01:00:00Z').status, 'RESOLVED'));
test('blocks invalid assignment and resolution transitions', () => {
assert.throws(() => assignTicket(opened(), ''));
assert.throws(() => resolveTicket(opened(), '2026-07-10T01:00:00Z'));
});
test('raises SLA breach only while unresolved', () => {
assert.equal(isSlaBreached(opened(), '2026-07-10T05:00:01Z'), true);
assert.equal(isSlaBreached(resolveTicket(assignTicket(opened(), 'ops-a'), '2026-07-10T01:00:00Z'), '2026-07-10T05:00:01Z'), false);
});