Bug 1593711 - Test task filtering with repeating tasks. r=pmorris
--HG-- extra : rebase_source : 2be313a1708c76edb0d739abb4c2e6a5709a2044 extra : histedit_source : 616bb1ada2a573f95f1a4516b2ec56cdaac757d4
This commit is contained in:
Родитель
d3ed88b5fe
Коммит
f27e8d93c7
|
@ -43,37 +43,52 @@ add_task(async () => {
|
|||
async function setFilterText(text) {
|
||||
EventUtils.synthesizeMouseAtCenter(document.getElementById("task-text-filter-field"), {});
|
||||
EventUtils.sendString(text);
|
||||
Assert.equal(document.getElementById("task-text-filter-field").value, text, "Filter text set");
|
||||
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");
|
||||
Assert.equal(
|
||||
document.getElementById("task-text-filter-field").value,
|
||||
"",
|
||||
"Filter text cleared"
|
||||
);
|
||||
await treeRefresh();
|
||||
}
|
||||
|
||||
async function checkVisibleTasks(...expectedTasks) {
|
||||
function toPrettyString(task) {
|
||||
if (task.recurrenceId) {
|
||||
return `${task.title}#${task.recurrenceId}`;
|
||||
}
|
||||
return task.title;
|
||||
}
|
||||
|
||||
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(", "));
|
||||
info("Expected: " + expectedTasks.map(toPrettyString).join(", "));
|
||||
info("Actual: " + actualTasks.map(toPrettyString).join(", "));
|
||||
|
||||
is(tree.view.rowCount, expectedTasks.length, "Correct number of tasks");
|
||||
Assert.equal(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"
|
||||
);
|
||||
for (let aTask of actualTasks) {
|
||||
Assert.ok(
|
||||
expectedTasks.some(eTask => eTask.hasSameIds(aTask)),
|
||||
toPrettyString(aTask)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let today = cal.dtz.now();
|
||||
today.hour = today.minute = today.second = 0;
|
||||
let yesterday = today.clone();
|
||||
yesterday.addDuration(cal.createDuration("-P1D"));
|
||||
let tomorrow = today.clone();
|
||||
|
@ -92,6 +107,24 @@ add_task(async () => {
|
|||
startsLater: await createTask("Starts later", { entryDate: later }),
|
||||
};
|
||||
|
||||
let repeatingTask = cal.createTodo();
|
||||
repeatingTask.title = "Repeating";
|
||||
repeatingTask.entryDate = yesterday;
|
||||
repeatingTask.recurrenceInfo = cal.createRecurrenceInfo(repeatingTask);
|
||||
repeatingTask.recurrenceInfo.appendRecurrenceItem(
|
||||
cal.createRecurrenceRule("RRULE:FREQ=DAILY;COUNT=3")
|
||||
);
|
||||
|
||||
let firstOccurrence = repeatingTask.recurrenceInfo.getOccurrenceFor(yesterday);
|
||||
firstOccurrence.isCompleted = true;
|
||||
firstOccurrence.completedDate = yesterday;
|
||||
repeatingTask.recurrenceInfo.modifyException(firstOccurrence, true);
|
||||
|
||||
repeatingTask = await calendar.addItem(repeatingTask);
|
||||
|
||||
let occurrences = repeatingTask.recurrenceInfo.getOccurrences(yesterday, later, 10);
|
||||
Assert.equal(occurrences.length, 3);
|
||||
|
||||
await openTasksTab();
|
||||
|
||||
await setFilterGroup("all");
|
||||
|
@ -103,7 +136,8 @@ add_task(async () => {
|
|||
tasks.overdue,
|
||||
tasks.startsToday,
|
||||
tasks.startsTomorrow,
|
||||
tasks.startsLater
|
||||
tasks.startsLater,
|
||||
repeatingTask
|
||||
);
|
||||
|
||||
await setFilterGroup("open");
|
||||
|
@ -114,17 +148,19 @@ add_task(async () => {
|
|||
tasks.overdue,
|
||||
tasks.startsToday,
|
||||
tasks.startsTomorrow,
|
||||
tasks.startsLater
|
||||
tasks.startsLater,
|
||||
occurrences[1],
|
||||
occurrences[2]
|
||||
);
|
||||
|
||||
await setFilterGroup("completed");
|
||||
await checkVisibleTasks(tasks.complete);
|
||||
await checkVisibleTasks(tasks.complete, occurrences[0]);
|
||||
|
||||
await setFilterGroup("overdue");
|
||||
await checkVisibleTasks(tasks.overdue);
|
||||
|
||||
await setFilterGroup("notstarted");
|
||||
await checkVisibleTasks(tasks.overdue, tasks.incomplete, tasks.startsToday);
|
||||
await checkVisibleTasks(tasks.overdue, tasks.incomplete, tasks.startsToday, occurrences[1]);
|
||||
|
||||
await setFilterGroup("next7days");
|
||||
await checkVisibleTasks(
|
||||
|
@ -134,7 +170,9 @@ add_task(async () => {
|
|||
tasks.started30,
|
||||
tasks.started60,
|
||||
tasks.complete,
|
||||
tasks.startsTomorrow
|
||||
tasks.startsTomorrow,
|
||||
occurrences[1],
|
||||
occurrences[2]
|
||||
);
|
||||
|
||||
await setFilterGroup("today");
|
||||
|
@ -144,7 +182,8 @@ add_task(async () => {
|
|||
tasks.startsToday,
|
||||
tasks.started30,
|
||||
tasks.started60,
|
||||
tasks.complete
|
||||
tasks.complete,
|
||||
occurrences[1]
|
||||
);
|
||||
|
||||
await setFilterGroup("throughcurrent");
|
||||
|
@ -154,7 +193,8 @@ add_task(async () => {
|
|||
tasks.startsToday,
|
||||
tasks.started30,
|
||||
tasks.started60,
|
||||
tasks.complete
|
||||
tasks.complete,
|
||||
occurrences[1]
|
||||
);
|
||||
|
||||
await setFilterText("No matches");
|
||||
|
@ -167,38 +207,39 @@ add_task(async () => {
|
|||
tasks.started60,
|
||||
tasks.complete,
|
||||
tasks.overdue,
|
||||
tasks.startsToday
|
||||
tasks.startsToday,
|
||||
occurrences[1]
|
||||
);
|
||||
|
||||
await setFilterText("StArTeD");
|
||||
await checkVisibleTasks(tasks.started30, tasks.started60);
|
||||
|
||||
await setFilterGroup("today");
|
||||
is(document.getElementById("task-text-filter-field").value, "StArTeD");
|
||||
Assert.equal(document.getElementById("task-text-filter-field").value, "StArTeD");
|
||||
await checkVisibleTasks(tasks.started30, tasks.started60);
|
||||
|
||||
await setFilterGroup("next7days");
|
||||
is(document.getElementById("task-text-filter-field").value, "StArTeD");
|
||||
Assert.equal(document.getElementById("task-text-filter-field").value, "StArTeD");
|
||||
await checkVisibleTasks(tasks.started30, tasks.started60);
|
||||
|
||||
await setFilterGroup("notstarted");
|
||||
is(document.getElementById("task-text-filter-field").value, "StArTeD");
|
||||
Assert.equal(document.getElementById("task-text-filter-field").value, "StArTeD");
|
||||
await checkVisibleTasks();
|
||||
|
||||
await setFilterGroup("overdue");
|
||||
is(document.getElementById("task-text-filter-field").value, "StArTeD");
|
||||
Assert.equal(document.getElementById("task-text-filter-field").value, "StArTeD");
|
||||
await checkVisibleTasks();
|
||||
|
||||
await setFilterGroup("completed");
|
||||
is(document.getElementById("task-text-filter-field").value, "StArTeD");
|
||||
Assert.equal(document.getElementById("task-text-filter-field").value, "StArTeD");
|
||||
await checkVisibleTasks();
|
||||
|
||||
await setFilterGroup("open");
|
||||
is(document.getElementById("task-text-filter-field").value, "StArTeD");
|
||||
Assert.equal(document.getElementById("task-text-filter-field").value, "StArTeD");
|
||||
await checkVisibleTasks(tasks.started30, tasks.started60);
|
||||
|
||||
await setFilterGroup("all");
|
||||
is(document.getElementById("task-text-filter-field").value, "StArTeD");
|
||||
Assert.equal(document.getElementById("task-text-filter-field").value, "StArTeD");
|
||||
await checkVisibleTasks(tasks.started30, tasks.started60);
|
||||
|
||||
await clearFilterText();
|
||||
|
@ -210,7 +251,8 @@ add_task(async () => {
|
|||
tasks.overdue,
|
||||
tasks.startsToday,
|
||||
tasks.startsTomorrow,
|
||||
tasks.startsLater
|
||||
tasks.startsLater,
|
||||
repeatingTask
|
||||
);
|
||||
|
||||
for (let task of Object.values(tasks)) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче