mirror of
https://github.com/immich-app/immich.git
synced 2026-03-23 00:58:58 +03:00
* feat(web): link expiration presets * refactor: implement suggestions * chore: remove createdAt prop * fix: tests * fix: button keys
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { renderWithTooltips } from '$tests/helpers';
|
|
import userEvent from '@testing-library/user-event';
|
|
import SharedLinkFormFields from './SharedLinkFormFields.svelte';
|
|
|
|
describe('SharedLinkFormFields component', () => {
|
|
const isChecked = (element: Element) =>
|
|
element instanceof HTMLInputElement ? element.checked : element.getAttribute('aria-checked') === 'true';
|
|
|
|
it('turns downloads off when metadata is disabled', async () => {
|
|
const { container } = renderWithTooltips(SharedLinkFormFields, {
|
|
slug: '',
|
|
password: '',
|
|
description: '',
|
|
allowDownload: true,
|
|
allowUpload: false,
|
|
showMetadata: true,
|
|
expiresAt: null,
|
|
});
|
|
const user = userEvent.setup();
|
|
|
|
const switches = Array.from(container.querySelectorAll('[role="switch"], input[type="checkbox"]'));
|
|
expect(switches).toHaveLength(3);
|
|
|
|
const [showMetadataSwitch, allowDownloadSwitch] = switches;
|
|
expect(isChecked(allowDownloadSwitch)).toBe(true);
|
|
|
|
await user.click(showMetadataSwitch);
|
|
|
|
expect(isChecked(showMetadataSwitch)).toBe(false);
|
|
expect(isChecked(allowDownloadSwitch)).toBe(false);
|
|
});
|
|
});
|