Release v0.19.0. See the `## [0.19.0] — 2026-09-29` section of [CHANGELOG.md](https://github.com/ralksta/immich-folio/blob/dev/CHANGELOG.md) for the full list. Highlights: client proofing links (#683), custom content pages (#738), asset picker search (#740), concurrent-edit detection (#742), env-locked settings (#739), an accessibility baseline (#741), three security fixes with advisories (#737, #755, #759), and a pre-release quality pass (#780–#797). --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: ralksta <ralksta@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: Ralf <rohlenbo79@gmail.com> Co-authored-by: Paul Thies <110185070+ImScheinox@users.noreply.github.com> Co-authored-by: lancetm714 <108419425+lancetm714@users.noreply.github.com> Co-authored-by: Lance Martin <lancetaylor95@gmail.com>
68 lines
2.4 KiB
TypeScript
68 lines
2.4 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest';
|
|
import { render, screen, cleanup, fireEvent, act } from '@testing-library/react';
|
|
import { HeroCarousel, INTERVAL_MS } from '../HeroCarousel';
|
|
|
|
vi.mock('next/image', () => ({
|
|
default: ({ className, src }: { className?: string; src: string }) => (
|
|
// eslint-disable-next-line @next/next/no-img-element
|
|
<img alt="" className={className} src={src} />
|
|
),
|
|
}));
|
|
|
|
const images = [{ src: '/a' }, { src: '/b' }, { src: '/c' }];
|
|
|
|
function mockReducedMotion(reduce: boolean) {
|
|
window.matchMedia = vi.fn().mockImplementation((query: string) => ({
|
|
matches: reduce && query.includes('reduce'),
|
|
media: query,
|
|
addEventListener: vi.fn(),
|
|
removeEventListener: vi.fn(),
|
|
}));
|
|
}
|
|
|
|
const activeSrc = (container: HTMLElement) =>
|
|
container.querySelector('.hero__carousel-image--active')?.getAttribute('src');
|
|
|
|
beforeEach(() => vi.useFakeTimers());
|
|
afterEach(() => {
|
|
cleanup();
|
|
vi.useRealTimers();
|
|
});
|
|
|
|
describe('HeroCarousel (#696)', () => {
|
|
it('advances on its own by default', () => {
|
|
mockReducedMotion(false);
|
|
const { container } = render(<HeroCarousel images={images} />);
|
|
expect(activeSrc(container)).toBe('/a');
|
|
act(() => vi.advanceTimersByTime(INTERVAL_MS));
|
|
expect(activeSrc(container)).toBe('/b');
|
|
});
|
|
|
|
it('does not advance under prefers-reduced-motion', () => {
|
|
mockReducedMotion(true);
|
|
const { container } = render(<HeroCarousel images={images} />);
|
|
act(() => vi.advanceTimersByTime(INTERVAL_MS * 3));
|
|
expect(activeSrc(container)).toBe('/a');
|
|
expect(screen.getByRole('button', { name: 'Play slideshow' })).toBeTruthy();
|
|
});
|
|
|
|
it('stops and restarts with the pause control', () => {
|
|
mockReducedMotion(false);
|
|
const { container } = render(<HeroCarousel images={images} />);
|
|
fireEvent.click(screen.getByRole('button', { name: 'Pause slideshow' }));
|
|
act(() => vi.advanceTimersByTime(INTERVAL_MS * 2));
|
|
expect(activeSrc(container)).toBe('/a');
|
|
|
|
fireEvent.click(screen.getByRole('button', { name: 'Play slideshow' }));
|
|
act(() => vi.advanceTimersByTime(INTERVAL_MS));
|
|
expect(activeSrc(container)).toBe('/b');
|
|
});
|
|
|
|
it('shows no control for a single image', () => {
|
|
mockReducedMotion(false);
|
|
render(<HeroCarousel images={[images[0]]} />);
|
|
expect(screen.queryByRole('button')).toBeNull();
|
|
});
|
|
});
|