Commit 249a4ff6 authored by Jason Goodman's avatar Jason Goodman Committed by Clement Ho

Fetch the Next Page if Bottom of Scroll is Reached

Also test to ensure pages are fetched as the user scrolls.
parent 87507322
...@@ -70,6 +70,7 @@ export default { ...@@ -70,6 +70,7 @@ export default {
'searchCount', 'searchCount',
'searchQuery', 'searchQuery',
'messages', 'messages',
'pageInfo',
]), ]),
isSearchingProjects() { isSearchingProjects() {
return this.searchCount > 0; return this.searchCount > 0;
...@@ -90,6 +91,7 @@ export default { ...@@ -90,6 +91,7 @@ export default {
'fetchSearchResults', 'fetchSearchResults',
'addProjectsToDashboard', 'addProjectsToDashboard',
'fetchProjects', 'fetchProjects',
'fetchNextPage',
'setProjectEndpoints', 'setProjectEndpoints',
'clearSearchResults', 'clearSearchResults',
'toggleSelectedProject', 'toggleSelectedProject',
...@@ -135,8 +137,10 @@ export default { ...@@ -135,8 +137,10 @@ export default {
:show-loading-indicator="isSearchingProjects" :show-loading-indicator="isSearchingProjects"
:show-minimum-search-query-message="messages.minimumQuery" :show-minimum-search-query-message="messages.minimumQuery"
:show-search-error-message="messages.searchError" :show-search-error-message="messages.searchError"
:total-results="pageInfo.totalResults"
@searched="searched" @searched="searched"
@projectClicked="projectClicked" @projectClicked="projectClicked"
@bottomReached="fetchNextPage"
/> />
</gl-modal> </gl-modal>
<div class="page-title-holder flex-fill d-flex align-items-center"> <div class="page-title-holder flex-fill d-flex align-items-center">
......
---
title: Fix Infinite Scrolling on Environments Dashboard Project Selector
merge_request: 20408
author:
type: fixed
...@@ -29,6 +29,7 @@ describe('dashboard', () => { ...@@ -29,6 +29,7 @@ describe('dashboard', () => {
removeProject: jest.fn(), removeProject: jest.fn(),
toggleSelectedProject: jest.fn(), toggleSelectedProject: jest.fn(),
fetchNextPage: jest.fn(), fetchNextPage: jest.fn(),
fetchProjects: jest.fn(),
}; };
propsData = { propsData = {
addPath: 'mock-addPath', addPath: 'mock-addPath',
...@@ -42,7 +43,6 @@ describe('dashboard', () => { ...@@ -42,7 +43,6 @@ describe('dashboard', () => {
localVue, localVue,
store, store,
methods: { methods: {
fetchProjects: () => {},
...actionSpies, ...actionSpies,
}, },
}); });
...@@ -135,6 +135,16 @@ describe('dashboard', () => { ...@@ -135,6 +135,16 @@ describe('dashboard', () => {
wrapper.find(ProjectSelector).vm.$emit('projectClicked', { name: 'test', id: 1 }); wrapper.find(ProjectSelector).vm.$emit('projectClicked', { name: 'test', id: 1 });
expect(actionSpies.toggleSelectedProject).toHaveBeenCalledWith({ name: 'test', id: 1 }); expect(actionSpies.toggleSelectedProject).toHaveBeenCalledWith({ name: 'test', id: 1 });
}); });
it('should fetch the next page when bottom is reached', () => {
wrapper.find(ProjectSelector).vm.$emit('bottomReached');
expect(actionSpies.fetchNextPage).toHaveBeenCalled();
});
it('should get the page info from the state', () => {
store.state.pageInfo = { totalResults: 100 };
expect(wrapper.find(ProjectSelector).props('totalResults')).toBe(100);
});
}); });
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment