Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discover] Allow user to generate a report after saving a modified saved search #63623

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -24,6 +24,7 @@ export default function({ getService, getPageObjects }) {
const browser = getService('browser');
const log = getService('log');
const config = getService('config');
const filterBar = getService('filterBar');
const PageObjects = getPageObjects([
'reporting',
'common',
Expand Down Expand Up @@ -161,7 +162,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