@@ -14,19 +14,38 @@ describe("TaskCalendarSyncService", () => {
1414 googleCalendarExport : {
1515 syncOnTaskUpdate : true ,
1616 targetCalendarId : "test-calendar" ,
17+ includeObsidianLink : true ,
1718 }
1819 } ,
20+ app : {
21+ vault : {
22+ getName : jest . fn ( ) . mockReturnValue ( "Martin OS" ) ,
23+ } ,
24+ } ,
1925 cacheManager : {
2026 getTaskInfo : jest . fn ( )
2127 } ,
2228 statusManager : {
23- getStatusConfig : jest . fn ( ) . mockReturnValue ( { label : " Todo" } )
29+ getStatusConfig : jest . fn ( ( status : string ) => ( { label : status === "ready" ? "Ready" : " Todo" } ) )
2430 } ,
2531 priorityManager : {
26- getPriorityConfig : jest . fn ( ) . mockReturnValue ( { label : " High" } )
32+ getPriorityConfig : jest . fn ( ( priority : string ) => ( { label : priority === "2-high" ? " High" : "Medium" } ) )
2733 } ,
2834 i18n : {
29- translate : jest . fn ( ) . mockReturnValue ( "Untitled Task" )
35+ translate : jest . fn ( ( key : string , params ?: Record < string , string | number > ) => {
36+ const translations : Record < string , string > = {
37+ "settings.integrations.googleCalendarExport.eventDescription.untitledTask" : "Untitled Task" ,
38+ "settings.integrations.googleCalendarExport.eventDescription.priority" : "Priority: {value}" ,
39+ "settings.integrations.googleCalendarExport.eventDescription.status" : "Status: {value}" ,
40+ "settings.integrations.googleCalendarExport.eventDescription.scheduled" : "Scheduled: {value}" ,
41+ "settings.integrations.googleCalendarExport.eventDescription.timeEstimate" : "Time Estimate: {value}" ,
42+ "settings.integrations.googleCalendarExport.eventDescription.contexts" : "Contexts: {value}" ,
43+ "settings.integrations.googleCalendarExport.eventDescription.projects" : "Projects: {value}" ,
44+ "settings.integrations.googleCalendarExport.eventDescription.openInObsidian" : "Open in Obsidian" ,
45+ } ;
46+ const translation = translations [ key ] || key ;
47+ return translation . replace ( / \{ ( \w + ) \} / g, ( _match , name ) => String ( params ?. [ name ] ?? "" ) ) ;
48+ } )
3049 }
3150 } ;
3251
@@ -78,4 +97,38 @@ describe("TaskCalendarSyncService", () => {
7897 expect ( syncService . executeTaskUpdate ) . toHaveBeenCalledTimes ( 1 ) ;
7998 expect ( syncService . executeTaskUpdate ) . toHaveBeenCalledWith ( secondPayload ) ;
8099 } ) ;
100+
101+ it ( "should build plain-text calendar descriptions for external calendar clients" , ( ) => {
102+ const description = syncService . buildEventDescription ( {
103+ path : "1 Tasks/Tasks/Download first personal data export batch.md" ,
104+ title : "Download first personal data export batch" ,
105+ status : "ready" ,
106+ priority : "2-high" ,
107+ scheduled : "2026-04-29" ,
108+ timeEstimate : 180 ,
109+ projects : [
110+ "[[0 Collect personal data exports for vault intelligence|Collect personal data exports for vault intelligence]]" ,
111+ "[[Projects/Nested Project.md]]" ,
112+ "[Markdown Project](Projects/Markdown%20Project.md)" ,
113+ ] ,
114+ contexts : [ "[[People/Martin Ball|Martin Ball]]" , "admin" ] ,
115+ } as TaskInfo ) ;
116+
117+ expect ( description ) . toContain ( "Priority: High" ) ;
118+ expect ( description ) . toContain ( "Status: Ready" ) ;
119+ expect ( description ) . toContain ( "Scheduled: 2026-04-29" ) ;
120+ expect ( description ) . toContain ( "Time Estimate: 3h 0m" ) ;
121+ expect ( description ) . toContain ( "Contexts: @Martin Ball, @admin" ) ;
122+ expect ( description ) . toContain (
123+ "Projects: Collect personal data exports for vault intelligence, Nested Project, Markdown Project"
124+ ) ;
125+ expect ( description ) . toContain (
126+ "Open in Obsidian: obsidian://open?vault=Martin%20OS&file=1%20Tasks%2FTasks%2FDownload%20first%20personal%20data%20export%20batch.md"
127+ ) ;
128+ expect ( description ) . not . toContain ( "[[" ) ;
129+ expect ( description ) . not . toContain ( "]]" ) ;
130+ expect ( description ) . not . toContain ( "<a " ) ;
131+ expect ( description ) . not . toContain ( "</a>" ) ;
132+ expect ( description ) . not . toContain ( "](" ) ;
133+ } ) ;
81134} ) ;
0 commit comments