Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: #29 Fix comments
  • Loading branch information
jorgecod committed Apr 16, 2020
commit 1fcb3cfcc9eba3598da19c06083dfaba48849d2e
4 changes: 2 additions & 2 deletions scripts/populate-keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
echo 'export const AUTHORITY = "'$AUTHORITY'";' >> src/environments/keys.ts
echo 'export const CLIENT_ID = "'$CLIENT_ID'";' >> src/environments/keys.ts
echo 'export const SCOPES = ["'$SCOPES'"];' >> src/environments/keys.ts
echo 'export const STACK_EXCHANGE_ID = ["'$STACK_EXCHANGE_ID'"];' >> src/environments/keys.ts
echo 'export const STACK_EXCHANGE_ACCESS_TOKEN = ["'$STACK_EXCHANGE_ACCESS_TOKEN'"];' >> src/environments/keys.ts
echo 'export const STACK_EXCHANGE_ID = "'$STACK_EXCHANGE_ID'";' >> src/environments/keys.ts
echo 'export const STACK_EXCHANGE_ACCESS_TOKEN = "'$STACK_EXCHANGE_ACCESS_TOKEN'";' >> src/environments/keys.ts
cat src/environments/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@

<app-search-project (changeFilterProject)="filterTechnology = $event"></app-search-project>
<div *ngIf="isLoading">LOADING...</div>
<div *ngIf="technologies" class="d-flex flex-column technology-content">
<div *ngIf="technology" class="d-flex flex-column technology-content">
<div
*ngFor="let technology of technologies.items | filterProject: filterTechnology"
(click)="setTechnology(technology.name)"
*ngFor="let item of technology.items | filterProject: filterTechnology"
(click)="setTechnology(item.name)"
class="technology-list"
[ngClass]="{ active: selectedTechnology.includes(technology.name) }"
[ngClass]="{ active: selectedTechnology.includes(item.name) }"
>
{{ technology.name }}
{{ item.name }}
</div>
</div>
<div class="tags-content d-flex flex-wrap">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('DetailsFieldsComponent', () => {
let fixture: ComponentFixture<DetailsFieldsComponent>;
let store: MockStore<TechnologyState>;
let mockTechnologySelector;
let length;

const state = {
technologyList: { items: [{ name: 'java' }] },
Expand Down Expand Up @@ -53,12 +54,6 @@ describe('DetailsFieldsComponent', () => {
expect(component).toBeTruthy();
});

it('should emit saveEntry event', () => {
spyOn(component.saveEntry, 'emit');
component.onSubmit();
expect(component.saveEntry.emit).toHaveBeenCalledWith(initialData);
});

it('should emit ngOnChange without data', () => {
component.entryToEdit = null;
component.ngOnChanges();
Expand All @@ -71,12 +66,22 @@ describe('DetailsFieldsComponent', () => {
expect(component.entryForm.value).toEqual(newData);
});

it('should dispatch LoadTechnology action #getTechnologies', () => {
it('should dispatch FindTechnology action #getTechnologies', () => {
const value = 'java';
spyOn(store, 'dispatch');
length = value.length;
component.getTechnologies(value);

expect(store.dispatch).toHaveBeenCalledWith(new actions.LoadTechnology(value));
expect(store.dispatch).toHaveBeenCalledWith(new actions.FindTechnology(value));
});

it('should NOT dispatch FindTechnology action #getTechnologies', () => {
const value = 'j';
spyOn(store, 'dispatch');
length = value.length;
component.getTechnologies(value);

expect(store.dispatch).not.toHaveBeenCalledWith(new actions.FindTechnology(value));
});

it('should add a new tag #setTechnology', () => {
Expand All @@ -102,4 +107,10 @@ describe('DetailsFieldsComponent', () => {
component.removeTag(index);
expect(component.selectedTechnology.length).toBe(1);
});

it('should emit saveEntry event', () => {
spyOn(component.saveEntry, 'emit');
component.onSubmit();
expect(component.saveEntry.emit).toHaveBeenCalledWith(initialData);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
@Output() saveEntry = new EventEmitter();
@ViewChild('closeModal') closeModal: ElementRef;
entryForm: FormGroup;
technologies: Technology;
technology: Technology;
filterTechnology = '';
selectedTechnology: string[] = [];
isLoading = false;
Expand All @@ -35,13 +35,13 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
const technologies$ = this.store.pipe(select(allTechnologies));
technologies$.subscribe((response) => {
this.isLoading = response.isLoading;
this.technologies = response.technologyList;
this.technology = response.technologyList;
});
}

ngOnChanges(): void {
if (this.entryToEdit) {
this.selectedTechnology = this.entryToEdit.technology;
this.selectedTechnology = this.entryToEdit.technologies;

this.entryForm.setValue({
project: this.entryToEdit.project,
Expand All @@ -54,7 +54,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {

getTechnologies(value) {
if (value.length >= 2) {
this.store.dispatch(new actions.LoadTechnology(value));
this.store.dispatch(new actions.FindTechnology(value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('ModalComponent', () => {
startDate: '2020-02-05T15:36:15.887Z',
endDate: '2020-02-05T18:36:15.887Z',
activity: 'development',
technology: ['Angular', 'TypeScript'],
technologies: ['Angular', 'TypeScript'],
};

spyOn(component.removeList, 'emit');
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/shared/models/entry.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export interface Entry {
startDate: string;
endDate: string;
activity: string;
technology: string[];
technologies: string[];
comments?: string;
ticket?: string;
}
12 changes: 6 additions & 6 deletions src/app/modules/shared/store/technology.actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import * as actions from './technology.actions';
import { Technology } from '../models';

describe('Actions for Technology', () => {
it('LoadTechnologySuccess type is TechnologyActionTypes.LOAD_TECHNOLOGY_SUCCESS', () => {
it('FindTechnologySuccess type is TechnologyActionTypes.FIND_TECHNOLOGIES_SUCESS', () => {
const technologyList: Technology = { items: [{ name: 'java' }, { name: 'javascript' }] };
const loadTechnologySuccess = new actions.LoadTechnologySuccess(technologyList);
expect(loadTechnologySuccess.type).toEqual(actions.TechnologyActionTypes.LOAD_TECHNOLOGY_SUCCESS);
const findTechnologySuccess = new actions.FindTechnologySuccess(technologyList);
expect(findTechnologySuccess.type).toEqual(actions.TechnologyActionTypes.FIND_TECHNOLOGIES_SUCESS);
});

it('LoadTechnologyFail type is TechnologyActionTypes.LOAD_TECHNOLOGY_FAIL', () => {
const loadTechnologyFail = new actions.LoadTechnologyFail('error');
expect(loadTechnologyFail.type).toEqual(actions.TechnologyActionTypes.LOAD_TECHNOLOGY_FAIL);
it('FindTechnologyFail type is TechnologyActionTypes.FIND_TECHNOLOGIES_FAIL', () => {
const findTechnologyFail = new actions.FindTechnologyFail('error');
expect(findTechnologyFail.type).toEqual(actions.TechnologyActionTypes.FIND_TECHNOLOGIES_FAIL);
});
});
20 changes: 10 additions & 10 deletions src/app/modules/shared/store/technology.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ import { Action } from '@ngrx/store';
import { Technology } from '../models/technology.model';

export enum TechnologyActionTypes {
LOAD_TECHNOLOGY = '[Technology] LOAD_TECHNOLOGY',
LOAD_TECHNOLOGY_SUCCESS = '[Technology] LOAD_TECHNOLOGY_SUCCESS',
LOAD_TECHNOLOGY_FAIL = '[Technology] LOAD_TECHNOLOGY_FAIL',
FIND_TECHNOLOGIES = '[Technology] FIND_TECHNOLOGIES',
FIND_TECHNOLOGIES_SUCESS = '[Technology] FIND_TECHNOLOGIES_SUCESS',
FIND_TECHNOLOGIES_FAIL = '[Technology] FIND_TECHNOLOGIES_FAIL ',
}

export class LoadTechnology implements Action {
public readonly type = TechnologyActionTypes.LOAD_TECHNOLOGY;
export class FindTechnology implements Action {
public readonly type = TechnologyActionTypes.FIND_TECHNOLOGIES;

constructor(readonly payload: string) {}
}

export class LoadTechnologySuccess implements Action {
readonly type = TechnologyActionTypes.LOAD_TECHNOLOGY_SUCCESS;
export class FindTechnologySuccess implements Action {
readonly type = TechnologyActionTypes.FIND_TECHNOLOGIES_SUCESS;

constructor(readonly payload: Technology) {}
}

export class LoadTechnologyFail implements Action {
public readonly type = TechnologyActionTypes.LOAD_TECHNOLOGY_FAIL;
export class FindTechnologyFail implements Action {
public readonly type = TechnologyActionTypes.FIND_TECHNOLOGIES_FAIL;

constructor(public error: string) {}
}

export type TechnologyActions = LoadTechnology | LoadTechnologySuccess | LoadTechnologyFail;
export type TechnologyActions = FindTechnology | FindTechnologySuccess | FindTechnologyFail;
10 changes: 5 additions & 5 deletions src/app/modules/shared/store/technology.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ export class TechnologyEffects {
constructor(private actions$: Actions, private technologyService: TechnologyService) {}

@Effect()
loadTechnology$: Observable<Action> = this.actions$.pipe(
ofType(actions.TechnologyActionTypes.LOAD_TECHNOLOGY),
map((action: actions.LoadTechnology) => action.payload),
findTechnology$: Observable<Action> = this.actions$.pipe(
ofType(actions.TechnologyActionTypes.FIND_TECHNOLOGIES),
map((action: actions.FindTechnology) => action.payload),
mergeMap((value) =>
this.technologyService.getTechnologies(value).pipe(
map((technology) => {
return new actions.LoadTechnologySuccess(technology);
return new actions.FindTechnologySuccess(technology);
}),
catchError((error) => of(new actions.LoadTechnologyFail(error)))
catchError((error) => of(new actions.FindTechnologyFail(error)))
)
)
);
Expand Down
12 changes: 6 additions & 6 deletions src/app/modules/shared/store/technology.reducers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import { Technology } from '../models/technology.model';
describe('technologyReducer', () => {
const initialState: TechnologyState = { technologyList: null, isLoading: false };

it('on LoadTechnology, isLoading is true', () => {
const action = new actions.LoadTechnology('java');
it('on FindTechnology, isLoading is true', () => {
const action = new actions.FindTechnology('java');
const state = technologyReducer(initialState, action);
expect(state.isLoading).toEqual(true);
});

it('on LoadTechnologySuccess, technologiesFound are saved in the store', () => {
it('on FindTechnologySuccess, technologiesFound are saved in the store', () => {
const technologiesFound: Technology = { items: [{ name: 'java' }] };
const action = new actions.LoadTechnologySuccess(technologiesFound);
const action = new actions.FindTechnologySuccess(technologiesFound);
const state = technologyReducer(initialState, action);
expect(state.technologyList).toEqual(technologiesFound);
});

it('on LoadTechnologyFail, technologyList equal []', () => {
const action = new actions.LoadTechnologyFail('error');
it('on FindTechnologyFail, technologyList equal []', () => {
const action = new actions.FindTechnologyFail('error');
const state = technologyReducer(initialState, action);
expect(state.technologyList).toEqual([]);
});
Expand Down
6 changes: 3 additions & 3 deletions src/app/modules/shared/store/technology.reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ export const initialState = {

export const technologyReducer = (state: TechnologyState = initialState, action: TechnologyActions) => {
switch (action.type) {
case TechnologyActionTypes.LOAD_TECHNOLOGY: {
case TechnologyActionTypes.FIND_TECHNOLOGIES: {
return {
...state,
isLoading: true,
};
}

case TechnologyActionTypes.LOAD_TECHNOLOGY_SUCCESS:
case TechnologyActionTypes.FIND_TECHNOLOGIES_SUCESS:
return {
...state,
technologyList: action.payload,
isLoading: false,
};

case TechnologyActionTypes.LOAD_TECHNOLOGY_FAIL: {
case TechnologyActionTypes.FIND_TECHNOLOGIES_FAIL: {
return {
technologyList: [],
isLoading: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('TimeEntriesComponent', () => {
startDate: '2020-02-05T15:36:15.887Z',
endDate: '2020-02-05T18:36:15.887Z',
activity: 'development',
technology: ['Angular', 'TypeScript'],
technologies: ['Angular', 'TypeScript'],
comments: 'No comments',
ticket: 'EY-25',
};
Expand Down Expand Up @@ -91,7 +91,7 @@ describe('TimeEntriesComponent', () => {
expect(component.entry.startDate).toBe(entry.startDate);
expect(component.entry.endDate).toBe(entry.endDate);
expect(component.entry.activity).toBe(entry.activity);
expect(component.entry.technology).toEqual(entry.technology);
expect(component.entry.technologies).toEqual(entry.technologies);
});

it('should save an Entry', () => {
Expand All @@ -101,7 +101,6 @@ describe('TimeEntriesComponent', () => {
expect(component.entryList[0].startDate).toBe('2020-02-05T15:36:15.887Z');
expect(component.entryList[0].endDate).toBe('2020-02-05T18:36:15.887Z');
expect(component.entryList[0].activity).toBe('development');
expect(component.entryList[0].technology).toEqual(['Angular', 'TypeScript']);
});

it('should delete a Entry', () => {
Expand Down
11 changes: 5 additions & 6 deletions src/app/modules/time-entries/pages/time-entries.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class TimeEntriesComponent implements OnInit {
startDate: '2020-02-05T15:36:15.887Z',
endDate: '2020-02-05T18:36:15.887Z',
activity: 'development',
technology: ['Angular', 'TypeScript'],
technologies: ['Angular', 'TypeScript'],
comments: 'No comments',
ticket: 'EY-25',
},
Expand All @@ -30,7 +30,7 @@ export class TimeEntriesComponent implements OnInit {
startDate: '2020-03-15T20:36:15.887Z',
endDate: '2020-03-15T23:36:15.887Z',
activity: 'development',
technology: ['Angular', 'TypeScript'],
technologies: ['Angular', 'TypeScript'],
comments: 'No comments',
ticket: 'EY-38',
},
Expand All @@ -40,7 +40,7 @@ export class TimeEntriesComponent implements OnInit {
startDate: '2020-03-15T23:36:15.887Z',
endDate: '2020-03-16T05:36:15.887Z',
activity: 'development',
technology: ['Angular', 'TypeScript'],
technologies: ['Angular', 'TypeScript'],
comments: 'No comments',
ticket: 'EY-225',
},
Expand All @@ -50,7 +50,7 @@ export class TimeEntriesComponent implements OnInit {
startDate: '2020-03-16T15:36:15.887Z',
endDate: '2020-03-16T18:36:15.887Z',
activity: 'development',
technology: ['javascript', 'java-stream'],
technologies: ['javascript', 'java-stream'],
comments: 'No comments',
ticket: 'EY-89',
},
Expand All @@ -60,7 +60,7 @@ export class TimeEntriesComponent implements OnInit {
startDate: '2020-04-01T09:36:15.887Z',
endDate: '2020-04-01T15:36:15.887Z',
activity: 'development',
technology: ['javascript', 'java', 'java-stream'],
technologies: ['javascript', 'java', 'java-stream'],
comments: 'No comments',
ticket: 'EY-59',
},
Expand All @@ -86,7 +86,6 @@ export class TimeEntriesComponent implements OnInit {
const entryIndex = this.entryList.findIndex((entry) => entry.id === this.entryId);
this.entryList[entryIndex].project = newData.project;
this.entryList[entryIndex].activity = newData.activity;
this.entryList[entryIndex].technology = newData.technology;
this.entryList[entryIndex].ticket = newData.jiraTicket;
this.entryList[entryIndex].comments = newData.notes;
}
Expand Down