import test from 'node:test';
import assert from 'node:assert/strict';
import { PORTAL_HUMAN_REQUEST_PHRASE } from '@wa-ticketing/shared';
import {
  isUnableToAssistReply,
  matchesDirectHumanRequest,
  matchesHumanConfirmNo,
  matchesHumanConfirmYes,
} from './humanRequestPhrases.js';

test('matchesDirectHumanRequest detects portal phrase and common wording', () => {
  assert.ok(matchesDirectHumanRequest(PORTAL_HUMAN_REQUEST_PHRASE));
  assert.ok(matchesDirectHumanRequest('Can I speak to a human please'));
  assert.ok(matchesDirectHumanRequest('I need a real person'));
  assert.ok(!matchesDirectHumanRequest('Hello'));
});

test('matchesHumanConfirmYes/No for short replies', () => {
  assert.ok(matchesHumanConfirmYes('yes'));
  assert.ok(matchesHumanConfirmYes('Yes please'));
  assert.ok(matchesHumanConfirmNo('no'));
  assert.ok(matchesHumanConfirmNo('not now'));
});

test('isUnableToAssistReply detects refusal-style AI text', () => {
  assert.ok(
    isUnableToAssistReply(
      "I'm unable to assist with that topic. Please speak to a human agent for further help.",
    ),
  );
  assert.ok(!isUnableToAssistReply('Here is how to reset your password.'));
});
