refactor(metadata): consolidate metadata providers on the frontend (#2719)

This commit is contained in:
Alex
2026-09-21 16:29:01 +01:00
committed by GitHub
parent c0f6f9cb80
commit 6b70d54662
100 changed files with 1659 additions and 5467 deletions
@@ -0,0 +1,41 @@
import {describe, expect, it} from 'vitest';
import {providerFieldsOf} from './metadata-provider-fields';
import {METADATA_PROVIDER_LIST} from './metadata-providers';
const fields = providerFieldsOf(METADATA_PROVIDER_LIST);
describe('provider fields', () => {
it('covers every provider field exactly once, in catalog order', () => {
expect(fields.map(field => field.name)).toEqual([
'openlibraryId',
'asin', 'amazonRating', 'amazonReviewCount',
'goodreadsId', 'goodreadsRating', 'goodreadsReviewCount',
'googleId',
'hardcoverId', 'hardcoverBookId', 'hardcoverRating', 'hardcoverReviewCount',
'comicvineId',
'lubimyczytacId', 'lubimyczytacRating',
'ranobedbId', 'ranobedbRating',
'audibleId', 'audibleRating', 'audibleReviewCount',
'applebooksId', 'applebooksRating', 'applebooksReviewCount',
]);
});
it('names each lock after its field and types IDs as strings', () => {
for (const field of fields) {
expect(field.lockName).toBe(`${field.name}Locked`);
expect(field.valueType).toBe(field.role === 'id' ? 'string' : 'number');
}
});
it('labels by role, except where the definition names its own key', () => {
const byName = new Map(fields.map(field => [field.name, field]));
expect(byName.get('goodreadsRating')).toMatchObject({
labelKey: 'metadata.providerFields.rating',
providerLabelKey: 'metadata.providers.goodReads',
});
expect(byName.get('asin')?.labelKey).toBe('metadata.providerFields.asin');
expect(byName.get('hardcoverBookId')?.labelKey).toBe('metadata.providerFields.hardcoverBookId');
});
});