apps/web/src/lib/specificKnowledgeFact.test.ts
1import { expect, test } from 'bun:test'
2import {
3 specificKnowledgeFact,
4 supportsSpecificKnowledgeFact,
5} from './specificKnowledgeFact'
6
7test('withdrawn named facts cannot be replaced by similarly named rooms or different fields', () => {
8 const fact = specificKnowledgeFact(
9 'What is the published workshop room name for Acme Learning Lounge?',
10 )
11 expect(fact).toBeDefined()
12 if (!fact) throw new Error('Expected named fact')
13 expect(
14 supportsSpecificKnowledgeFact(
15 fact,
16 'Q: What is the cloakroom sign label for Acme Learning Lounge?\nA: AMBER BIRCH.',
17 ),
18 ).toBe(false)
19 expect(
20 supportsSpecificKnowledgeFact(
21 fact,
22 'The workshop room name is Speaker Green Room.',
23 ),
24 ).toBe(false)
25 expect(
26 supportsSpecificKnowledgeFact(
27 fact,
28 'Q: What is the published workshop room name for Acme Learning Lounge?\nA: VIOLET MAPLE.',
29 ),
30 ).toBe(true)
31 expect(
32 supportsSpecificKnowledgeFact(
33 fact,
34 'Q: What is the published workshop room name for Acme Learning Lounge?',
35 ),
36 ).toBe(false)
37 expect(
38 supportsSpecificKnowledgeFact(
39 fact,
40 'Q: Where is Acme Learning Lounge?\nA: Hall A.\nQ: What is the workshop room name for Another Company?\nA: Green Room.',
41 ),
42 ).toBe(false)
43})
44
45test('broad learning, event and sales questions retain semantic discovery', () => {
46 for (const message of [
47 'What sessions cover skills?',
48 'How do I book a ticket?',
49 'What is the venue for Paris?',
50 'Which room is my session in?',
51 'Can I sponsor the event?',
52 ])
53 expect(specificKnowledgeFact(message)).toBeUndefined()
54 expect(
55 specificKnowledgeFact(
56 'What is the published welcome phrase in the Acme visitor leaflet?',
57 )?.entity,
58 ).toBe('Acme visitor leaflet')
59})
60