Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
feat: TTL-815-test-calendar-view-feature-toggle
  • Loading branch information
Nicole Garcia committed Jan 18, 2023
commit 7e52f21d39ad70d8258c77e5387be12a8138641e
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<button type="button" (click)="newEntry()" data-toggle="modal" data-target="#editRecordsByDate" class="btn btn-primary">
Add new entry
</button>
<button type="button" (click)="onDisplayModeChange()" class="btn btn-primary float-right" *ngIf="isFeatureToggleCalendarActive">
<button type="button" (click)="onDisplayModeChange()" class="btn btn-primary float-right">
<em class="fas fa-list" *ngIf="displayGridView"></em>
<em class="fas fa-th" *ngIf="!displayGridView"></em>
</button>
Expand Down
70 changes: 0 additions & 70 deletions src/app/modules/time-entries/pages/time-entries.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,31 +510,6 @@ describe('TimeEntriesComponent', () => {
expect(cookieService.get).toHaveBeenCalledWith(sentParameter);
});

it('set false in isFeatureToggleCalendarActive when cookie does not exist', () => {
spyOn(cookieService, 'get');

component.ngOnInit();

expect(component.isFeatureToggleCalendarActive).toBeFalse();
});

it('set true in isFeatureToggleCalendarActive when cookiesService.get() return true', () => {
const cookieResponseValue = 'true';
spyOn(cookieService, 'get').and.returnValue(cookieResponseValue);

component.ngOnInit();

expect(component.isFeatureToggleCalendarActive).toBeTrue();
});

it('set false in isFeatureToggleCalendarActive when cookiesService.get() return false', () => {
const cookieResponseValue = 'false';
spyOn(cookieService, 'get').and.returnValue(cookieResponseValue);

component.ngOnInit();

expect(component.isFeatureToggleCalendarActive).toBeFalse();
});

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

it('not view button onDisplayModeChange when isFeatureToggleCalendarActive is false', () => {
component.isFeatureToggleCalendarActive = false;

fixture.detectChanges();

const HTMLTimeEntriesDebugElement: DebugElement = fixture.debugElement;
const HTMLTimeEntriesElement: HTMLElement = HTMLTimeEntriesDebugElement.nativeElement;
const HTMLTimeEntriesButton = HTMLTimeEntriesElement.querySelector('.btn.btn-primary.float-right');
expect(HTMLTimeEntriesButton).toBeNull();
});

it('view list button when displayGridView is true and isFeatureToggleCalendarActive is true', () => {
const expectedIconInsideButton = '.fa-list';
const unexpectedIconInsideButton = '.fa-th';
component.isFeatureToggleCalendarActive = true;
component.displayGridView = true;

fixture.detectChanges();

const HTMLTimeEntriesDebugElement: DebugElement = fixture.debugElement;
const HTMLTimeEntriesElement: HTMLElement = HTMLTimeEntriesDebugElement.nativeElement;
const HTMLTimeEntriesButton = HTMLTimeEntriesElement.querySelector('.btn.btn-primary.float-right');
const HTMLExpectedChildButton = HTMLTimeEntriesButton.querySelector(expectedIconInsideButton);
const HTMLUnexpectedChildButton = HTMLTimeEntriesButton.querySelector(unexpectedIconInsideButton);
expect(HTMLExpectedChildButton).not.toBeNull();
expect(HTMLUnexpectedChildButton).toBeNull();
});

it('view calendar button when displayGridView is false and isFeatureToggleCalendarActive is true', () => {
const expectedIconInsideButton = '.fa-th';
const unexpectedIconInsideButton = '.fa-list';
component.isFeatureToggleCalendarActive = true;
component.displayGridView = false;

fixture.detectChanges();

const HTMLTimeEntriesDebugElement: DebugElement = fixture.debugElement;
const HTMLTimeEntriesElement: HTMLElement = HTMLTimeEntriesDebugElement.nativeElement;
const HTMLTimeEntriesButton = HTMLTimeEntriesElement.querySelector('.btn.btn-primary.float-right');
const HTMLExpectedChildButton = HTMLTimeEntriesButton.querySelector(expectedIconInsideButton);
const HTMLUnexpectedChildButton = HTMLTimeEntriesButton.querySelector(unexpectedIconInsideButton);
expect(HTMLExpectedChildButton).not.toBeNull();
expect(HTMLUnexpectedChildButton).toBeNull();
});

it('view calendarView when displayGridView is true', () => {
const expectedView = '#gridView';
component.displayGridView = true;
Expand Down
3 changes: 0 additions & 3 deletions src/app/modules/time-entries/pages/time-entries.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { EntryState } from '../../time-clock/store/entry.reducer';
import { EntryActionTypes } from './../../time-clock/store/entry.actions';
import { getActiveTimeEntry, getTimeEntriesDataSource } from './../../time-clock/store/entry.selectors';
import { CookieService } from 'ngx-cookie-service';
import { FeatureToggle } from './../../../../environments/enum';
import { CalendarView } from 'angular-calendar';
import { ParseDateTimeOffset } from '../../shared/formatters/parse-date-time-offset/parse-date-time-offset';

Expand Down Expand Up @@ -43,7 +42,6 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
wasEditingExistingTimeEntry = false;
canMarkEntryAsWIP = true;
timeEntriesDataSource$: Observable<DataSource<Entry>>;
isFeatureToggleCalendarActive: boolean;
displayGridView: boolean;
selectedDate: moment.Moment;
selectedYearAsText: string;
Expand All @@ -68,7 +66,6 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {

ngOnInit(): void {
this.loadActiveEntry();
this.isFeatureToggleCalendarActive = (this.cookiesService.get(FeatureToggle.TIME_TRACKER_CALENDAR) === 'true');
this.entriesSubscription = this.actionsSubject$.pipe(
filter((action: any) => (
action.type === EntryActionTypes.CREATE_ENTRY_SUCCESS ||
Expand Down