Repository navigation
fix(dashboard): 新建定时任务的前置条件测试按目标群解析工作目录 - #3024
Merged
Merged
Conversation
新建表单的「测试前置条件」用 GET 下发的 Bot 默认目录当 cwd,而任务落库时 服务端按「显式目录 → 目标群 oncall → Bot 默认目录」解析。目标群绑定了不同 的 oncall 目录时,测试和真实触发在两个目录里跑,前置脚本可能误报通过。 - 前置条件测试接口在请求不带 workingDir 时,用建任务同一个 resolveDashboardScheduleWorkingDir 按 chatId 解析目录 - 新建表单发送首个目标群的 chatId,不再发送 Bot 默认目录;没选群时不能测试 - schedule_working_dir_unavailable / invalid_working_dir 显示中英文提示, 指向「Bot 配置 → 默认工作目录」或目标群的 oncall 目录
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 7, 2026 11:04
This was referenced Nov 7, 2026
|
🚀 Released in v3.59.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2853
只处理 issue 里的第 1、2 项。第 3~5 项(补 GET 分支测试、
getBot写法对齐、多群目录语义注释)不在本 PR 内。现象
schedule_working_dir_unavailable/invalid_working_dir。根因
GET /api/bot-default-oncall下发的scheduleWorkingDir由不带 chatId 的resolveDashboardScheduleWorkingDir(appId)算出,只是 Bot 级兜底。新建表单把它当作前置条件测试的 cwd,而POST /api/schedules落库时走带 chatId 的三级链(显式目录 → 目标群 oncall → Bot 默认目录)。两条链路的目录因此分叉。编辑态用的是已落库的workingDir,不受影响。修法
POST /api/schedules/precondition/test在请求不带workingDir时,用建任务同一个resolveDashboardScheduleWorkingDir(appId, chatId)解析目录,解析失败时返回同样的错误码。带workingDir的请求(编辑态)行为不变。chatId(和建任务时服务端取的主群一致),不再发送 Bot 默认目录;还没选群时测试按钮不可用;切换目标群会清掉上次的测试结果。GET 里的
scheduleWorkingDir字段保留不动,表单不再读它。影响范围
只影响 Dashboard 新建定时任务表单的前置条件测试,以及这两个错误码的显示文案。建任务的目录解析、编辑态测试、CLI 侧都不变。
验证
新增 3 个用例,都在旧代码上失败、修复后通过(vitest 和 bun 两路都已确认):
test/dashboard-schedule-creator.test.ts:目标群绑定了 oncall 目录时,前置条件测试的脚本断言自己在 oncall 目录里运行;Bot 没有默认目录时返回schedule_working_dir_unavailable。test/dashboard-schedule-precondition-layout.test.ts:新建表单没选群时不能测试;选群后请求体带chatId、不带workingDir;错误码显示为中文提示。变异验证(每条单独回退,都有用例失败):表单仍发 Bot 默认目录;去掉错误码映射;服务端忽略 chatId;没选群也允许测试。
创建失败那条提示和测试结果共用同一个映射函数;页面组件本身没有测试夹具,创建失败的调用点没有单独的用例。
相关测试:
dashboard-ipc、dashboard-schedules-ui、dashboard-schedule-chat-picker、dashboard-bot-payload、dashboard-schedule-precondition-layout、dashboard-schedule-creator、dashboard-i18n*共 982 个通过;bun run build(含 tsc)通过。