fix permissions and teacher attendance workflows

This commit is contained in:
2026-07-10 20:40:52 +08:00
parent 247879f276
commit 8ed1682b90
95 changed files with 4745 additions and 1237 deletions

View File

@@ -0,0 +1,41 @@
import { SchedulesService } from './schedules.service';
const createQb = () => ({
andWhere: jest.fn().mockReturnThis(),
orderBy: jest.fn().mockReturnThis(),
addOrderBy: jest.fn().mockReturnThis(),
getMany: jest.fn().mockResolvedValue([]),
});
describe('SchedulesService — teacher class scope', () => {
it('filters schedule list to assigned classes when no class filter is selected', async () => {
const qb = createQb();
const scheduleRepo = { createQueryBuilder: jest.fn().mockReturnValue(qb) };
const service = new SchedulesService(
scheduleRepo as never,
{} as never,
{} as never,
{} as never,
);
await service.findAll({}, [3, 5]);
expect(qb.andWhere).toHaveBeenCalledWith('cs.classId IN (:...accessibleClassIds)', {
accessibleClassIds: [3, 5],
});
});
it('returns no schedules when teacher has no assigned classes', async () => {
const qb = createQb();
const scheduleRepo = { createQueryBuilder: jest.fn().mockReturnValue(qb) };
const service = new SchedulesService(
scheduleRepo as never,
{} as never,
{} as never,
{} as never,
);
await expect(service.findAll({}, [])).resolves.toEqual([]);
expect(qb.getMany).not.toHaveBeenCalled();
});
});