feat(G1,P16A,P16B): 收口主数据核心与节假日日历增强
这个提交包含在:
@@ -13,7 +13,7 @@ describe("FeatureFlags Service", () => {
|
||||
it("returns env_hard_off when config disables it globally", async () => {
|
||||
const result = await featureFlags.evaluateFeatureFlag({
|
||||
prisma: {},
|
||||
config: { invoiceVerificationEnabled: false },
|
||||
config: { invoiceVerificationEnabled: false, leaveHolidayCalendarEnabled: true },
|
||||
flagKey: featureFlags.FEATURE_FLAG_KEYS.invoiceVerification,
|
||||
});
|
||||
expect(result.enabled).toBe(false);
|
||||
@@ -34,7 +34,7 @@ describe("FeatureFlags Service", () => {
|
||||
|
||||
const result = await featureFlags.evaluateFeatureFlag({
|
||||
prisma: mockPrisma,
|
||||
config: { invoiceVerificationEnabled: true },
|
||||
config: { invoiceVerificationEnabled: true, leaveHolidayCalendarEnabled: true },
|
||||
flagKey: featureFlags.FEATURE_FLAG_KEYS.invoiceVerification,
|
||||
});
|
||||
|
||||
@@ -56,7 +56,7 @@ describe("FeatureFlags Service", () => {
|
||||
|
||||
const result = await featureFlags.evaluateFeatureFlag({
|
||||
prisma: mockPrisma,
|
||||
config: { invoiceVerificationEnabled: true },
|
||||
config: { invoiceVerificationEnabled: true, leaveHolidayCalendarEnabled: true },
|
||||
flagKey: featureFlags.FEATURE_FLAG_KEYS.invoiceVerification,
|
||||
departmentId: "dep_B",
|
||||
strictDepartment: true
|
||||
@@ -80,7 +80,7 @@ describe("FeatureFlags Service", () => {
|
||||
|
||||
const result = await featureFlags.evaluateFeatureFlag({
|
||||
prisma: mockPrisma,
|
||||
config: { invoiceVerificationEnabled: true },
|
||||
config: { invoiceVerificationEnabled: true, leaveHolidayCalendarEnabled: true },
|
||||
flagKey: featureFlags.FEATURE_FLAG_KEYS.invoiceVerification,
|
||||
departmentId: "dep_B",
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const {
|
||||
calculateRequestedDays,
|
||||
calculateRequestedDaysByWorkingCalendar,
|
||||
leaveRangesOverlap,
|
||||
summarizeLeaveLedgerEntries,
|
||||
} = require("../../../src/services/leave");
|
||||
@@ -49,6 +50,54 @@ describe("Leave Service", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("calculateRequestedDaysByWorkingCalendar", () => {
|
||||
it("skips weekend days by default and respects adjusted workdays", () => {
|
||||
expect(
|
||||
calculateRequestedDaysByWorkingCalendar({
|
||||
startDate: "2026-03-20",
|
||||
endDate: "2026-03-22",
|
||||
startSession: "am",
|
||||
endSession: "pm",
|
||||
calendarDays: [],
|
||||
}),
|
||||
).toBe(1);
|
||||
|
||||
expect(
|
||||
calculateRequestedDaysByWorkingCalendar({
|
||||
startDate: "2026-03-20",
|
||||
endDate: "2026-03-22",
|
||||
startSession: "am",
|
||||
endSession: "pm",
|
||||
calendarDays: [{ date: "2026-03-21", day_type: "adjusted_workday" }],
|
||||
}),
|
||||
).toBe(2);
|
||||
});
|
||||
|
||||
it("skips configured holidays inside a weekday span", () => {
|
||||
expect(
|
||||
calculateRequestedDaysByWorkingCalendar({
|
||||
startDate: "2026-03-16",
|
||||
endDate: "2026-03-17",
|
||||
startSession: "am",
|
||||
endSession: "pm",
|
||||
calendarDays: [{ date: "2026-03-17", day_type: "holiday" }],
|
||||
}),
|
||||
).toBe(1);
|
||||
});
|
||||
|
||||
it("rejects ranges that become fully non-working after calendar adjustment", () => {
|
||||
expect(() =>
|
||||
calculateRequestedDaysByWorkingCalendar({
|
||||
startDate: "2026-03-21",
|
||||
endDate: "2026-03-22",
|
||||
startSession: "am",
|
||||
endSession: "pm",
|
||||
calendarDays: [],
|
||||
}),
|
||||
).toThrow(/参数校验失败/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("leaveRangesOverlap", () => {
|
||||
it("detects overlapping half-day ranges", () => {
|
||||
expect(
|
||||
|
||||
在新工单中引用
屏蔽一个用户