Files
immich-folio/components/__tests__/LeafletMapLabels.test.tsx
Ralksta ad8b09700b release: v0.19.0
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>
2026-09-29 22:50:30 +02:00

51 lines
2.0 KiB
TypeScript

// @vitest-environment jsdom
import { describe, it, expect, afterEach } from 'vitest';
import { render, cleanup, waitFor } from '@testing-library/react';
import { I18nProvider } from '@/components/I18nProvider';
import { LeafletMap, localizedLeafletPrefix } from '@/components/LeafletMap';
import { de } from '@/lib/i18n/locales/de';
/**
* Leaflet ships English control labels: "Zoom in" / "Zoom out" on the zoom
* buttons (also their aria-label) and "A JavaScript library for interactive
* maps" on the credit link. On a German site they now come from the
* dictionary like every other visitor-facing string.
*/
afterEach(() => cleanup());
describe('LeafletMap control labels', () => {
it('takes the zoom button and credit titles from the dictionary', async () => {
const { container } = render(
<I18nProvider locale="de">
<LeafletMap markers={[]} />
</I18nProvider>,
);
const zoomIn = await waitFor(() => {
const el = container.querySelector('.leaflet-control-zoom-in');
if (!el) throw new Error('map not initialised yet');
return el;
});
const zoomOut = container.querySelector('.leaflet-control-zoom-out');
expect(zoomIn.getAttribute('title')).toBe(de.map.zoomIn);
expect(zoomIn.getAttribute('aria-label')).toBe(de.map.zoomIn);
expect(zoomOut?.getAttribute('title')).toBe(de.map.zoomOut);
const credit = container.querySelector('.leaflet-control-attribution a[href*="leafletjs"]');
expect(credit?.getAttribute('title')).toBe(de.map.leafletTitle);
expect(container.innerHTML).not.toContain('Zoom in');
expect(container.innerHTML).not.toContain('A JavaScript library');
});
});
describe('localizedLeafletPrefix', () => {
it('swaps only the title and escapes it', () => {
const prefix = '<a href="https://leafletjs.com" title="English">Leaflet</a>';
expect(localizedLeafletPrefix(prefix, 'Karten "&" mehr')).toBe(
'<a href="https://leafletjs.com" title="Karten &quot;&amp;&quot; mehr">Leaflet</a>',
);
});
});