11import { describe , expect , it } from "vitest" ;
2- import type {
3- ConversationEntity ,
4- ResolvedFields ,
5- ResolvedSlots ,
6- TimeSpec ,
7- } from "./index" ;
2+ import type { ConversationEntity , ResolvedFields , TimeSpec } from "./index" ;
83import { deriveProposalCompatibility } from "./proposal-rules" ;
94
105function t ( hour : number , minute : number ) : TimeSpec {
116 return { kind : "absolute" , hour, minute } ;
127}
138
14- function sf ( slots : ResolvedSlots ) : ResolvedFields {
15- return { scheduleFields : slots } ;
9+ type ScheduleFields = NonNullable < ResolvedFields [ "scheduleFields" ] > ;
10+
11+ function sf ( fields : ScheduleFields ) : ResolvedFields {
12+ return { scheduleFields : fields } ;
1613}
1714
1815type ProposalOption = Extract < ConversationEntity , { kind : "proposal_option" } > ;
1916
2017function makeProposal (
21- overrides : Partial < ProposalOption [ "data" ] > & { slotSnapshot : ResolvedSlots } ,
18+ overrides : Partial < ProposalOption [ "data" ] > & {
19+ fieldSnapshot : ResolvedFields ;
20+ } ,
2221) : ProposalOption {
2322 return {
2423 id : "proposal-1" ,
@@ -38,10 +37,10 @@ function makeProposal(
3837}
3938
4039describe ( "deriveProposalCompatibility" , ( ) => {
41- describe ( "slot -based compatibility" , ( ) => {
42- it ( "is compatible when committed slots match the snapshot" , ( ) => {
40+ describe ( "field -based compatibility" , ( ) => {
41+ it ( "is compatible when committed fields match the snapshot" , ( ) => {
4342 const proposal = makeProposal ( {
44- slotSnapshot : { time : t ( 15 , 0 ) , day : "friday" } ,
43+ fieldSnapshot : sf ( { time : t ( 15 , 0 ) , day : "friday" } ) ,
4544 } ) ;
4645
4746 const result = deriveProposalCompatibility (
@@ -53,9 +52,9 @@ describe("deriveProposalCompatibility", () => {
5352 expect ( result . compatible ) . toBe ( true ) ;
5453 } ) ;
5554
56- it ( "is incompatible when a committed slot differs from the snapshot" , ( ) => {
55+ it ( "is incompatible when a committed field differs from the snapshot" , ( ) => {
5756 const proposal = makeProposal ( {
58- slotSnapshot : { time : t ( 15 , 0 ) } ,
57+ fieldSnapshot : sf ( { time : t ( 15 , 0 ) } ) ,
5958 } ) ;
6059
6160 const result = deriveProposalCompatibility (
@@ -68,9 +67,9 @@ describe("deriveProposalCompatibility", () => {
6867 expect ( result . reason ) . toMatch ( / d i f f e r s f r o m p r o p o s a l s n a p s h o t / ) ;
6968 } ) ;
7069
71- it ( "is compatible when committed slot is new (not in snapshot)" , ( ) => {
70+ it ( "is compatible when committed field is new (not in snapshot)" , ( ) => {
7271 const proposal = makeProposal ( {
73- slotSnapshot : { day : "friday" } ,
72+ fieldSnapshot : sf ( { day : "friday" } ) ,
7473 } ) ;
7574
7675 const result = deriveProposalCompatibility (
@@ -82,9 +81,9 @@ describe("deriveProposalCompatibility", () => {
8281 expect ( result . compatible ) . toBe ( true ) ;
8382 } ) ;
8483
85- it ( "is compatible when committed slots are empty" , ( ) => {
84+ it ( "is compatible when committed fields are empty" , ( ) => {
8685 const proposal = makeProposal ( {
87- slotSnapshot : { time : t ( 15 , 0 ) , day : "friday" } ,
86+ fieldSnapshot : sf ( { time : t ( 15 , 0 ) , day : "friday" } ) ,
8887 } ) ;
8988
9089 const result = deriveProposalCompatibility (
@@ -98,7 +97,7 @@ describe("deriveProposalCompatibility", () => {
9897
9998 it ( "detects duration change as incompatible" , ( ) => {
10099 const proposal = makeProposal ( {
101- slotSnapshot : { duration : 30 } ,
100+ fieldSnapshot : sf ( { duration : 30 } ) ,
102101 } ) ;
103102
104103 const result = deriveProposalCompatibility (
@@ -116,7 +115,7 @@ describe("deriveProposalCompatibility", () => {
116115 it ( "is incompatible when action kind changes from plan to edit" , ( ) => {
117116 const proposal = makeProposal ( {
118117 originatingTurnText : "schedule a meeting" ,
119- slotSnapshot : { time : t ( 15 , 0 ) } ,
118+ fieldSnapshot : sf ( { time : t ( 15 , 0 ) } ) ,
120119 } ) ;
121120
122121 const result = deriveProposalCompatibility (
@@ -132,7 +131,7 @@ describe("deriveProposalCompatibility", () => {
132131 it ( "skips action kind check for clarification answers" , ( ) => {
133132 const proposal = makeProposal ( {
134133 originatingTurnText : "move the meeting" ,
135- slotSnapshot : { time : t ( 15 , 0 ) } ,
134+ fieldSnapshot : sf ( { time : t ( 15 , 0 ) } ) ,
136135 } ) ;
137136
138137 const result = deriveProposalCompatibility (
0 commit comments