@@ -40,6 +40,8 @@ const mockSelectedCalendar: SelectedCalendar = {
4040 channelResourceUri : "test-resource-uri" ,
4141 channelExpiration : new Date ( Date . now ( ) + 86400000 ) ,
4242 syncSubscribedAt : new Date ( ) ,
43+ syncSubscribedErrorAt : null ,
44+ syncSubscribedErrorCount : 0 ,
4345 syncToken : "test-sync-token" ,
4446 syncedAt : new Date ( ) ,
4547 syncErrorAt : null ,
@@ -122,7 +124,6 @@ describe("SelectedCalendarRepository", () => {
122124 expect ( mockPrismaClient . selectedCalendar . findMany ) . toHaveBeenCalledWith ( {
123125 where : {
124126 integration : { in : [ "google_calendar" , "office365_calendar" ] } ,
125- OR : [ { syncSubscribedAt : null } , { channelExpiration : { lte : expect . any ( Date ) } } ] ,
126127 user : {
127128 teams : {
128129 some : {
@@ -131,7 +132,24 @@ describe("SelectedCalendarRepository", () => {
131132 } ,
132133 } ,
133134 } ,
134- AND : undefined ,
135+ AND : [
136+ {
137+ OR : [
138+ { syncSubscribedAt : null } ,
139+ { channelExpiration : null } ,
140+ { channelExpiration : { lte : expect . any ( Date ) } } ,
141+ ] ,
142+ } ,
143+ {
144+ OR : [
145+ { syncSubscribedErrorAt : null } ,
146+ { syncSubscribedErrorAt : { lt : expect . any ( Date ) } } ,
147+ ] ,
148+ } ,
149+ {
150+ syncSubscribedErrorCount : { lt : 3 } ,
151+ } ,
152+ ] ,
135153 } ,
136154 take : 10 ,
137155 } ) ;
@@ -152,7 +170,6 @@ describe("SelectedCalendarRepository", () => {
152170 expect ( mockPrismaClient . selectedCalendar . findMany ) . toHaveBeenCalledWith ( {
153171 where : {
154172 integration : { in : [ ] } ,
155- OR : [ { syncSubscribedAt : null } , { channelExpiration : { lte : expect . any ( Date ) } } ] ,
156173 user : {
157174 teams : {
158175 some : {
@@ -161,7 +178,24 @@ describe("SelectedCalendarRepository", () => {
161178 } ,
162179 } ,
163180 } ,
164- AND : undefined ,
181+ AND : [
182+ {
183+ OR : [
184+ { syncSubscribedAt : null } ,
185+ { channelExpiration : null } ,
186+ { channelExpiration : { lte : expect . any ( Date ) } } ,
187+ ] ,
188+ } ,
189+ {
190+ OR : [
191+ { syncSubscribedErrorAt : null } ,
192+ { syncSubscribedErrorAt : { lt : expect . any ( Date ) } } ,
193+ ] ,
194+ } ,
195+ {
196+ syncSubscribedErrorCount : { lt : 3 } ,
197+ } ,
198+ ] ,
165199 } ,
166200 take : 5 ,
167201 } ) ;
@@ -182,7 +216,6 @@ describe("SelectedCalendarRepository", () => {
182216 expect ( mockPrismaClient . selectedCalendar . findMany ) . toHaveBeenCalledWith ( {
183217 where : {
184218 integration : { in : [ "google_calendar" ] } ,
185- OR : [ { syncSubscribedAt : null } , { channelExpiration : { lte : expect . any ( Date ) } } ] ,
186219 user : {
187220 teams : {
188221 some : {
@@ -191,7 +224,24 @@ describe("SelectedCalendarRepository", () => {
191224 } ,
192225 } ,
193226 } ,
194- AND : undefined ,
227+ AND : [
228+ {
229+ OR : [
230+ { syncSubscribedAt : null } ,
231+ { channelExpiration : null } ,
232+ { channelExpiration : { lte : expect . any ( Date ) } } ,
233+ ] ,
234+ } ,
235+ {
236+ OR : [
237+ { syncSubscribedErrorAt : null } ,
238+ { syncSubscribedErrorAt : { lt : expect . any ( Date ) } } ,
239+ ] ,
240+ } ,
241+ {
242+ syncSubscribedErrorCount : { lt : 3 } ,
243+ } ,
244+ ] ,
195245 } ,
196246 take : 10 ,
197247 } ) ;
@@ -215,7 +265,6 @@ describe("SelectedCalendarRepository", () => {
215265 expect ( mockPrismaClient . selectedCalendar . findMany ) . toHaveBeenCalledWith ( {
216266 where : {
217267 integration : { in : [ "google_calendar" ] } ,
218- OR : [ { syncSubscribedAt : null } , { channelExpiration : { lte : expect . any ( Date ) } } ] ,
219268 user : {
220269 teams : {
221270 some : {
@@ -225,6 +274,22 @@ describe("SelectedCalendarRepository", () => {
225274 } ,
226275 } ,
227276 AND : [
277+ {
278+ OR : [
279+ { syncSubscribedAt : null } ,
280+ { channelExpiration : null } ,
281+ { channelExpiration : { lte : expect . any ( Date ) } } ,
282+ ] ,
283+ } ,
284+ {
285+ OR : [
286+ { syncSubscribedErrorAt : null } ,
287+ { syncSubscribedErrorAt : { lt : expect . any ( Date ) } } ,
288+ ] ,
289+ } ,
290+ {
291+ syncSubscribedErrorCount : { lt : 3 } ,
292+ } ,
228293 { NOT : { externalId : { endsWith : "@group.v.calendar.google.com" } } } ,
229294 { NOT : { externalId : { endsWith : "@group.calendar.google.com" } } } ,
230295 ] ,
0 commit comments