mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 19:40:34 +00:00
330644e88b
The service delivers the pictures review approved for a place, but TREK never read them. A new TrekCommunityService in the maps domain asks the TREK Places API for them (the index row for a gers place, /v1/community for an OSM one), accepts only paths of the service's picture store, and fetches the bytes with the installation's key, capped at 4 MB. Enrichment puts them ahead of Google and Commons, through the same photo cache, credited as TREK Community under CC BY 4.0. The enrichment cache now follows the community version for OSM places too, so a newly approved picture shows on the next open. Also lowers the client's no-non-null-assertion baseline to 380: moving Use this text into the description card removed two.
41 lines
1.7 KiB
TypeScript
41 lines
1.7 KiB
TypeScript
// FE-PLANNER-PHOTOCREDIT-001 to FE-PLANNER-PHOTOCREDIT-003: who a source's photo is credited to,
|
|
// and the one-line caption the gallery shows under it.
|
|
import type { PlacePhotoCandidate } from '@trek/shared';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
import { creditOf, photoCaption, sourceLabelFor } from './placePhotoCredit';
|
|
|
|
function photo(over: Partial<PlacePhotoCandidate> = {}): PlacePhotoCandidate {
|
|
return {
|
|
key: 'k',
|
|
url: '/api/maps/place-photo/k/bytes',
|
|
attribution: 'Alice',
|
|
license: 'CC BY-SA 4.0',
|
|
licenseUrl: null,
|
|
sourceUrl: null,
|
|
source: 'wikimedia',
|
|
...over,
|
|
} as PlacePhotoCandidate;
|
|
}
|
|
|
|
describe('placePhotoCredit', () => {
|
|
it('FE-PLANNER-PHOTOCREDIT-001: each provider is named by its proper name', () => {
|
|
expect(sourceLabelFor('google')).toBe('Google');
|
|
expect(sourceLabelFor('wikipedia')).toBe('Wikipedia');
|
|
expect(sourceLabelFor('wikimedia')).toBe('Wikimedia Commons');
|
|
expect(sourceLabelFor('community')).toBe('TREK Community');
|
|
});
|
|
|
|
it('FE-PLANNER-PHOTOCREDIT-002: the author is credited, and the provider when there is none', () => {
|
|
expect(creditOf(photo())).toBe('Alice');
|
|
expect(creditOf(photo({ attribution: null, source: 'google' }))).toBe('Google');
|
|
expect(creditOf(photo({ attribution: '', source: 'wikipedia' }))).toBe('Wikipedia');
|
|
});
|
|
|
|
it('FE-PLANNER-PHOTOCREDIT-003: the caption joins the credit and the licence with a comma, not a dot', () => {
|
|
expect(photoCaption(photo())).toBe('Alice, CC BY-SA 4.0');
|
|
expect(photoCaption(photo({ attribution: null, license: null, source: 'google' }))).toBe('Google');
|
|
expect(photoCaption(photo()).includes('·')).toBe(false);
|
|
});
|
|
});
|