mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[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:
parent
12df7500da
commit
5f8b41411a
@ -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>
|
||||
|
@ -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();
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -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 {
|
||||
onFolderLoaded(nodePaging: NodePaging): void {
|
||||
if (!this.showingSearchResults) {
|
||||
this.attemptNodeSelection(this.documentList.folderNode);
|
||||
this.pagination = nodePage.list.pagination;
|
||||
this.skipCount = nodePage.list.pagination.skipCount;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether breadcrumb has to be shown or not
|
||||
*/
|
||||
showBreadcrumbs() {
|
||||
return !this.showingSearchResults || this.chosenNode;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -786,15 +786,6 @@ describe('DocumentList', () => {
|
||||
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', () => {
|
||||
documentList.dataTable = null;
|
||||
expect(documentList.isEmptyTemplateDefined()).toBeFalsy();
|
||||
|
@ -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(
|
||||
res => {
|
||||
|
||||
|
@ -21,7 +21,6 @@ import {
|
||||
} from '@alfresco/adf-core';
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Response } from '@angular/http';
|
||||
import { MinimalNodeEntity, MinimalNodeEntryEntity, NodePaging } from 'alfresco-js-api';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import 'rxjs/add/observable/throw';
|
||||
@ -109,8 +108,9 @@ export class DocumentListService {
|
||||
* @returns Details of the created folder node
|
||||
*/
|
||||
createFolder(name: string, parentId: string): Observable<MinimalNodeEntity> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().nodes.createFolder(name, '/', parentId))
|
||||
.catch(err => this.handleError(err));
|
||||
let observable = Observable.fromPromise(this.apiService.getInstance().nodes.createFolder(name, '/', parentId));
|
||||
observable.catch(err => this.handleError(err));
|
||||
return observable;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,7 +182,7 @@ export class DocumentListService {
|
||||
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
|
||||
// instead of just logging it to the console
|
||||
this.logService.error(error);
|
||||
|
@ -1,4 +1,4 @@
|
||||
<div *ngIf="pagination?.hasMoreItems" class="adf-infinite-pagination">
|
||||
<div *ngIf="pagination?.hasMoreItems || isLoading" class="adf-infinite-pagination">
|
||||
<button mat-button
|
||||
*ngIf="!isLoading"
|
||||
class="adf-infinite-pagination-load-more"
|
||||
|
@ -46,7 +46,7 @@ export class InfinitePaginationComponent implements OnInit, OnDestroy, Paginatio
|
||||
merge: true
|
||||
};
|
||||
|
||||
/** Pagination object. */
|
||||
/** @deprecated 2.3.0 Pagination object. */
|
||||
@Input()
|
||||
pagination: PaginationModel;
|
||||
|
||||
@ -58,7 +58,6 @@ export class InfinitePaginationComponent implements OnInit, OnDestroy, Paginatio
|
||||
@Input()
|
||||
pageSize: number = InfinitePaginationComponent.DEFAULT_PAGE_SIZE;
|
||||
|
||||
/** @deprecated 2.3.0 use the paginated component interface to use it. */
|
||||
/** Is a new page loading? */
|
||||
@Input('loading')
|
||||
isLoading: boolean = false;
|
||||
|
@ -24,6 +24,6 @@ export interface PaginatedComponent {
|
||||
* @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
|
||||
*/
|
||||
supportedPageSizes: number[];
|
||||
updatePagination(params: PaginationModel);
|
||||
supportedPageSizes?: number[];
|
||||
updatePagination(pagination: PaginationModel);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ describe('NotificationService', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
xit('should open a message notification bar', (done) => {
|
||||
it('should open a message notification bar', (done) => {
|
||||
let promise = fixture.componentInstance.sendMessage();
|
||||
promise.afterDismissed().subscribe(() => {
|
||||
done();
|
||||
@ -62,7 +62,7 @@ describe('NotificationService', () => {
|
||||
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();
|
||||
promise.afterDismissed().subscribe(() => {
|
||||
done();
|
||||
|
@ -430,7 +430,7 @@ describe('ViewerComponent', () => {
|
||||
|
||||
});
|
||||
|
||||
xdescribe('View', () => {
|
||||
describe('View', () => {
|
||||
|
||||
describe('Overlay mode true', () => {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user