mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-08 14:51:32 +00:00
[AAE-1695] reduce manual tests (#5455)
* tests cleanup * cleanup search control tests * EmptyContentComponent tests * fix names * search filter category test * task list test and code polish * process list tests and cleanup * extra task-list tests * extra start-task tests * code cleanup
This commit is contained in:
@@ -81,17 +81,19 @@
|
||||
<div class="adf-new-task-footer" fxLayout="row" fxLayoutAlign="end end">
|
||||
<button
|
||||
mat-button
|
||||
class="adf-uppercase"
|
||||
(click)="onCancel()"
|
||||
id="button-cancel">
|
||||
{{'ADF_TASK_LIST.START_TASK.FORM.ACTION.CANCEL'|translate}}
|
||||
{{ 'ADF_TASK_LIST.START_TASK.FORM.ACTION.CANCEL' | translate }}
|
||||
</button>
|
||||
<button
|
||||
color="primary"
|
||||
mat-button
|
||||
class="adf-uppercase"
|
||||
[disabled]="!isFormValid()"
|
||||
(click)="saveTask()"
|
||||
id="button-start">
|
||||
{{'ADF_TASK_LIST.START_TASK.FORM.ACTION.START'|translate}}
|
||||
{{ 'ADF_TASK_LIST.START_TASK.FORM.ACTION.START' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
</mat-card-actions>
|
||||
|
@@ -34,6 +34,10 @@
|
||||
|
||||
adf-start-task {
|
||||
|
||||
.mat-button.adf-uppercase {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
people-widget {
|
||||
width: 100%;
|
||||
.mat-form-field-label-wrapper {
|
||||
@@ -54,13 +58,6 @@
|
||||
}
|
||||
|
||||
.adf {
|
||||
|
||||
&-new-task-footer {
|
||||
.mat-button {
|
||||
text-transform: uppercase !important;
|
||||
}
|
||||
}
|
||||
|
||||
&-start-task-input-container .mat-form-field-wrapper {
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ describe('StartTaskComponent', () => {
|
||||
let getFormListSpy: jasmine.Spy;
|
||||
let createNewTaskSpy: jasmine.Spy;
|
||||
let logSpy: jasmine.Spy;
|
||||
|
||||
const fakeForms$ = [
|
||||
{
|
||||
id: 123,
|
||||
@@ -58,6 +59,7 @@ describe('StartTaskComponent', () => {
|
||||
|
||||
service = TestBed.get(TaskListService);
|
||||
logService = TestBed.get(LogService);
|
||||
|
||||
getFormListSpy = spyOn(service, 'getFormList').and.returnValue(new Observable((observer) => {
|
||||
observer.next(fakeForms$);
|
||||
observer.complete();
|
||||
@@ -71,10 +73,6 @@ describe('StartTaskComponent', () => {
|
||||
TestBed.resetTestingModule();
|
||||
});
|
||||
|
||||
it('should create instance of StartTaskComponent', () => {
|
||||
expect(component instanceof StartTaskComponent).toBe(true, 'should create StartTaskComponent');
|
||||
});
|
||||
|
||||
it('should fetch fake form on init', () => {
|
||||
component.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
@@ -309,6 +307,21 @@ describe('StartTaskComponent', () => {
|
||||
expect(element.querySelector('#button-start').textContent).toContain('ADF_TASK_LIST.START_TASK.FORM.ACTION.START');
|
||||
});
|
||||
|
||||
it('should render start task button with primary color', () => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#button-start').classList.contains('mat-primary')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should render task buttons with uppercase text', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const startButton = element.querySelector<HTMLButtonElement>('#button-start');
|
||||
expect(startButton.classList.contains('adf-uppercase')).toBeTruthy();
|
||||
|
||||
const cancelButton = element.querySelector<HTMLButtonElement>('#button-cancel');
|
||||
expect(cancelButton.classList.contains('adf-uppercase')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should not emit TaskDetails OnCancel', () => {
|
||||
const emitSpy = spyOn(component.cancel, 'emit');
|
||||
component.onCancel();
|
||||
|
@@ -18,8 +18,8 @@
|
||||
<mat-progress-spinner
|
||||
*ngIf="!customLoadingContent"
|
||||
class="adf-task-list-loading-margin"
|
||||
[color]="'primary'"
|
||||
[mode]="'indeterminate'">
|
||||
color="primary"
|
||||
mode="indeterminate">
|
||||
</mat-progress-spinner>
|
||||
<ng-content select="adf-custom-loading-content-template"></ng-content>
|
||||
</ng-template>
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Component, SimpleChange, ViewChild } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { AppConfigService, setupTestBed, CoreModule, DataTableModule, DataRowEvent, ObjectDataRow } from '@alfresco/adf-core';
|
||||
import { TaskListService } from '../services/tasklist.service';
|
||||
@@ -79,6 +79,29 @@ describe('TaskListComponent', () => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should display loading spinner', () => {
|
||||
component.isLoading = true;
|
||||
|
||||
const spinner = fixture.debugElement.query(By.css('.mat-progress-spinner'));
|
||||
expect(spinner).toBeDefined();
|
||||
});
|
||||
|
||||
it('should hide loading spinner upon loading complete', async(() => {
|
||||
component.isLoading = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
let spinner = fixture.debugElement.query(By.css('.mat-progress-spinner'));
|
||||
expect(spinner).toBeDefined();
|
||||
|
||||
component.isLoading = false;
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
spinner = fixture.debugElement.query(By.css('.mat-progress-spinner'));
|
||||
expect(spinner).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should use the default schemaColumn as default', () => {
|
||||
component.ngAfterContentInit();
|
||||
expect(component.columns).toBeDefined();
|
||||
|
@@ -29,7 +29,7 @@ import { TaskListModel } from '../models/task-list.model';
|
||||
import { taskPresetsDefaultModel } from '../models/task-preset.model';
|
||||
import { TaskListService } from './../services/tasklist.service';
|
||||
import moment from 'moment-es6';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { takeUntil, finalize } from 'rxjs/operators';
|
||||
import { TaskDetailsModel } from '../models/task-details.model';
|
||||
|
||||
@Component({
|
||||
@@ -125,19 +125,19 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
|
||||
|
||||
/** Emitted when a task in the list is clicked */
|
||||
@Output()
|
||||
rowClick: EventEmitter<string> = new EventEmitter<string>();
|
||||
rowClick = new EventEmitter<string>();
|
||||
|
||||
/** Emitted when rows are selected/unselected */
|
||||
@Output()
|
||||
rowsSelected: EventEmitter<any[]> = new EventEmitter<any[]>();
|
||||
rowsSelected = new EventEmitter<any[]>();
|
||||
|
||||
/** Emitted when the task list is loaded */
|
||||
@Output()
|
||||
success: EventEmitter<any> = new EventEmitter<any>();
|
||||
success = new EventEmitter<any>();
|
||||
|
||||
/** Emitted when an error occurs. */
|
||||
@Output()
|
||||
error: EventEmitter<any> = new EventEmitter<any>();
|
||||
error = new EventEmitter<any>();
|
||||
|
||||
currentInstanceId: string;
|
||||
selectedInstances: any[];
|
||||
@@ -258,22 +258,24 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
|
||||
|
||||
private load() {
|
||||
this.isLoading = true;
|
||||
this.loadTasksByState().subscribe(
|
||||
(tasks) => {
|
||||
this.rows = this.optimizeTaskDetails(tasks.data);
|
||||
this.selectTask(this.landingTaskId);
|
||||
this.success.emit(tasks);
|
||||
this.isLoading = false;
|
||||
this.pagination.next({
|
||||
count: tasks.data.length,
|
||||
maxItems: this.size,
|
||||
skipCount: this.page * this.size,
|
||||
totalItems: tasks.total
|
||||
|
||||
this.loadTasksByState()
|
||||
.pipe(finalize(() => this.isLoading = false))
|
||||
.subscribe(
|
||||
tasks => {
|
||||
this.rows = this.optimizeTaskDetails(tasks.data);
|
||||
this.selectTask(this.landingTaskId);
|
||||
this.success.emit(tasks);
|
||||
this.pagination.next({
|
||||
count: tasks.data.length,
|
||||
maxItems: this.size,
|
||||
skipCount: this.page * this.size,
|
||||
totalItems: tasks.total
|
||||
});
|
||||
},
|
||||
error => {
|
||||
this.error.emit(error);
|
||||
});
|
||||
}, (error) => {
|
||||
this.error.emit(error);
|
||||
this.isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
private loadTasksByState(): Observable<TaskListModel> {
|
||||
@@ -288,14 +290,17 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
|
||||
selectTask(taskIdSelected: string): void {
|
||||
if (!this.isListEmpty()) {
|
||||
let dataRow = null;
|
||||
|
||||
if (taskIdSelected) {
|
||||
dataRow = this.rows.find((currentRow: any) => {
|
||||
return currentRow['id'] === taskIdSelected;
|
||||
});
|
||||
}
|
||||
|
||||
if (!dataRow && this.selectFirstRow) {
|
||||
dataRow = this.rows[0];
|
||||
}
|
||||
|
||||
if (dataRow) {
|
||||
dataRow.isSelected = true;
|
||||
this.currentInstanceId = dataRow['id'];
|
||||
@@ -345,6 +350,7 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
|
||||
onRowKeyUp(event: CustomEvent) {
|
||||
if (event.detail.keyboardEvent.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
|
||||
this.currentInstanceId = event.detail.row.getValue('id');
|
||||
this.rowClick.emit(this.currentInstanceId);
|
||||
}
|
||||
@@ -365,7 +371,6 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
|
||||
}
|
||||
|
||||
private createRequestNode() {
|
||||
|
||||
const requestNode = {
|
||||
appDefinitionId: this.appId,
|
||||
dueAfter: this.dueAfter ? moment(this.dueAfter).toDate() : null,
|
||||
@@ -387,8 +392,10 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
|
||||
|
||||
updatePagination(params: PaginationModel) {
|
||||
const needsReload = params.maxItems || params.skipCount;
|
||||
|
||||
this.size = params.maxItems;
|
||||
this.page = this.currentPage(params.skipCount, params.maxItems);
|
||||
|
||||
if (needsReload) {
|
||||
this.reload();
|
||||
}
|
||||
|
Reference in New Issue
Block a user