Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "time-tracker",
"version": "1.50.0",
"version": "1.50.2",
"scripts": {
"preinstall": "npx npm-force-resolutions",
"ng": "ng",
Expand Down
3 changes: 0 additions & 3 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { HomeComponent } from './modules/home/home.component';
import { LoginComponent } from './modules/login/login.component';
import { CustomerComponent } from './modules/customer-management/pages/customer.component';
import { UsersComponent } from './modules/users/pages/users.component';
import { TechnologyReportComponent } from './modules/technology-report/pages/technology-report.component';
import { TechnologiesReportGuard } from './guards/technologies-report-guard/technologies-report.guard';

const routes: Routes = [
{
Expand All @@ -26,7 +24,6 @@ const routes: Routes = [
{ path: 'activities-management', component: ActivitiesManagementComponent },
{ path: 'customers-management', canActivate: [AdminGuard], component: CustomerComponent },
{ path: 'users', canActivate: [AdminGuard], component: UsersComponent },
{ path: 'technology-report', canActivate: [AdminGuard, TechnologiesReportGuard], component: TechnologyReportComponent },
{ path: '', pathMatch: 'full', redirectTo: 'time-clock' },
],
},
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import { RouterTestingModule } from '@angular/router/testing';
import { Router, Routes } from '@angular/router';
import { TimeClockComponent } from '../../../time-clock/pages/time-clock.component';
import { of } from 'rxjs';
import { FeatureManagerService } from '../../feature-toggles/feature-toggle-manager.service';
import { UserInfoService } from 'src/app/modules/user/services/user-info.service';

describe('SidebarComponent', () => {
let component: SidebarComponent;
let fixture: ComponentFixture<SidebarComponent>;
let azureAdB2CServiceStubInjected;
let featureManagerServiceStubInjected: FeatureManagerService;
let userInfoService: UserInfoService;
let router;
const routes: Routes = [{ path: 'time-clock', component: TimeClockComponent }];
Expand Down Expand Up @@ -47,7 +45,6 @@ describe('SidebarComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(SidebarComponent);
azureAdB2CServiceStubInjected = TestBed.inject(AzureAdB2CService);
featureManagerServiceStubInjected = TestBed.inject(FeatureManagerService);
userInfoService = TestBed.inject(UserInfoService);
component = fixture.componentInstance;
fixture.detectChanges();
Expand Down Expand Up @@ -86,21 +83,4 @@ describe('SidebarComponent', () => {
});
});

it('List Technologies item is added when feature flag "ui-list-technologies" is enabled for user', () => {
spyOn(featureManagerServiceStubInjected, 'isToggleEnabledForUser').and.returnValue(of(true));
const itemsSidebar = [];

component.toggleListTechnologies(itemsSidebar);

expect(itemsSidebar.length).toBe(1);
});

it('List Technologies item is not added when feature flag "ui-list-technologies" is disabled for user', () => {
spyOn(featureManagerServiceStubInjected, 'isToggleEnabledForUser').and.returnValue(of(false));
const itemsSidebar = [];

component.toggleListTechnologies(itemsSidebar);

expect(itemsSidebar.length).toBe(0);
});
});
19 changes: 0 additions & 19 deletions src/app/modules/shared/components/sidebar/sidebar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ItemSidebar } from './models/item-sidebar.model';
import { NavigationStart, Router } from '@angular/router';
import { Observable, Subscription } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { FeatureManagerService } from '../../feature-toggles/feature-toggle-manager.service';
import { UserInfoService } from 'src/app/modules/user/services/user-info.service';

