[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
11 changed files with 58 additions and 143 deletions

View File

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

View File

@@ -132,23 +132,9 @@ describe('ContentNodeSelectorComponent', () => {
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,
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');
}));
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();
typeToSearchBox('a');
@@ -563,7 +549,7 @@ describe('ContentNodeSelectorComponent', () => {
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();
setTimeout(() => {
@@ -577,7 +563,7 @@ describe('ContentNodeSelectorComponent', () => {
}, 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');
typeToSearchBox('shenron');
@@ -588,12 +574,10 @@ describe('ContentNodeSelectorComponent', () => {
tick(debounceSearch);
expect(component.highlighter.highlight).not.toHaveBeenCalled();
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();
setTimeout(() => {
@@ -614,7 +598,7 @@ describe('ContentNodeSelectorComponent', () => {
}, 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');
tick(debounceSearch);
@@ -631,7 +615,7 @@ describe('ContentNodeSelectorComponent', () => {
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' } });
fixture.detectChanges();
@@ -655,49 +639,13 @@ describe('ContentNodeSelectorComponent', () => {
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', () => {
const skipCount = 5;
component.searchTerm = '';
component.pagination = {
hasMoreItems: true
};
fixture.detectChanges();
component.getNextPageOfSearch({ skipCount });
component.updatePagination({ skipCount });
fixture.detectChanges();
expect(component.searchTerm).toBe('');
@@ -708,7 +656,6 @@ describe('ContentNodeSelectorComponent', () => {
it('should set its loading state to true after search was started', fakeAsync(() => {
component.showingSearchResults = true;
component.pagination = { hasMoreItems: true };
typeToSearchBox('shenron');
@@ -716,28 +663,12 @@ describe('ContentNodeSelectorComponent', () => {
fixture.detectChanges();
tick(debounceSearch);
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).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.
*/
import { Component, EventEmitter, Input, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core';
import {
Component,
EventEmitter,
Input,
OnInit,
Output,
ViewChild,
ViewEncapsulation
} from '@angular/core';
import {
AlfrescoApiService,
HighlightDirective,
UserPreferencesService
AlfrescoApiService, HighlightDirective, UserPreferencesService,
PaginatedComponent, PaginationModel
} from '@alfresco/adf-core';
import { FormControl } from '@angular/forms';
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 { ContentNodeSelectorService } from './content-node-selector.service';
import { debounceTime } from 'rxjs/operators';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
export type ValidationFunction = (entry: MinimalNodeEntryEntity) => boolean;
@@ -48,7 +40,7 @@ const defaultValidation = () => true;
encapsulation: ViewEncapsulation.None,
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. */
@Input()
@@ -118,8 +110,9 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
inDialog: boolean = false;
_chosenNode: MinimalNodeEntryEntity = null;
folderIdToShow: string | null = null;
paginationStrategy: PaginationStrategy;
pagination: Pagination;
paginationStrategy: PaginationStrategy = PaginationStrategy.Infinite;
pagination: BehaviorSubject<PaginationModel>;
skipCount: number = 0;
infiniteScroll: boolean = false;
debounceSearch: number = 200;
@@ -136,6 +129,14 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
this.search(searchValue);
});
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) {
@@ -153,7 +154,6 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
ngOnInit() {
this.folderIdToShow = this.currentFolderId;
this.paginationStrategy = PaginationStrategy.Infinite;
this.breadcrumbTransform = this.breadcrumbTransform ? this.breadcrumbTransform : null;
this.isSelectionValid = this.isSelectionValid ? this.isSelectionValid : defaultValidation;
@@ -179,16 +179,6 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
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
*/
@@ -250,9 +240,9 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
*
* @param event Pagination object
*/
getNextPageOfSearch(event: Pagination): void {
updatePagination(pagination: Pagination): void {
this.infiniteScroll = true;
this.skipCount = event.skipCount;
this.skipCount = pagination.skipCount;
if (this.searchTerm.length > 0) {
this.querySearch();
@@ -285,18 +275,18 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
*
* @param results Search results
*/
private showSearchResults(results: NodePaging): void {
private showSearchResults(nodePaging: NodePaging): void {
this.showingSearchResults = true;
this.loadingSearchResults = false;
// Documentlist hack, since data displaying for preloaded nodes is a little bit messy there
if (!this.nodes) {
this.nodes = results;
this.nodes = nodePaging;
} 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();
}
@@ -313,6 +303,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
* Sets showingSearchResults state to be able to differentiate between search results or folder results
*/
onFolderChange(): void {
this.showingSearchResults = false;
this.infiniteScroll = false;
this.clearSearch();
}
@@ -320,10 +311,17 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
/**
* Attempts to set the currently loaded node
*/
onFolderLoaded(nodePage: NodePaging): void {
this.attemptNodeSelection(this.documentList.folderNode);
this.pagination = nodePage.list.pagination;
this.skipCount = nodePage.list.pagination.skipCount;
onFolderLoaded(nodePaging: NodePaging): void {
if (!this.showingSearchResults) {
this.attemptNodeSelection(this.documentList.folderNode);
}
}
/**
* Returns whether breadcrumb has to be shown or not
*/
showBreadcrumbs() {
return !this.showingSearchResults || this.chosenNode;
}
/**