diff --git a/projects/aca-content/src/lib/services/content-management.service.spec.ts b/projects/aca-content/src/lib/services/content-management.service.spec.ts index 2f4484615a..d32bba14aa 100644 --- a/projects/aca-content/src/lib/services/content-management.service.spec.ts +++ b/projects/aca-content/src/lib/services/content-management.service.spec.ts @@ -22,28 +22,29 @@ * from Hyland Software. If not, see . */ -import { TestBed, fakeAsync, tick, flush } from '@angular/core/testing'; -import { of, throwError, Subject, BehaviorSubject, EMPTY } from 'rxjs'; -import { Actions, ofType, EffectsModule } from '@ngrx/effects'; +import { fakeAsync, flush, TestBed, tick } from '@angular/core/testing'; +import { BehaviorSubject, EMPTY, of, Subject, throwError } from 'rxjs'; +import { Actions, EffectsModule, ofType } from '@ngrx/effects'; import { AppStore, - SnackbarWarningAction, - SnackbarInfoAction, - SnackbarErrorAction, - PurgeDeletedNodesAction, - RestoreDeletedNodesAction, - NavigateToParentFolder, + CopyNodesAction, DeleteNodesAction, MoveNodesAction, - CopyNodesAction, - ShareNodeAction, - SetSelectedNodesAction, - UnlockWriteAction, - SnackbarActionTypes, + NavigateRouteAction, + NavigateToParentFolder, NodeActionTypes, + PurgeDeletedNodesAction, ReloadDocumentListAction, - ViewNodeVersionAction, - ViewNodeExtras + RestoreDeletedNodesAction, + SetSelectedNodesAction, + ShareNodeAction, + SnackbarActionTypes, + SnackbarErrorAction, + SnackbarInfoAction, + SnackbarWarningAction, + UnlockWriteAction, + ViewNodeExtras, + ViewNodeVersionAction } from '@alfresco/aca-shared/store'; import { map } from 'rxjs/operators'; import { NodeEffects } from '../store/effects/node.effects'; @@ -52,17 +53,17 @@ import { AppHookService, ContentApiService } from '@alfresco/aca-shared'; import { Store } from '@ngrx/store'; import { ContentManagementService } from './content-management.service'; import { NodeActionsService } from './node-actions.service'; -import { TranslationService, NotificationService } from '@alfresco/adf-core'; +import { NotificationService, TranslationService } from '@alfresco/adf-core'; import { MatDialog, MatDialogModule, MatDialogRef } from '@angular/material/dialog'; import { MatSnackBarModule, MatSnackBarRef, SimpleSnackBar } from '@angular/material/snack-bar'; -import { NodeEntry, Node, VersionPaging } from '@alfresco/js-api'; +import { Node, NodeEntry, VersionPaging } from '@alfresco/js-api'; import { + FileModel, NewVersionUploaderDataAction, NewVersionUploaderService, NodeAspectService, - ViewVersion, NodesApiService, - FileModel + ViewVersion } from '@alfresco/adf-content-services'; describe('ContentManagementService', () => { @@ -1769,4 +1770,18 @@ describe('ContentManagementService', () => { expect(document.querySelector).not.toHaveBeenCalled(); }); }); + + describe('deleteLibrary', () => { + it('should dispatch NavigateRouteAction to /libraries after successful deletion', fakeAsync(() => { + const libraryId = 'test-library-id'; + spyOn(contentApi, 'deleteSite').and.returnValue(of(null)); + spyOn(store, 'dispatch').and.callThrough(); + + contentManagementService.deleteLibrary(libraryId); + tick(); + + expect(store.dispatch).toHaveBeenCalledWith(new SnackbarInfoAction('APP.MESSAGES.INFO.LIBRARY_DELETED')); + expect(store.dispatch).toHaveBeenCalledWith(new NavigateRouteAction(['/libraries'])); + })); + }); }); diff --git a/projects/aca-content/src/lib/services/content-management.service.ts b/projects/aca-content/src/lib/services/content-management.service.ts index 6adb643ccb..9f16bd2b7b 100644 --- a/projects/aca-content/src/lib/services/content-management.service.ts +++ b/projects/aca-content/src/lib/services/content-management.service.ts @@ -48,15 +48,15 @@ import { ConfirmDialogComponent, FolderDialogComponent, LibraryDialogComponent, - ShareDialogComponent, - NodeAspectService, - NewVersionUploaderService, - NewVersionUploaderDialogData, NewVersionUploaderData, NewVersionUploaderDataAction, - NodesApiService + NewVersionUploaderDialogData, + NewVersionUploaderService, + NodeAspectService, + NodesApiService, + ShareDialogComponent } from '@alfresco/adf-content-services'; -import { TranslationService, NotificationService } from '@alfresco/adf-core'; +import { NotificationService, TranslationService } from '@alfresco/adf-core'; import { DeletedNodesPaging, Node, NodeEntry, PathInfo, SiteBodyCreate, SiteEntry } from '@alfresco/js-api'; import { Injectable } from '@angular/core'; import { MatDialog, MatDialogConfig } from '@angular/material/dialog'; @@ -289,6 +289,7 @@ export class ContentManagementService { () => { this.appHookService.libraryDeleted.next(id); this.store.dispatch(new SnackbarInfoAction('APP.MESSAGES.INFO.LIBRARY_DELETED')); + this.store.dispatch(new NavigateRouteAction(['/libraries'])); }, () => { this.store.dispatch(new SnackbarErrorAction('APP.MESSAGES.ERRORS.DELETE_LIBRARY_FAILED'));