Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8899)

Unified Diff: chrome/test/data/webui/md_bookmarks/store_test.js

Issue 2645273002: [MD Bookmarks] Modify search to retain the previously selected folder. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/md_bookmarks/store_test.js
diff --git a/chrome/test/data/webui/md_bookmarks/store_test.js b/chrome/test/data/webui/md_bookmarks/store_test.js
index 67b65c14df8e7bdc85a59b0e378c576602fd826e..880cd257d354eefe15a406c48b68eff3adfa089d 100644
--- a/chrome/test/data/webui/md_bookmarks/store_test.js
+++ b/chrome/test/data/webui/md_bookmarks/store_test.js
@@ -233,19 +233,19 @@ suite('<bookmarks-store>', function() {
'Paris',
];
overrideBookmarksSearch(SEARCH_RESULTS);
+ var prevFolder = store.idToNodeMap_[store.selectedId];
// Search for a non-empty string.
store.searchTerm = 'a';
- assertFalse(store.rootNode.children[0].isSelected);
- assertEquals(null, store.selectedId);
+ assertFalse(prevFolder.isSelected);
+ assertEquals(prevFolder.id, store.selectedId);
assertEquals(SEARCH_RESULTS, store.displayedList);
- // Clear the searchTerm.
+ // Clearing search sets the displayed list to the previous folder.
store.searchTerm = '';
- var defaultFolder = store.rootNode.children[0];
- assertTrue(defaultFolder.isSelected);
- assertEquals(defaultFolder.id, store.selectedId);
- assertEquals(defaultFolder.children, store.displayedList);
+ assertTrue(prevFolder.isSelected);
+ assertEquals(prevFolder.id, store.selectedId);
+ assertEquals(prevFolder.children, store.displayedList);
// Search with no bookmarks returned.
var EMPTY_RESULT = [];
@@ -274,9 +274,21 @@ suite('<bookmarks-store>', function() {
test('route updates from search', function() {
overrideBookmarksSearch([]);
+ var prevFolderId = '3';
+ store.fire('selected-folder-changed', prevFolderId);
+
+ // Searching sets the previous folder and searchTerm as the URL parameters.
tsergeant 2017/01/25 00:23:18 You should also test the opposite direction: If I
angelayang 2017/01/31 02:25:03 Okay i placed those in the 'search updates from ro
var searchTerm = 'Boat24';
store.searchTerm = searchTerm;
- assertEquals('chrome://bookmarks/?q=' + searchTerm, window.location.href);
+ assertEquals(
+ 'chrome://bookmarks/?id=' + prevFolderId + '&q=' + searchTerm,
+ window.location.href);
+
+ // Search parameter is removed from the URL when search is cleared.
+ searchTerm = '';
+ store.searchTerm = searchTerm;
+ assertEquals(
+ 'chrome://bookmarks/?id=' + prevFolderId, window.location.href);
});
test('selectedId updates from route', function() {

Powered by Google App Engine
This is Rietveld 408576698