mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 02:13:51 -04:00
* refactor: downloadApi * refactor: assetApi * chore: drop axios * chore: tidy up * chore: fix exports * fix: show notification when download starts
70 lines
2.2 KiB
TypeScript
70 lines
2.2 KiB
TypeScript
import {
|
|
AlbumResponseDto,
|
|
AssetFileUploadResponseDto,
|
|
LoginResponseDto,
|
|
SharedLinkResponseDto,
|
|
SharedLinkType,
|
|
createAlbum,
|
|
} from '@immich/sdk';
|
|
import { test } from '@playwright/test';
|
|
import { apiUtils, asBearerAuth, dbUtils } from 'src/utils';
|
|
|
|
test.describe('Shared Links', () => {
|
|
let admin: LoginResponseDto;
|
|
let asset: AssetFileUploadResponseDto;
|
|
let album: AlbumResponseDto;
|
|
let sharedLink: SharedLinkResponseDto;
|
|
let sharedLinkPassword: SharedLinkResponseDto;
|
|
|
|
test.beforeAll(async () => {
|
|
apiUtils.setup();
|
|
await dbUtils.reset();
|
|
admin = await apiUtils.adminSetup();
|
|
asset = await apiUtils.createAsset(admin.accessToken);
|
|
album = await createAlbum(
|
|
{
|
|
createAlbumDto: {
|
|
albumName: 'Test Album',
|
|
assetIds: [asset.id],
|
|
},
|
|
},
|
|
{ headers: asBearerAuth(admin.accessToken) }
|
|
);
|
|
sharedLink = await apiUtils.createSharedLink(admin.accessToken, {
|
|
type: SharedLinkType.Album,
|
|
albumId: album.id,
|
|
});
|
|
sharedLinkPassword = await apiUtils.createSharedLink(admin.accessToken, {
|
|
type: SharedLinkType.Album,
|
|
albumId: album.id,
|
|
password: 'test-password',
|
|
});
|
|
});
|
|
|
|
test.afterAll(async () => {
|
|
await dbUtils.teardown();
|
|
});
|
|
|
|
test('download from a shared link', async ({ page }) => {
|
|
await page.goto(`/share/${sharedLink.key}`);
|
|
await page.getByRole('heading', { name: 'Test Album' }).waitFor();
|
|
await page.locator('.group > div').first().hover();
|
|
await page.waitForSelector('#asset-group-by-date svg');
|
|
await page.getByRole('checkbox').click();
|
|
await page.getByRole('button', { name: 'Download' }).click();
|
|
await page.getByText('DOWNLOADING', { exact: true }).waitFor();
|
|
});
|
|
|
|
test('enter password for a shared link', async ({ page }) => {
|
|
await page.goto(`/share/${sharedLinkPassword.key}`);
|
|
await page.getByPlaceholder('Password').fill('test-password');
|
|
await page.getByRole('button', { name: 'Submit' }).click();
|
|
await page.getByRole('heading', { name: 'Test Album' }).waitFor();
|
|
});
|
|
|
|
test('show error for invalid shared link', async ({ page }) => {
|
|
await page.goto('/share/invalid');
|
|
await page.getByRole('heading', { name: 'Invalid share key' }).waitFor();
|
|
});
|
|
});
|