File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,33 @@ describe("onDocumentTagged", () => {
51
51
} ) ;
52
52
} ) ;
53
53
54
+ // Currently, the AI system writes to a comments collection under an empty document whose ID is the same as the
55
+ // document key. This test should be removed (or updated) when the AI system is modified to write to a comments
56
+ // collection under a complete metadata document like comments from human users are.
57
+ test ( "should add new values when a new AI-generated comment is made" , async ( ) => {
58
+ const wrapped = fft . wrap ( onDocumentTagged ) ;
59
+ const commentRef = documentCollection . doc ( "doc-key" ) . collection ( "comments" ) . doc ( "ai-comment-1" ) ;
60
+
61
+ await commentRef . set ( { tags : [ "ai-tag-1" , "ai-tag-2" ] } ) ;
62
+ const event = {
63
+ params : {
64
+ root : "demo" ,
65
+ space : "test" ,
66
+ documentId : "doc-key" ,
67
+ commentId : "ai-comment-1" ,
68
+ } ,
69
+ } ;
70
+ await wrapped ( event ) ;
71
+
72
+ const docSnapshot = await documentCollection . doc ( "1234" ) . get ( ) ;
73
+ const docData = docSnapshot . data ( ) ;
74
+
75
+ expect ( docData ) . toEqual ( {
76
+ key : "doc-key" ,
77
+ strategies : [ "ai-tag-1" , "ai-tag-2" ] ,
78
+ } ) ;
79
+ } ) ;
80
+
54
81
test ( "should remove values from a document's strategies array when an existing comment is deleted" , async ( ) => {
55
82
const wrapped = fft . wrap ( onDocumentTagged ) ;
56
83
const commentRef1 = documentCollection . doc ( "1234" ) . collection ( "comments" ) . doc ( "5678" ) ;
You can’t perform that action at this time.
0 commit comments