Skip to content

Commit

Permalink
test: add tests for organisations with matching group
Browse files Browse the repository at this point in the history
check if record collect the right logo/thumbnail
  • Loading branch information
f-necas committed Jul 17, 2023
1 parent 0b6a439 commit 8c212f6
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ const sampleOrgB: Organisation = {
recordCount: 1,
description: null,
}
const sampleOrgC: Organisation = {
emails: ['[email protected]'],
email: '[email protected]',
logoUrl: '/geonetwork/images/harvesting/ifremer.png',
name: 'Ifremer',
recordCount: 1,
description: null,
}

const organisationsAggregationMock = {
aggregations: {
Expand Down Expand Up @@ -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: '[email protected]',
doc_count: 1,
},
],
},
},
],
},
},
Expand Down Expand Up @@ -181,6 +203,13 @@ describe('OrganisationsFromMetadataService', () => {
name: 'BAKOM',
recordCount: 1,
},
{
description: null,
emails: ['[email protected]'],
logoUrl: null,
name: 'Ifremer',
recordCount: 1,
},
])
})
})
Expand All @@ -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])
})
})
})
Expand Down Expand Up @@ -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 },
})
})
})
Expand Down Expand Up @@ -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: '[email protected]',
website: 'https://www.ifremer.fr/',
logoUrl:
'http://localhost/geonetwork/images/logos/81e8a591-7815-4d2f-a7da-5673192e74c9.png',
name: 'Ifremer',
email: '[email protected]',
logoUrl: 'http://localhost/geonetwork/images/harvesting/ifremer.png',
},
resourceContacts: [
{
email: '[email protected]',
logoUrl:
'http://localhost/geonetwork/images/harvesting/ifremer.png',
name: 'Ifremer',
organisation: 'Ifremer',
},
{
email: '[email protected]',
logoUrl:
Expand Down
19 changes: 19 additions & 0 deletions libs/util/shared/src/lib/fixtures/groups.fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]',
referrer: null,
description: '',
name: 'Ifremer',
label: {
ger: 'Ifremer',
ita: 'Ifremer',
fre: 'Ifremer',
roh: 'Ifremer',
eng: 'Ifremer',
},
},
])

0 comments on commit 8c212f6

Please sign in to comment.