Commit 99a0b04e authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

FilesApp UI tests fix Uncaught Type Error undefined updateItemByEntry

* Defer call of setupCrostini_ until after |setupAndWaitUntilReady|
  to ensure UI has been created.
* Stopped sending 'onDirectoryChanged' events for downloads and drive
  after adding new items and instead click Downloads entry to select
  it, or click Refresh button if downloads is already selected to
  ensure new items are refreshed and shown.

Bug: 853594
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: I47a7e062f8d9cbce44b68ee5203f545c9635a195
Reviewed-on: https://chromium-review.googlesource.com/1103428Reviewed-by: default avatarAlexey Baskakov <loyso@chromium.org>
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567931}
parent 10d99281
......@@ -6,9 +6,9 @@ const crostini = {};
crostini.testCrostiniNotEnabled = (done) => {
chrome.fileManagerPrivate.crostiniEnabled_ = false;
fileManager.setupCrostini_();
test.setupAndWaitUntilReady()
.then(() => {
fileManager.setupCrostini_();
return test.waitForElementLost(
'#directory-tree .tree-item [root-type-icon="crostini"]');
})
......@@ -24,9 +24,9 @@ crostini.testCrostiniSuccess = (done) => {
chrome.fileManagerPrivate.mountCrostiniContainer = (callback) => {
mountCallback = callback;
};
fileManager.setupCrostini_();
test.setupAndWaitUntilReady()
.then(() => {
fileManager.setupCrostini_();
// Linux Files fake root is shown.
return test.waitForElement(
'#directory-tree .tree-item [root-type-icon="crostini"]');
......@@ -84,9 +84,9 @@ crostini.testCrostiniError = (done) => {
callback();
chrome.runtime.lastError = null;
};
fileManager.setupCrostini_();
test.setupAndWaitUntilReady()
.then(() => {
fileManager.setupCrostini_();
return test.waitForElement(
'#directory-tree .tree-item [root-type-icon="crostini"]');
})
......@@ -111,9 +111,9 @@ crostini.testCrostiniError = (done) => {
crostini.testCrostiniMountOnDrag = (done) => {
chrome.fileManagerPrivate.crostiniEnabled_ = true;
chrome.fileManagerPrivate.mountCrostiniContainerDelay_ = 0;
fileManager.setupCrostini_();
test.setupAndWaitUntilReady()
.then(() => {
fileManager.setupCrostini_();
return test.waitForElement(
'#directory-tree .tree-item [root-type-icon="crostini"]');
})
......
......@@ -428,12 +428,6 @@ test.addEntries = function(downloads, drive, crostini) {
str('LINUX_FILES_ROOT_LABEL'));
crostiniVolumeInfo.fileSystem.populate(
test.TestEntryInfo.getMockFileSystemPopulateRows(crostini, '/'), true);
// Send onDirectoryChanged events.
chrome.fileManagerPrivate.onDirectoryChanged.dispatchEvent(
{eventType: 'changed', entry: fsDownloads.root});
chrome.fileManagerPrivate.onDirectoryChanged.dispatchEvent(
{eventType: 'changed', entry: fsDrive.entries['/root']});
};
/**
......@@ -528,9 +522,12 @@ test.setupAndWaitUntilReady = function(resolve) {
return test.waitForElement(
'#directory-tree [volume-type-icon="downloads"]');
})
.then(() => {
.then((downloadsIcon) => {
// Click Downloads, or refresh button if already on Downloads.
assertTrue(test.fakeMouseClick(
'#directory-tree [volume-type-icon="downloads"]'));
downloadsIcon.parentElement.hasAttribute('selected') ?
'#refresh-button' :
'#directory-tree [volume-type-icon="downloads"]'));
return test.waitForFiles(
test.TestEntryInfo.getExpectedRows(test.BASIC_LOCAL_ENTRY_SET));
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment