@@ -549,4 +549,61 @@ ${userUnit.relations},
549549 owner : 'managed' ,
550550 } ) ;
551551 } ) ;
552+
553+ test ( 'convex auth schema registration reuses existing double-quoted authSchema import' , async ( ) => {
554+ const dir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'kitcn-auth-item-' ) ) ;
555+ const functionsDir = path . join ( dir , 'convex' , 'functions' ) ;
556+ const schemaPath = path . join ( functionsDir , 'schema.ts' ) ;
557+ const schemaSource = `
558+ import { authSchema } from "./authSchema";
559+ import { defineSchema } from "convex/server";
560+
561+ export default defineSchema({
562+ messages: {},
563+ });
564+ ` . trim ( ) ;
565+
566+ fs . mkdirSync ( functionsDir , { recursive : true } ) ;
567+ fs . writeFileSync ( schemaPath , schemaSource , 'utf8' ) ;
568+
569+ const descriptor = getPluginCatalogEntry ( 'auth' ) ;
570+ const plan =
571+ await descriptor . integration ?. buildSchemaRegistrationPlanFile ?.( {
572+ config : createDefaultConfig ( ) ,
573+ functionsDir,
574+ lockfile : {
575+ plugins : { } ,
576+ } ,
577+ overwrite : true ,
578+ preset : 'convex' ,
579+ preview : false ,
580+ promptAdapter : {
581+ confirm : async ( ) => false ,
582+ isInteractive : ( ) => false ,
583+ multiselect : async ( ) => [ ] ,
584+ select : async ( ) => 'ignored' ,
585+ } ,
586+ roots : {
587+ appRootDir : null ,
588+ clientLibRootDir : null ,
589+ crpcFilePath : path . join ( dir , 'convex' , 'lib' , 'crpc.ts' ) ,
590+ envFilePath : path . join ( dir , 'convex' , 'lib' , 'get-env.ts' ) ,
591+ functionsRootDir : functionsDir ,
592+ libRootDir : path . join ( dir , 'convex' , 'lib' ) ,
593+ projectContext : null ,
594+ sharedApiFilePath : path . join ( dir , 'convex' , 'shared' , 'api.ts' ) ,
595+ } ,
596+ yes : true ,
597+ } ) ;
598+
599+ expect (
600+ plan ?. content . match (
601+ / i m p o r t \{ a u t h S c h e m a \} f r o m [ ' " ] \. \/ a u t h S c h e m a [ ' " ] ; / g
602+ )
603+ ) . toHaveLength ( 1 ) ;
604+ expect ( plan ?. content ) . toContain (
605+ 'import { authSchema } from "./authSchema";'
606+ ) ;
607+ expect ( plan ?. content ) . toContain ( '...authSchema,' ) ;
608+ } ) ;
552609} ) ;
0 commit comments