release: v0.16.0

See CHANGELOG.md for the full v0.16.0 entry.

---------

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>
This commit is contained in:
Ralksta
2026-09-22 14:12:13 +02:00
committed by GitHub
parent c3f92ca4ec
commit a3a6319c29
120 changed files with 6818 additions and 975 deletions

View File

@@ -1,5 +1,11 @@
import { describe, it, expect } from 'vitest';
import { parsePhotoHash, buildPhotoHash, buildPhotoPermalink } from '@/lib/photoHash';
import {
parsePhotoHash,
buildPhotoHash,
parsePhotoQuery,
buildPhotoQuery,
buildPhotoPermalink,
} from '@/lib/photoHash';
describe('buildPhotoHash', () => {
it('presents the index 1-indexed', () => {
@@ -33,6 +39,46 @@ describe('parsePhotoHash', () => {
});
});
describe('parsePhotoQuery', () => {
it('reads the photo param', () => {
expect(parsePhotoQuery('?photo=v2:abc123')).toBe('v2:abc123');
});
it('returns null when absent', () => {
expect(parsePhotoQuery('')).toBeNull();
expect(parsePhotoQuery('?preview=true')).toBeNull();
});
it('ignores an empty value', () => {
// URLSearchParams reads `?photo=` as the empty string, not absent — callers
// treat an empty token the same as "not addressing a photo" downstream,
// but this function reports exactly what was in the URL.
expect(parsePhotoQuery('?photo=')).toBe('');
});
});
describe('buildPhotoQuery', () => {
it('adds the photo param to an empty search string', () => {
expect(buildPhotoQuery('', 'v2:abc')).toBe('?photo=v2%3Aabc');
});
it('preserves other query parameters', () => {
expect(buildPhotoQuery('?preview=true', 'v2:abc')).toBe('?preview=true&photo=v2%3Aabc');
});
it('replaces an existing photo param rather than duplicating it', () => {
expect(buildPhotoQuery('?photo=old', 'v2:new')).toBe('?photo=v2%3Anew');
});
it('removes the param when assetId is null', () => {
expect(buildPhotoQuery('?photo=v2:abc&preview=true', null)).toBe('?preview=true');
});
it('returns an empty string when nothing is left', () => {
expect(buildPhotoQuery('?photo=v2:abc', null)).toBe('');
});
});
describe('buildPhotoPermalink', () => {
const location = {
origin: 'https://folio.example',
@@ -40,19 +86,30 @@ describe('buildPhotoPermalink', () => {
search: '',
};
it('builds an absolute link to the photo', () => {
expect(buildPhotoPermalink(location, 2)).toBe('https://folio.example/travel/iceland#photo-3');
it('builds an absolute link to the photo, addressed by its stable id', () => {
expect(buildPhotoPermalink(location, 'v2:abc123')).toBe(
'https://folio.example/travel/iceland?photo=v2%3Aabc123',
);
});
it('preserves an existing query string', () => {
expect(buildPhotoPermalink({ ...location, search: '?preview=true' }, 0)).toBe(
'https://folio.example/travel/iceland?preview=true#photo-1',
expect(buildPhotoPermalink({ ...location, search: '?preview=true' }, 'v2:abc123')).toBe(
'https://folio.example/travel/iceland?preview=true&photo=v2%3Aabc123',
);
});
it('works at the site root', () => {
expect(buildPhotoPermalink({ ...location, pathname: '/' }, 0)).toBe(
'https://folio.example/#photo-1',
expect(buildPhotoPermalink({ ...location, pathname: '/' }, 'v2:abc123')).toBe(
'https://folio.example/?photo=v2%3Aabc123',
);
});
// The whole point: the same asset keeps the same link no matter where it
// now sits in the album (#588). The old #photo-N form could not promise
// that at all — it named a position, not a photo.
it('does not change when the asset moves to a different position', () => {
expect(buildPhotoPermalink(location, 'v2:abc123')).toBe(
buildPhotoPermalink(location, 'v2:abc123'),
);
});
});