@@ -7,7 +7,6 @@ import { drizzle as drizzleSqliteAdapter } from 'drizzle-orm/better-sqlite3';
7
7
// Modules to mock
8
8
import * as configModule from '../../../src/db/config' ;
9
9
import * as staticSchemaModule from '../../../src/db/schema.sqlite' ;
10
- import * as schemaModule from '../../../src/db/schema' ; // For inputPluginTableDefinitions
11
10
12
11
// Functions from the module under test
13
12
import {
@@ -100,10 +99,6 @@ vi.mock('../../../src/db/schema.sqlite', () => ({
100
99
// e.g., authUser: {}, authSession: {}
101
100
// For now, an empty object might suffice if generateSchema doesn't rely on specific props
102
101
// from staticSchema for the core tests.
103
- } ) ) ;
104
-
105
- // Mock './schema' for inputPluginTableDefinitions
106
- vi . mock ( '../../../src/db/schema' , ( ) => ( {
107
102
pluginTableDefinitions : { } , // Start with empty plugin definitions
108
103
} ) ) ;
109
104
@@ -207,20 +202,20 @@ describe('Database Service (db/index.ts)', () => {
207
202
} ;
208
203
209
204
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
212
207
// 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 > ;
214
209
for ( const key in ptd ) {
215
210
delete ptd [ key ] ;
216
211
}
217
212
} ) ;
218
213
219
214
it ( 'should register table definitions from plugins' , ( ) => {
220
215
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 ) ;
224
219
} ) ;
225
220
} ) ;
226
221
} ) ;
0 commit comments