refactor(web): co-locate single-use components in /routes (#27921)

* co-locate single use components to /routes

* revert accidentally changed paths

* fix mangled path

* fmt

* fix accidentally moved multi-use components
This commit is contained in:
Freddie Floydd
2026-04-18 02:21:36 +01:00
committed by GitHub
parent b0e4850d76
commit 03af669856
128 changed files with 108 additions and 108 deletions
@@ -1,62 +0,0 @@
import ShareCover from '$lib/components/sharedlinks-page/covers/share-cover.svelte';
import { getAssetMediaUrl } from '$lib/utils';
import { albumFactory } from '@test-data/factories/album-factory';
import { assetFactory } from '@test-data/factories/asset-factory';
import { sharedLinkFactory } from '@test-data/factories/shared-link-factory';
import { render, screen } from '@testing-library/svelte';
vi.mock('$lib/utils');
describe('ShareCover component', () => {
it('renders an image when the shared link is an album', () => {
const component = render(ShareCover, {
sharedLink: sharedLinkFactory.build({ album: albumFactory.build({ albumName: '123' }) }),
preload: false,
class: 'text',
});
const img = component.getByTestId('album-image') as HTMLImageElement;
expect(img.alt).toBe('123');
expect(img.getAttribute('loading')).toBe('lazy');
expect(img.className).toBe('size-full rounded-xl object-cover aspect-square text');
});
it('renders an image when the shared link is an individual share', () => {
vi.mocked(getAssetMediaUrl).mockReturnValue('/asdf');
const component = render(ShareCover, {
sharedLink: sharedLinkFactory.build({ assets: [assetFactory.build({ id: 'someId' })] }),
preload: false,
class: 'text',
});
const img = component.getByTestId('album-image') as HTMLImageElement;
expect(img.alt).toBe('individual_share');
expect(img.getAttribute('loading')).toBe('lazy');
expect(img.className).toBe('size-full rounded-xl object-cover aspect-square text');
expect(img.getAttribute('src')).toBe('/asdf');
expect(getAssetMediaUrl).toHaveBeenCalledWith({ id: 'someId' });
});
it('renders an image when the shared link has no album or assets', () => {
const component = render(ShareCover, {
sharedLink: sharedLinkFactory.build(),
preload: false,
class: 'text',
});
const img = component.getByTestId('album-image') as HTMLImageElement;
expect(img.alt).toBe('unnamed_share');
expect(img.getAttribute('loading')).toBe('lazy');
expect(img.className).toBe('size-full rounded-xl object-cover aspect-square text');
});
it.skip('renders fallback image when asset is not resized', () => {
const sharedLink = sharedLinkFactory.build({ assets: [assetFactory.build()] });
render(ShareCover, {
sharedLink,
preload: false,
});
// TODO emit image error event and check if fallback image is rendered
const img = screen.getByTestId<HTMLImageElement>('album-image');
expect(img.alt).toBe('unnamed_share');
});
});
@@ -1,31 +0,0 @@
<script lang="ts">
import AlbumCover from '$lib/components/album-page/album-cover.svelte';
import AssetCover from '$lib/components/sharedlinks-page/covers/asset-cover.svelte';
import NoCover from '$lib/components/sharedlinks-page/covers/no-cover.svelte';
import { getAssetMediaUrl } from '$lib/utils';
import type { SharedLinkResponseDto } from '@immich/sdk';
import { t } from 'svelte-i18n';
interface Props {
sharedLink: SharedLinkResponseDto;
preload?: boolean;
class?: string;
}
let { sharedLink, preload = false, class: className = '' }: Props = $props();
</script>
<div class="relative shrink-0 size-22">
{#if sharedLink?.album}
<AlbumCover album={sharedLink.album} class={className} {preload} />
{:else if sharedLink.assets[0]}
<AssetCover
alt={$t('individual_share')}
class={className}
{preload}
src={getAssetMediaUrl({ id: sharedLink.assets[0].id })}
/>
{:else}
<NoCover alt={$t('unnamed_share')} class={className} {preload} />
{/if}
</div>