refactor: remove residual campus and department fields
This commit is contained in:
31
apps/server/src/archive/archive-report.service.spec.ts
Normal file
31
apps/server/src/archive/archive-report.service.spec.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { ArchiveReportService } from './archive-report.service';
|
||||
|
||||
describe('ArchiveReportService retired profile fields', () => {
|
||||
it('does not render the retired campus field in a student report', async () => {
|
||||
const service = new ArchiveReportService(
|
||||
{ findOne: jest.fn().mockResolvedValue({ campusLocation: '旧校区', grade: '高三' }) } as never,
|
||||
{ find: jest.fn().mockResolvedValue([]) } as never,
|
||||
{ find: jest.fn().mockResolvedValue([]) } as never,
|
||||
{ find: jest.fn().mockResolvedValue([]) } as never,
|
||||
{ findOne: jest.fn().mockResolvedValue(null) } as never,
|
||||
{ find: jest.fn().mockResolvedValue([]) } as never,
|
||||
{
|
||||
findOne: jest.fn().mockResolvedValue({
|
||||
id: 1,
|
||||
name: '测试学生',
|
||||
gender: '男',
|
||||
phone: '',
|
||||
ethnicity: '',
|
||||
emergencyContact: '',
|
||||
emergencyPhone: '',
|
||||
}),
|
||||
} as never,
|
||||
);
|
||||
|
||||
const html = await service.generateReportHtml(1);
|
||||
|
||||
expect(html).not.toContain('旧校区');
|
||||
expect(html).not.toContain('<span>校区</span>');
|
||||
expect(html).toContain('高三');
|
||||
});
|
||||
});
|
||||
@@ -308,7 +308,6 @@ ${this.buildLearningAndResult(learnings, result, now)}
|
||||
<div class="summary-row"><span>民族</span><span>${this.esc(student.ethnicity || '-')}</span></div>
|
||||
<div class="summary-row"><span>紧急联系人</span><span>${this.esc(student.emergencyContact || '-')}</span></div>
|
||||
<div class="summary-row"><span>紧急电话</span><span>${this.esc(student.emergencyPhone || '-')}</span></div>
|
||||
<div class="summary-row"><span>校区</span><span>${this.esc(profile?.campusLocation || '-')}</span></div>
|
||||
<div class="summary-row"><span>年级</span><span>${this.esc(profile?.grade || '-')}</span></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
18
apps/server/src/archive/dto/archive.dto.spec.ts
Normal file
18
apps/server/src/archive/dto/archive.dto.spec.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'reflect-metadata';
|
||||
import { plainToInstance } from 'class-transformer';
|
||||
import { validate } from 'class-validator';
|
||||
import { UpsertProfileDto } from './archive.dto';
|
||||
|
||||
describe('UpsertProfileDto retired fields', () => {
|
||||
it('removes the retired campusLocation field under whitelist validation', async () => {
|
||||
const dto = plainToInstance(UpsertProfileDto, {
|
||||
grade: '高三',
|
||||
campusLocation: '旧校区',
|
||||
});
|
||||
|
||||
await validate(dto, { whitelist: true });
|
||||
|
||||
expect(dto).toMatchObject({ grade: '高三' });
|
||||
expect(dto).not.toHaveProperty('campusLocation');
|
||||
});
|
||||
});
|
||||
@@ -5,7 +5,6 @@ export class UpsertProfileDto {
|
||||
@IsOptional() @IsString() targetMajor?: string;
|
||||
@IsOptional() @IsString() subjectDirection?: string;
|
||||
@IsOptional() @IsString() grade?: string;
|
||||
@IsOptional() @IsString() campusLocation?: string;
|
||||
@IsOptional() @IsDateString() profileDate?: string;
|
||||
@IsOptional() @IsString() notes?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user