Skip to content

Commit

Permalink
[ACS-6891] The user is not redirected to the library page after delet…
Browse files Browse the repository at this point in the history
…ing the library from the Manage Members view
  • Loading branch information
dominikiwanekhyland committed Feb 28, 2024
1 parent ec5c5cf commit 8322355
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,29 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

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';
Expand All @@ -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', () => {
Expand Down Expand Up @@ -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']));
}));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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'));
Expand Down

0 comments on commit 8322355

Please sign in to comment.