From 3ef4224596f32f4f025f6ebdbc410a6015a6e94d Mon Sep 17 00:00:00 2001 From: "Gantner, Florian Klaus" Date: Mon, 3 Jul 2023 19:15:45 +0200 Subject: [PATCH 1/2] added MY_SELECTED and MINE orcid sync options --- .../orcid-sync-settings/orcid-sync-settings.component.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/item-page/orcid-page/orcid-sync-settings/orcid-sync-settings.component.ts b/src/app/item-page/orcid-page/orcid-sync-settings/orcid-sync-settings.component.ts index 6ef5f20c6e5..3490ba1deae 100644 --- a/src/app/item-page/orcid-page/orcid-sync-settings/orcid-sync-settings.component.ts +++ b/src/app/item-page/orcid-page/orcid-sync-settings/orcid-sync-settings.component.ts @@ -90,7 +90,7 @@ 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(), @@ -98,7 +98,7 @@ export class OrcidSyncSettingsComponent implements OnInit { }; }); - this.syncFundingOptions = ['DISABLED', 'ALL'] + this.syncFundingOptions = ['DISABLED', 'ALL', 'MY_SELECTED', 'MINE'] .map((value) => { return { label: this.messagePrefix + '.sync-fundings.' + value.toLowerCase(), @@ -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'); } /** From 77a41452ed30c64942dbd4556dbec80126472d2e Mon Sep 17 00:00:00 2001 From: "Gantner, Florian Klaus" Date: Thu, 17 Aug 2023 17:38:39 +0200 Subject: [PATCH 2/2] tests for MY_SELECTED and MINE orcid sync options --- .../orcid-sync-settings.component.spec.ts | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/src/app/item-page/orcid-page/orcid-sync-settings/orcid-sync-settings.component.spec.ts b/src/app/item-page/orcid-page/orcid-sync-settings/orcid-sync-settings.component.spec.ts index cd466ae4a43..3fff53c9250 100644 --- a/src/app/item-page/orcid-page/orcid-sync-settings/orcid-sync-settings.component.spec.ts +++ b/src/app/item-page/orcid-page/orcid-sync-settings/orcid-sync-settings.component.spec.ts @@ -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(); + }); + }); });