@@ -17,8 +17,16 @@ import { generateShortId } from '@sim/utils/id'
1717import { DrizzleQueryError } from 'drizzle-orm/errors'
1818import { afterEach , beforeEach , describe , expect , it , vi } from 'vitest'
1919import * as connectorTokens from '@/lib/knowledge/connectors/access-token'
20- import { executeSync , isConnectorRunnableStatus } from '@/lib/knowledge/connectors/sync-engine'
21- import { CREDENTIAL_REVOKED_SYNC_ERROR } from '@/lib/knowledge/connectors/sync-limits'
20+ import {
21+ buildSyncDatabaseRetryUpdate ,
22+ buildSyncFailureUpdate ,
23+ executeSync ,
24+ isConnectorRunnableStatus ,
25+ } from '@/lib/knowledge/connectors/sync-engine'
26+ import {
27+ CREDENTIAL_REVOKED_SYNC_ERROR ,
28+ MAX_CONSECUTIVE_FAILURES ,
29+ } from '@/lib/knowledge/connectors/sync-limits'
2230import {
2331 classifySuspectListing ,
2432 evaluateListingSafety ,
@@ -1110,7 +1118,6 @@ describe('executeSync database failures', () => {
11101118 consecutiveFailures ?: number ,
11111119 firstPage ?: { documents : ExternalDocument [ ] }
11121120 ) {
1113- const { MAX_CONSECUTIVE_FAILURES } = await import ( '@/lib/knowledge/connectors/sync-limits' )
11141121 const connector = {
11151122 id : 'c-1' ,
11161123 knowledgeBaseId : 'kb-1' ,
@@ -2167,9 +2174,6 @@ describe('buildSyncDatabaseRetryUpdate', () => {
21672174 const minutesAfter = ( mins : number ) => now . getTime ( ) + mins * 60 * 1000
21682175
21692176 it ( 'keeps the error visible without advancing the auto-disable counter' , async ( ) => {
2170- const { buildSyncDatabaseRetryUpdate } = await import ( '@/lib/knowledge/connectors/sync-engine' )
2171- const { MAX_CONSECUTIVE_FAILURES } = await import ( '@/lib/knowledge/connectors/sync-limits' )
2172-
21732177 const update = buildSyncDatabaseRetryUpdate ( now , MAX_CONSECUTIVE_FAILURES - 1 , 'db timeout' , 40 )
21742178 expect ( update ) . toMatchObject ( {
21752179 status : 'error' ,
@@ -2182,18 +2186,12 @@ describe('buildSyncDatabaseRetryUpdate', () => {
21822186 } )
21832187
21842188 it ( 'schedules the next run after the resolved retry delay' , async ( ) => {
2185- const { buildSyncDatabaseRetryUpdate } = await import ( '@/lib/knowledge/connectors/sync-engine' )
2186-
21872189 expect ( buildSyncDatabaseRetryUpdate ( now , 0 , 'db timeout' , 90 * 60 * 1000 ) . nextSyncAt ) . toEqual (
21882190 new Date ( minutesAfter ( 90 ) )
21892191 )
21902192 } )
21912193
21922194 it ( 'leaves a later source failure to be judged on source failures alone' , async ( ) => {
2193- const { buildSyncDatabaseRetryUpdate, buildSyncFailureUpdate } = await import (
2194- '@/lib/knowledge/connectors/sync-engine'
2195- )
2196-
21972195 let failures = 1
21982196 for ( let run = 0 ; run < 30 ; run ++ ) {
21992197 failures = buildSyncDatabaseRetryUpdate (
0 commit comments