Bug 1673654 - Open events in calendar summary dialog for today pane and unifinder. r=darktrojan

This commit is contained in:
Lasana Murray 2020-11-21 12:50:19 +02:00
Родитель 2883abc27b
Коммит aba17be84f
6 изменённых файлов: 181 добавлений и 2 удалений

Просмотреть файл

@ -222,7 +222,7 @@ agendaListbox.onKeyPress = function(aEvent) {
agendaListbox.editSelectedItem = function() { agendaListbox.editSelectedItem = function() {
let listItem = document.getElementById("agenda-listbox").selectedItem; let listItem = document.getElementById("agenda-listbox").selectedItem;
if (listItem) { if (listItem) {
modifyEventWithDialog(listItem.occurrence, true); openEventDialogForViewing(listItem.occurrence);
} }
}; };

Просмотреть файл

@ -313,7 +313,7 @@ function unifinderDoubleClick(event) {
let calendarEvent = unifinderTreeView.getItemFromEvent(event); let calendarEvent = unifinderTreeView.getItemFromEvent(event);
if (calendarEvent) { if (calendarEvent) {
modifyEventWithDialog(calendarEvent, true); openEventDialogForViewing(calendarEvent);
} else { } else {
createEventWithDialog(); createEventWithDialog();
} }

Просмотреть файл

@ -14,6 +14,7 @@ support-files = data/**
skip-if = os == 'win' # Bug 306495 skip-if = os == 'win' # Bug 306495
[browser_calendarList.js] [browser_calendarList.js]
[browser_calendarTelemetry.js] [browser_calendarTelemetry.js]
[browser_calendarUnifinder.js]
[browser_eventDisplay.js] [browser_eventDisplay.js]
[browser_import.js] [browser_import.js]
[browser_localICS.js] [browser_localICS.js]

Просмотреть файл

@ -0,0 +1,78 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const { mailTestUtils } = ChromeUtils.import(
"resource://testing-common/mailnews/MailTestUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
CalEvent: "resource:///modules/CalEvent.jsm",
CalRecurrenceInfo: "resource:///modules/CalRecurrenceInfo.jsm",
});
/**
* Tests clicking on events opens in the summary dialog for both
* non-recurring and recurring events.
*/
add_task(async function testOpenEvent() {
let uri = Services.io.newURI("moz-memory-calendar://");
let manager = cal.getCalendarManager();
let calendar = manager.createCalendar("memory", uri);
let calendarProxy = cal.async.promisifyCalendar(calendar);
calendar.name = "Unifinder Test";
manager.registerCalendar(calendar);
registerCleanupFunction(() => manager.removeCalendar(calendar));
let now = cal.dtz.now();
let noRepeatEvent = new CalEvent();
noRepeatEvent.id = "no repeat event";
noRepeatEvent.title = "No Repeat Event";
noRepeatEvent.startDate = now;
noRepeatEvent.endDate = noRepeatEvent.startDate.clone();
noRepeatEvent.endDate.hour++;
let repeatEvent = new CalEvent();
repeatEvent.id = "repeated event";
repeatEvent.title = "Repeat Event";
repeatEvent.startDate = now;
repeatEvent.endDate = noRepeatEvent.startDate.clone();
repeatEvent.endDate.hour++;
repeatEvent.recurrenceInfo = new CalRecurrenceInfo(repeatEvent);
repeatEvent.recurrenceInfo.appendRecurrenceItem(
cal.createRecurrenceRule("RRULE:FREQ=DAILY;COUNT=30")
);
await CalendarTestUtils.openCalendarTab(window);
if (window.isUnifinderHidden()) {
window.toggleUnifinder();
await BrowserTestUtils.waitForCondition(
() => window.isUnifinderHidden(),
"calendar unifinder is open"
);
}
for (let event of [noRepeatEvent, repeatEvent]) {
await calendarProxy.addItem(event);
let dialogWindowPromise = CalendarTestUtils.waitForEventDialog();
let tree = document.querySelector("#unifinder-search-results-tree");
mailTestUtils.treeClick(EventUtils, window, tree, 0, 1, { clickCount: 2 });
let dialogWindow = await dialogWindowPromise;
let docUri = dialogWindow.document.documentURI;
Assert.ok(
docUri === "chrome://calendar/content/calendar-summary-dialog.xhtml",
"event summary dialog did show"
);
await BrowserTestUtils.closeWindow(dialogWindow);
await calendarProxy.deleteItem(event);
}
});

Просмотреть файл

@ -9,6 +9,7 @@ var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm")
XPCOMUtils.defineLazyModuleGetters(this, { XPCOMUtils.defineLazyModuleGetters(this, {
CalEvent: "resource:///modules/CalEvent.jsm", CalEvent: "resource:///modules/CalEvent.jsm",
CalRecurrenceInfo: "resource:///modules/CalRecurrenceInfo.jsm",
}); });
add_task(async function testTodayPane() { add_task(async function testTodayPane() {
@ -157,3 +158,80 @@ add_task(async function testTodayPane() {
Assert.ok(!header.getAttribute("checked")); Assert.ok(!header.getAttribute("checked"));
} }
}); });
/**
* Tests the today pane opens events in the summary dialog for both
* non-recurring and recurring events.
*/
add_task(async function testOpenEvent() {
let now = cal.dtz.now();
let uri = Services.io.newURI("moz-memory-calendar://");
let manager = cal.getCalendarManager();
let calendar = manager.createCalendar("memory", uri);
let calendarProxy = cal.async.promisifyCalendar(calendar);
calendar.name = "TestOpenEvent";
manager.registerCalendar(calendar);
registerCleanupFunction(() => manager.removeCalendar(calendar));
// Let the UI respond to the registration of the calendar.
await new Promise(resolve => setTimeout(resolve));
await new Promise(resolve => setTimeout(resolve));
let todayPanePanel = document.querySelector("#today-pane-panel");
let todayPaneBtn = document.querySelector("#calendar-status-todaypane-button");
// Go to mail tab.
selectFolderTab();
// Verify today pane open.
if (todayPanePanel.hasAttribute("collapsed")) {
EventUtils.synthesizeMouseAtCenter(todayPaneBtn, {});
}
Assert.ok(!todayPanePanel.hasAttribute("collapsed"));
let noRepeatEvent = new CalEvent();
noRepeatEvent.id = "no repeat event";
noRepeatEvent.title = "No Repeat Event";
noRepeatEvent.startDate = now.clone();
noRepeatEvent.endDate = noRepeatEvent.startDate.clone();
noRepeatEvent.endDate.hour++;
let repeatEvent = new CalEvent();
repeatEvent.id = "repeated event";
repeatEvent.title = "Repeated Event";
repeatEvent.startDate = now.clone();
repeatEvent.endDate = noRepeatEvent.startDate.clone();
repeatEvent.endDate.hour++;
repeatEvent.recurrenceInfo = new CalRecurrenceInfo(repeatEvent);
repeatEvent.recurrenceInfo.appendRecurrenceItem(
cal.createRecurrenceRule("RRULE:FREQ=DAILY;COUNT=5")
);
for (let event of [noRepeatEvent, repeatEvent]) {
await calendarProxy.addItem(event);
// Let the UI respond to the new events.
await new Promise(resolve => setTimeout(resolve));
await new Promise(resolve => setTimeout(resolve));
let listBox = agendaListbox.agendaListboxControl;
let richlistitem = listBox.querySelector("#today-header + richlistitem");
Assert.ok(richlistitem.textContent.includes(event.title), "event title is correct");
let dialogWindowPromise = CalendarTestUtils.waitForEventDialog();
EventUtils.synthesizeMouseAtCenter(richlistitem, { clickCount: 2 });
let dialogWindow = await dialogWindowPromise;
let docUri = dialogWindow.document.documentURI;
Assert.ok(
docUri === "chrome://calendar/content/calendar-summary-dialog.xhtml",
"event summary dialog shown"
);
await BrowserTestUtils.closeWindow(dialogWindow);
await calendarProxy.deleteItem(event);
}
});

Просмотреть файл

@ -7,6 +7,7 @@
const EXPORTED_SYMBOLS = ["CalendarTestUtils"]; const EXPORTED_SYMBOLS = ["CalendarTestUtils"];
const EventUtils = ChromeUtils.import("resource://testing-common/mozmill/EventUtils.jsm"); const EventUtils = ChromeUtils.import("resource://testing-common/mozmill/EventUtils.jsm");
const { BrowserTestUtils } = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
const { Assert } = ChromeUtils.import("resource://testing-common/Assert.jsm"); const { Assert } = ChromeUtils.import("resource://testing-common/Assert.jsm");
/** /**
@ -116,4 +117,25 @@ const CalendarTestUtils = {
await new Promise(resolve => win.setTimeout(resolve)); await new Promise(resolve => win.setTimeout(resolve));
}, },
/**
* This produces a Promise for waiting on an event dialog to open.
* The mode parameter can be specified to indicate which of the dialogs to
* wait for.
*
* @param {string} [mode="view"] Can be "view" or "edit".
*
* @returns {Promise<Window>}
*/
waitForEventDialog(mode = "view") {
let uri =
mode === "edit"
? "chrome://calendar/content/calendar-event-dialog.xhtml"
: "chrome://calendar/content/calendar-summary-dialog.xhtml";
return BrowserTestUtils.domWindowOpened(null, async win => {
await BrowserTestUtils.waitForEvent(win, "load");
return win.document.documentURI == uri;
});
},
}; };