diff options
Diffstat (limited to 'comm/calendar/test/browser/views/browser_weekView.js')
-rw-r--r-- | comm/calendar/test/browser/views/browser_weekView.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/comm/calendar/test/browser/views/browser_weekView.js b/comm/calendar/test/browser/views/browser_weekView.js new file mode 100644 index 0000000000..0835da2f23 --- /dev/null +++ b/comm/calendar/test/browser/views/browser_weekView.js @@ -0,0 +1,81 @@ +/* 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/. */ + +var { formatDate, formatTime, saveAndCloseItemDialog, setData } = ChromeUtils.import( + "resource://testing-common/calendar/ItemEditingHelpers.jsm" +); + +var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm"); + +var TITLE1 = "Week View Event"; +var TITLE2 = "Week View Event Changed"; +var DESC = "Week View Event Description"; + +add_task(async function testWeekView() { + let calendar = CalendarTestUtils.createCalendar(); + registerCleanupFunction(() => { + CalendarTestUtils.removeCalendar(calendar); + }); + + await CalendarTestUtils.setCalendarView(window, "week"); + await CalendarTestUtils.goToDate(window, 2009, 1, 1); + + // Verify date. + await TestUtils.waitForCondition(() => { + let dateLabel = document.querySelector("#week-view .day-column-selected calendar-event-column"); + return dateLabel?.date.icalString == "20090101"; + }, "Date is selected"); + + // Create event at 8 AM. + // Thursday of 2009-01-05 is 4th with default settings. + let eventBox = CalendarTestUtils.weekView.getHourBoxAt(window, 5, 8); + let { dialogWindow, iframeWindow, iframeDocument } = await CalendarTestUtils.editNewEvent( + window, + eventBox + ); + + // Check that the start time is correct. + let someDate = cal.createDateTime(); + someDate.resetTo(2009, 0, 5, 8, 0, 0, cal.dtz.UTC); + + let startPicker = iframeDocument.getElementById("event-starttime"); + Assert.equal(startPicker._datepicker._inputField.value, formatDate(someDate)); + Assert.equal(startPicker._timepicker._inputField.value, formatTime(someDate)); + + // Fill in title, description and calendar. + await setData(dialogWindow, iframeWindow, { + title: TITLE1, + description: DESC, + calendar: "Test", + }); + + await saveAndCloseItemDialog(dialogWindow); + + // If it was created successfully, it can be opened. + ({ dialogWindow, iframeWindow } = await CalendarTestUtils.weekView.editEventAt(window, 5, 1)); + // Change title and save changes. + await setData(dialogWindow, iframeWindow, { title: TITLE2 }); + await saveAndCloseItemDialog(dialogWindow); + + // Check if name was saved. + let eventName; + await TestUtils.waitForCondition(() => { + eventBox = CalendarTestUtils.weekView.getEventBoxAt(window, 5, 1); + if (!eventBox) { + return false; + } + eventName = eventBox.querySelector(".event-name-label").textContent; + return eventName == TITLE2; + }, "event name did not update in time"); + + Assert.equal(eventName, TITLE2); + + // Delete event. + EventUtils.synthesizeMouseAtCenter(eventBox, {}, window); + eventBox.focus(); + EventUtils.synthesizeKey("VK_DELETE", {}, window); + await CalendarTestUtils.weekView.waitForNoEventBoxAt(window, 5, 1); + + Assert.ok(true, "Test ran to completion"); +}); |