pr feedback

This commit is contained in:
martabal
2024-05-12 17:25:49 +02:00
parent 7ced61e67d
commit 0f6e665d99
13 changed files with 74 additions and 32 deletions

View File

@@ -78,7 +78,7 @@ const peopleWithFaces = (faces: AssetFaceEntity[]): PeopleWithFacesResponseDto =
}
}
return { faces: result, numberOfFaces: faces.length };
return { visiblePeople: result, numberOfFaces: faces.length };
};
export function mapAsset(entity: AssetEntity, options: AssetMapOptions = {}): AssetResponseDto {

View File

@@ -78,7 +78,7 @@ export class PersonWithFacesResponseDto extends PersonResponseDto {
}
export class PeopleWithFacesResponseDto {
faces!: PersonWithFacesResponseDto[];
visiblePeople!: PersonWithFacesResponseDto[];
@ApiProperty({ type: 'integer' })
numberOfFaces!: number;
}

View File

@@ -449,6 +449,18 @@ describe(PersonService.name, () => {
await expect(sut.unassignFace(authStub.admin, faceStub.face1.id)).resolves.toStrictEqual(
mapFaces(faceStub.unassignedFace, authStub.admin),
);
expect(mediaMock.generateThumbnail).not.toHaveBeenCalled();
});
it('should not unassign a face if user has no create access', async () => {
personMock.getFaceById.mockResolvedValueOnce(faceStub.face1);
accessMock.person.checkOwnerAccess.mockResolvedValue(new Set([personStub.noName.id]));
personMock.reassignFace.mockResolvedValue(1);
personMock.getRandomFace.mockResolvedValue(null);
personMock.getFaceById.mockResolvedValueOnce(faceStub.unassignedFace);
await expect(sut.unassignFace(authStub.admin, faceStub.face1.id)).rejects.toBeInstanceOf(BadRequestException);
});
});
@@ -465,6 +477,18 @@ describe(PersonService.name, () => {
sut.unassignFaces(authStub.admin, { data: [{ assetId: faceStub.face1.id, personId: 'person-1' }] }),
).resolves.toStrictEqual([{ id: 'assetFaceId1', success: true }]);
});
it('should not unassign a face if the user has no create access', async () => {
personMock.getFacesByIds.mockResolvedValueOnce([faceStub.face1]);
accessMock.person.checkOwnerAccess.mockResolvedValue(new Set([personStub.noName.id]));
personMock.reassignFace.mockResolvedValue(1);
personMock.getRandomFace.mockResolvedValue(null);
personMock.getFaceById.mockResolvedValueOnce(faceStub.unassignedFace);
await expect(
sut.unassignFaces(authStub.admin, { data: [{ assetId: faceStub.face1.id, personId: 'person-1' }] }),
).rejects.toBeInstanceOf(BadRequestException);
});
});
describe('handlePersonCleanup', () => {