fix(admin,server): 修复 Dashboard 甘特图时间线与数据校验
Some checks failed
CI / check (pull_request) Failing after 1m54s
Some checks failed
CI / check (pull_request) Failing after 1m54s
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { buildGanttOption } from './DashboardCharts';
|
||||
import type { GanttOccupancy } from './Dashboard.types';
|
||||
|
||||
const ganttRoom = (occupancies: GanttOccupancy[]) => [
|
||||
{ roomNumber: 'A101', occupancies },
|
||||
];
|
||||
|
||||
describe('buildGanttOption 甘特图时间线', () => {
|
||||
it('未退宿的入住条在查看过去月份时截断到 periodEnd,而不是画到今天', () => {
|
||||
const option = buildGanttOption(
|
||||
ganttRoom([
|
||||
{
|
||||
studentName: '张三',
|
||||
checkInDate: '2026-05-01',
|
||||
checkOutDate: null,
|
||||
},
|
||||
]),
|
||||
{ periodEnd: '2026-06-30', today: '2026-08-07' },
|
||||
);
|
||||
|
||||
const series = option.series as Array<{ data: Array<{ value: [string, string, string, boolean] }> }>;
|
||||
expect(series[0].data[0].value[2]).toBe('2026-06-30');
|
||||
expect(series[0].data[0].value[3]).toBe(true);
|
||||
});
|
||||
|
||||
it('未退宿的入住条在查看当前月时截断到今天', () => {
|
||||
const option = buildGanttOption(
|
||||
ganttRoom([
|
||||
{
|
||||
studentName: '张三',
|
||||
checkInDate: '2026-07-01',
|
||||
checkOutDate: null,
|
||||
},
|
||||
]),
|
||||
{ periodEnd: '2026-08-31', today: '2026-08-07' },
|
||||
);
|
||||
|
||||
const series = option.series as Array<{ data: Array<{ value: [string, string, string, boolean] }> }>;
|
||||
expect(series[0].data[0].value[2]).toBe('2026-08-07');
|
||||
});
|
||||
|
||||
it('已退宿的入住条保留真实退宿日期', () => {
|
||||
const option = buildGanttOption(
|
||||
ganttRoom([
|
||||
{
|
||||
studentName: '李四',
|
||||
checkInDate: '2026-05-01',
|
||||
checkOutDate: '2026-06-15',
|
||||
},
|
||||
]),
|
||||
{ periodEnd: '2026-06-30', today: '2026-08-07' },
|
||||
);
|
||||
|
||||
const series = option.series as Array<{ data: Array<{ value: [string, string, string, boolean] }> }>;
|
||||
expect(series[0].data[0].value[2]).toBe('2026-06-15');
|
||||
expect(series[0].data[0].value[3]).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user