Commit 2fb3ade1 authored by Tifenn Guillas's avatar Tifenn Guillas
Browse files

Merge branch 'tests-integration' into 'develop'

Tests integration

See merge request !63
parents 50e41af5 c520ba4b
Pipeline #1598 failed with stages
in 28 minutes and 16 seconds
......@@ -51,7 +51,14 @@ sonar_scanner:
image: portus.lam.fr/ci-tools/sonar-scanner:latest
stage: sonar
script:
- sonar-scanner -Dsonar.projectKey=anis-client -Dsonar.sources=src -Dsonar.projectVersion=$VERSION -Dsonar.host.url=$SONARQUBE_URL -Dsonar.login=$SONAR_TOKEN -Dsonar.typescript.lcov.reportPaths=./coverage/lcov.info
- sonar-scanner \
-Dsonar.projectKey=anis-client \
-Dsonar.sources=src \
-Dsonar.projectVersion=$VERSION
-Dsonar.host.url=$SONARQUBE_URL
-Dsonar.login=$SONAR_TOKEN
-Dsonar.exclusions=**.spec.ts
-Dsonar.typescript.lcov.reportPaths=./coverage/lcov.info
cache:
paths:
- node_modules
......
......@@ -45,7 +45,7 @@
</li>
<li class="divider dropdown-divider"></li>
<li role="menuitem">
<a class="dropdown-item text-danger pointer" (click)="logout.emit()">
<a class="dropdown-item text-danger pointer" (click)="emitLogout()">
<span class="fas fa-sign-out-alt fa-fw"></span> Sign Out
</a>
</li>
......
......@@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NavComponent } from './nav.component';
describe('Component: NavComponent', () => {
describe('[Core] Component: NavComponent', () => {
let component: NavComponent;
let fixture: ComponentFixture<NavComponent>;
......@@ -45,4 +45,9 @@ describe('Component: NavComponent', () => {
const template = fixture.nativeElement;
expect(template.querySelector('#button-sign-in')).toBeFalsy();
});
it('raises the logout event when clicked', () => {
component.logout.subscribe((event) => expect(event).toBe(undefined));
component.emitLogout();
});
});
......@@ -11,6 +11,10 @@ import { LoginToken } from '../../login/store/model';
export class NavComponent {
@Input() isAuthenticated: boolean;
@Input() loginToken: LoginToken;
@Output() logout: EventEmitter<{}> = new EventEmitter();
@Output() logout: EventEmitter<any> = new EventEmitter();
isCollapsed = true;
emitLogout() {
this.logout.emit();
}
}
......@@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NotFoundPageComponent } from './not-found-page.component';
describe('Component: NotFoundPageComponent', () => {
describe('[Core] Component: NotFoundPageComponent', () => {
let component: NotFoundPageComponent;
let fixture: ComponentFixture<NotFoundPageComponent>;
......
......@@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ObjectDisplayComponent } from './object-display.component';
describe('Component: ObjectDisplayComponent', () => {
describe('[Detail] Component: ObjectDisplayComponent', () => {
it('#getAttributesVisible() should filter and sort #attributeList', () => {
const component = new ObjectDisplayComponent();
component.attributeList = [
......
......@@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AccountBenefitsComponent } from './account-benefits.component';
describe('Component: AccountBenefitsComponent', () => {
describe('[Login] Component: AccountBenefitsComponent', () => {
let component: AccountBenefitsComponent;
let fixture: ComponentFixture<AccountBenefitsComponent>;
......
<form name="form" (ngSubmit)="f.form.valid && submitted.emit(f.form.value)" #f="ngForm" novalidate>
<form name="form" (ngSubmit)="f.form.valid && emitSubmit(f.form.value)" #f="ngForm" novalidate>
<div class="form-group">
<label for="email">Email address</label>
<input type="email" id="email" class="form-control" name="email" [(ngModel)]="email" placeholder="Enter email"
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormForgotPasswordComponent } from './form-forgot-password.component';
import { FormsModule } from '@angular/forms';
describe('[Login] Component: FormForgotPasswordComponent', () => {
let component: FormForgotPasswordComponent;
let fixture: ComponentFixture<FormForgotPasswordComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [FormForgotPasswordComponent],
imports: [FormsModule]
});
fixture = TestBed.createComponent(FormForgotPasswordComponent);
component = fixture.componentInstance;
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
it('raises the submit form event when clicked', () => {
const email = 'test@email.com';
component.submitted.subscribe((event: string) => expect(event).toEqual(email));
component.emitSubmit(email);
});
});
......@@ -7,4 +7,8 @@ import { Component, Output, EventEmitter } from '@angular/core';
export class FormForgotPasswordComponent {
email = '';
@Output() submitted: EventEmitter<string> = new EventEmitter();
emitSubmit(email: string) {
this.submitted.emit(email);
}
}
<form name="form" (ngSubmit)="f.form.valid && submitted.emit(f.form.value)" #f="ngForm" novalidate>
<form name="form" (ngSubmit)="f.form.valid && emitSubmit(f.form.value)" #f="ngForm" novalidate>
<div class="form-group">
<label for="email">Email address</label>
<input type="email" id="email" class="form-control" name="email" [(ngModel)]="model.email"
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { FormLoginComponent } from './form-login.component';
import { Login } from '../store/model';
describe('[Login] Component: FormLoginComponent', () => {
let component: FormLoginComponent;
let fixture: ComponentFixture<FormLoginComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [FormLoginComponent],
imports: [FormsModule]
});
fixture = TestBed.createComponent(FormLoginComponent);
component = fixture.componentInstance;
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
it('raises the submit form event when clicked', () => {
const login: Login = { email: 'test@email.com', password: 'password'};
component.submitted.subscribe((event: Login) => expect(event).toEqual(login));
component.emitSubmit(login);
});
});
import { Component, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core';
import { Component, Output, EventEmitter } from '@angular/core';
import { Login } from '../store/model';
......@@ -9,4 +9,8 @@ import { Login } from '../store/model';
export class FormLoginComponent {
model: Login = new Login();
@Output() submitted: EventEmitter<Login> = new EventEmitter();
emitSubmit(login: Login) {
this.submitted.emit(login);
}
}
<form (ngSubmit)="f.form.valid && submitted.emit(f.form.value)" #f="ngForm" novalidate>
<form (ngSubmit)="f.form.valid && emitSubmit(f.form.value)" #f="ngForm" novalidate>
<div class="form-group">
<label for="register_email">Email address</label>
<input type="email" id="register_email" class="form-control" name="email" [(ngModel)]="model.email"
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { FormRegisterComponent } from './form-register.component';
import { Login } from '../store/model';
describe('[Login] Component: FormRegisterComponent', () => {
let component: FormRegisterComponent;
let fixture: ComponentFixture<FormRegisterComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [FormRegisterComponent],
imports: [FormsModule]
});
fixture = TestBed.createComponent(FormRegisterComponent);
component = fixture.componentInstance;
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
it('raises the submit form event when clicked', () => {
const login: Login = { email: 'test@email.com', password: 'password'};
component.submitted.subscribe((event: Login) => expect(event).toEqual(login));
component.emitSubmit(login);
});
});
......@@ -9,4 +9,8 @@ import { Login } from '../store/model';
export class FormRegisterComponent {
model: Login = new Login();
@Output() submitted: EventEmitter<Login> = new EventEmitter();
emitSubmit(login: Login) {
this.submitted.emit(login);
}
}
......@@ -8,12 +8,12 @@ import * as fromLogin from '../store/login.reducer';
@Component({
selector: 'app-change-password',
templateUrl: 'change-password.component.html',
styleUrls: [ 'login.component.css']
styleUrls: ['login.component.css']
})
export class ChangePasswordComponent {
model = {password: '', newPassword: '', confirmPassword: ''};
model = { password: '', newPassword: '', confirmPassword: '' };
constructor(private store: Store<{login: fromLogin.State}>) { }
constructor(private store: Store<{ login: fromLogin.State }>) { }
submitted() {
this.store.dispatch(new loginActions.ChangePasswordAction({
......
......@@ -19,8 +19,8 @@
[placeholderMin]="attribute.placeholder_min"
[placeholderMax]="attribute.placeholder_max"
[criterion]="getCriterion(attribute.id)"
(add)="add($event)"
(delete)="delete($event)">
(addCriterion)="add($event)"
(deldeleteCriterionete)="delete($event)">
</app-between>
</div>
<div *ngSwitchCase="'select'">
......@@ -37,7 +37,6 @@
<div *ngSwitchCase="'select-multiple'">
<app-select-multiple class="criteria"
[id]="attribute.id"
[operator]="attribute.operator"
[label]="attribute.form_label"
[options]="getOptions(attribute.id)"
[criterion]="getCriterion(attribute.id)"
......@@ -67,12 +66,11 @@
<div *ngSwitchCase="'checkbox'">
<app-checkbox class="criteria"
[id]="attribute.id"
[operator]="attribute.operator"
[label]="attribute.form_label"
[options]="getOptions(attribute.id)"
[criterion]="getCriterion(attribute.id)"
(add)="add($event)"
(delete)="delete($event)">
(addCriterion)="add($event)"
(deleteCriterion)="delete($event)">
</app-checkbox>
</div>
<div *ngSwitchCase="'date'">
......@@ -92,8 +90,8 @@
[operator]="attribute.operator"
[label]="attribute.form_label"
[criterion]="getCriterion(attribute.id)"
(add)="add($event)"
(delete)="delete($event)">
(addCriterion)="add($event)"
(deleteCriterion)="delete($event)">
</app-between-date>
</div>
<div *ngSwitchCase="'time'">
......
......@@ -12,10 +12,10 @@
</div>
<div class="col-2 text-center">
<button class="btn btn-outline-success" *ngIf="!field.disabled" [hidden]="!field.value"
(click)="addCriterion()">
(click)="emitAdd()">
<span class="fas fa-plus fa-fw"></span>
</button>
<button class="btn btn-outline-danger" *ngIf="field.disabled" (click)="deleteCriterion()">
<button class="btn btn-outline-danger" *ngIf="field.disabled" (click)="emitDelete()">
<span class="fa fa-times fa-fw"></span>
</button>
</div>
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { BsDatepickerModule } from 'ngx-bootstrap';
import { FormsModule, ReactiveFormsModule, FormControl } from '@angular/forms';
import { BetweenDateComponent } from './between-date.component';
import { BetweenCriterion } from '../../../store/model';
describe('[Search][Criteria][SearchType] Component: BetweenDateComponent', () => {
let component: BetweenDateComponent;
let fixture: ComponentFixture<BetweenDateComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [BetweenDateComponent],
imports: [BsDatepickerModule.forRoot(), FormsModule, ReactiveFormsModule]
});
fixture = TestBed.createComponent(BetweenDateComponent);
component = fixture.componentInstance;
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
it('#getDateString() should format a datetime object into a string', () => {
const dateObject = new Date('February 08, 2019 15:47:00');
const expectedDateString = '2019-02-08';
const formatedDate = component.getDateString(dateObject);
expect(formatedDate).toEqual(expectedDateString);
});
it('#getDefault() should not fill and enable form if criterion not defined', () => {
const expectedFieldValue = '';
component.getDefault(undefined);
expect(component.field.value).toEqual(expectedFieldValue);
expect(component.field.enabled).toBeTruthy();
});
it('#getDefault() should fill and disable form if criterion is defined', () => {
const criterion = new BetweenCriterion(1, '2019-02-08', '2019-02-17');
const expectedFieldValue = [new Date(criterion.min), new Date(criterion.max)];
component.getDefault(criterion);
expect(component.field.value).toEqual(expectedFieldValue);
expect(component.field.disabled).toBeTruthy();
});
it('raises the add criterion event when clicked', () => {
component.id = 1;
const dateMin = '2019-02-08';
const dateMax = '2019-02-17';
component.field = new FormControl([new Date(dateMin), new Date(dateMax)]);
const expectedCriterion = new BetweenCriterion(component.id, dateMin, dateMax);
component.addCriterion.subscribe((event: BetweenCriterion) => expect(event).toEqual(expectedCriterion));
component.emitAdd();
});
it('raises the delete criterion event when clicked', () => {
component.id = 1;
component.deleteCriterion.subscribe((event: number) => expect(event).toEqual(1));
component.emitDelete();
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment