Skip to content

Commit

Permalink
[TLC-674] Properly test for existence of duplicates section
Browse files Browse the repository at this point in the history
  • Loading branch information
kshepherd committed Feb 28, 2024
1 parent 04b3250 commit 5f1e082
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ export class PoolSearchResultListElementComponent extends SearchResultListElemen
*/
showThumbnails: boolean;

enableDetectDuplicates$: Observable<any>;

constructor(
protected linkService: LinkService,
protected truncatableService: TruncatableService,
Expand All @@ -101,14 +99,6 @@ export class PoolSearchResultListElementComponent extends SearchResultListElemen
followLink('submitter')
), followLink('action'));

// Get configuration for duplicate detection feature
this.enableDetectDuplicates$ = this.configService.findByPropertyName('duplicate.enable').pipe(
getFirstCompletedRemoteData(),
map((rd: RemoteData<ConfigurationProperty>) => {
return (rd.hasSucceeded && rd.payload && rd.payload.values[0] === 'true');
})
);

(this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>).pipe(
getFirstCompletedRemoteData(),
mergeMap((wfiRD: RemoteData<WorkflowItem>) => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/submission/objects/submission-objects.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ export class SubmissionObjectEffects {
// or if configuration overrides this behaviour
if (!alwaysDisplayDuplicates()) {
const duplicatesSectionId = findKey(currentState.sections, (section) => section.sectionType === SectionsType.Duplicates);
if (isNotUndefined(duplicatesSectionId) && isEmpty((sections[duplicatesSectionId] as WorkspaceitemSectionDuplicatesObject).potentialDuplicates)) {
if (isNotUndefined(duplicatesSectionId) && sections.hasOwnProperty(duplicatesSectionId) && isEmpty((sections[duplicatesSectionId] as WorkspaceitemSectionDuplicatesObject).potentialDuplicates)) {
mappedActions.push(new CleanDuplicateDetectionAction(submissionId));

Check warning on line 453 in src/app/submission/objects/submission-objects.effects.ts

View check run for this annotation

Codecov / codecov/patch

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

Added line #L453 was not covered by tests
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/submission/objects/submission-objects.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ function deleteFile(state: SubmissionObjectState, action: DeleteUploadedFileActi
}

function cleanDuplicateDetectionSection(state: SubmissionObjectState, action: CleanDuplicateDetectionAction): SubmissionObjectState {
if (isNotEmpty(state[ action.payload.submissionId ])) {
if (isNotEmpty(state[ action.payload.submissionId ]) && state[action.payload.submissionId].sections.hasOwnProperty('duplicates')) {
return Object.assign({}, state, {

Check warning on line 866 in src/app/submission/objects/submission-objects.reducer.ts

View check run for this annotation

Codecov / codecov/patch

src/app/submission/objects/submission-objects.reducer.ts#L866

Added line #L866 was not covered by tests
[ action.payload.submissionId ]: Object.assign({}, state[ action.payload.submissionId ], {
sections: Object.assign({}, state[ action.payload.submissionId ].sections, {
Expand Down

0 comments on commit 5f1e082

Please sign in to comment.