沉淀数字员工角色偏好状态
This commit is contained in:
@@ -156,6 +156,50 @@ describe("digital employee state service", () => {
|
||||
expect(mockState.ensureSchemaCalls).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("persists console role and role preferences in UI state", async () => {
|
||||
const { readDigitalEmployeeUiState, saveDigitalEmployeeUiState } = await import("./stateService");
|
||||
|
||||
saveDigitalEmployeeUiState({
|
||||
action: "update_role_preferences",
|
||||
metadata: { source: "ops-settings" },
|
||||
state: {
|
||||
selectedDutyIdsByDate: {},
|
||||
confirmedDates: {},
|
||||
reportScheduleTime: "17:30",
|
||||
reportGeneratedAtByDate: {},
|
||||
decisionResultsByDate: {},
|
||||
consoleRole: "engineering",
|
||||
rolePreferences: {
|
||||
workStart: "10:00",
|
||||
workEnd: "19:00",
|
||||
notification: "system",
|
||||
},
|
||||
profile: {
|
||||
name: "飞天数字员工",
|
||||
company: "qimingclaw 客户端",
|
||||
position: "客户端任务执行员",
|
||||
currentStatus: "working",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(readDigitalEmployeeUiState()).toMatchObject({
|
||||
reportScheduleTime: "17:30",
|
||||
consoleRole: "engineering",
|
||||
rolePreferences: {
|
||||
workStart: "10:00",
|
||||
workEnd: "19:00",
|
||||
notification: "system",
|
||||
},
|
||||
});
|
||||
const preferenceEvent = Array.from(mockState.db?.events.values() ?? [])
|
||||
.find((event) => event.kind === "digital_workday_update_role_preferences");
|
||||
expect(preferenceEvent).toMatchObject({
|
||||
kind: "digital_workday_update_role_preferences",
|
||||
message: "数字员工运营偏好已更新",
|
||||
});
|
||||
});
|
||||
|
||||
it("records governance commands as formal runtime records", async () => {
|
||||
const { recordDigitalEmployeeGovernanceCommand } = await import("./stateService");
|
||||
|
||||
|
||||
@@ -168,6 +168,8 @@ export interface DigitalEmployeeUiState {
|
||||
reportScheduleTime: string;
|
||||
reportGeneratedAtByDate: Record<string, string>;
|
||||
decisionResultsByDate: Record<string, Record<string, string>>;
|
||||
consoleRole?: string;
|
||||
rolePreferences?: Record<string, unknown>;
|
||||
profile: {
|
||||
name: string;
|
||||
company: string;
|
||||
@@ -258,6 +260,8 @@ function defaultUiState(): DigitalEmployeeUiState {
|
||||
reportScheduleTime: "18:00",
|
||||
reportGeneratedAtByDate: {},
|
||||
decisionResultsByDate: {},
|
||||
consoleRole: "sales",
|
||||
rolePreferences: {},
|
||||
profile: {
|
||||
name: "飞天数字员工",
|
||||
company: "qimingclaw 客户端",
|
||||
@@ -304,6 +308,11 @@ function normalizeNestedStringMap(value: unknown): Record<string, Record<string,
|
||||
);
|
||||
}
|
||||
|
||||
function normalizeRecord(value: unknown): Record<string, unknown> {
|
||||
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
||||
return { ...value as Record<string, unknown> };
|
||||
}
|
||||
|
||||
function normalizeUiState(
|
||||
value: Partial<DigitalEmployeeUiState>,
|
||||
): DigitalEmployeeUiState {
|
||||
@@ -317,6 +326,10 @@ function normalizeUiState(
|
||||
: fallback.reportScheduleTime,
|
||||
reportGeneratedAtByDate: normalizeStringMap(value.reportGeneratedAtByDate),
|
||||
decisionResultsByDate: normalizeNestedStringMap(value.decisionResultsByDate),
|
||||
consoleRole: typeof value.consoleRole === "string" && value.consoleRole.trim()
|
||||
? value.consoleRole
|
||||
: fallback.consoleRole,
|
||||
rolePreferences: normalizeRecord(value.rolePreferences),
|
||||
profile: {
|
||||
name: typeof profile.name === "string" && profile.name.trim()
|
||||
? profile.name
|
||||
@@ -347,6 +360,10 @@ function digitalEmployeeUiActionMessage(action: string, date?: string): string {
|
||||
return `数字员工日报已生成${suffix}`;
|
||||
case "decide_approval":
|
||||
return `数字员工待决策事项已处理${suffix}`;
|
||||
case "update_console_role":
|
||||
return "数字员工角色已更新";
|
||||
case "update_role_preferences":
|
||||
return "数字员工运营偏好已更新";
|
||||
default:
|
||||
return `数字员工页面状态已更新${suffix}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user