Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DH][IGN] : Quality score widget stuck at 87% #1076

Merged
merged 4 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 46 additions & 6 deletions apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,21 @@ describe('dataset pages', () => {
.children('div')
.should('have.length', 5)
})
it('should not display the same text twice in the constraints', () => {
// this dataset has the same text for the license and the legal constraints
cy.visit('/dataset/9e1ea778-d0ce-4b49-90b7-37bc0e448300')
cy.get('datahub-record-metadata')
.find('gn-ui-expandable-panel')
.first()
.click()
cy.get('datahub-record-metadata')
.find('gn-ui-expandable-panel')
.first()
.children('div')
.eq(1)
.children('div')
.should('have.length', 1)
})
})
})
describe('features', () => {
Expand Down Expand Up @@ -300,12 +315,37 @@ describe('dataset pages', () => {
})
cy.reload()
})

it('should display quality widget', () => {
cy.get('gn-ui-metadata-quality gn-ui-progress-bar')
.eq(0)
.should('have.attr', 'ng-reflect-value', 87)
cy.screenshot({ capture: 'fullPage' })
describe('Score is less than 100%', () => {
it('should display the score', () => {
cy.get('gn-ui-metadata-quality gn-ui-progress-bar')
.eq(0)
.should('have.attr', 'ng-reflect-value', 87)
cy.screenshot({ capture: 'fullPage' })
})
it('should not check all the criteria', () => {
cy.get('gn-ui-metadata-quality').realHover()
cy.get('gn-ui-metadata-quality-item')
.find('ng-icon')
.eq(4)
.should('have.attr', 'ng-reflect-name', 'matWarningAmber')
})
})
describe('Score is 100%', () => {
beforeEach(() => {
cy.visit('/dataset/6d0bfdf4-4e94-48c6-9740-3f9facfd453c')
})
it('should display the score', () => {
cy.get('gn-ui-metadata-quality gn-ui-progress-bar')
.eq(0)
.should('have.attr', 'ng-reflect-value', 100)
})
it('should check all the criteria if score is 100%', () => {
cy.get('gn-ui-metadata-quality').realHover()
cy.get('gn-ui-metadata-quality-item')
.find('ng-icon')
.eq(4)
.should('have.attr', 'ng-reflect-name', 'matCheck')
})
})
})
})
Expand Down
28 changes: 26 additions & 2 deletions libs/api/metadata-converter/src/lib/gn4/gn4.converter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,15 @@ describe('Gn4Converter', () => {

it('parses the legal constraints', async () => {
const record = (await service.readRecord(hit)) as DatasetRecord
expect(record.legalConstraints).toEqual([])
expect(record.legalConstraints).toEqual([
{
text: 'Öffentlich zugängliche Geobasisdaten: Zugangsberechtigungsstufe A (nach GeoIV, Art. 21).',
url: new URL('https://registry.geocat.ch/use-limitation/levelA'),
},
{
text: 'Es gelten die Nutzungsbedingungen für Geodaten des Kantons Wallis (https://www.vs.ch/de/web/guest/rechtliches).',
},
])
})

it('parses the security constraints', async () => {
Expand Down Expand Up @@ -1014,6 +1022,15 @@ describe('Gn4Converter', () => {
{
text: "Restriction légale d'utilisation à préciser",
},
{
text: 'Pas de restriction d’accès public',
url: new URL(
'http://inspire.ec.europa.eu/metadatacodelist/LimitationsOnPublicAccess/noLimitations'
),
},
{
text: 'Licence Ouverte version 2.0 https://www.etalab.gouv.fr/wp-content/uploads/2017/04/ETALAB-Licence-Ouverte-v2.0.pdf',
},
],
securityConstraints: [],
otherConstraints: [
Expand Down Expand Up @@ -1909,7 +1926,14 @@ describe('Gn4Converter', () => {
),
defaultLanguage: 'de',
otherLanguages: ['fr', 'it'],
legalConstraints: [],
legalConstraints: [
{
text: 'Opendata BY: Freie Nutzung. Quellenangabe ist Pflicht.',
url: new URL(
'https://opendata.swiss/en/terms-of-use/#terms_by'
),
},
],
licenses: [
{
text: 'Opendata BY: Freie Nutzung. Quellenangabe ist Pflicht.',
Expand Down
10 changes: 0 additions & 10 deletions libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,16 +378,6 @@ export class Gn4FieldMapper {
...output,
[outputField]: outputArray,
}
// avoid legal constraints being duplicates of licenses
if (
'legalConstraints' in result &&
(type === 'legal' || type === 'license')
) {
result.legalConstraints = result.legalConstraints.filter(
(constraint) =>
!output.licenses?.some((license) => license.text === constraint.text)
)
}
return result
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,35 @@ describe('MetadataInfoComponent', () => {
})
})
})
describe('legalConstraints', () => {
beforeEach(() => {
fixture = TestBed.createComponent(MetadataInfoComponent)
component = fixture.componentInstance
component.metadata = datasetRecordsFixture()[0] as DatasetRecord
fixture.detectChanges()
})
it('should filter out the licenses from the legal constraints', () => {
component.metadata = {
...datasetRecordsFixture()[0],
licenses: [
...datasetRecordsFixture()[0].licenses,
{
text: 'Contains sensitive information related to national defense',
url: new URL('https:/google.com/pages/licence/'),
},
],
} as DatasetRecord
expect(component.legalConstraints).toEqual([
"Dataset access isn't possible since it does not really exist",
])
})
it('should not return anything if the license is the only legal constraint', () => {
component.metadata = {
...datasetRecordsFixture()[0],
legalConstraints: datasetRecordsFixture()[0].licenses,
} as DatasetRecord
fixture.detectChanges()
expect(component.legalConstraints).toEqual([])
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ export class MetadataInfoComponent {
get legalConstraints() {
let array = []
if (this.metadata.legalConstraints?.length) {
const licensesTexts = this.metadata.licenses.map(
(license) => license.text
)
array = array.concat(
this.metadata.legalConstraints.filter((c) => c.text).map((c) => c.text)
this.metadata.legalConstraints
.filter((c) => c.text && !licensesTexts.includes(c.text))
.map((c) => c.text)
)
}
return array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ProgressBarComponent,
} from '@geonetwork-ui/ui/widgets'
import { CommonModule } from '@angular/common'
import { TranslateModule } from '@ngx-translate/core'

@Component({
selector: 'gn-ui-metadata-quality',
Expand All @@ -27,6 +28,7 @@ import { CommonModule } from '@angular/common'
PopoverComponent,
ProgressBarComponent,
MetadataQualityItemComponent,
TranslateModule,
],
})
export class MetadataQualityComponent implements OnChanges {
Expand Down
Loading