Skip to content

MY_SELECTED and MINE orcid sync options #38

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

Open
wants to merge 4 commits into
base: dspace-cris-2023_02_x
Choose a base branch
from
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 @@ -258,4 +258,79 @@ describe('OrcidSyncSettingsComponent test suite', () => {
});
});

describe('form submit with relation', () => {
beforeEach(() => {
scheduler = getTestScheduler();
notificationsService = (comp as any).notificationsService;
formGroup = new FormGroup({
syncMode: new FormControl('MANUAL'),
syncFundings: new FormControl('MINE'),
syncPublications: new FormControl('MY_SELECTED'),
syncProfile_BIOGRAPHICAL: new FormControl(true),
syncProfile_IDENTIFIERS: new FormControl(true),
});
spyOn(comp.settingsUpdated, 'emit');
});

it('should call updateByOrcidOperations properly with selected relations', () => {
researcherProfileService.findByRelatedItem.and.returnValue(createSuccessfulRemoteDataObject$(mockResearcherProfile));
researcherProfileService.patch.and.returnValue(createSuccessfulRemoteDataObject$(mockResearcherProfile));
const expectedOps: Operation[] = [
{
path: '/orcid/mode',
op: 'replace',
value: 'MANUAL'
}, {
path: '/orcid/publications',
op: 'replace',
value: 'MY_SELECTED'
}, {
path: '/orcid/fundings',
op: 'replace',
value: 'MINE'
}, {
path: '/orcid/profile',
op: 'replace',
value: 'BIOGRAPHICAL,IDENTIFIERS'
}
];

scheduler.schedule(() => comp.onSubmit(formGroup));
scheduler.flush();

expect(researcherProfileService.patch).toHaveBeenCalledWith(mockResearcherProfile, expectedOps);
});

it('should show notification on success', () => {
researcherProfileService.findByRelatedItem.and.returnValue(createSuccessfulRemoteDataObject$(mockResearcherProfile));
researcherProfileService.patch.and.returnValue(createSuccessfulRemoteDataObject$(mockResearcherProfile));

scheduler.schedule(() => comp.onSubmit(formGroup));
scheduler.flush();

expect(notificationsService.success).toHaveBeenCalled();
expect(comp.settingsUpdated.emit).toHaveBeenCalled();
});

it('should show notification on error', () => {
researcherProfileService.findByRelatedItem.and.returnValue(createFailedRemoteDataObject$());

scheduler.schedule(() => comp.onSubmit(formGroup));
scheduler.flush();

expect(notificationsService.error).toHaveBeenCalled();
expect(comp.settingsUpdated.emit).not.toHaveBeenCalled();
});

it('should show notification on error', () => {
researcherProfileService.findByRelatedItem.and.returnValue(createSuccessfulRemoteDataObject$(mockResearcherProfile));
researcherProfileService.patch.and.returnValue(createFailedRemoteDataObject$());

scheduler.schedule(() => comp.onSubmit(formGroup));
scheduler.flush();

expect(notificationsService.error).toHaveBeenCalled();
expect(comp.settingsUpdated.emit).not.toHaveBeenCalled();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ export class OrcidSyncSettingsComponent implements OnInit {
}
];

this.syncPublicationOptions = ['DISABLED', 'ALL']
this.syncPublicationOptions = ['DISABLED', 'ALL', 'MY_SELECTED', 'MINE']
.map((value) => {
return {
label: this.messagePrefix + '.sync-publications.' + value.toLowerCase(),
value: value,
};
});

this.syncFundingOptions = ['DISABLED', 'ALL']
this.syncFundingOptions = ['DISABLED', 'ALL', 'MY_SELECTED', 'MINE']
.map((value) => {
return {
label: this.messagePrefix + '.sync-fundings.' + value.toLowerCase(),
Expand All @@ -118,8 +118,8 @@ export class OrcidSyncSettingsComponent implements OnInit {
});

this.currentSyncMode = this.getCurrentPreference('dspace.orcid.sync-mode', ['BATCH', 'MANUAL'], 'MANUAL');
this.currentSyncPublications = this.getCurrentPreference('dspace.orcid.sync-publications', ['DISABLED', 'ALL'], 'DISABLED');
this.currentSyncFunding = this.getCurrentPreference('dspace.orcid.sync-fundings', ['DISABLED', 'ALL'], 'DISABLED');
this.currentSyncPublications = this.getCurrentPreference('dspace.orcid.sync-publications', ['DISABLED', 'ALL', 'MY_SELECTED', 'MINE'], 'DISABLED');
this.currentSyncFunding = this.getCurrentPreference('dspace.orcid.sync-fundings', ['DISABLED', 'ALL', 'MY_SELECTED', 'MINE'], 'DISABLED');
}

/**
Expand Down