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

Datahub: Fix display of usage conditions #634

Merged
merged 3 commits into from
Sep 25, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
class="material-symbols-outlined inline-block align-bottom pt-1.5 text-xs text-black"
>open_in_new</mat-icon
>
<span class="text-primary">{{ metadata.landingPage }}</span>
<span class="text-primary break-all">{{ metadata.landingPage }}</span>
</a>
</div>
</gn-ui-expandable-panel>
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,25 @@ describe('MetadataInfoComponent', () => {
}).compileComponents()
})

beforeEach(() => {
fixture = TestBed.createComponent(MetadataInfoComponent)
component = fixture.componentInstance
component.incomplete = false
component.metadata = DATASET_RECORDS[0]
fixture.detectChanges()
})

it('should create', () => {
expect(component).toBeTruthy()
})

describe('When a section is empty', () => {
beforeEach(() => {
fixture = TestBed.createComponent(MetadataInfoComponent)
component = fixture.componentInstance
component.metadata = {
id: '',
uuid: '',
title: '',
metadataUrl: '',
keywords: [],
constraints: null,
...DATASET_RECORDS[0],
useLimitations: null,
accessConstraints: null,
extras: {
isOpenData: false,
},
keywords: null,
}
fixture.detectChanges()
})
it('should display a message for no usage or constraints', () => {
const displayedElement =
fixture.nativeElement.getElementsByClassName('noUsage')
const displayedElement = fixture.nativeElement.querySelector('.noUsage')
expect(displayedElement).toBeTruthy()
})

it('should not display the keywords section', () => {
const displayedElement =
fixture.nativeElement.querySelector('ng-container')
Expand All @@ -55,23 +44,14 @@ describe('MetadataInfoComponent', () => {

describe('When a section is not empty', () => {
beforeEach(() => {
component.metadata = {
id: '',
uuid: '',
title: '',
metadataUrl: '',
keywords: ['banana', 'pear'],
constraints: ['no usage'],
}
fixture = TestBed.createComponent(MetadataInfoComponent)
component = fixture.componentInstance
component.metadata = DATASET_RECORDS[0]
fixture.detectChanges()
})
it('should not display a message for no usage or constraints', () => {
// Use waitForAsync to handle asynchronous changes in the DOM.
fixture.whenStable().then(() => {
const displayedElement =
fixture.nativeElement.getElementsByClassName('noUsage')
expect(displayedElement).toBeFalsy()
})
const displayedElement = fixture.nativeElement.querySelector('.noUsage')
expect(displayedElement).toBeFalsy()
})

it('should display the keywords section', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class MetadataInfoComponent {

get hasUsage() {
return (
('extras' in this.metadata && 'isOpenData' in this.metadata.extras) ||
this.metadata.extras?.isOpenData === true ||
this.metadata.useLimitations?.length ||
this.metadata.accessConstraints?.length
)
Expand Down
Loading