diff --git a/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts b/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts index 2b7dde9933..cc8a846dd5 100644 --- a/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts +++ b/apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts @@ -1,5 +1,4 @@ import 'cypress-real-events' -import { tile } from 'ol/loadingstrategy' import path from 'path' beforeEach(() => { @@ -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') @@ -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) => { + // 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') }) }) diff --git a/apps/datahub/src/app/record/record-metadata/record-metadata.component.spec.ts b/apps/datahub/src/app/record/record-metadata/record-metadata.component.spec.ts index 0b23b693b5..7726e60cdd 100644 --- a/apps/datahub/src/app/record/record-metadata/record-metadata.component.spec.ts +++ b/apps/datahub/src/app/record/record-metadata/record-metadata.component.spec.ts @@ -45,6 +45,7 @@ class MdViewFacadeMock { otherLinks$ = new BehaviorSubject([]) related$ = new BehaviorSubject(null) error$ = new BehaviorSubject(null) + isMetadataLoading$ = new BehaviorSubject(false) } class SearchServiceMock { @@ -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 + ) + }) }) }) }) diff --git a/apps/datahub/src/app/record/record-metadata/record-metadata.component.ts b/apps/datahub/src/app/record/record-metadata/record-metadata.component.ts index 43c712f165..3d485c2c0f 100644 --- a/apps/datahub/src/app/record/record-metadata/record-metadata.component.ts +++ b/apps/datahub/src/app/record/record-metadata/record-metadata.component.ts @@ -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 ) ) diff --git a/support-services/docker-entrypoint-initdb.d/dump b/support-services/docker-entrypoint-initdb.d/dump index f1f88acdff..55bf76ca5e 100644 Binary files a/support-services/docker-entrypoint-initdb.d/dump and b/support-services/docker-entrypoint-initdb.d/dump differ