Skip to content

Commit 487febc

Browse files
authored
feat: TTL-815-test-calendar-view-feature-toggle (#972)
Co-authored-by: Nicole Garcia <nicolsss>
1 parent 05d4d26 commit 487febc

File tree

3 files changed

+1
-74
lines changed

3 files changed

+1
-74
lines changed

src/app/modules/time-entries/pages/time-entries.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<button type="button" (click)="newEntry()" data-toggle="modal" data-target="#editRecordsByDate" class="btn btn-primary">
44
Add new entry
55
</button>
6-
<button type="button" (click)="onDisplayModeChange()" class="btn btn-primary float-right" *ngIf="isFeatureToggleCalendarActive">
6+
<button type="button" (click)="onDisplayModeChange()" class="btn btn-primary float-right">
77
<em class="fas fa-list" *ngIf="displayGridView"></em>
88
<em class="fas fa-th" *ngIf="!displayGridView"></em>
99
</button>

src/app/modules/time-entries/pages/time-entries.component.spec.ts

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -510,31 +510,6 @@ describe('TimeEntriesComponent', () => {
510510
expect(cookieService.get).toHaveBeenCalledWith(sentParameter);
511511
});
512512

513-
it('set false in isFeatureToggleCalendarActive when cookie does not exist', () => {
514-
spyOn(cookieService, 'get');
515-
516-
component.ngOnInit();
517-
518-
expect(component.isFeatureToggleCalendarActive).toBeFalse();
519-
});
520-
521-
it('set true in isFeatureToggleCalendarActive when cookiesService.get() return true', () => {
522-
const cookieResponseValue = 'true';
523-
spyOn(cookieService, 'get').and.returnValue(cookieResponseValue);
524-
525-
component.ngOnInit();
526-
527-
expect(component.isFeatureToggleCalendarActive).toBeTrue();
528-
});
529-
530-
it('set false in isFeatureToggleCalendarActive when cookiesService.get() return false', () => {
531-
const cookieResponseValue = 'false';
532-
spyOn(cookieService, 'get').and.returnValue(cookieResponseValue);
533-
534-
component.ngOnInit();
535-
536-
expect(component.isFeatureToggleCalendarActive).toBeFalse();
537-
});
538513

539514
it('set true in displayGridView when its initial value is false and call onDisplayModeChange', () => {
540515
const expectedValue = true;
@@ -644,51 +619,6 @@ describe('TimeEntriesComponent', () => {
644619
expect(component.calendarView).toBe(CalendarView.Month);
645620
});
646621

647-
it('not view button onDisplayModeChange when isFeatureToggleCalendarActive is false', () => {
648-
component.isFeatureToggleCalendarActive = false;
649-
650-
fixture.detectChanges();
651-
652-
const HTMLTimeEntriesDebugElement: DebugElement = fixture.debugElement;
653-
const HTMLTimeEntriesElement: HTMLElement = HTMLTimeEntriesDebugElement.nativeElement;
654-
const HTMLTimeEntriesButton = HTMLTimeEntriesElement.querySelector('.btn.btn-primary.float-right');
655-
expect(HTMLTimeEntriesButton).toBeNull();
656-
});
657-
658-
it('view list button when displayGridView is true and isFeatureToggleCalendarActive is true', () => {
659-
const expectedIconInsideButton = '.fa-list';
660-
const unexpectedIconInsideButton = '.fa-th';
661-
component.isFeatureToggleCalendarActive = true;
662-
component.displayGridView = true;
663-
664-
fixture.detectChanges();
665-
666-
const HTMLTimeEntriesDebugElement: DebugElement = fixture.debugElement;
667-
const HTMLTimeEntriesElement: HTMLElement = HTMLTimeEntriesDebugElement.nativeElement;
668-
const HTMLTimeEntriesButton = HTMLTimeEntriesElement.querySelector('.btn.btn-primary.float-right');
669-
const HTMLExpectedChildButton = HTMLTimeEntriesButton.querySelector(expectedIconInsideButton);
670-
const HTMLUnexpectedChildButton = HTMLTimeEntriesButton.querySelector(unexpectedIconInsideButton);
671-
expect(HTMLExpectedChildButton).not.toBeNull();
672-
expect(HTMLUnexpectedChildButton).toBeNull();
673-
});
674-
675-
it('view calendar button when displayGridView is false and isFeatureToggleCalendarActive is true', () => {
676-
const expectedIconInsideButton = '.fa-th';
677-
const unexpectedIconInsideButton = '.fa-list';
678-
component.isFeatureToggleCalendarActive = true;
679-
component.displayGridView = false;
680-
681-
fixture.detectChanges();
682-
683-
const HTMLTimeEntriesDebugElement: DebugElement = fixture.debugElement;
684-
const HTMLTimeEntriesElement: HTMLElement = HTMLTimeEntriesDebugElement.nativeElement;
685-
const HTMLTimeEntriesButton = HTMLTimeEntriesElement.querySelector('.btn.btn-primary.float-right');
686-
const HTMLExpectedChildButton = HTMLTimeEntriesButton.querySelector(expectedIconInsideButton);
687-
const HTMLUnexpectedChildButton = HTMLTimeEntriesButton.querySelector(unexpectedIconInsideButton);
688-
expect(HTMLExpectedChildButton).not.toBeNull();
689-
expect(HTMLUnexpectedChildButton).toBeNull();
690-
});
691-
692622
it('view calendarView when displayGridView is true', () => {
693623
const expectedView = '#gridView';
694624
component.displayGridView = true;

src/app/modules/time-entries/pages/time-entries.component.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { EntryState } from '../../time-clock/store/entry.reducer';
1414
import { EntryActionTypes } from './../../time-clock/store/entry.actions';
1515
import { getActiveTimeEntry, getTimeEntriesDataSource } from './../../time-clock/store/entry.selectors';
1616
import { CookieService } from 'ngx-cookie-service';
17-
import { FeatureToggle } from './../../../../environments/enum';
1817
import { CalendarView } from 'angular-calendar';
1918
import { ParseDateTimeOffset } from '../../shared/formatters/parse-date-time-offset/parse-date-time-offset';
2019

@@ -43,7 +42,6 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
4342
wasEditingExistingTimeEntry = false;
4443
canMarkEntryAsWIP = true;
4544
timeEntriesDataSource$: Observable<DataSource<Entry>>;
46-
isFeatureToggleCalendarActive: boolean;
4745
displayGridView: boolean;
4846
selectedDate: moment.Moment;
4947
selectedYearAsText: string;
@@ -68,7 +66,6 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
6866

6967
ngOnInit(): void {
7068
this.loadActiveEntry();
71-
this.isFeatureToggleCalendarActive = (this.cookiesService.get(FeatureToggle.TIME_TRACKER_CALENDAR) === 'true');
7269
this.entriesSubscription = this.actionsSubject$.pipe(
7370
filter((action: any) => (
7471
action.type === EntryActionTypes.CREATE_ENTRY_SUCCESS ||

0 commit comments

Comments
 (0)