Skip to content

Commit

Permalink
Merge pull request #947 from geonetwork/dh-fix-record-has-no-link-dis…
Browse files Browse the repository at this point in the history
…played-while-loading

[DATAHUB]: Record has no link error displayed when loading
  • Loading branch information
rcaplier authored Jul 24, 2024
2 parents e6ae55a + 0587e8a commit 7856573
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 19 deletions.
28 changes: 24 additions & 4 deletions apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'cypress-real-events'
import { tile } from 'ol/loadingstrategy'
import path from 'path'

beforeEach(() => {
Expand Down Expand Up @@ -94,6 +93,13 @@ describe('dataset pages', () => {
})

describe('GENERAL : display & functions', () => {
describe('no-link-error block', () => {
it("shouldn't be there until metadata is fully loaded", () => {
cy.visit('/dataset/a3774ef6-809d-4dd1-984f-9254f49cbd0a')
cy.get('[data-test=dataset-has-no-link-block]').should('not.exist')
})
})

describe('header', () => {
it('should display the title, favorite star group and arrow back', () => {
cy.get('datahub-header-record')
Expand Down Expand Up @@ -591,10 +597,24 @@ describe('dataset pages', () => {
})

describe('When there is no link', () => {
beforeEach(() => {
cy.visit('/dataset/a3774ef6-809d-4dd1-984f-9254f49cbd0a')
})
it('display the error datasetHasNoLink error block', () => {
cy.login()

cy.intercept(
'GET',
'/geonetwork/srv/api/userfeedback?metadataUuid=a3774ef6-809d-4dd1-984f-9254f49cbd0a',
(req) => {

Check warning on line 606 in apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts

View workflow job for this annotation

GitHub Actions / Format check, lint, unit tests

'req' is defined but never used
// Test if the error block is not shown before the metadata is fully loaded
cy.get('[data-test="dataset-has-no-link-block"]').should(
'not.exist'
)
}
).as('getData')

cy.visit('/dataset/a3774ef6-809d-4dd1-984f-9254f49cbd0a')

cy.wait('@getData')

cy.get('[data-test="dataset-has-no-link-block"]').should('exist')
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class MdViewFacadeMock {
otherLinks$ = new BehaviorSubject([])
related$ = new BehaviorSubject(null)
error$ = new BehaviorSubject(null)
isMetadataLoading$ = new BehaviorSubject(false)
}

class SearchServiceMock {
Expand Down Expand Up @@ -659,20 +660,39 @@ describe('RecordMetadataComponent', () => {
})

describe('When there are no link (download, api or other links)', () => {
beforeEach(() => {
facade.apiLinks$.next([])
facade.downloadLinks$.next([])
facade.otherLinks$.next([])
fixture.detectChanges()
describe('When the metadata is not fully loaded', () => {
beforeEach(() => {
facade.isMetadataLoading$.next(true)
facade.apiLinks$.next([])
facade.downloadLinks$.next([])
facade.otherLinks$.next([])
fixture.detectChanges()
})
it("doesn' show the no link error block", () => {
const result = fixture.debugElement.query(
By.css('[data-test="dataset-has-no-link-block"]')
)
expect(result).toBeFalsy()
})
})
it('shows the no link error block', () => {
const result = fixture.debugElement.query(
By.css('[data-test="dataset-has-no-link-block"]')
)
expect(result).toBeTruthy()
expect(result.componentInstance.type).toBe(
ErrorType.DATASET_HAS_NO_LINK
)

describe('When the metadata is not fully loaded', () => {
beforeEach(() => {
facade.isMetadataLoading$.next(false)
facade.apiLinks$.next([])
facade.downloadLinks$.next([])
facade.otherLinks$.next([])
fixture.detectChanges()
})
it('shows the no link error block', () => {
const result = fixture.debugElement.query(
By.css('[data-test="dataset-has-no-link-block"]')
)
expect(result).toBeTruthy()
expect(result.componentInstance.type).toBe(
ErrorType.DATASET_HAS_NO_LINK
)
})
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,17 @@ export class RecordMetadataComponent {
)

displayDatasetHasNoLinkBlock$ = combineLatest([
this.metadataViewFacade.isMetadataLoading$,
this.displayDownload$,
this.displayApi$,
this.displayOtherLinks,
]).pipe(
map(
([displayDownload, displayApi, displayOtherLinks]) =>
!displayDownload && !displayApi && !displayOtherLinks
([isMetadataLoading, displayDownload, displayApi, displayOtherLinks]) =>
!isMetadataLoading &&
!displayDownload &&
!displayApi &&
!displayOtherLinks
)
)

Expand Down
Binary file modified support-services/docker-entrypoint-initdb.d/dump
Binary file not shown.

0 comments on commit 7856573

Please sign in to comment.