Commit c851ee75 authored by Jimmy Gong's avatar Jimmy Gong Committed by Commit Bot

Reland "Fix flaky printmanagement browser test"

This is a reland of 75e29f77

- The fix is to ensure that the print-management dom element is
  created and ready by the time we're querying for its child elements.
- This was done by flushing the dom when the whenCalled promise is
  resolved, ensuring that the elements are ready.

Original change's description:
> Fix flaky printmanagement browser test
>
> - The original cause of the flaky is because the page element was not
>   ready by the time we try to query for elements within it.
> - The fix is to attach a promise to the instatiation of the page and
>   to only continue with the test once the promise is resolved. This
>   ensures that each step of the test is handled synchronously.
>
> Bug: 1068860
> Test: browser_tests
> Change-Id: I0a30e2971107b44354603adbb0396ddfea3c218d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2142951
> Reviewed-by: Kyle Horimoto <khorimoto@chromium.org>
> Commit-Queue: jimmy gong <jimmyxgong@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#757687}

Bug: 1068860
Change-Id: I4b2e8b3836aa676c3d5aa43295432dd1afed6927
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2145253
Commit-Queue: jimmy gong <jimmyxgong@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758135}
parent 04a1b14e
...@@ -84,7 +84,6 @@ function verifyPrintJobs(expected, actual) { ...@@ -84,7 +84,6 @@ function verifyPrintJobs(expected, actual) {
* @return {!Array<!HTMLElement>} * @return {!Array<!HTMLElement>}
*/ */
function getPrintJobEntries(page) { function getPrintJobEntries(page) {
flush();
const entryList = page.$$('#entryList'); const entryList = page.$$('#entryList');
return Array.from( return Array.from(
entryList.querySelectorAll('print-job-entry:not([hidden])')); entryList.querySelectorAll('print-job-entry:not([hidden])'));
...@@ -186,6 +185,7 @@ suite('PrintManagementTest', () => { ...@@ -186,6 +185,7 @@ suite('PrintManagementTest', () => {
}); });
teardown(function() { teardown(function() {
mojoApi_ = null;
page.remove(); page.remove();
page = null; page = null;
}); });
...@@ -198,6 +198,7 @@ suite('PrintManagementTest', () => { ...@@ -198,6 +198,7 @@ suite('PrintManagementTest', () => {
mojoApi_.setPrintJobs(printJobs); mojoApi_.setPrintJobs(printJobs);
page = document.createElement('print-management'); page = document.createElement('print-management');
document.body.appendChild(page); document.body.appendChild(page);
assert(!!page);
flush(); flush();
} }
...@@ -218,8 +219,8 @@ suite('PrintManagementTest', () => { ...@@ -218,8 +219,8 @@ suite('PrintManagementTest', () => {
// app to sort the list when it first loads. Since reverse() mutates the // app to sort the list when it first loads. Since reverse() mutates the
// original array, use a copy array to prevent mutating |expectedArr|. // original array, use a copy array to prevent mutating |expectedArr|.
initializePrintManagementApp(expectedArr.slice().reverse()); initializePrintManagementApp(expectedArr.slice().reverse());
return mojoApi_.whenCalled('getPrintJobs').then(() => {
mojoApi_.whenCalled('getPrintJobs').then(() => { flush();
verifyPrintJobs(expectedArr, getPrintJobEntries(page)); verifyPrintJobs(expectedArr, getPrintJobEntries(page));
}); });
}); });
......
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