@@ -143,6 +143,19 @@ async function fixture() {
143143 return { ...ids , principal : createSessionPrincipal ( { userId : editorId } ) }
144144}
145145
146+ /** File creation marks a revision pending, so a requeue check starts from no revision at all. */
147+ async function clearSearchRevision ( fileId : string ) {
148+ await db . delete ( workspaceFileSearchRevision ) . where ( eq ( workspaceFileSearchRevision . fileId , fileId ) )
149+ }
150+
151+ async function searchRevision ( fileId : string ) {
152+ const [ revision ] = await db
153+ . select ( )
154+ . from ( workspaceFileSearchRevision )
155+ . where ( eq ( workspaceFileSearchRevision . fileId , fileId ) )
156+ return revision
157+ }
158+
146159function createInput ( projectId : string , content = 'Project architecture' ) {
147160 return {
148161 projectId,
@@ -704,6 +717,7 @@ describe('Project rendered artifacts against PostgreSQL and private storage', ()
704717 await released
705718 } )
706719 await held
720+ await clearSearchRevision ( source . file . id )
707721 try {
708722 const rendered = await observeWorkspaceFileDelivery (
709723 async ( ) => release ( ) ,
@@ -718,10 +732,7 @@ describe('Project rendered artifacts against PostgreSQL and private storage', ()
718732 release ( )
719733 await concurrentReader
720734 }
721- const [ revision ] = await db
722- . select ( )
723- . from ( workspaceFileSearchRevision )
724- . where ( eq ( workspaceFileSearchRevision . fileId , source . file . id ) )
735+ const revision = await searchRevision ( source . file . id )
725736 expect ( revision ?. status ) . toBe ( 'pending' )
726737 expect ( revision ?. sourceContentUpdatedAt ) . toEqual ( source . file . contentUpdatedAt )
727738 }
@@ -755,6 +766,7 @@ describe('Project rendered artifacts against PostgreSQL and private storage', ()
755766 await released
756767 } )
757768 await held
769+ await clearSearchRevision ( source . file . id )
758770 try {
759771 const started = performance . now ( )
760772 const rendered = await readProjectFileArtifact . execute ( {
@@ -769,11 +781,7 @@ describe('Project rendered artifacts against PostgreSQL and private storage', ()
769781 release ( )
770782 await concurrentReader
771783 }
772- const revisions = await db
773- . select ( )
774- . from ( workspaceFileSearchRevision )
775- . where ( eq ( workspaceFileSearchRevision . fileId , source . file . id ) )
776- expect ( revisions ) . toEqual ( [ ] )
784+ expect ( await searchRevision ( source . file . id ) ) . toBeUndefined ( )
777785 }
778786 )
779787
0 commit comments