mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* Add checks for changed query and update in $scope.updateQuery * Add functional test by counting fetches
This commit is contained in:
parent
b863c0fb80
commit
1381864f8d
4 changed files with 31 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
|||
<discover-app class="app-container">
|
||||
<discover-app class="app-container" data-fetch-counter="{{fetchCounter}}">
|
||||
<h1 class="euiScreenReaderOnly">{{screenTitle}}</h1>
|
||||
|
||||
<!-- Local nav. -->
|
||||
|
|
|
@ -194,6 +194,8 @@ function discoverController(
|
|||
const savedSearch = $route.current.locals.savedObjects.savedSearch;
|
||||
$scope.searchSource = savedSearch.searchSource;
|
||||
$scope.indexPattern = resolveIndexPatternLoading();
|
||||
//used for functional testing
|
||||
$scope.fetchCounter = 0;
|
||||
|
||||
const getTimeField = () => {
|
||||
return isDefaultType($scope.indexPattern) ? $scope.indexPattern.timeFieldName : undefined;
|
||||
|
@ -784,7 +786,7 @@ function discoverController(
|
|||
$scope.opts.fetch = $scope.fetch = function() {
|
||||
// ignore requests to fetch before the app inits
|
||||
if (!init.complete) return;
|
||||
|
||||
$scope.fetchCounter++;
|
||||
$scope.fetchError = undefined;
|
||||
|
||||
// Abort any in-progress requests before fetching again
|
||||
|
@ -821,9 +823,11 @@ function discoverController(
|
|||
});
|
||||
};
|
||||
|
||||
$scope.updateQuery = function({ query }) {
|
||||
setAppState({ query });
|
||||
$fetchObservable.next();
|
||||
$scope.updateQuery = function({ query }, isUpdate = true) {
|
||||
if (!_.isEqual(query, appStateContainer.getState().query) || isUpdate === false) {
|
||||
setAppState({ query });
|
||||
$fetchObservable.next();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.updateSavedQueryId = newSavedQueryId => {
|
||||
|
|
|
@ -224,5 +224,22 @@ export default function({ getService, getPageObjects }) {
|
|||
expect(rowData.startsWith('Sep 22, 2015 @ 16:50:13.253')).to.be.ok();
|
||||
});
|
||||
});
|
||||
describe('usage of discover:searchOnPageLoad', () => {
|
||||
it('should fetch data from ES initially when discover:searchOnPageLoad is false', async function() {
|
||||
await kibanaServer.uiSettings.replace({ 'discover:searchOnPageLoad': false });
|
||||
await PageObjects.common.navigateToApp('discover');
|
||||
await PageObjects.header.awaitKibanaChrome();
|
||||
|
||||
expect(await PageObjects.discover.getNrOfFetches()).to.be(0);
|
||||
});
|
||||
|
||||
it('should not fetch data from ES initially when discover:searchOnPageLoad is true', async function() {
|
||||
await kibanaServer.uiSettings.replace({ 'discover:searchOnPageLoad': true });
|
||||
await PageObjects.common.navigateToApp('discover');
|
||||
await PageObjects.header.awaitKibanaChrome();
|
||||
|
||||
expect(await PageObjects.discover.getNrOfFetches()).to.be(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -300,6 +300,11 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider
|
|||
'true'
|
||||
);
|
||||
}
|
||||
public async getNrOfFetches() {
|
||||
const el = await find.byCssSelector('[data-fetch-counter]');
|
||||
const nr = await el.getAttribute('data-fetch-counter');
|
||||
return Number(nr);
|
||||
}
|
||||
}
|
||||
|
||||
return new DiscoverPage();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue