mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
[ACA-2067] Side navigation - highlight element with children only when not expanded (#880)
* highlight parent element condition * update test * e2e
This commit is contained in:
committed by
Suzana Dirla
parent
465646e87e
commit
f68200a633
@@ -53,21 +53,21 @@ describe('Sidebar', () => {
|
|||||||
it('My Libraries is automatically selected on expanding File Libraries - [C289900]', async () => {
|
it('My Libraries is automatically selected on expanding File Libraries - [C289900]', async () => {
|
||||||
await page.clickFileLibraries();
|
await page.clickFileLibraries();
|
||||||
expect(await browser.getCurrentUrl()).toContain(APP_ROUTES.MY_LIBRARIES);
|
expect(await browser.getCurrentUrl()).toContain(APP_ROUTES.MY_LIBRARIES);
|
||||||
expect(await sidenav.isActive(SIDEBAR_LABELS.FILE_LIBRARIES)).toBe(true, 'File Libraries link not active');
|
expect(await sidenav.isActive(SIDEBAR_LABELS.FILE_LIBRARIES)).toBe(false, 'File Libraries link is active');
|
||||||
expect(await sidenav.childIsActive(SIDEBAR_LABELS.MY_LIBRARIES)).toBe(true, 'My Libraries link not active');
|
expect(await sidenav.childIsActive(SIDEBAR_LABELS.MY_LIBRARIES)).toBe(true, 'My Libraries link not active');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('navigate to Favorite Libraries - [C289902]', async () => {
|
it('navigate to Favorite Libraries - [C289902]', async () => {
|
||||||
await page.goToFavoriteLibraries();
|
await page.goToFavoriteLibraries();
|
||||||
expect(await browser.getCurrentUrl()).toContain(APP_ROUTES.FAVORITE_LIBRARIES);
|
expect(await browser.getCurrentUrl()).toContain(APP_ROUTES.FAVORITE_LIBRARIES);
|
||||||
expect(await sidenav.isActive(SIDEBAR_LABELS.FILE_LIBRARIES)).toBe(true, 'File Libraries link not active');
|
expect(await sidenav.isActive(SIDEBAR_LABELS.FILE_LIBRARIES)).toBe(false, 'File Libraries link is active');
|
||||||
expect(await sidenav.childIsActive(SIDEBAR_LABELS.FAVORITE_LIBRARIES)).toBe(true, 'Favorite Libraries link not active');
|
expect(await sidenav.childIsActive(SIDEBAR_LABELS.FAVORITE_LIBRARIES)).toBe(true, 'Favorite Libraries link not active');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('navigate to My Libraries - [C289901]', async () => {
|
it('navigate to My Libraries - [C289901]', async () => {
|
||||||
await page.goToMyLibraries();
|
await page.goToMyLibraries();
|
||||||
expect(await browser.getCurrentUrl()).toContain(APP_ROUTES.MY_LIBRARIES);
|
expect(await browser.getCurrentUrl()).toContain(APP_ROUTES.MY_LIBRARIES);
|
||||||
expect(await sidenav.isActive(SIDEBAR_LABELS.FILE_LIBRARIES)).toBe(true, 'File Libraries link not active');
|
expect(await sidenav.isActive(SIDEBAR_LABELS.FILE_LIBRARIES)).toBe(false, 'File Libraries link is active');
|
||||||
expect(await sidenav.childIsActive(SIDEBAR_LABELS.MY_LIBRARIES)).toBe(true, 'My Libraries link not active');
|
expect(await sidenav.childIsActive(SIDEBAR_LABELS.MY_LIBRARIES)).toBe(true, 'My Libraries link not active');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -40,18 +40,22 @@
|
|||||||
|
|
||||||
<ng-container *ngIf="item.children && item.children.length">
|
<ng-container *ngIf="item.children && item.children.length">
|
||||||
<mat-expansion-panel
|
<mat-expansion-panel
|
||||||
|
#expansionPanel="matExpansionPanel"
|
||||||
[acaExpansionPanel]="item"
|
[acaExpansionPanel]="item"
|
||||||
[expanded]="routerLink.isActive"
|
[expanded]="routerLink.isActive"
|
||||||
[@.disabled]="true">
|
[@.disabled]="true">
|
||||||
<mat-expansion-panel-header expandedHeight="48px" collapsedHeight="48px">
|
<mat-expansion-panel-header expandedHeight="48px" collapsedHeight="48px">
|
||||||
<mat-panel-title [attr.title]="item.description | translate">
|
<mat-panel-title [attr.title]="item.description | translate">
|
||||||
<mat-icon [color]="routerLink.isActive? 'accent': 'primary'">{{ item.icon }}</mat-icon>
|
<mat-icon [color]="routerLink.isActive && !expansionPanel.expanded? 'accent': 'primary'">
|
||||||
<span class="item--label item--parent"
|
{{ item.icon }}
|
||||||
|
</mat-icon>
|
||||||
|
<span
|
||||||
|
class="item--label item--parent"
|
||||||
[ngClass]="{
|
[ngClass]="{
|
||||||
'item--active': routerLink.isActive,
|
'item--default': !routerLink.isActive && expansionPanel.expanded,
|
||||||
'item--default': !routerLink.isActive
|
'item--active': routerLink.isActive && !expansionPanel.expanded
|
||||||
}">
|
}"
|
||||||
{{ item.title | translate }}</span>
|
>{{ item.title | translate }}</span>
|
||||||
</mat-panel-title>
|
</mat-panel-title>
|
||||||
</mat-expansion-panel-header>
|
</mat-expansion-panel-header>
|
||||||
|
|
||||||
|
@@ -26,29 +26,53 @@
|
|||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { TestBed, async, ComponentFixture } from '@angular/core/testing';
|
import { TestBed, async, ComponentFixture } from '@angular/core/testing';
|
||||||
import { SidenavComponent } from './sidenav.component';
|
import { SidenavComponent } from './sidenav.component';
|
||||||
import { EffectsModule } from '@ngrx/effects';
|
|
||||||
import { NodeEffects } from '../../store/effects/node.effects';
|
|
||||||
import { AppTestingModule } from '../../testing/app-testing.module';
|
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||||
import { ExperimentalDirective } from '../../directives/experimental.directive';
|
import { MatExpansionModule } from '@angular/material/expansion';
|
||||||
|
import { AppExtensionService } from '../../extensions/extension.service';
|
||||||
|
|
||||||
describe('SidenavComponent', () => {
|
describe('SidenavComponent', () => {
|
||||||
let fixture: ComponentFixture<SidenavComponent>;
|
let fixture: ComponentFixture<SidenavComponent>;
|
||||||
let component: SidenavComponent;
|
let component: SidenavComponent;
|
||||||
|
let extensionService: AppExtensionService;
|
||||||
|
const navbarMock = <any>[
|
||||||
|
{
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
route: 'route'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [AppTestingModule, EffectsModule.forRoot([NodeEffects])],
|
imports: [MatExpansionModule, AppTestingModule],
|
||||||
declarations: [SidenavComponent, ExperimentalDirective],
|
providers: [AppExtensionService],
|
||||||
|
declarations: [SidenavComponent],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
})
|
})
|
||||||
.compileComponents()
|
.compileComponents()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
fixture = TestBed.createComponent(SidenavComponent);
|
fixture = TestBed.createComponent(SidenavComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
extensionService = TestBed.get(AppExtensionService);
|
||||||
|
|
||||||
|
extensionService.navbar = navbarMock;
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should be created', () => {
|
it('should set the sidenav data', async(() => {
|
||||||
expect(component).toBeTruthy();
|
expect(component.groups).toEqual(<any>[
|
||||||
});
|
{
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
route: 'route',
|
||||||
|
url: '/route'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
@@ -41,6 +41,10 @@
|
|||||||
color: mat-color($foreground, text);
|
color: mat-color($foreground, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.item--label {
|
||||||
|
color: mat-color($primary, 0.87);
|
||||||
|
}
|
||||||
|
|
||||||
.item--active {
|
.item--active {
|
||||||
color: mat-color($accent);
|
color: mat-color($accent);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user