mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
fix(metadata): stop duplicating moved provider IDs
Keep providers with compatibility ID fields out of the generic external-provider rows so the editor exposes one valid input. Closes #1997
This commit is contained in:
@@ -22,6 +22,7 @@ import {
|
||||
FORMAT_TO_GROUP,
|
||||
IDENTIFIER_INPUT_KIND_BY_FIELD,
|
||||
getPrimaryBookFile,
|
||||
isKnownMetadataProviderKey,
|
||||
isValidSeriesIndex,
|
||||
parseSeriesIndex,
|
||||
isComicFormat,
|
||||
@@ -202,7 +203,9 @@ const visibleProviderIdFields = computed(() => filterProviderIdFields(availableM
|
||||
const externalProviderIdRows = computed(() => {
|
||||
const rows = new Map<string, { key: string; label: string; registered: boolean }>()
|
||||
for (const provider of availableMetadataProviders.value ?? []) {
|
||||
if (provider.source === 'external') rows.set(provider.key, { key: provider.key, label: provider.label, registered: true })
|
||||
if (provider.source === 'external' && !isKnownMetadataProviderKey(provider.key)) {
|
||||
rows.set(provider.key, { key: provider.key, label: provider.label, registered: true })
|
||||
}
|
||||
}
|
||||
for (const key of Object.keys(form.externalProviderIds)) {
|
||||
if (!rows.has(key)) rows.set(key, { key, label: key, registered: false })
|
||||
|
||||
@@ -225,6 +225,21 @@ describe('EditMetadataTab cover tiles', () => {
|
||||
expect(body.metadata).toMatchObject({ isbn10: '0306406152', isbn13: '9780306406157' })
|
||||
})
|
||||
|
||||
it('renders a moved external provider only through its compatibility ID field', async () => {
|
||||
vi.mocked(api).mockImplementation(async (url) => {
|
||||
if (String(url).includes('/metadata-fetch/providers')) {
|
||||
return json([{ key: 'lubimyczytac', label: 'LubimyCzytac', identifiable: true, source: 'external' }])
|
||||
}
|
||||
return json({})
|
||||
})
|
||||
const wrapper = mountTab(makeBook({ providerIds: { lubimyczytac: '5212514/nie-zapomnij-nakarmic' } }))
|
||||
await flushPromises()
|
||||
|
||||
expect(wrapper.get<HTMLInputElement>('#provider-id-lubimyczytacId').element.value).toBe('5212514/nie-zapomnij-nakarmic')
|
||||
expect(wrapper.find('#provider-id-external-lubimyczytac').exists()).toBe(false)
|
||||
expect(wrapper.text()).toContain('1/1')
|
||||
})
|
||||
|
||||
// Issue #1624: identifiers pasted from Amazon carry hyphens and invisible characters.
|
||||
it('saves pasted identifiers cleaned instead of truncated', async () => {
|
||||
vi.mocked(api).mockImplementation(async (url, init) => {
|
||||
|
||||
Reference in New Issue
Block a user