Fix FolderShortcuts test to select by label
Change ShortcutItem to set the 'label' attribute of an element, so that the FolderShortcuts test can select these elements, with a TODO to remove later. This is the fastest way to fix the integration tests to work when team drives is enabled (and the IDs move around). This also makes the tests robust against more directories being added to the top- level tree. Other approaches considered: (1) Add a getIdForTreeElementWithName method to background/js/test_util.js. This doesn't work with waitForElement() since calling it beforehand fails immediately when the element doesn't exist. Adding a waitForElementInTreeWithName() could work, but you would need both methods, and adding waitFor*() methods is a bit tricky to write. (2) Use :nth-child selectors. This doesn't work because shortcuts are added in alphabetical order, meaning new shortcuts added might invalidate previous selectors. So the selectors aren't static. (3) Pass the expected index of the shortcut into each method call. This works for all methods except ones involving Drive, which use a slightly different selector. Also, for methods like removeShortcut(), it's impossible to tell whether the item has been removed (since all the elements shift up by 1, the shortcut at this index is now just the next shortcut in the list). (4) Keep track of the shortcut state in the test, and predict the indexes based on that. This is harder to do, and requires a nontrivial test rewrite. Bug: 849497 Cq-Include-Trybots: luci.chromium.try:closure_compilation Change-Id: Id26c559ea893491cf942b19a874fee29bde79534 Reviewed-on: https://chromium-review.googlesource.com/1103434Reviewed-by:Noel Gordon <noel@chromium.org> Commit-Queue: Sasha Morrissey <sashab@chromium.org> Cr-Commit-Position: refs/heads/master@{#568328}
Showing
Please register or sign in to comment