diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/calendar/test/browser/eventDialog/browser_attendeesDialogNoEdit.js | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'comm/calendar/test/browser/eventDialog/browser_attendeesDialogNoEdit.js')
-rw-r--r-- | comm/calendar/test/browser/eventDialog/browser_attendeesDialogNoEdit.js | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/comm/calendar/test/browser/eventDialog/browser_attendeesDialogNoEdit.js b/comm/calendar/test/browser/eventDialog/browser_attendeesDialogNoEdit.js new file mode 100644 index 0000000000..a103173790 --- /dev/null +++ b/comm/calendar/test/browser/eventDialog/browser_attendeesDialogNoEdit.js @@ -0,0 +1,68 @@ +/* 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/. */ + +/* globals openAttendeesWindow, closeAttendeesWindow, findAndFocusMatchingRow */ + +const { CalEvent } = ChromeUtils.import("resource:///modules/CalEvent.jsm"); + +add_setup(async function () { + await CalendarTestUtils.setCalendarView(window, "day"); + CalendarTestUtils.goToDate(window, 2023, 2, 18); +}); + +add_task(async function testBackingOutWithNoAttendees() { + const calendar = CalendarTestUtils.createCalendar(); + calendar.setProperty("organizerId", "mailto:foo@example.com"); + calendar.setProperty("organizerCN", "Foo Fooson"); + + // Create an event which currently has no attendees or organizer. + const event = await calendar.addItem( + new CalEvent(CalendarTestUtils.dedent` + BEGIN:VEVENT + SUMMARY:An event + DTSTART:20230218T100000Z + DTEND:20230218T110000Z + END:VEVENT + `) + ); + + // Remember event details so we can refetch it after editing. + const eventId = event.id; + const eventModified = event.lastModifiedTime; + + // Sanity check. + Assert.equal(event.organizer, null, "event should not have an organizer"); + Assert.equal(event.getAttendees().length, 0, "event should not have any attendees"); + + // Open our event for editing. + const { dialogWindow: eventWindow } = await CalendarTestUtils.dayView.editEventAt(window, 1); + const attendeesWindow = await openAttendeesWindow(eventWindow); + + findAndFocusMatchingRow(attendeesWindow, "there should be a row matching the organizer", value => + value.includes(calendar.getProperty("organizerCN")) + ); + + // We changed our mind. Save and close the event. + await closeAttendeesWindow(attendeesWindow); + await CalendarTestUtils.items.saveAndCloseItemDialog(eventWindow); + + // The event is still counted as modified even with no changes. If this + // changes in the future, we'll just need to wait a reasonable time and fetch + // the event again. + await TestUtils.waitForCondition(async () => { + const item = await calendar.getItem(eventId); + return item.lastModifiedTime != eventModified; + }); + + const editedEvent = await calendar.getItem(eventId); + + // Verify that the organizer was set on the event. + const organizer = editedEvent.organizer; + Assert.ok(!organizer, "there should still be no organizer for the event"); + + const attendees = editedEvent.getAttendees(); + Assert.equal(attendees.length, 0, "there should still be no attendees of the event"); + + CalendarTestUtils.removeCalendar(calendar); +}); |