diff --git a/src/app/record/components/record-header/record-header.component.html b/src/app/record/components/record-header/record-header.component.html index 4c521b417c..b7bc1d5757 100644 --- a/src/app/record/components/record-header/record-header.component.html +++ b/src/app/record/components/record-header/record-header.component.html @@ -9,7 +9,7 @@ [primaryIdText]="bannerPrimaryIdText" [secondaryIdText]="bannerSecondaryIdText" [expanded]="recordSummaryOpen" - [canToggleExpanded]="!noDisplayableData" + [canToggleExpanded]="canToggleRecordSummary" (expandedChange)="recordSummaryLinkClick()" [regionNames]="regionNames" [regionOrcidId]="regionOrcidId" @@ -32,10 +32,10 @@ record-header-summary-actions > - + {{ hideSummaryLabel }} - + {{ showSummaryLabel }} diff --git a/src/app/record/components/record-header/record-header.component.spec.ts b/src/app/record/components/record-header/record-header.component.spec.ts index dd014634ba..4117fb14ab 100644 --- a/src/app/record/components/record-header/record-header.component.spec.ts +++ b/src/app/record/components/record-header/record-header.component.spec.ts @@ -123,6 +123,74 @@ describe('RecordHeaderComponent', () => { expect(component.bannerCaption).toBe('') }) + describe('records with no publicly available information', () => { + function setUpEmptyRecord() { + const userRecord = getUserRecord() + + state.setIsPublicRecord(userRecord.userInfo.REAL_USER_ORCID) + state.setAffiliations(0) + state.setDisplaySideBar(false) + state.setDisplayBiography(false) + state.setUserRecord({ + ...userRecord, + names: undefined, + otherNames: undefined, + affiliations: [], + }) + state.setLoadingRecordHeader(false) + fixture.detectChanges() + } + + it('should offer the record summary toggle', () => { + setUpEmptyRecord() + + expect(component.noDisplayableData).toBeTrue() + expect(component.canToggleRecordSummary).toBeTrue() + expect(summaryToggleButton()).not.toBeNull() + expect(summaryToggleButton().textContent).toContain('Show record summary') + }) + + it('should open the record summary when the toggle is clicked', () => { + setUpEmptyRecord() + + let recordSummaryOpen: boolean + state.recordSummaryOpen$.subscribe((open) => (recordSummaryOpen = open)) + + summaryToggleButton().click() + fixture.detectChanges() + + expect(recordSummaryOpen).toBeTrue() + expect(summaryToggleButton().textContent).toContain('Hide record summary') + }) + + it('should keep the copy iD and print actions hidden', () => { + setUpEmptyRecord() + + expect( + fixture.nativeElement.querySelector('[header-banner-id-actions]') + ).toBeNull() + }) + + it('should not offer the toggle when the record does not exist', () => { + const userRecord = getUserRecord() + + state.setIsPublicRecord(userRecord.userInfo.REAL_USER_ORCID) + state.setUserRecord({ + ...userRecord, + userInfo: { ...userRecord.userInfo, USER_NOT_FOUND: true }, + }) + state.setLoadingRecordHeader(false) + fixture.detectChanges() + + expect(component.canToggleRecordSummary).toBeFalse() + expect(summaryToggleButton()).toBeNull() + }) + }) + + function summaryToggleButton(): HTMLElement | null { + return fixture.nativeElement.querySelector('.summary-actions-area button') + } + it('should render the featured employment caption from shared state', () => { const userRecord = getUserRecord() const featuredAffiliation = diff --git a/src/app/record/components/record-header/record-header.component.ts b/src/app/record/components/record-header/record-header.component.ts index c47af3166e..1e274a9c89 100644 --- a/src/app/record/components/record-header/record-header.component.ts +++ b/src/app/record/components/record-header/record-header.component.ts @@ -101,6 +101,12 @@ export class RecordHeaderComponent implements OnInit, OnDestroy { ) } + // The summary still carries the Key dates panel when there is no public + // information to show, so records with no displayable data keep the toggle. + get canToggleRecordSummary(): boolean { + return !this.userInfo?.USER_NOT_FOUND + } + // Issue banner property get issueTitle(): string { if (!this.userInfo?.RECORD_WITH_ISSUES) { diff --git a/src/app/record/components/record-info/record-info.component.html b/src/app/record/components/record-info/record-info.component.html index b22ecf86e0..c8541527b3 100644 --- a/src/app/record/components/record-info/record-info.component.html +++ b/src/app/record/components/record-info/record-info.component.html @@ -4,7 +4,7 @@ [ngClass]="{ 'no-padding': displayBiography || displaySideBar }" >

@@ -34,9 +34,9 @@

@@ -57,7 +57,7 @@

- +

This account has been deprecated, please see account