Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pac
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tools
pac
Commits
97dfb046
Commit
97dfb046
authored
Oct 09, 2026
by
luoqi
Browse files
Options
Browse Files
Download
Plain Diff
Merge CLI channel isolation fix into test
parents
51438523
75233df0
Pipeline
#3723
failed in 0 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
apps/pac-service/src/cli/bootstrap-flags.ts
+4
-0
apps/pac-service/tests/weixin-aibot.lifecycle.spec.ts
+41
-0
No files found.
apps/pac-service/src/cli/bootstrap-flags.ts
View file @
97dfb046
...
@@ -14,4 +14,8 @@
...
@@ -14,4 +14,8 @@
*/
*/
export
function
disableSchedulersForCli
():
void
{
export
function
disableSchedulersForCli
():
void
{
process
.
env
.
PAC_SCHEDULER_DISABLED
=
'1'
;
process
.
env
.
PAC_SCHEDULER_DISABLED
=
'1'
;
// CLI 不订阅机器人消息,避免与常驻服务竞争连接或执行群聊请求。
// 设为空而非删除,防止 ConfigModule 再次读取 .env 时补回凭据。
process
.
env
.
PAC_WX_AIBOT_BOT_ID
=
''
;
process
.
env
.
PAC_WX_AIBOT_SECRET
=
''
;
}
}
apps/pac-service/tests/weixin-aibot.lifecycle.spec.ts
0 → 100644
View file @
97dfb046
import
AiBot
from
'@wecom/aibot-node-sdk'
;
import
{
disableSchedulersForCli
}
from
'../src/cli/bootstrap-flags'
;
import
{
WeixinAibotService
}
from
'../src/modules/weixin-aibot/weixin-aibot.service'
;
jest
.
mock
(
'@wecom/aibot-node-sdk'
,
()
=>
({
__esModule
:
true
,
default
:
{
WSClient
:
jest
.
fn
()
},
generateReqId
:
jest
.
fn
(),
}));
describe
(
'企微机器人启动隔离'
,
()
=>
{
const
original
=
{
...
process
.
env
};
const
make
=
()
=>
new
WeixinAibotService
({}
as
never
,
{}
as
never
,
{}
as
never
,
{}
as
never
);
beforeEach
(()
=>
{
process
.
env
.
PAC_WX_AIBOT_BOT_ID
=
'test-bot'
;
process
.
env
.
PAC_WX_AIBOT_SECRET
=
'test-secret'
;
jest
.
clearAllMocks
();
});
afterEach
(()
=>
{
process
.
env
=
{
...
original
};
});
it
(
'维护 CLI 即使继承完整机器人配置,也不建立连接或注册消息处理'
,
()
=>
{
disableSchedulersForCli
();
const
service
=
make
();
service
.
onModuleInit
();
service
.
onModuleDestroy
();
expect
(
AiBot
.
WSClient
).
not
.
toHaveBeenCalled
();
expect
(
process
.
env
.
PAC_SCHEDULER_DISABLED
).
toBe
(
'1'
);
});
it
(
'常驻服务仍正常订阅,并在关闭时断开'
,
()
=>
{
const
client
=
{
on
:
jest
.
fn
(),
connect
:
jest
.
fn
(),
disconnect
:
jest
.
fn
()
};
jest
.
mocked
(
AiBot
.
WSClient
).
mockImplementation
(()
=>
client
as
never
);
const
service
=
make
();
service
.
onModuleInit
();
expect
(
client
.
on
).
toHaveBeenCalledWith
(
'message.text'
,
expect
.
any
(
Function
));
expect
(
client
.
connect
).
toHaveBeenCalledTimes
(
1
);
service
.
onModuleDestroy
();
expect
(
client
.
disconnect
).
toHaveBeenCalledTimes
(
1
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment