1414
1515import { ObjectQL } from '@objectql/core' ;
1616import { MockDriver } from './mock-driver' ;
17+ import { FormulaPlugin } from '../src/formula-plugin' ;
1718
1819describe ( 'Formula Integration' , ( ) => {
1920 let app : ObjectQL ;
@@ -28,8 +29,18 @@ describe('Formula Integration', () => {
2829 }
2930 } ) ;
3031
32+ // Install the Formula Plugin with a context that has a hook method
33+ const formulaPlugin = new FormulaPlugin ( ) ;
34+ const ctx = {
35+ engine : app ,
36+ hook : ( event : string , handler : any ) => {
37+ app . registerHook ( event , handler ) ;
38+ }
39+ } ;
40+ await formulaPlugin . install ( ctx ) ;
41+
3142 // Register an object with formula fields
32- app . registerObject ( {
43+ const contactSchema = {
3344 name : 'contact' ,
3445 fields : {
3546 first_name : {
@@ -68,7 +79,11 @@ describe('Formula Integration', () => {
6879 label : 'Status' ,
6980 } ,
7081 } ,
71- } ) ;
82+ } ;
83+
84+ // Register in both SchemaRegistry and MetadataRegistry
85+ app . registerObject ( contactSchema ) ;
86+ app . metadata . register ( 'object' , contactSchema ) ;
7287
7388 await app . init ( ) ;
7489 } ) ;
@@ -157,7 +172,7 @@ describe('Formula Integration', () => {
157172 describe ( 'Complex Formula Examples' , ( ) => {
158173 beforeEach ( async ( ) => {
159174 // Register an object with more complex formulas
160- app . registerObject ( {
175+ const orderSchema = {
161176 name : 'order' ,
162177 fields : {
163178 subtotal : { type : 'currency' } ,
@@ -185,7 +200,11 @@ describe('Formula Integration', () => {
185200 data_type : 'text' ,
186201 } ,
187202 } ,
188- } ) ;
203+ } ;
204+
205+ // Register in both SchemaRegistry and MetadataRegistry
206+ app . registerObject ( orderSchema ) ;
207+ app . metadata . register ( 'object' , orderSchema ) ;
189208 } ) ;
190209
191210 it ( 'should calculate complex financial formulas' , async ( ) => {
@@ -247,7 +266,7 @@ describe('Formula Integration', () => {
247266
248267 describe ( 'Formula Error Handling' , ( ) => {
249268 beforeEach ( async ( ) => {
250- app . registerObject ( {
269+ const productSchema = {
251270 name : 'product' ,
252271 fields : {
253272 name : { type : 'text' } ,
@@ -258,7 +277,11 @@ describe('Formula Integration', () => {
258277 data_type : 'number' ,
259278 } ,
260279 } ,
261- } ) ;
280+ } ;
281+
282+ // Register in both SchemaRegistry and MetadataRegistry
283+ app . registerObject ( productSchema ) ;
284+ app . metadata . register ( 'object' , productSchema ) ;
262285 } ) ;
263286
264287 it ( 'should handle formula evaluation errors gracefully' , async ( ) => {
0 commit comments