From 553ae4db7bef1012692e0a55a45e4cd264bcb9c4 Mon Sep 17 00:00:00 2001 From: suzanadirla Date: Wed, 20 Dec 2017 00:14:36 +0200 Subject: [PATCH] =?UTF-8?q?[ADF-2070][ADF-2071][ADF-2072]=20'Load=20more'?= =?UTF-8?q?=20on=20destination=20picker=20does=E2=80=A6=20(#2774)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [ADF-2070][ADF-2071][ADF-2072] 'Load more' on destination picker doesn't display correct content of folders * [ADF-2070][ADF-2071][ADF-2072] add tests * [ADF-2070][ADF-2071][ADF-2072] 'Load more' on destination picker doesn't display correct content of folders --- ...tent-node-selector-panel.component.spec.ts | 28 +++++++++++++++++++ .../content-node-selector-panel.component.ts | 5 +++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/content-services/content-node-selector/content-node-selector-panel.component.spec.ts b/lib/content-services/content-node-selector/content-node-selector-panel.component.spec.ts index d007a2c814..4bffb8248c 100644 --- a/lib/content-services/content-node-selector/content-node-selector-panel.component.spec.ts +++ b/lib/content-services/content-node-selector/content-node-selector-panel.component.spec.ts @@ -522,6 +522,34 @@ describe('ContentNodeSelectorComponent', () => { expect(searchSpy).toHaveBeenCalledWith(defaultSearchOptions('kakarot', undefined, skipCount)); }); + 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\'s 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}); + fixture.detectChanges(); + expect(component.searchTerm).toBe(''); + + expect(component.infiniteScroll).toBeTruthy(); + expect(component.skipCount).toBe(skipCount); + expect(searchSpy).not.toHaveBeenCalled(); + }); + it('should set its loading state to true after search was started', (done) => { component.showingSearchResults = true; component.pagination = { hasMoreItems: true }; diff --git a/lib/content-services/content-node-selector/content-node-selector-panel.component.ts b/lib/content-services/content-node-selector/content-node-selector-panel.component.ts index f23ce93fda..4e814c63e9 100644 --- a/lib/content-services/content-node-selector/content-node-selector-panel.component.ts +++ b/lib/content-services/content-node-selector/content-node-selector-panel.component.ts @@ -202,7 +202,10 @@ export class ContentNodeSelectorPanelComponent implements OnInit { getNextPageOfSearch(event: Pagination): void { this.infiniteScroll = true; this.skipCount = event.skipCount; - this.querySearch(); + + if (this.searchTerm.length > 0) { + this.querySearch(); + } } /**