Skip to content

Commit 77f31b4

Browse files
FrancescoMolinaroAndrea Barbasso
authored andcommitted
Merged in task/dspace-cris-2023_02_x/DSC-2010 (pull request DSpace#2498)
[DSC-2010] port fix for nested errors Approved-by: Andrea Barbasso
2 parents 7b3e778 + c83e6b1 commit 77f31b4

2 files changed

Lines changed: 62 additions & 1 deletion

File tree

src/app/submission/objects/submission-objects.effects.spec.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,67 @@ describe('SubmissionObjectEffects test suite', () => {
717717
// expect(notificationsServiceStub.success).toHaveBeenCalled();
718718
});
719719

720+
it('should handle sections without errorsToShow property gracefully', () => {
721+
const stateWithMissingErrorsToShow = {
722+
826: {
723+
...submissionState['826'],
724+
sections: {
725+
...submissionState['826'].sections,
726+
'sectionWithoutErrors': {
727+
sectionType: 'custom',
728+
enabled: true,
729+
data: {},
730+
} as any,
731+
},
732+
},
733+
};
734+
735+
store.nextState({
736+
submission: {
737+
objects: stateWithMissingErrorsToShow,
738+
},
739+
} as any);
740+
741+
const response = [Object.assign({}, mockSubmissionRestResponse[0], {
742+
sections: mockSectionsData,
743+
})];
744+
actions = hot('--a-', {
745+
a: {
746+
type: SubmissionObjectActionTypes.SAVE_SUBMISSION_FORM_SUCCESS,
747+
payload: {
748+
submissionId: submissionId,
749+
submissionObject: response,
750+
},
751+
},
752+
});
753+
754+
const expected = cold('--(bcd)-', {
755+
b: new UpdateSectionDataAction(
756+
submissionId,
757+
'traditionalpageone',
758+
mockSectionsData.traditionalpageone as any,
759+
[],
760+
[],
761+
),
762+
c: new UpdateSectionDataAction(
763+
submissionId,
764+
'license',
765+
mockSectionsData.license as any,
766+
[],
767+
[],
768+
),
769+
d: new UpdateSectionDataAction(
770+
submissionId,
771+
'upload',
772+
mockSectionsData.upload as any,
773+
[],
774+
[],
775+
),
776+
});
777+
778+
expect(submissionObjectEffects.saveSubmissionSuccess$).toBeObservable(expected);
779+
});
780+
720781
});
721782

722783
describe('saveSubmissionSectionSuccess$', () => {

src/app/submission/objects/submission-objects.effects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ export class SubmissionObjectEffects {
485485
}
486486

487487
const sections: WorkspaceitemSectionsObject = (item.sections && isNotEmpty(item.sections)) ? item.sections : {};
488-
const sectionsKeys: string[] = union(Object.keys(sections), Object.keys(errorsList));
488+
const sectionsKeys = union(Object.keys(sections), Object.keys(currentState.sections).filter(key => currentState.sections[key].errorsToShow?.length > 0), Object.keys(errorsList));
489489

490490
for (const sectionId of sectionsKeys) {
491491
const sectionErrors = errorsList[sectionId] || [];

0 commit comments

Comments
 (0)