diff --git a/backend/doc/domain/resource_lookup.py b/backend/doc/domain/resource_lookup.py index 616f0d31..4a33ef6b 100644 --- a/backend/doc/domain/resource_lookup.py +++ b/backend/doc/domain/resource_lookup.py @@ -723,7 +723,8 @@ def add_data_not_supplied_by_data_api(repos_info: list[RepoEntry]) -> list[RepoE """ DOC needs to support some resources which are not supplied by the data API so we augment the data returned from the data API to include - them here. + them here. If a (language code, resource type) pair already exists in + repos_info, do not add it again. """ def make_entry(url: HttpUrl, resource_type: str, lang: Language) -> RepoEntry: @@ -774,7 +775,15 @@ def make_entry(url: HttpUrl, resource_type: str, lang: Language) -> RepoEntry: en_lang, ), ] - repos_info.extend(extra_entries) + existing_pairs = { + (entry.content.language.ietf_code, entry.content.resource_type) + for entry in repos_info + } + for entry in extra_entries: + key = (entry.content.language.ietf_code, entry.content.resource_type) + if key not in existing_pairs: + repos_info.append(entry) + existing_pairs.add(key) return repos_info diff --git a/frontend/tests/e2e/test.ts b/frontend/tests/e2e/test.ts index 3691a8d3..3a515d9e 100644 --- a/frontend/tests/e2e/test.ts +++ b/frontend/tests/e2e/test.ts @@ -420,3 +420,14 @@ test('test burmese', async ({ page }) => { await page.getByText('Use PrinceXml to produce the').click() await page.getByRole('button', { name: 'Generate File' }).click() }) + +test('test merge of data API data and DOC only data', async ({ page }) => { + await page.goto('http://localhost:8001/') + await expect(page.getByRole('main')).toContainText('Bahasa Indonesia (Indonesian)') + await page.getByLabel('Bahasa Indonesia (Indonesian').check() + await page.getByRole('button', { name: 'Next' }).click() + await page.getByText('Matius').click() + await page.getByRole('button', { name: 'Next' }).click() + await expect(page.locator('body')).toContainText('Bahasa Indonesian Bible') + await expect(page.locator('body')).toContainText('Translation Notes') +})