Skip to content
Open
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 @@ -9,7 +9,7 @@
[primaryIdText]="bannerPrimaryIdText"
[secondaryIdText]="bannerSecondaryIdText"
[expanded]="recordSummaryOpen"
[canToggleExpanded]="!noDisplayableData"
[canToggleExpanded]="canToggleRecordSummary"
(expandedChange)="recordSummaryLinkClick()"
[regionNames]="regionNames"
[regionOrcidId]="regionOrcidId"
Expand All @@ -32,10 +32,10 @@
record-header-summary-actions
></app-record-edit-button>

<span header-banner-expanded-label *ngIf="!noDisplayableData">
<span header-banner-expanded-label>
{{ hideSummaryLabel }}
</span>
<span header-banner-collapsed-label *ngIf="!noDisplayableData">
<span header-banner-collapsed-label>
{{ showSummaryLabel }}
</span>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions src/app/record/components/record-info/record-info.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[ngClass]="{ 'no-padding': displayBiography || displaySideBar }"
>
<ng-container
*ngIf="userInfo.IS_LOCKED === 'true' && !userInfo.PRIMARY_RECORD"
*ngIf="userInfo?.IS_LOCKED === 'true' && !userInfo?.PRIMARY_RECORD"
>
<p>
<ng-container i18n="@@topBar.weLockRecords">
Expand Down Expand Up @@ -34,9 +34,9 @@

<ng-container
*ngIf="
userInfo.IS_DEACTIVATED === 'true' &&
userInfo.IS_LOCKED === 'false' &&
!userInfo.PRIMARY_RECORD
userInfo?.IS_DEACTIVATED === 'true' &&
userInfo?.IS_LOCKED === 'false' &&
!userInfo?.PRIMARY_RECORD
"
>
<p>
Expand All @@ -57,7 +57,7 @@
</p>
</ng-container>

<ng-container *ngIf="userInfo.PRIMARY_RECORD">
<ng-container *ngIf="userInfo?.PRIMARY_RECORD">
<p>
<ng-container i18n="@@topBar.accountDeprecated">
This account has been deprecated, please see account </ng-container
Expand Down
Loading