1- import { describe , expect , it } from 'bun:test'
1+ import '@pluxel/hmr/services'
2+ import { describe , expect , it } from 'vitest'
23
34import { mkdir , rm } from 'node:fs/promises'
45import { randomUUID } from 'node:crypto'
56import path from 'node:path'
67
7- import { BasePlugin , Plugin , withTestHost , type TestHost } from '@pluxel/core /test'
8+ import { BasePlugin , Plugin , withHost , type Host } from '@pluxel/test'
89import { MikroOrmLibsql } from 'pluxel-plugin-mikro-orm'
910import { KvMemory } from 'pluxel-plugin-kv'
1011import { BotCore , type AnyMessage } from 'pluxel-plugin-bot-core'
@@ -16,7 +17,7 @@ import { ChatCommand } from './decorators'
1617import { InstallChatCommands } from './install'
1718import { cmd } from './draft'
1819
19- type HostCtx = { host : TestHost ; chatbots : Chatbots }
20+ type HostCtx = { host : Host ; chatbots : Chatbots }
2021
2122async function withChatbotsHost (
2223 plugins : any [ ] ,
@@ -27,14 +28,14 @@ async function withChatbotsHost(
2728 await mkdir ( dataDir , { recursive : true } )
2829 const dbName = path . join ( dataDir , `chatbots-${ randomUUID ( ) } .sqlite` )
2930 try {
30- await withTestHost ( async ( host ) => {
31+ await withHost ( async ( host ) => {
3132 const cfg = host . ctx . configService as unknown as { ready ?: Promise < void > }
3233 if ( cfg . ready ) await cfg . ready
3334
34- host . registerAll ( MikroOrmLibsql , KvMemory , BotCore , Chatbots , ...plugins )
35+ host . add ( [ MikroOrmLibsql , KvMemory , BotCore , Chatbots , ...plugins ] )
3536
36- host . setConfig ( 'MikroOrm' , { config : { dbName, ensureSchemaOnInit : true } } )
37- host . setConfig ( 'bot-core' , {
37+ host . cfg ( 'MikroOrm' ) . set ( { config : { dbName, ensureSchemaOnInit : true } } )
38+ host . cfg ( 'bot-core' ) . set ( {
3839 config : {
3940 bridges : {
4041 kook : { enabled : false } ,
@@ -44,7 +45,7 @@ async function withChatbotsHost(
4445 debug : false ,
4546 } ,
4647 } )
47- host . setConfig ( 'bot-suite' , {
48+ host . cfg ( 'bot-suite' ) . set ( {
4849 config : {
4950 cmdPrefix : '/' ,
5051 debug : false ,
@@ -56,9 +57,9 @@ async function withChatbotsHost(
5657 } ,
5758 } )
5859
59- await host . commitStrict ( )
60+ await host . commit ( )
6061
61- await fn ( { host, chatbots : host . getOrThrow ( Chatbots ) } )
62+ await fn ( { host, chatbots : host . require ( Chatbots ) } )
6263 } )
6364 } finally {
6465 await rm ( dbName , { force : true } )
@@ -114,8 +115,8 @@ describe('chatbots cmdkit (plugin lifecycle integration)', () => {
114115 expect ( ( r as any ) . val ) . toBe ( 'pong' )
115116 }
116117
117- host . unregister ( CmdTestA )
118- await host . commitStrict ( )
118+ host . remove ( CmdTestA )
119+ await host . commit ( )
119120
120121 expect ( registry . list ( ) . some ( ( x ) => x . id === 'cmd-test-a.cmd.ping' ) ) . toBe ( false )
121122 {
@@ -164,7 +165,7 @@ describe('chatbots cmdkit (plugin lifecycle integration)', () => {
164165 }
165166
166167 host . replace ( CmdTestA_v1 , CmdTestA_v2 )
167- await host . commitStrict ( )
168+ await host . commit ( )
168169
169170 const entries = registry . list ( ) . filter ( ( x ) => x . id === 'cmd-test-a.cmd.ping' )
170171 expect ( entries . length ) . toBe ( 1 )
0 commit comments