Skip to content

Commit

Permalink
Reset dirty saved query on reload (#43927) (#44142)
Browse files Browse the repository at this point in the history
* Clears changes a loaded saved query before loading another one

* Adds general functional test to ensure changes to a saved query are discarded on reloading it

* Moves resetting a dirty saved query to the app controllers in Discover, Visualize and Dashboard
  • Loading branch information
TinaHeiligers authored Aug 27, 2019
1 parent 3dc3f0b commit 23bf0d5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ export class DashboardAppController {
};

$scope.onSavedQueryUpdated = savedQuery => {
$scope.savedQuery = savedQuery;
$scope.savedQuery = { ...savedQuery };
};

$scope.onClearSavedQuery = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ function discoverController(
};

$scope.onSavedQueryUpdated = savedQuery => {
$scope.savedQuery = savedQuery;
$scope.savedQuery = { ...savedQuery };
};

$scope.onClearSavedQuery = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ function VisEditor(
};

$scope.onSavedQueryUpdated = savedQuery => {
$scope.savedQuery = savedQuery;
$scope.savedQuery = { ...savedQuery };
};

$scope.onClearSavedQuery = () => {
Expand Down
7 changes: 7 additions & 0 deletions test/functional/apps/discover/_saved_queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ export default function ({ getService, getPageObjects }) {
await savedQueryManagementComponent.clearCurrentlyLoadedQuery();
expect(await queryBar.getQueryString()).to.eql('');
});

it('resets any changes to a loaded query on reloading the same saved query', async () => {
await savedQueryManagementComponent.loadSavedQuery('OkResponse');
await queryBar.setQuery('response:503');
await savedQueryManagementComponent.loadSavedQuery('OkResponse');
expect(await queryBar.getQueryString()).to.eql('response:404');
});
});
});
}

0 comments on commit 23bf0d5

Please sign in to comment.