@Component({
Expand All @@ -19,7 +18,6 @@ export class SidebarComponent implements OnInit, OnDestroy {
constructor(
private router: Router,
private userInfoService: UserInfoService,
private featureManagerService: FeatureManagerService,
) {
this.navStart = this.router.events.pipe(
filter((evt) => evt instanceof NavigationStart)
Expand All @@ -29,7 +27,6 @@ export class SidebarComponent implements OnInit, OnDestroy {
ngOnInit(): void {
this.toggleSideBar();
this.sidebarItems$ = this.getSidebarItems().subscribe();
this.toggleListTechnologies(this.itemsSidebar);
this.highlightMenuOption(this.router.routerState.snapshot.url);
this.navStart.subscribe((evt) => {
this.highlightMenuOption(evt.url);
Expand Down Expand Up @@ -68,22 +65,6 @@ export class SidebarComponent implements OnInit, OnDestroy {
);
}

toggleListTechnologies(itemsSidebar: ItemSidebar[]) {
this.featureManagerService
.isToggleEnabledForUser('ui-list-technologies')
.subscribe((enabled) => {
if (enabled === true) {
const listTechnologiesItem = {
route: '/technology-report',
icon: 'fas fa-user',
text: 'Technology Report',
active: false,
};
itemsSidebar.push(listTechnologiesItem);
}
});
}

highlightMenuOption(route) {
this.itemsSidebar.map((item) => (item.active = false));
this.itemsSidebar.filter((item) => item.route === route).map((item) => (item.active = true));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { FeatureToggle } from './../../../../../environments/enum';
import { TestBed } from '@angular/core/testing';
import { of } from 'rxjs';
import { FeatureManagerService } from '../feature-toggle-manager.service';
Expand All @@ -23,18 +22,6 @@ describe('FeatureToggleGeneralService', () => {
expect(featureToggleGeneralService).toBeTruthy();
});

const params = [{ bool: false }, { bool: true }];
params.map((param) => {
it(`isActivated should return a boolean ${param.bool}`, () => {
const toggleName = FeatureToggle.SWITCH_GROUP;
featureManagerService.isToggleEnabledForUser = () => of(param.bool);

featureToggleGeneralService.isActivated(toggleName).subscribe((enabled) => {
expect(enabled).toBe(param.bool);
});
});
});

it('getActivated return a FeatureToggleModel', () => {
const anyNotMatchingFilter = new TargetingFeatureFilterModel(
{ Audience: { Groups: ['a-group'], Users: ['user-a'] } },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { map } from 'rxjs/operators';
import { FeatureToggle } from './../../../../../environments/enum';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { FeatureManagerService } from '../feature-toggle-manager.service';
Expand All @@ -11,10 +9,6 @@ import { FeatureToggleModel } from '../feature-toggle.model';
export class FeatureToggleGeneralService {
constructor(private featureManagerService: FeatureManagerService) {}

isActivated(featureToggle: FeatureToggle): Observable<boolean> {
return this.featureManagerService.isToggleEnabledForUser(featureToggle);
}

getActivated(): Observable<FeatureToggleModel[]>{
return this.featureManagerService.getAllFeatureToggleEnableForUser();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { TargetingFeatureFilterModel } from './filters/targeting/targeting-featu


describe('FeatureToggleManager', () => {
const featureToggleKey = 'foo';
const featureToggleLabel = 'dev';
const fakeAppConfigurationConnectionString = 'Endpoint=http://fake.foo;Id=fake.id;Secret=fake.secret';
const aFeatureToggle = new FeatureToggleModel('any-id', true, []);
let service: FeatureManagerService;
Expand All @@ -26,18 +24,6 @@ describe('FeatureToggleManager', () => {
spyOn(fakeFeatureToggleProvider, 'getFeatureToggle').and.returnValue(of(aFeatureToggle));
service = new FeatureManagerService(fakeFeatureToggleProvider);
});
it('manager uses feature provider to build feature toggle model', async () => {
service.isToggleEnabled(featureToggleKey, featureToggleLabel).subscribe((value) => {

expect(fakeFeatureToggleProvider).toHaveBeenCalledWith(featureToggleKey, featureToggleLabel);
});
});

it('manager extracts enabled attribute from feature toggle model', async () => {
service.isToggleEnabled(featureToggleKey, featureToggleLabel).subscribe((value) => {
expect(value).toEqual(aFeatureToggle.enabled);
});
});
});


Expand All @@ -52,29 +38,14 @@ describe('FeatureToggleManager', () => {
);

let aToggleWithFilters;
let getFeatureToggleSpy;

beforeEach(() => {
aToggleWithFilters = new FeatureToggleModel('any-other-id', true, [anyMatchingFilter]);
fakeFeatureToggleProvider = new FeatureToggleProvider(
new AppConfigurationClient(fakeAppConfigurationConnectionString),
new FeatureFilterProvider(new AzureAdB2CService())
);
getFeatureToggleSpy = spyOn(fakeFeatureToggleProvider, 'getFeatureToggle').and.returnValue(of(aToggleWithFilters));
service = new FeatureManagerService(fakeFeatureToggleProvider);
spyOn(service, 'isToggleEnabled').and.returnValue(of(true));
});

it('manager uses feature provider to build feature toggle model', async () => {
service.isToggleEnabledForUser(featureToggleKey, featureToggleLabel).subscribe((value) => {
expect(getFeatureToggleSpy).toHaveBeenCalledWith(featureToggleKey, featureToggleLabel);
});
});

it('given a feature toggle with filters which match the verification, then the response is true', async () => {
service.isToggleEnabledForUser(featureToggleKey, featureToggleLabel).subscribe((value) => {
expect(value).toEqual(true);
});
});

it('given a feature toggle with filters which do not match the verification, then the response is false', async () => {
Expand All @@ -87,9 +58,6 @@ describe('FeatureToggleManager', () => {
spyOn(fakeFeatureToggleProvider, 'getFeatureToggle').and.returnValue(of(aToggleWithFilters));
service = new FeatureManagerService(fakeFeatureToggleProvider);

service.isToggleEnabledForUser(featureToggleKey, featureToggleLabel).subscribe((value) => {
expect(value).toEqual(false);
});
});

it('Get empty when getAllFeatureToggle() return empty', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { from, Observable, zip } from 'rxjs';
import { from, Observable} from 'rxjs';
import { map } from 'rxjs/operators';
import { FeatureToggleProvider } from './feature-toggle-provider.service';
import { FeatureToggleModel } from './feature-toggle.model';
Expand All @@ -11,31 +11,6 @@ export class FeatureManagerService {

constructor(private featureToggleProvider: FeatureToggleProvider) { }

public isToggleEnabled(toggleName: string, toggleLabel?: string): Observable<boolean> {
return this.featureToggleProvider
.getFeatureToggle(toggleName, toggleLabel)
.pipe(map((featureToggle) => featureToggle.enabled));
}

public isToggleEnabledForUser(toggleName: string, toggleLabel?: string): Observable<boolean> {
const matchesFilters$: Observable<boolean> = this.featureToggleProvider
.getFeatureToggle(toggleName, toggleLabel)
.pipe(
map(featureToggle => featureToggle.filters),
map(filters => filters.map(filter => filter.evaluate())),
map(filterEvaluations => filterEvaluations.includes(true))
);

const result$: Observable<boolean> = zip(
this.isToggleEnabled(toggleName, toggleLabel),
matchesFilters$
).pipe(
map(([enabled, enabledForUser]) => enabled && enabledForUser)
);

return result$;
}

public getAllFeatureToggleEnableForUser(): Observable<FeatureToggleModel[]> {
return from(this.featureToggleProvider.getAllFeatureToggle()).pipe(
map((allFeatureToggle) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ describe('CalendarComponent', () => {
});

it('emit current date and call navigationEnable when call handleChangeDateEvent', () => {
const calendarView: CalendarView = CalendarView.Month;
const fakeValueEmit = {
date: currentDate.toDate(),
date: currentDate.toDate()
};
const calendarView = CalendarView.Month;
spyOn(component, 'navigationEnable');
spyOn(component.changeDate, 'emit');
spyOn(component, 'isVisibleForCurrentDate');
Expand All @@ -221,6 +221,14 @@ describe('CalendarComponent', () => {
expect(component.calendarView).toEqual(fakeCalendarView);
});

it('emit calendarView Day when call changeCalendarView', () => {
const fakeCalendarView: CalendarView = CalendarView.Day;
component.calendarView = CalendarView.Month;
spyOn(component.changeView, 'emit');
component.changeCalendarView(fakeCalendarView);
expect(component.changeView.emit).toHaveBeenCalledWith({ calendarView: fakeCalendarView });
});

it('set srcoll to current time marker in calendarView when is call scrollToCurrentTimeMarker', () => {
const fakeCalendarView: CalendarView = CalendarView.Week;
spyOn(component, 'scrollToCurrentTimeMarker');
Expand Down Expand Up @@ -257,7 +265,7 @@ describe('CalendarComponent', () => {

it('set true in nextDateDisabled when call navigationEnable and calendarView == Month and currentDate equal to initialDate', () => {
component.currentDate = moment().toDate();
component.initialDate = moment().add(2, 'day').toDate();
component.initialDate = moment().toDate();

component.navigationEnable(CalendarView.Month);

Expand Down
Loading