[NO-ISSUE] RE enable failing test (#3168)

* restore viewer test

* fix content node selector breadcrumb tests

* fix skipped test

* notification service uncomment test

* remove duplicated test
exclude dialog test
This commit is contained in:
Eugenio Romano 2018-04-11 09:03:03 +01:00 committed by GitHub
parent 12df7500da
commit 5f8b41411a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 58 additions and 143 deletions

View File

@ -33,10 +33,10 @@
<adf-toolbar> <adf-toolbar>
<adf-toolbar-title> <adf-toolbar-title>
<ng-container *ngIf="showingSearchResults && !chosenNode"> <ng-container *ngIf="!showBreadcrumbs()">
<span class="search-results-label">{{ 'NODE_SELECTOR.SEARCH_RESULTS' | translate }}</span> <span class="search-results-label">{{ 'NODE_SELECTOR.SEARCH_RESULTS' | translate }}</span>
</ng-container> </ng-container>
<adf-dropdown-breadcrumb *ngIf="needBreadcrumbs()" <adf-dropdown-breadcrumb *ngIf="showBreadcrumbs()"
class="adf-content-node-selector-content-breadcrumb" class="adf-content-node-selector-content-breadcrumb"
(navigate)="clearSearch()" (navigate)="clearSearch()"
[target]="documentList" [target]="documentList"
@ -58,7 +58,6 @@
[showHeader]="false" [showHeader]="false"
[node]="nodes" [node]="nodes"
[maxItems]="pageSize" [maxItems]="pageSize"
[skipCount]="skipCount"
[rowFilter]="rowFilter" [rowFilter]="rowFilter"
[imageResolver]="imageResolver" [imageResolver]="imageResolver"
[currentFolderId]="folderIdToShow" [currentFolderId]="folderIdToShow"
@ -92,10 +91,7 @@
<adf-infinite-pagination <adf-infinite-pagination
[target]="documentList" [target]="documentList"
[pagination]="pagination"
[pageSize]="pageSize"
[loading]="loadingSearchResults" [loading]="loadingSearchResults"
(loadMore)="getNextPageOfSearch($event)"
data-automation-id="content-node-selector-search-pagination"> data-automation-id="content-node-selector-search-pagination">
{{ 'ADF-DOCUMENT-LIST.LAYOUT.LOAD_MORE' | translate }} {{ 'ADF-DOCUMENT-LIST.LAYOUT.LOAD_MORE' | translate }}
</adf-infinite-pagination> </adf-infinite-pagination>

View File

@ -132,23 +132,9 @@ describe('ContentNodeSelectorComponent', () => {
component.chosenNode = expectedNode; component.chosenNode = expectedNode;
}); });
it('should update skipCount on folder loaded', () => {
component.skipCount = 8;
component.onFolderLoaded({
list: {
pagination: {
skipCount: 10
}
}
});
expect(component.skipCount).toBe(10, 'skipCount is updated');
});
}); });
xdescribe('Breadcrumbs', () => { describe('Breadcrumbs', () => {
let documentListService, let documentListService,
sitesService, sitesService,
@ -498,7 +484,7 @@ describe('ContentNodeSelectorComponent', () => {
expect(component.folderIdToShow).toBe('cat-girl-nuku-nuku', 'back to the folder in which the search was performed'); expect(component.folderIdToShow).toBe('cat-girl-nuku-nuku', 'back to the folder in which the search was performed');
})); }));
xit('should clear the search field, nodes and chosenNode on folder navigation in the results list', fakeAsync(() => { it('should clear the search field, nodes and chosenNode on folder navigation in the results list', fakeAsync(() => {
spyOn(component, 'clearSearch').and.callThrough(); spyOn(component, 'clearSearch').and.callThrough();
typeToSearchBox('a'); typeToSearchBox('a');
@ -563,7 +549,7 @@ describe('ContentNodeSelectorComponent', () => {
expect(documentList.componentInstance.imageResolver).toBe(resolver); expect(documentList.componentInstance.imageResolver).toBe(resolver);
}); });
xit('should show the result list when search was performed', (done) => { it('should show the result list when search was performed', (done) => {
typeToSearchBox(); typeToSearchBox();
setTimeout(() => { setTimeout(() => {
@ -577,7 +563,7 @@ describe('ContentNodeSelectorComponent', () => {
}, 300); }, 300);
}); });
xit('should highlight the results when search was performed in the next timeframe', fakeAsync(() => { it('should highlight the results when search was performed in the next timeframe', fakeAsync(() => {
spyOn(component.highlighter, 'highlight'); spyOn(component.highlighter, 'highlight');
typeToSearchBox('shenron'); typeToSearchBox('shenron');
@ -588,12 +574,10 @@ describe('ContentNodeSelectorComponent', () => {
tick(debounceSearch); tick(debounceSearch);
expect(component.highlighter.highlight).not.toHaveBeenCalled();
expect(component.highlighter.highlight).toHaveBeenCalledWith('shenron'); expect(component.highlighter.highlight).toHaveBeenCalledWith('shenron');
})); }));
xit('should show the default text instead of result list if search was cleared', (done) => { it('should show the default text instead of result list if search was cleared', (done) => {
typeToSearchBox(); typeToSearchBox();
setTimeout(() => { setTimeout(() => {
@ -614,7 +598,7 @@ describe('ContentNodeSelectorComponent', () => {
}, 300); }, 300);
}); });
xit('should reload the original documentlist when clearing the search input', fakeAsync(() => { it('should reload the original documentlist when clearing the search input', fakeAsync(() => {
typeToSearchBox('shenron'); typeToSearchBox('shenron');
tick(debounceSearch); tick(debounceSearch);
@ -631,7 +615,7 @@ describe('ContentNodeSelectorComponent', () => {
expect(documentList.componentInstance.currentFolderId).toBe('cat-girl-nuku-nuku'); expect(documentList.componentInstance.currentFolderId).toBe('cat-girl-nuku-nuku');
})); }));
xit('should set the folderIdToShow to the default "currentFolderId" if siteId is undefined', (done) => { it('should set the folderIdToShow to the default "currentFolderId" if siteId is undefined', (done) => {
component.siteChanged(<SiteEntry> { entry: { guid: 'Kame-Sennin Muten Roshi' } }); component.siteChanged(<SiteEntry> { entry: { guid: 'Kame-Sennin Muten Roshi' } });
fixture.detectChanges(); fixture.detectChanges();
@ -655,49 +639,13 @@ describe('ContentNodeSelectorComponent', () => {
expect(pagination).toBeNull(); expect(pagination).toBeNull();
}); });
xit('should be shown when diplaying search results', fakeAsync(() => {
typeToSearchBox('shenron');
tick(debounceSearch);
respondWithSearchResults(ONE_FOLDER_RESULT);
fixture.detectChanges();
const pagination = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-pagination"]'));
expect(pagination).not.toBeNull();
}));
xit('button callback should load the next batch of results by calling the search api', async(() => {
const skipCount = 8;
component.searchTerm = 'kakarot';
component.getNextPageOfSearch({ skipCount });
fixture.whenStable().then(() => {
expect(searchSpy).toHaveBeenCalledWith('kakarot', undefined, skipCount, 25);
});
}));
it('should be shown when pagination\'s hasMoreItems is true', () => {
component.pagination = {
hasMoreItems: true
};
fixture.detectChanges();
const pagination = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-pagination"]'));
expect(pagination).not.toBeNull();
});
it('button callback should load the next batch of folder results when there is no searchTerm', () => { it('button callback should load the next batch of folder results when there is no searchTerm', () => {
const skipCount = 5; const skipCount = 5;
component.searchTerm = ''; component.searchTerm = '';
component.pagination = {
hasMoreItems: true
};
fixture.detectChanges(); fixture.detectChanges();
component.getNextPageOfSearch({ skipCount }); component.updatePagination({ skipCount });
fixture.detectChanges(); fixture.detectChanges();
expect(component.searchTerm).toBe(''); expect(component.searchTerm).toBe('');
@ -708,7 +656,6 @@ describe('ContentNodeSelectorComponent', () => {
it('should set its loading state to true after search was started', fakeAsync(() => { it('should set its loading state to true after search was started', fakeAsync(() => {
component.showingSearchResults = true; component.showingSearchResults = true;
component.pagination = { hasMoreItems: true };
typeToSearchBox('shenron'); typeToSearchBox('shenron');
@ -716,28 +663,12 @@ describe('ContentNodeSelectorComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
tick(debounceSearch);
const spinnerSelector = By.css('[data-automation-id="content-node-selector-search-pagination"] [data-automation-id="adf-infinite-pagination-spinner"]'); const spinnerSelector = By.css('[data-automation-id="content-node-selector-search-pagination"] [data-automation-id="adf-infinite-pagination-spinner"]');
const paginationLoading = fixture.debugElement.query(spinnerSelector); const paginationLoading = fixture.debugElement.query(spinnerSelector);
expect(paginationLoading).not.toBeNull(); expect(paginationLoading).not.toBeNull();
})); }));
xit('should set its loading state to true after search was performed', fakeAsync(() => {
component.showingSearchResults = true;
component.pagination = { hasMoreItems: true };
typeToSearchBox('shenron');
tick(debounceSearch);
fixture.detectChanges();
respondWithSearchResults(ONE_FOLDER_RESULT);
fixture.detectChanges();
const spinnerSelector = By.css('[data-automation-id="content-node-selector-search-pagination"] [data-automation-id="adf-infinite-pagination-spinner"]');
const paginationLoading = fixture.debugElement.query(spinnerSelector);
expect(paginationLoading).toBeNull();
}));
}); });
}); });

View File

@ -15,19 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
import { Component, EventEmitter, Input, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core';
import { import {
Component, AlfrescoApiService, HighlightDirective, UserPreferencesService,
EventEmitter, PaginatedComponent, PaginationModel
Input,
OnInit,
Output,
ViewChild,
ViewEncapsulation
} from '@angular/core';
import {
AlfrescoApiService,
HighlightDirective,
UserPreferencesService
} from '@alfresco/adf-core'; } from '@alfresco/adf-core';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { MinimalNodeEntryEntity, NodePaging, Pagination, SiteEntry, SitePaging } from 'alfresco-js-api'; import { MinimalNodeEntryEntity, NodePaging, Pagination, SiteEntry, SitePaging } from 'alfresco-js-api';
@ -36,6 +27,7 @@ import { RowFilter } from '../document-list/data/row-filter.model';
import { ImageResolver } from '../document-list/data/image-resolver.model'; import { ImageResolver } from '../document-list/data/image-resolver.model';
import { ContentNodeSelectorService } from './content-node-selector.service'; import { ContentNodeSelectorService } from './content-node-selector.service';
import { debounceTime } from 'rxjs/operators'; import { debounceTime } from 'rxjs/operators';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
export type ValidationFunction = (entry: MinimalNodeEntryEntity) => boolean; export type ValidationFunction = (entry: MinimalNodeEntryEntity) => boolean;
@ -48,7 +40,7 @@ const defaultValidation = () => true;
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
host: { 'class': 'adf-content-node-selector-panel' } host: { 'class': 'adf-content-node-selector-panel' }
}) })
export class ContentNodeSelectorPanelComponent implements OnInit { export class ContentNodeSelectorPanelComponent implements OnInit, PaginatedComponent {
/** Node ID of the folder currently listed. */ /** Node ID of the folder currently listed. */
@Input() @Input()
@ -118,8 +110,9 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
inDialog: boolean = false; inDialog: boolean = false;
_chosenNode: MinimalNodeEntryEntity = null; _chosenNode: MinimalNodeEntryEntity = null;
folderIdToShow: string | null = null; folderIdToShow: string | null = null;
paginationStrategy: PaginationStrategy; paginationStrategy: PaginationStrategy = PaginationStrategy.Infinite;
pagination: Pagination; pagination: BehaviorSubject<PaginationModel>;
skipCount: number = 0; skipCount: number = 0;
infiniteScroll: boolean = false; infiniteScroll: boolean = false;
debounceSearch: number = 200; debounceSearch: number = 200;
@ -136,6 +129,14 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
this.search(searchValue); this.search(searchValue);
}); });
this.pageSize = this.preferences.paginationSize; this.pageSize = this.preferences.paginationSize;
let defaultPagination = <PaginationModel> {
maxItems: this.pageSize,
skipCount: 0,
totalItems: 0,
hasMoreItems: false
};
this.pagination = new BehaviorSubject<PaginationModel>(defaultPagination);
} }
set chosenNode(value: MinimalNodeEntryEntity) { set chosenNode(value: MinimalNodeEntryEntity) {
@ -153,7 +154,6 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.folderIdToShow = this.currentFolderId; this.folderIdToShow = this.currentFolderId;
this.paginationStrategy = PaginationStrategy.Infinite;
this.breadcrumbTransform = this.breadcrumbTransform ? this.breadcrumbTransform : null; this.breadcrumbTransform = this.breadcrumbTransform ? this.breadcrumbTransform : null;
this.isSelectionValid = this.isSelectionValid ? this.isSelectionValid : defaultValidation; this.isSelectionValid = this.isSelectionValid ? this.isSelectionValid : defaultValidation;
@ -179,16 +179,6 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
this.updateResults(); this.updateResults();
} }
/**
* Returns whether breadcrumb has to be shown or not
*/
needBreadcrumbs() {
const whenInFolderNavigation = !this.showingSearchResults,
whenInSelectingSearchResult = this.showingSearchResults && this.chosenNode;
return whenInFolderNavigation || whenInSelectingSearchResult;
}
/** /**
* Returns the actually selected|entered folder node or null in case of searching for the breadcrumb * Returns the actually selected|entered folder node or null in case of searching for the breadcrumb
*/ */
@ -250,9 +240,9 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
* *
* @param event Pagination object * @param event Pagination object
*/ */
getNextPageOfSearch(event: Pagination): void { updatePagination(pagination: Pagination): void {
this.infiniteScroll = true; this.infiniteScroll = true;
this.skipCount = event.skipCount; this.skipCount = pagination.skipCount;
if (this.searchTerm.length > 0) { if (this.searchTerm.length > 0) {
this.querySearch(); this.querySearch();
@ -285,18 +275,18 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
* *
* @param results Search results * @param results Search results
*/ */
private showSearchResults(results: NodePaging): void { private showSearchResults(nodePaging: NodePaging): void {
this.showingSearchResults = true; this.showingSearchResults = true;
this.loadingSearchResults = false; this.loadingSearchResults = false;
// Documentlist hack, since data displaying for preloaded nodes is a little bit messy there // Documentlist hack, since data displaying for preloaded nodes is a little bit messy there
if (!this.nodes) { if (!this.nodes) {
this.nodes = results; this.nodes = nodePaging;
} else { } else {
this.documentList.data.loadPage(results, true); this.documentList.data.loadPage(nodePaging, true);
} }
this.pagination = results.list.pagination; this.pagination.next(nodePaging.list.pagination);
this.highlight(); this.highlight();
} }
@ -313,6 +303,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
* Sets showingSearchResults state to be able to differentiate between search results or folder results * Sets showingSearchResults state to be able to differentiate between search results or folder results
*/ */
onFolderChange(): void { onFolderChange(): void {
this.showingSearchResults = false;
this.infiniteScroll = false; this.infiniteScroll = false;
this.clearSearch(); this.clearSearch();
} }
@ -320,10 +311,17 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
/** /**
* Attempts to set the currently loaded node * Attempts to set the currently loaded node
*/ */
onFolderLoaded(nodePage: NodePaging): void { onFolderLoaded(nodePaging: NodePaging): void {
this.attemptNodeSelection(this.documentList.folderNode); if (!this.showingSearchResults) {
this.pagination = nodePage.list.pagination; this.attemptNodeSelection(this.documentList.folderNode);
this.skipCount = nodePage.list.pagination.skipCount; }
}
/**
* Returns whether breadcrumb has to be shown or not
*/
showBreadcrumbs() {
return !this.showingSearchResults || this.chosenNode;
} }
/** /**

View File

@ -786,15 +786,6 @@ describe('DocumentList', () => {
expect(documentList.navigationMode).toBe(DocumentListComponent.SINGLE_CLICK_NAVIGATION); expect(documentList.navigationMode).toBe(DocumentListComponent.SINGLE_CLICK_NAVIGATION);
}); });
xit('should emit error on wrong folder id', (done) => {
documentList.error.subscribe(() => {
done();
});
documentList.currentFolderId = 'wrong-id';
documentList.ngOnChanges({ currentFolderId: new SimpleChange(null, documentList.currentFolderId, true) });
});
it('should require dataTable to check empty template', () => { it('should require dataTable to check empty template', () => {
documentList.dataTable = null; documentList.dataTable = null;
expect(documentList.isEmptyTemplateDefined()).toBeFalsy(); expect(documentList.isEmptyTemplateDefined()).toBeFalsy();

View File

@ -116,7 +116,7 @@ describe('DocumentListService', () => {
}); });
}); });
xit('should emit an error when the folder already exist', () => { it('should emit an error when the folder already exist', () => {
service.createFolder('fake-name', 'fake-path').subscribe( service.createFolder('fake-name', 'fake-path').subscribe(
res => { res => {

View File

@ -21,7 +21,6 @@ import {
} from '@alfresco/adf-core'; } from '@alfresco/adf-core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Response } from '@angular/http';
import { MinimalNodeEntity, MinimalNodeEntryEntity, NodePaging } from 'alfresco-js-api'; import { MinimalNodeEntity, MinimalNodeEntryEntity, NodePaging } from 'alfresco-js-api';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/throw'; import 'rxjs/add/observable/throw';
@ -109,8 +108,9 @@ export class DocumentListService {
* @returns Details of the created folder node * @returns Details of the created folder node
*/ */
createFolder(name: string, parentId: string): Observable<MinimalNodeEntity> { createFolder(name: string, parentId: string): Observable<MinimalNodeEntity> {
return Observable.fromPromise(this.apiService.getInstance().nodes.createFolder(name, '/', parentId)) let observable = Observable.fromPromise(this.apiService.getInstance().nodes.createFolder(name, '/', parentId));
.catch(err => this.handleError(err)); observable.catch(err => this.handleError(err));
return observable;
} }
/** /**
@ -182,7 +182,7 @@ export class DocumentListService {
return this.contentService.hasPermission(node, permission); return this.contentService.hasPermission(node, permission);
} }
private handleError(error: Response) { private handleError(error: any) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
this.logService.error(error); this.logService.error(error);

View File

@ -1,4 +1,4 @@
<div *ngIf="pagination?.hasMoreItems" class="adf-infinite-pagination"> <div *ngIf="pagination?.hasMoreItems || isLoading" class="adf-infinite-pagination">
<button mat-button <button mat-button
*ngIf="!isLoading" *ngIf="!isLoading"
class="adf-infinite-pagination-load-more" class="adf-infinite-pagination-load-more"

View File

@ -46,7 +46,7 @@ export class InfinitePaginationComponent implements OnInit, OnDestroy, Paginatio
merge: true merge: true
}; };
/** Pagination object. */ /** @deprecated 2.3.0 Pagination object. */
@Input() @Input()
pagination: PaginationModel; pagination: PaginationModel;
@ -58,7 +58,6 @@ export class InfinitePaginationComponent implements OnInit, OnDestroy, Paginatio
@Input() @Input()
pageSize: number = InfinitePaginationComponent.DEFAULT_PAGE_SIZE; pageSize: number = InfinitePaginationComponent.DEFAULT_PAGE_SIZE;
/** @deprecated 2.3.0 use the paginated component interface to use it. */
/** Is a new page loading? */ /** Is a new page loading? */
@Input('loading') @Input('loading')
isLoading: boolean = false; isLoading: boolean = false;

View File

@ -24,6 +24,6 @@ export interface PaginatedComponent {
* @deprecated 2.3.0 : the supported page size should be retrieved via the user preferences * @deprecated 2.3.0 : the supported page size should be retrieved via the user preferences
* and given to the pagination component, and not retrieved by the paginated object * and given to the pagination component, and not retrieved by the paginated object
*/ */
supportedPageSizes: number[]; supportedPageSizes?: number[];
updatePagination(params: PaginationModel); updatePagination(pagination: PaginationModel);
} }

View File

@ -51,7 +51,7 @@ describe('NotificationService', () => {
fixture.detectChanges(); fixture.detectChanges();
}); });
xit('should open a message notification bar', (done) => { it('should open a message notification bar', (done) => {
let promise = fixture.componentInstance.sendMessage(); let promise = fixture.componentInstance.sendMessage();
promise.afterDismissed().subscribe(() => { promise.afterDismissed().subscribe(() => {
done(); done();
@ -62,7 +62,7 @@ describe('NotificationService', () => {
expect(document.querySelector('snack-bar-container')).not.toBeNull(); expect(document.querySelector('snack-bar-container')).not.toBeNull();
}); });
xit('should open a message notification bar with action', (done) => { it('should open a message notification bar with action', (done) => {
let promise = fixture.componentInstance.sendMessageAction(); let promise = fixture.componentInstance.sendMessageAction();
promise.afterDismissed().subscribe(() => { promise.afterDismissed().subscribe(() => {
done(); done();

View File

@ -430,7 +430,7 @@ describe('ViewerComponent', () => {
}); });
xdescribe('View', () => { describe('View', () => {
describe('Overlay mode true', () => { describe('Overlay mode true', () => {