diff --git a/backend/tests/test_hr_leave_sqlserver_support.py b/backend/tests/test_hr_leave_sqlserver_support.py index 14907889..ed672487 100644 --- a/backend/tests/test_hr_leave_sqlserver_support.py +++ b/backend/tests/test_hr_leave_sqlserver_support.py @@ -1,4 +1,5 @@ from app.services.hr_leave_sqlserver import HRLeaveSQLServerService +from types import SimpleNamespace def test_supports_strong_leave_balance_intent_without_self_pronoun(): @@ -6,8 +7,27 @@ def test_supports_strong_leave_balance_intent_without_self_pronoun(): assert HRLeaveSQLServerService.supports("还有多少假期") assert HRLeaveSQLServerService.supports("年假还有多少天") assert HRLeaveSQLServerService.supports("还有多少年假") + assert HRLeaveSQLServerService.supports("我还有多少假期") + assert HRLeaveSQLServerService.supports("自己还有多少假期") def test_supports_rejects_leave_process_questions(): assert not HRLeaveSQLServerService.supports("假期怎么申请") assert not HRLeaveSQLServerService.supports("年假制度是什么") + + +def test_supports_other_person_leave_queries_for_guardrail(): + assert HRLeaveSQLServerService.supports("张三还有多少假期") + assert HRLeaveSQLServerService.supports("曹惠鹏还有多少假期") + assert HRLeaveSQLServerService.supports("帮我查一下其他人的年假情况") + + +def test_is_querying_other_person_leave_distinguishes_self_and_others(): + user = SimpleNamespace(real_name="李四", username="lisi", employee_id="E1001") + assert HRLeaveSQLServerService._is_querying_other_person_leave("张三还有多少假期", user) + assert HRLeaveSQLServerService._is_querying_other_person_leave("曹惠鹏还有多少假期", user) + assert HRLeaveSQLServerService._is_querying_other_person_leave("帮我查一下其他人的年假情况", user) + assert not HRLeaveSQLServerService._is_querying_other_person_leave("我还有多少假期", user) + assert not HRLeaveSQLServerService._is_querying_other_person_leave("自己还有多少假期", user) + assert not HRLeaveSQLServerService._is_querying_other_person_leave("还有多少假期", user) + assert not HRLeaveSQLServerService._is_querying_other_person_leave("李四的年假还有多少", user) diff --git a/docs/FixedAssets_20260622_062452.xlsx b/docs/FixedAssets_20260622_062452.xlsx new file mode 100644 index 00000000..82b2e0f5 Binary files /dev/null and b/docs/FixedAssets_20260622_062452.xlsx differ diff --git a/docs/FixedAssets_20260622_063956.xlsx b/docs/FixedAssets_20260622_063956.xlsx new file mode 100644 index 00000000..728c3379 Binary files /dev/null and b/docs/FixedAssets_20260622_063956.xlsx differ diff --git a/docs/FixedAssets_20260622_190024.xlsx b/docs/FixedAssets_20260622_190024.xlsx new file mode 100644 index 00000000..1fecdf7f Binary files /dev/null and b/docs/FixedAssets_20260622_190024.xlsx differ diff --git a/docs/FixedAssets_latest.xlsx b/docs/FixedAssets_latest.xlsx new file mode 100644 index 00000000..1fecdf7f Binary files /dev/null and b/docs/FixedAssets_latest.xlsx differ diff --git a/docs/convention/COMMIT_CONVENTION.md b/docs/convention/COMMIT_CONVENTION.md index 3ee04784..0349ec45 100644 --- a/docs/convention/COMMIT_CONVENTION.md +++ b/docs/convention/COMMIT_CONVENTION.md @@ -6,7 +6,7 @@ - 一个提交只做一件事(或同一类紧密相关的事)。 - 提交信息要让不了解上下文的人也能快速理解“改了什么、为什么改”。 -- **`type` 与 `scope` 使用英文**;**`subject` 与 `body` 使用中文**,便于团队阅读且 scope 与代码模块一一对应。 +- **`type`** **与** **`scope`** **使用英文**;**`subject`** **与** **`body`** **使用中文**,便于团队阅读且 scope 与代码模块一一对应。 - 所有人遵循同一格式,减少代码评审和回溯成本。 ## 2. 标准格式(必须) @@ -79,20 +79,20 @@ Scope 应对齐代码模块,便于从提交信息定位到目录。选取规 2. 目录名转 kebab-case:`shipping_notice` → `shipping-notice`,`rohs_check` → `rohs-check`。 3. 跨模块改动选影响最大的模块;纯基建用 `jenkins`、`migration`、`deps`、`ci` 等。 -| scope | 典型目录/模块 | -| --- | --- | -| `schedule` | `services/schedule/`、`api/schedule_admin`、前端 `features/admin/modules/schedules/` | -| `shipping-notice` | `services/shipping_notice/`、`api/workspace_shipping_notice` | -| `file-check` | `services/file_check*`、`api/file_check_tools` | -| `rohs-check` | RoHS 实例(历史 scope,新改动请用 `file-check`) | -| `knowledge-base` | `api/knowledge_base`、`services/knowledge_cleaning/` | -| `chat` | `api/chat`、前端 chat 相关 | -| `auth` | 登录认证 | -| `admin` | 管理后台通用 | -| `agents` | Agent 管理 | -| `api` | 跨模块 API 层重构 | -| `migration` | Alembic 迁移 | -| `jenkins` / `ci` / `deps` | 工程与依赖 | +| scope | 典型目录/模块 | +| ------------------------- | -------------------------------------------------------------------------------- | +| `schedule` | `services/schedule/`、`api/schedule_admin`、前端 `features/admin/modules/schedules/` | +| `shipping-notice` | `services/shipping_notice/`、`api/workspace_shipping_notice` | +| `file-check` | `services/file_check*`、`api/file_check_tools` | +| `rohs-check` | RoHS 实例(历史 scope,新改动请用 `file-check`) | +| `knowledge-base` | `api/knowledge_base`、`services/knowledge_cleaning/` | +| `chat` | `api/chat`、前端 chat 相关 | +| `auth` | 登录认证 | +| `admin` | 管理后台通用 | +| `agents` | Agent 管理 | +| `api` | 跨模块 API 层重构 | +| `migration` | Alembic 迁移 | +| `jenkins` / `ci` / `deps` | 工程与依赖 | 示例: @@ -203,8 +203,8 @@ revert: feat(shipping-notice): 支持微信扫码结账 可选工具(尚未配置,可按需引入): - `commitizen` 或 `cz-git`:交互式提交,降低学习成本。 -- 参考链接:https://www.conventionalcommits.org/en/v1.0.0/ +- 参考链接: ---- +*** 维护建议:本规范由团队共同维护,若新增 `type` 或调整规则,请在评审通过后更新本文档并同步工具配置。 diff --git a/frontend/src/features/chat/leave/leaveIntent.test.ts b/frontend/src/features/chat/leave/leaveIntent.test.ts new file mode 100644 index 00000000..6225cab2 --- /dev/null +++ b/frontend/src/features/chat/leave/leaveIntent.test.ts @@ -0,0 +1,22 @@ +/** + * 用途:覆盖请假强/弱意图边界,避免“咨询规则”被误判成“立即发起请假”。 + * 依赖:与 leaveIntent.ts 中的 isStrongLeaveIntent 保持一致。 + * 逻辑:弱咨询句应继续走 Dify;强请假句才触发表单流程。 + */ +import { describe, expect, it } from 'vitest'; + +import { isStrongLeaveIntent } from './leaveIntent'; + +describe('isStrongLeaveIntent', () => { + it('将非强请假咨询句判定为弱意图', () => { + // 断言:规则咨询不应触发本地请假表单,应继续走 Dify 问答。 + expect(isStrongLeaveIntent('年假可以按照小时请假吗?')).toBe(false); + expect(isStrongLeaveIntent('怎么请年假?年假可以按照小时请假吗?')).toBe(false); + }); + + it('保留强请假意图触发表单', () => { + // 断言:明确申请/发起请假的表达仍应保留原有请假流程。 + expect(isStrongLeaveIntent('我要请假')).toBe(true); + expect(isStrongLeaveIntent('帮我请年假')).toBe(true); + }); +});