mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 01:12:58 -04:00
* feat: folder view poc * fix(folder-view): ui modifications * fix(folder-view): improves utility return types * fix(folder-view): update getAssetsByOriginalPath Endpoint now only returns direct children of the path instead of all images in all subfolders. Functions renamed and scoped to "folder", endpoints renamed * fix(folder-view): improve typing * fix(folder-view): replaces css with tailwind * fix(folder-view): includes folders in main panel * feat(folder-view): folder cache implementation * fix(folder-view): can now search for absolute paths * fix(folder-view): sets default sort to alphabetical by filename * refactor/styling the browser view * double click to navigate * folder tree * use correct side bar icon * styling when selected * correct open icon * folder layout * return assetReponseDto * it's alive * update new api * more styling for folder tree * use query params and path viewer * use arrow up left for parent folder backward navigation * use arrow up left for parent folder backward navigation * encode URL * handle long folder name * refactor to the view controller * remove unused code * clear cache when logout * cleaning up * cleaning up web * clean as new * clean as new * pr feedback + show asset name * add tests * add tests * remove generated file * lint * revert docker-compose.dev file * Update server/src/services/view.service.ts Co-authored-by: Jason Rasmussen <jason@rasm.me> * Update server/src/services/view.service.ts Co-authored-by: Jason Rasmussen <jason@rasm.me> --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com> Co-authored-by: Jason Rasmussen <jason@rasm.me>
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import { mapAsset } from 'src/dtos/asset-response.dto';
|
|
import { IAssetRepository } from 'src/interfaces/asset.interface';
|
|
|
|
import { ViewService } from 'src/services/view.service';
|
|
import { assetStub } from 'test/fixtures/asset.stub';
|
|
import { authStub } from 'test/fixtures/auth.stub';
|
|
import { newAssetRepositoryMock } from 'test/repositories/asset.repository.mock';
|
|
|
|
import { Mocked } from 'vitest';
|
|
|
|
describe(ViewService.name, () => {
|
|
let sut: ViewService;
|
|
let assetMock: Mocked<IAssetRepository>;
|
|
|
|
beforeEach(() => {
|
|
assetMock = newAssetRepositoryMock();
|
|
|
|
sut = new ViewService(assetMock);
|
|
});
|
|
|
|
it('should work', () => {
|
|
expect(sut).toBeDefined();
|
|
});
|
|
|
|
describe('getUniqueOriginalPaths', () => {
|
|
it('should return unique original paths', async () => {
|
|
const mockPaths = ['path1', 'path2', 'path3'];
|
|
assetMock.getUniqueOriginalPaths.mockResolvedValue(mockPaths);
|
|
|
|
const result = await sut.getUniqueOriginalPaths(authStub.admin);
|
|
|
|
expect(result).toEqual(mockPaths);
|
|
expect(assetMock.getUniqueOriginalPaths).toHaveBeenCalledWith(authStub.admin.user.id);
|
|
});
|
|
});
|
|
|
|
describe('getAssetsByOriginalPath', () => {
|
|
it('should return assets by original path', async () => {
|
|
const path = '/asset';
|
|
|
|
const asset1 = { ...assetStub.image, originalPath: '/asset/path1' };
|
|
const asset2 = { ...assetStub.image, originalPath: '/asset/path2' };
|
|
|
|
const mockAssets = [asset1, asset2];
|
|
|
|
const mockAssetReponseDto = mockAssets.map((a) => mapAsset(a, { auth: authStub.admin }));
|
|
|
|
assetMock.getAssetsByOriginalPath.mockResolvedValue(mockAssets);
|
|
|
|
const result = await sut.getAssetsByOriginalPath(authStub.admin, path);
|
|
expect(result).toEqual(mockAssetReponseDto);
|
|
await expect(assetMock.getAssetsByOriginalPath(authStub.admin.user.id, path)).resolves.toEqual(mockAssets);
|
|
});
|
|
});
|
|
});
|