Bug 1624849 - Attempt to fix intermittent failures in browser_taskDisplay.js. rs=bustage-fix a=test-only
authorGeoff Lankow <geoff@darktrojan.net>
Wed, 17 Jun 2020 20:35:37 +1200
changeset 39443 b3ff74f96880dc9dc72399cb5adf59fa4203e395
parent 39442 2e2037a688124d09804a762499be68ce3c8ec57c
child 39444 5e938016a48af323aea49e67c6d4ea7c499892f5
push id402
push userclokep@gmail.com
push dateMon, 29 Jun 2020 20:48:04 +0000
reviewersbustage-fix, test-only
bugs1624849
Bug 1624849 - Attempt to fix intermittent failures in browser_taskDisplay.js. rs=bustage-fix a=test-only
calendar/test/browser/browser_taskDisplay.js
--- a/calendar/test/browser/browser_taskDisplay.js
+++ b/calendar/test/browser/browser_taskDisplay.js
@@ -25,42 +25,49 @@ add_task(async () => {
   }
 
   function treeRefresh() {
     return BrowserTestUtils.waitForEvent(tree, "refresh");
   }
 
   async function setFilterGroup(name) {
     info(`Setting filter to ${name}`);
-    EventUtils.synthesizeMouseAtCenter(document.getElementById(`opt_${name}_filter`), {});
+    let radio = document.getElementById(`opt_${name}_filter`);
+    EventUtils.synthesizeMouseAtCenter(radio, {});
     await treeRefresh();
+    Assert.equal(
+      document.getElementById("calendar-task-tree").getAttribute("filterValue"),
+      radio.value,
+      "Filter group changed"
+    );
   }
 
   async function setFilterText(text) {
     EventUtils.synthesizeMouseAtCenter(document.getElementById("task-text-filter-field"), {});
     EventUtils.sendString(text);
     await treeRefresh();
   }
 
   async function clearFilterText() {
     EventUtils.synthesizeMouseAtCenter(document.getElementById("task-text-filter-field"), {});
     EventUtils.synthesizeKey("VK_ESCAPE");
     is(document.getElementById("task-text-filter-field").value, "", "Filter text cleared");
     await treeRefresh();
   }
 
-  function checkVisibleTasks(...expectedTasks) {
+  async function checkVisibleTasks(...expectedTasks) {
     let actualTasks = [];
     for (let i = 0; i < tree.view.rowCount; i++) {
       actualTasks.push(tree.getTaskAtRow(i));
     }
     info("Expected: " + expectedTasks.map(task => task.title).join(", "));
     info("Actual: " + actualTasks.map(task => task.title).join(", "));
 
     is(tree.view.rowCount, expectedTasks.length, "Correct number of tasks");
+    await new Promise(r => setTimeout(r));
 
     // Although the order of expectedTasks matches the observed behaviour when
     // this test was written, order is NOT checked here. The order of the list
     // is not well defined (particularly when changing the filter text).
     ok(
       expectedTasks.every(task => actualTasks.includes(task)),
       "All expected tasks found"
     );
@@ -83,134 +90,135 @@ add_task(async () => {
     startsToday: await createTask("Starts today", { entryDate: today }),
     startsTomorrow: await createTask("Starts tomorrow", { entryDate: tomorrow }),
     startsLater: await createTask("Starts later", { entryDate: later }),
   };
 
   await openTasksTab();
 
   await setFilterGroup("all");
-  checkVisibleTasks(
+  await checkVisibleTasks(
     tasks.incomplete,
     tasks.started30,
     tasks.started60,
     tasks.complete,
     tasks.overdue,
     tasks.startsToday,
     tasks.startsTomorrow,
     tasks.startsLater
   );
 
   await setFilterGroup("open");
-  checkVisibleTasks(
+  await checkVisibleTasks(
     tasks.incomplete,
     tasks.started30,
     tasks.started60,
     tasks.overdue,
     tasks.startsToday,
     tasks.startsTomorrow,
     tasks.startsLater
   );
 
   await setFilterGroup("completed");
-  checkVisibleTasks(tasks.complete);
+  await checkVisibleTasks(tasks.complete);
 
   await setFilterGroup("overdue");
-  checkVisibleTasks(tasks.overdue);
+  await checkVisibleTasks(tasks.overdue);
 
   await setFilterGroup("notstarted");
-  checkVisibleTasks(tasks.overdue, tasks.incomplete, tasks.startsToday);
+  await checkVisibleTasks(tasks.overdue, tasks.incomplete, tasks.startsToday);
 
   await setFilterGroup("next7days");
-  checkVisibleTasks(
+  await checkVisibleTasks(
     tasks.overdue,
     tasks.incomplete,
     tasks.startsToday,
     tasks.started30,
     tasks.started60,
     tasks.complete,
     tasks.startsTomorrow
   );
 
   await setFilterGroup("today");
-  checkVisibleTasks(
+  await checkVisibleTasks(
     tasks.overdue,
     tasks.incomplete,
     tasks.startsToday,
     tasks.started30,
     tasks.started60,
     tasks.complete
   );
 
   await setFilterGroup("throughcurrent");
-  checkVisibleTasks(
+  await checkVisibleTasks(
     tasks.overdue,
     tasks.incomplete,
     tasks.startsToday,
     tasks.started30,
     tasks.started60,
     tasks.complete
   );
 
   await setFilterText("No matches");
-  checkVisibleTasks();
+  await checkVisibleTasks();
 
   await clearFilterText();
-  checkVisibleTasks(
+  await checkVisibleTasks(
     tasks.incomplete,
     tasks.started30,
     tasks.started60,
     tasks.complete,
     tasks.overdue,
     tasks.startsToday
   );
 
   await setFilterText("StArTeD");
-  checkVisibleTasks(tasks.started30, tasks.started60);
+  await checkVisibleTasks(tasks.started30, tasks.started60);
 
   await setFilterGroup("today");
   is(document.getElementById("task-text-filter-field").value, "StArTeD");
-  checkVisibleTasks(tasks.started30, tasks.started60);
+  await checkVisibleTasks(tasks.started30, tasks.started60);
 
   await setFilterGroup("next7days");
   is(document.getElementById("task-text-filter-field").value, "StArTeD");
-  checkVisibleTasks(tasks.started30, tasks.started60);
+  await checkVisibleTasks(tasks.started30, tasks.started60);
 
   await setFilterGroup("notstarted");
   is(document.getElementById("task-text-filter-field").value, "StArTeD");
-  checkVisibleTasks();
+  await checkVisibleTasks();
 
   await setFilterGroup("overdue");
   is(document.getElementById("task-text-filter-field").value, "StArTeD");
-  checkVisibleTasks();
+  await checkVisibleTasks();
 
   await setFilterGroup("completed");
   is(document.getElementById("task-text-filter-field").value, "StArTeD");
-  checkVisibleTasks();
+  await checkVisibleTasks();
 
   await setFilterGroup("open");
   is(document.getElementById("task-text-filter-field").value, "StArTeD");
-  checkVisibleTasks(tasks.started30, tasks.started60);
+  await checkVisibleTasks(tasks.started30, tasks.started60);
 
   await setFilterGroup("all");
   is(document.getElementById("task-text-filter-field").value, "StArTeD");
-  checkVisibleTasks(tasks.started30, tasks.started60);
+  await checkVisibleTasks(tasks.started30, tasks.started60);
 
   await clearFilterText();
-  checkVisibleTasks(
+  await checkVisibleTasks(
     tasks.started30,
     tasks.started60,
     tasks.incomplete,
     tasks.complete,
     tasks.overdue,
     tasks.startsToday,
     tasks.startsTomorrow,
     tasks.startsLater
   );
 
   for (let task of Object.values(tasks)) {
     await calendar.deleteItem(task);
   }
+  await setFilterGroup("throughcurrent");
 });
 
 registerCleanupFunction(() => {
   deleteCalendars(controller, CALENDARNAME);
 });