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:
@@ -117,6 +117,7 @@ async getGanttData(
|
||||
.leftJoinAndSelect('o.student', 'student')
|
||||
.leftJoinAndSelect('o.room', 'room')
|
||||
.where('room.status != :archived', { archived: 'archived' })
|
||||
.andWhere('o.status = :status', { status: 'active' })
|
||||
.orderBy('room.roomNumber', 'ASC')
|
||||
.addOrderBy('o.checkInDate', 'ASC');
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ const queriesService = (attendanceRepo?: unknown) =>
|
||||
|
||||
const createQb = () => ({
|
||||
leftJoin: jest.fn().mockReturnThis(),
|
||||
leftJoinAndSelect: jest.fn().mockReturnThis(),
|
||||
select: jest.fn().mockReturnThis(),
|
||||
addSelect: jest.fn().mockReturnThis(),
|
||||
where: jest.fn().mockReturnThis(),
|
||||
@@ -13,9 +14,11 @@ const createQb = () => ({
|
||||
groupBy: jest.fn().mockReturnThis(),
|
||||
addGroupBy: jest.fn().mockReturnThis(),
|
||||
orderBy: jest.fn().mockReturnThis(),
|
||||
addOrderBy: jest.fn().mockReturnThis(),
|
||||
limit: jest.fn().mockReturnThis(),
|
||||
getRawMany: jest.fn().mockResolvedValue([]),
|
||||
getRawOne: jest.fn().mockResolvedValue({ cnt: '0' }),
|
||||
getMany: jest.fn().mockResolvedValue([]),
|
||||
});
|
||||
|
||||
describe('DashboardService — teacher class scope', () => {
|
||||
@@ -48,6 +51,18 @@ describe('DashboardService — teacher class scope', () => {
|
||||
});
|
||||
|
||||
describe('DashboardService — boundary conditions', () => {
|
||||
it('excludes archived occupancy records from the gantt timeline', async () => {
|
||||
const qb = createQb();
|
||||
const occRepo = { createQueryBuilder: jest.fn().mockReturnValue(qb) };
|
||||
const queries = queriesService();
|
||||
|
||||
await queries.getGanttData(occRepo as never, () => undefined);
|
||||
|
||||
expect(qb.andWhere).toHaveBeenCalledWith('o.status = :status', {
|
||||
status: 'active',
|
||||
});
|
||||
});
|
||||
|
||||
it('uses a deny-all predicate instead of an empty SQL IN list', async () => {
|
||||
const qb = createQb();
|
||||
const attendanceRepo = { createQueryBuilder: jest.fn().mockReturnValue(qb) };
|
||||
|
||||
Reference in New Issue
Block a user