forked from immich-app/immich
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(server): make owner as required response for AlbumResponseDto (i…
- Loading branch information
1 parent
fb4969d
commit 43fd773
Showing
8 changed files
with
41 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { AlbumService } from './album.service'; | ||
import { AuthUserDto } from '../../decorators/auth-user.decorator'; | ||
import { BadRequestException, NotFoundException, ForbiddenException } from '@nestjs/common'; | ||
import { AlbumEntity } from '@app/infra'; | ||
import { AlbumResponseDto, ICryptoRepository } from '@app/domain'; | ||
import { AlbumEntity, UserEntity } from '@app/infra'; | ||
import { AlbumResponseDto, ICryptoRepository, mapUser } from '@app/domain'; | ||
import { AddAssetsResponseDto } from './response-dto/add-assets-response.dto'; | ||
import { IAlbumRepository } from './album-repository'; | ||
import { DownloadService } from '../../modules/download/download.service'; | ||
|
@@ -21,14 +21,27 @@ describe('Album service', () => { | |
email: '[email protected]', | ||
isAdmin: false, | ||
}); | ||
|
||
const albumOwner: UserEntity = Object.freeze({ | ||
...authUser, | ||
firstName: 'auth', | ||
lastName: 'user', | ||
createdAt: 'date', | ||
updatedAt: 'date', | ||
profileImagePath: '', | ||
shouldChangePassword: false, | ||
oauthId: '', | ||
tags: [], | ||
}); | ||
const albumId = 'f19ab956-4761-41ea-a5d6-bae948308d58'; | ||
const sharedAlbumOwnerId = '2222'; | ||
const sharedAlbumSharedAlsoWithId = '3333'; | ||
const ownedAlbumSharedWithId = '4444'; | ||
|
||
const _getOwnedAlbum = () => { | ||
const albumEntity = new AlbumEntity(); | ||
albumEntity.ownerId = authUser.id; | ||
albumEntity.ownerId = albumOwner.id; | ||
albumEntity.owner = albumOwner; | ||
albumEntity.id = albumId; | ||
albumEntity.albumName = 'name'; | ||
albumEntity.createdAt = 'date'; | ||
|
@@ -42,7 +55,8 @@ describe('Album service', () => { | |
|
||
const _getOwnedSharedAlbum = () => { | ||
const albumEntity = new AlbumEntity(); | ||
albumEntity.ownerId = authUser.id; | ||
albumEntity.ownerId = albumOwner.id; | ||
albumEntity.owner = albumOwner; | ||
albumEntity.id = albumId; | ||
albumEntity.albumName = 'name'; | ||
albumEntity.createdAt = 'date'; | ||
|
@@ -68,6 +82,7 @@ describe('Album service', () => { | |
const _getSharedWithAuthUserAlbum = () => { | ||
const albumEntity = new AlbumEntity(); | ||
albumEntity.ownerId = sharedAlbumOwnerId; | ||
albumEntity.owner = albumOwner; | ||
albumEntity.id = albumId; | ||
albumEntity.albumName = 'name'; | ||
albumEntity.createdAt = 'date'; | ||
|
@@ -174,22 +189,22 @@ describe('Album service', () => { | |
}); | ||
|
||
it('gets an owned album', async () => { | ||
const ownerId = authUser.id; | ||
const albumId = 'f19ab956-4761-41ea-a5d6-bae948308d58'; | ||
|
||
const albumEntity = _getOwnedAlbum(); | ||
albumRepositoryMock.get.mockImplementation(() => Promise.resolve<AlbumEntity>(albumEntity)); | ||
|
||
const expectedResult: AlbumResponseDto = { | ||
ownerId: albumOwner.id, | ||
owner: mapUser(albumOwner), | ||
id: albumId, | ||
albumName: 'name', | ||
albumThumbnailAssetId: null, | ||
createdAt: 'date', | ||
updatedAt: 'date', | ||
id: 'f19ab956-4761-41ea-a5d6-bae948308d58', | ||
ownerId, | ||
shared: false, | ||
assets: [], | ||
sharedUsers: [], | ||
assets: [], | ||
albumThumbnailAssetId: null, | ||
shared: false, | ||
assetCount: 0, | ||
}; | ||
await expect(sut.getAlbumInfo(authUser, albumId)).resolves.toEqual(expectedResult); | ||
|
@@ -473,6 +488,7 @@ describe('Album service', () => { | |
const albumEntity = new AlbumEntity(); | ||
|
||
albumEntity.ownerId = authUser.id; | ||
albumEntity.owner = albumOwner; | ||
albumEntity.id = albumId; | ||
albumEntity.albumName = 'name'; | ||
albumEntity.createdAt = 'date'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters