fix tests
This commit is contained in:
@@ -264,7 +264,13 @@ export class AccessCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case Permission.ALBUM_REMOVE_ASSET: {
|
case Permission.ALBUM_REMOVE_ASSET: {
|
||||||
return await this.repository.album.checkOwnerAccess(auth.user.id, ids);
|
const isOwner = await this.repository.album.checkOwnerAccess(auth.user.id, ids);
|
||||||
|
const isShared = await this.repository.album.checkSharedAlbumAccess(
|
||||||
|
auth.user.id,
|
||||||
|
setDifference(ids, isOwner),
|
||||||
|
AlbumUserRole.EDITOR,
|
||||||
|
);
|
||||||
|
return setUnion(isOwner, isShared);
|
||||||
}
|
}
|
||||||
|
|
||||||
case Permission.ASSET_UPLOAD: {
|
case Permission.ASSET_UPLOAD: {
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ describe(AlbumService.name, () => {
|
|||||||
ownerId: authStub.admin.user.id,
|
ownerId: authStub.admin.user.id,
|
||||||
albumName: albumStub.empty.albumName,
|
albumName: albumStub.empty.albumName,
|
||||||
description: albumStub.empty.description,
|
description: albumStub.empty.description,
|
||||||
sharedUsers: [{ user: { id: 'user-id' } }],
|
albumUsers: [{ user: { id: 'user-id' } }],
|
||||||
assets: [{ id: '123' }],
|
assets: [{ id: '123' }],
|
||||||
albumThumbnailAssetId: '123',
|
albumThumbnailAssetId: '123',
|
||||||
});
|
});
|
||||||
@@ -230,7 +230,7 @@ describe(AlbumService.name, () => {
|
|||||||
ownerId: authStub.admin.user.id,
|
ownerId: authStub.admin.user.id,
|
||||||
albumName: 'Test album',
|
albumName: 'Test album',
|
||||||
description: '',
|
description: '',
|
||||||
sharedUsers: [],
|
albumUsers: [],
|
||||||
assets: [{ id: 'asset-1' }],
|
assets: [{ id: 'asset-1' }],
|
||||||
albumThumbnailAssetId: 'asset-1',
|
albumThumbnailAssetId: 'asset-1',
|
||||||
});
|
});
|
||||||
@@ -366,7 +366,7 @@ describe(AlbumService.name, () => {
|
|||||||
user: userStub.user2,
|
user: userStub.user2,
|
||||||
albumId: albumStub.sharedWithAdmin.id,
|
albumId: albumStub.sharedWithAdmin.id,
|
||||||
album: albumStub.sharedWithAdmin,
|
album: albumStub.sharedWithAdmin,
|
||||||
role: AlbumUserRole.EDITOR,
|
role: AlbumUserRole.VIEWER,
|
||||||
});
|
});
|
||||||
await sut.addUsers(authStub.user1, albumStub.sharedWithAdmin.id, { sharedUserIds: [authStub.user2.user.id] });
|
await sut.addUsers(authStub.user1, albumStub.sharedWithAdmin.id, { sharedUserIds: [authStub.user2.user.id] });
|
||||||
expect(albumUserMock.create).toHaveBeenCalledWith({
|
expect(albumUserMock.create).toHaveBeenCalledWith({
|
||||||
@@ -730,7 +730,7 @@ describe(AlbumService.name, () => {
|
|||||||
expect(albumMock.update).not.toHaveBeenCalled();
|
expect(albumMock.update).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should skip assets without user permission to remove', async () => {
|
it('should skip assets when user has remove permission on album but not on asset', async () => {
|
||||||
accessMock.album.checkSharedAlbumAccess.mockResolvedValue(new Set(['album-123']));
|
accessMock.album.checkSharedAlbumAccess.mockResolvedValue(new Set(['album-123']));
|
||||||
albumMock.getById.mockResolvedValue(_.cloneDeep(albumStub.oneAsset));
|
albumMock.getById.mockResolvedValue(_.cloneDeep(albumStub.oneAsset));
|
||||||
albumMock.getAssetIds.mockResolvedValue(new Set(['asset-id']));
|
albumMock.getAssetIds.mockResolvedValue(new Set(['asset-id']));
|
||||||
|
|||||||
Reference in New Issue
Block a user