@@ -7,7 +7,6 @@ import { drizzle as drizzleSqliteAdapter } from 'drizzle-orm/better-sqlite3';
77// Modules to mock
88import * as configModule from '../../../src/db/config' ;
99import * as staticSchemaModule from '../../../src/db/schema.sqlite' ;
10- import * as schemaModule from '../../../src/db/schema' ; // For inputPluginTableDefinitions
1110
1211// Functions from the module under test
1312import {
@@ -100,10 +99,6 @@ vi.mock('../../../src/db/schema.sqlite', () => ({
10099 // e.g., authUser: {}, authSession: {}
101100 // For now, an empty object might suffice if generateSchema doesn't rely on specific props
102101 // from staticSchema for the core tests.
103- } ) ) ;
104-
105- // Mock './schema' for inputPluginTableDefinitions
106- vi . mock ( '../../../src/db/schema' , ( ) => ( {
107102 pluginTableDefinitions : { } , // Start with empty plugin definitions
108103} ) ) ;
109104
@@ -207,20 +202,20 @@ describe('Database Service (db/index.ts)', () => {
207202 } ;
208203
209204 beforeEach ( ( ) => {
210- // Reset pluginTableDefinitions from schemaModule for each test
211- // schemaModule .pluginTableDefinitions = {}; // This causes a read-only error
205+ // Reset pluginTableDefinitions from staticSchemaModule for each test
206+ // staticSchemaModule .pluginTableDefinitions = {}; // This causes a read-only error
212207 // Instead, clear the properties of the mocked object
213- const ptd = schemaModule . pluginTableDefinitions as Record < string , any > ;
208+ const ptd = staticSchemaModule . pluginTableDefinitions as Record < string , any > ;
214209 for ( const key in ptd ) {
215210 delete ptd [ key ] ;
216211 }
217212 } ) ;
218213
219214 it ( 'should register table definitions from plugins' , ( ) => {
220215 registerPluginTables ( [ plugin1 , plugin2 ] ) ;
221- expect ( schemaModule . pluginTableDefinitions ) . toHaveProperty ( 'plugin1_myTable' ) ;
222- expect ( schemaModule . pluginTableDefinitions [ 'plugin1_myTable' ] ) . toEqual ( plugin1 . databaseExtension ?. tableDefinitions ?. myTable ) ;
223- expect ( Object . keys ( schemaModule . pluginTableDefinitions ) . length ) . toBe ( 1 ) ;
216+ expect ( staticSchemaModule . pluginTableDefinitions ) . toHaveProperty ( 'plugin1_myTable' ) ;
217+ expect ( staticSchemaModule . pluginTableDefinitions [ 'plugin1_myTable' ] ) . toEqual ( plugin1 . databaseExtension ?. tableDefinitions ?. myTable ) ;
218+ expect ( Object . keys ( staticSchemaModule . pluginTableDefinitions ) . length ) . toBe ( 1 ) ;
224219 } ) ;
225220 } ) ;
226221} ) ;
0 commit comments