feat(ai): add tenant-safe hierarchical expense learning
This commit is contained in:
@@ -407,13 +407,48 @@ test('忘记偏好失败时不移除 memory,也不改当前字段', async () =
|
||||
assert.match(toasts.at(-1), /偏好服务暂不可用/)
|
||||
})
|
||||
|
||||
test('申请预览 UI 解释已应用偏好并提供可访问的忘记入口', () => {
|
||||
test('组织记忆不允许普通用户调用忘记接口', async () => {
|
||||
const organizationMemory = {
|
||||
memoryId: 'memory-enterprise-policy',
|
||||
fieldKey: 'transport_mode',
|
||||
fieldLabel: '出行方式',
|
||||
value: '火车',
|
||||
status: 'applied',
|
||||
scopeType: 'enterprise',
|
||||
canRevoke: false
|
||||
}
|
||||
const message = {
|
||||
id: 'preview-enterprise-memory',
|
||||
applicationPreview: createPreview({ memoryApplications: [organizationMemory] })
|
||||
}
|
||||
const { actions, toasts } = createActions()
|
||||
let requestCount = 0
|
||||
global.fetch = async () => {
|
||||
requestCount += 1
|
||||
throw new Error('不应发起组织记忆删除请求')
|
||||
}
|
||||
|
||||
const forgotten = await actions.forgetApplicationPreviewMemory(message, organizationMemory)
|
||||
|
||||
assert.equal(forgotten, false)
|
||||
assert.equal(requestCount, 0)
|
||||
assert.equal(message.applicationPreview.memoryApplications.length, 1)
|
||||
assert.match(toasts.at(-1), /管理员统一维护/)
|
||||
})
|
||||
|
||||
test('申请预览 UI 解释分层记忆,仅个人记忆提供忘记入口', () => {
|
||||
assert.match(messageItemTemplate, /<TravelReimbursementMemoryPanel :message="message" :ui="ui" \/>/)
|
||||
assert.match(memoryPanelTemplate, /resolveAppliedApplicationPreviewMemories\(props\.message\)/)
|
||||
assert.match(memoryPanelTemplate, /已按历史偏好填入/)
|
||||
assert.match(memoryPanelTemplate, /企业制度填充/)
|
||||
assert.match(memoryPanelTemplate, /部门基线填充/)
|
||||
assert.match(memoryPanelTemplate, /个性化填充/)
|
||||
assert.match(memoryPanelTemplate, /您仍可直接修改上方字段/)
|
||||
assert.match(memoryPanelTemplate, /忘记此偏好/)
|
||||
assert.match(memoryPanelTemplate, /v-if="canForgetMemory\(memory\)"/)
|
||||
assert.match(memoryPanelTemplate, /memory\.scopeType === 'user' && memory\.canRevoke === true/)
|
||||
assert.match(memoryPanelTemplate, /:aria-busy="ui\.isForgettingApplicationMemory\(memory\)"/)
|
||||
assert.match(memoryPanelTemplate, /检测到同层级设置冲突/)
|
||||
assert.doesNotMatch(memoryPanelTemplate, /JSON\.stringify\(memory\.conflicts/)
|
||||
assert.match(memoryPanelTemplate, /resolveVisibleApplicationLearningReceipts\(props\.message\)/)
|
||||
assert.match(memoryPanelTemplate, /ui\.resolveApplicationLearningReceiptTitle\(receipt\)/)
|
||||
assert.doesNotMatch(messageItemTemplate, /已按历史偏好填入/)
|
||||
|
||||
Reference in New Issue
Block a user