Skip to content

Commit

Permalink
[ACS-3742] Bug Fixes for new Layout (#3149)
Browse files Browse the repository at this point in the history
* Bug Fixes

* Bug Fixes

* Bug Fixes

* Bug Fixes

* implemented review comments

* ACS-3742 Renamed title

---------

Co-authored-by: Aleksander Sklorz <[email protected]>
  • Loading branch information
vijayanssettu and AleksanderSklorz authored Apr 28, 2023
1 parent ca58bab commit c2a1dd9
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,34 @@ import { SearchInputComponent } from './search-input.component';
import { AppTestingModule } from '../../../testing/app-testing.module';
import { Actions, ofType } from '@ngrx/effects';
import { SearchByTermAction, SearchActionTypes, SnackbarErrorAction, SnackbarActionTypes } from '@alfresco/aca-shared/store';
import { AppHookService } from '@alfresco/aca-shared';
import { AppHookService, AppService } from '@alfresco/aca-shared';
import { map } from 'rxjs/operators';
import { SearchQueryBuilderService } from '@alfresco/adf-content-services';
import { SearchNavigationService } from '../search-navigation.service';
import { BehaviorSubject, Subject } from 'rxjs';

describe('SearchInputComponent', () => {
let fixture: ComponentFixture<SearchInputComponent>;
let component: SearchInputComponent;
let actions$: Actions;
let appHookService: AppHookService;
let searchInputService: SearchNavigationService;
const appServiceMock = {
appNavNarMode$: new BehaviorSubject('collapsed'),
toggleAppNavBar$: new Subject()
};

beforeEach(() => {
TestBed.configureTestingModule({
imports: [AppTestingModule],
declarations: [SearchInputComponent],
providers: [SearchQueryBuilderService],
providers: [
{
provide: AppService,
useValue: appServiceMock
},
SearchQueryBuilderService
],
schemas: [NO_ERRORS_SCHEMA]
});

Expand All @@ -59,6 +70,13 @@ describe('SearchInputComponent', () => {
fixture.destroy();
});

it('should collapsed sidenav by default', () => {
spyOn(appServiceMock.appNavNarMode$, 'next');
component.ngOnInit();

expect(appServiceMock.appNavNarMode$.next).toHaveBeenCalledWith('collapsed');
});

it('should change flag on library400Error event', async () => {
fixture.detectChanges();
await fixture.whenStable();
Expand Down Expand Up @@ -225,4 +243,11 @@ describe('SearchInputComponent', () => {
expect(searchInputService.navigateBack).toHaveBeenCalledWith();
});
});

it('should sidenav expanded after the component is destroy', () => {
spyOn(appServiceMock.appNavNarMode$, 'next');
component.ngOnDestroy();

expect(appServiceMock.appNavNarMode$.next).toHaveBeenCalledWith('expanded');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

import { AppHookService } from '@alfresco/aca-shared';
import { AppHookService, AppService } from '@alfresco/aca-shared';
import { AppStore, SearchByTermAction, SearchOptionIds, SearchOptionModel, SnackbarErrorAction } from '@alfresco/aca-shared/store';
import { SearchQueryBuilderService } from '@alfresco/adf-content-services';
import { AppConfigService } from '@alfresco/adf-core';
Expand Down Expand Up @@ -86,6 +86,7 @@ export class SearchInputComponent implements OnInit, OnDestroy {
private router: Router,
private store: Store<AppStore>,
private appHookService: AppHookService,
private appService: AppService,
public searchInputService: SearchNavigationService
) {
this.searchOnChange = this.config.get<boolean>('search.aca:triggeredOnChange', true);
Expand Down Expand Up @@ -113,6 +114,7 @@ export class SearchInputComponent implements OnInit, OnDestroy {
}

showInputValue() {
this.appService.appNavNarMode$.next('collapsed');
this.has400LibraryError = false;
this.searchedWord = this.getUrlSearchTerm();

Expand All @@ -122,6 +124,7 @@ export class SearchInputComponent implements OnInit, OnDestroy {
}

ngOnDestroy(): void {
this.appService.appNavNarMode$.next('expanded');
this.onDestroy$.next(true);
this.onDestroy$.complete();
this.removeContentFilters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,31 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
import { SearchLibrariesResultsComponent } from './search-libraries-results.component';
import { SearchLibrariesQueryBuilderService } from './search-libraries-query-builder.service';
import { DocumentListComponent } from '@alfresco/adf-content-services';
import { BehaviorSubject, Subject } from 'rxjs';
import { AppService } from '@alfresco/aca-shared';

describe('SearchLibrariesResultsComponent', () => {
let component: SearchLibrariesResultsComponent;
let fixture: ComponentFixture<SearchLibrariesResultsComponent>;

const emptyPage = { list: { pagination: { totalItems: 0 }, entries: [] } };
const appServiceMock = {
appNavNarMode$: new BehaviorSubject('collapsed'),
toggleAppNavBar$: new Subject()
};

beforeEach(() => {
TestBed.configureTestingModule({
imports: [AppTestingModule, AppConfigModule],
declarations: [DataTableComponent, DocumentListComponent, SearchLibrariesResultsComponent],
schemas: [NO_ERRORS_SCHEMA],
providers: [SearchLibrariesQueryBuilderService]
providers: [
{
provide: AppService,
useValue: appServiceMock
},
SearchLibrariesQueryBuilderService
]
});

fixture = TestBed.createComponent(SearchLibrariesResultsComponent);
Expand All @@ -54,4 +66,11 @@ describe('SearchLibrariesResultsComponent', () => {

expect(component.onSearchResultLoaded).toHaveBeenCalledWith(emptyPage);
});

it('should collapsed sidenav by default', () => {
spyOn(appServiceMock.appNavNarMode$, 'next');
component.ngOnInit();

expect(appServiceMock.appNavNarMode$.next).toHaveBeenCalledWith('collapsed');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { ActivatedRoute, Params } from '@angular/router';
import { Store } from '@ngrx/store';
import { ContentManagementService } from '../../../services/content-management.service';
import { SearchLibrariesQueryBuilderService } from './search-libraries-query-builder.service';
import { AppExtensionService, AppHookService, PageComponent } from '@alfresco/aca-shared';
import { AppExtensionService, AppHookService, AppService, PageComponent } from '@alfresco/aca-shared';
import { DocumentListPresetRef } from '@alfresco/adf-extensions';

@Component({
Expand All @@ -52,6 +52,7 @@ export class SearchLibrariesResultsComponent extends PageComponent implements On
private librariesQueryBuilder: SearchLibrariesQueryBuilderService,
private route: ActivatedRoute,
private appHookService: AppHookService,
private appService: AppService,
store: Store<AppStore>,
extensions: AppExtensionService,
content: ContentManagementService
Expand All @@ -65,6 +66,7 @@ export class SearchLibrariesResultsComponent extends PageComponent implements On
}

ngOnInit() {
this.appService.appNavNarMode$.next('collapsed');
super.ngOnInit();

this.columns = this.extensions.documentListPresets.searchLibraries || [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,12 @@ describe('SearchNavigationService', () => {

expect(routerNavigate).toHaveBeenCalledWith(['/search']);
});

it('should navigate back to the previous route when call the navigateBack function', () => {
const routerNavigate = spyOn(router, 'navigate');
service.saveRoute('');
service.navigateBack();

expect(routerNavigate).toHaveBeenCalledWith(['/personal-files']);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export class SearchNavigationService {
navigateBack(): void {
if (this.previousRoute) {
this.router.navigate([this.previousRoute]);
} else {
this.router.navigate(['/personal-files']);
}
}

Expand Down

0 comments on commit c2a1dd9

Please sign in to comment.