From 8c212f66bf15031c483d3b1a3181f1494efa5e1d Mon Sep 17 00:00:00 2001 From: Florian Necas Date: Mon, 17 Jul 2023 08:34:11 +0200 Subject: [PATCH] test: add tests for organisations with matching group check if record collect the right logo/thumbnail --- .../organisations/organisations.component.ts | 2 +- ...rganisations-from-metadata.service.spec.ts | 51 +++++++++++++++---- .../src/lib/fixtures/groups.fixtures.ts | 19 +++++++ 3 files changed, 62 insertions(+), 10 deletions(-) diff --git a/libs/feature/catalog/src/lib/organisations/organisations.component.ts b/libs/feature/catalog/src/lib/organisations/organisations.component.ts index b8fa9a1834..13de8a4a95 100644 --- a/libs/feature/catalog/src/lib/organisations/organisations.component.ts +++ b/libs/feature/catalog/src/lib/organisations/organisations.component.ts @@ -90,7 +90,7 @@ export class OrganisationsComponent { return index } - getOrganisationUrl(organisation: Organisation) { + getOrganisationUrl(organisation: Organisation): string { if (!this.urlTemplate) return null return this.urlTemplate.replace('${name}', organisation.name) } diff --git a/libs/feature/catalog/src/lib/organisations/service/organisations-from-metadata.service.spec.ts b/libs/feature/catalog/src/lib/organisations/service/organisations-from-metadata.service.spec.ts index ec7cfa8ac8..efcd28b9f9 100644 --- a/libs/feature/catalog/src/lib/organisations/service/organisations-from-metadata.service.spec.ts +++ b/libs/feature/catalog/src/lib/organisations/service/organisations-from-metadata.service.spec.ts @@ -29,6 +29,14 @@ const sampleOrgB: Organisation = { recordCount: 1, description: null, } +const sampleOrgC: Organisation = { + emails: ['ifremer.ifremer@ifremer.admin.ch'], + email: 'ifremer.ifremer@ifremer.admin.ch', + logoUrl: '/geonetwork/images/harvesting/ifremer.png', + name: 'Ifremer', + recordCount: 1, + description: null, +} const organisationsAggregationMock = { aggregations: { @@ -67,6 +75,20 @@ const organisationsAggregationMock = { ], }, }, + { + key: 'Ifremer', + doc_count: 1, + mail: { + doc_count_error_upper_bound: 0, + sum_other_doc_count: 0, + buckets: [ + { + key: 'ifremer.ifremer@ifremer.admin.ch', + doc_count: 1, + }, + ], + }, + }, ], }, }, @@ -181,6 +203,13 @@ describe('OrganisationsFromMetadataService', () => { name: 'BAKOM', recordCount: 1, }, + { + description: null, + emails: ['ifremer.ifremer@ifremer.admin.ch'], + logoUrl: null, + name: 'Ifremer', + recordCount: 1, + }, ]) }) }) @@ -192,7 +221,7 @@ describe('OrganisationsFromMetadataService', () => { .subscribe((orgs) => (organisations = orgs)) }) it('get organisations hydrated from groups via name or email mapping', () => { - expect(organisations).toEqual([sampleOrgA, sampleOrgB]) + expect(organisations).toEqual([sampleOrgA, sampleOrgB, sampleOrgC]) }) }) }) @@ -245,12 +274,12 @@ describe('OrganisationsFromMetadataService', () => { let filters beforeEach(async () => { filters = await firstValueFrom( - service.getFiltersForOrgs([sampleOrgA, sampleOrgB]) + service.getFiltersForOrgs([sampleOrgA, sampleOrgB, sampleOrgC]) ) }) it('generates filters', () => { expect(filters).toEqual({ - OrgForResource: { ARE: true, BAKOM: true }, + OrgForResource: { ARE: true, BAKOM: true, Ifremer: true }, }) }) }) @@ -288,14 +317,18 @@ describe('OrganisationsFromMetadataService', () => { title: 'Surval - Données par paramètre', uuid: 'cf5048f6-5bbf-4e44-ba74-e6f429af51ea', contact: { - name: "Cellule d'administration Quadrige", - organisation: 'Ifremer', - email: 'q2suppor@ifremer.fr', - website: 'https://www.ifremer.fr/', - logoUrl: - 'http://localhost/geonetwork/images/logos/81e8a591-7815-4d2f-a7da-5673192e74c9.png', + name: 'Ifremer', + email: 'ifremer.ifremer@ifremer.admin.ch', + logoUrl: 'http://localhost/geonetwork/images/harvesting/ifremer.png', }, resourceContacts: [ + { + email: 'ifremer.ifremer@ifremer.admin.ch', + logoUrl: + 'http://localhost/geonetwork/images/harvesting/ifremer.png', + name: 'Ifremer', + organisation: 'Ifremer', + }, { email: 'q2_support@ifremer.fr', logoUrl: diff --git a/libs/util/shared/src/lib/fixtures/groups.fixtures.ts b/libs/util/shared/src/lib/fixtures/groups.fixtures.ts index 671cebfd2a..3f71a2d302 100644 --- a/libs/util/shared/src/lib/fixtures/groups.fixtures.ts +++ b/libs/util/shared/src/lib/fixtures/groups.fixtures.ts @@ -58,4 +58,23 @@ export const GROUPS_FIXTURE = deepFreeze([ eng: 'Municipality of Köniz', }, }, + { + logo: 'ifremer.png', + website: 'www.ifremer.ch', + defaultCategory: null, + allowedCategories: [], + enableAllowedCategories: false, + id: 348385324, + email: 'ifremer.ifremer@ifremer.admin.ch', + referrer: null, + description: '', + name: 'Ifremer', + label: { + ger: 'Ifremer', + ita: 'Ifremer', + fre: 'Ifremer', + roh: 'Ifremer', + eng: 'Ifremer', + }, + }, ])