Skip to content

Commit

Permalink
[Discover] Allow user to generate a report after saving a modified sa…
Browse files Browse the repository at this point in the history
…ved search (elastic#63623)

* Fix missing reset of initial state when saving saved searches

* Fix invalid setting of docTitle

* Add functional test
  • Loading branch information
kertal committed Apr 20, 2020
1 parent 375c63a commit 915ab0c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const {
core,
chrome,
data,
docTitle,
history,
indexPatterns,
filterManager,
Expand Down Expand Up @@ -214,6 +213,7 @@ function discoverController(
isAppStateDirty,
kbnUrlStateStorage,
getPreviousAppState,
resetInitialAppState,
} = getState({
defaultAppState: getStateDefaults(),
storeInSessionStorage: config.get('state:storeInSessionStorage'),
Expand Down Expand Up @@ -373,6 +373,8 @@ function discoverController(
// If the save wasn't successful, put the original values back.
if (!response.id || response.error) {
savedSearch.title = currentTitle;
} else {
resetInitialAppState();
}
return response;
});
Expand Down Expand Up @@ -758,7 +760,7 @@ function discoverController(
} else {
// Update defaults so that "reload saved query" functions correctly
setAppState(getStateDefaults());
docTitle.change(savedSearch.lastSavedTitle);
chrome.docTitle.change(savedSearch.lastSavedTitle);
}
}
});
Expand Down
21 changes: 21 additions & 0 deletions x-pack/test/reporting/functional/reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function({ getService, getPageObjects }) {
const esArchiver = getService('esArchiver');
const browser = getService('browser');
const log = getService('log');
const filterBar = getService('filterBar');
const PageObjects = getPageObjects([
'reporting',
'common',
Expand Down Expand Up @@ -123,7 +124,27 @@ export default function({ getService, getPageObjects }) {
expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null);
});

it('becomes available/not available when a saved search is created, changed and saved again', async () => {
// create new search, csv export is not available
await PageObjects.discover.clickNewSearchButton();
await PageObjects.reporting.openCsvReportingPanel();
expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true');
// save search, csv export is available
await PageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton 2');
await PageObjects.reporting.openCsvReportingPanel();
expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null);
// add filter, csv export is not available
await filterBar.addFilter('currency', 'is', 'EUR');
await PageObjects.reporting.openCsvReportingPanel();
expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true');
// save search again, csv export is available
await PageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton 2');
await PageObjects.reporting.openCsvReportingPanel();
expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null);
});

it('generates a report with data', async () => {
await PageObjects.discover.clickNewSearchButton();
await PageObjects.reporting.setTimepickerInDataRange();
await PageObjects.discover.saveSearch('my search - with data - expectReportCanBeCreated');
await PageObjects.reporting.openCsvReportingPanel();
Expand Down

0 comments on commit 915ab0c

Please sign in to comment.