Calendar item context flyout implementation
This commit is contained in:
@@ -18,6 +18,7 @@ using Wino.Core.Domain.Models.Calendar;
|
||||
using Wino.Core.Domain.Models.Navigation;
|
||||
using Wino.Messaging.Client.Calendar;
|
||||
using Xunit;
|
||||
using Wino.Calendar.ViewModels.Messages;
|
||||
|
||||
namespace Wino.Core.Tests;
|
||||
|
||||
@@ -311,6 +312,22 @@ public class CalendarPageViewModelTests
|
||||
accountCalendarViewModel.MailAccount.Should().BeSameAs(account);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReceiveCalendarItemRightTappedMessage_SelectsItemForDetails()
|
||||
{
|
||||
var settings = CreateSettings();
|
||||
var preferencesService = CreatePreferencesService(settings);
|
||||
var calendarService = new Mock<ICalendarService>();
|
||||
var calendar = CreateCalendar(CreateAccount(), "Calendar");
|
||||
var itemViewModel = new CalendarItemViewModel(CreateCalendarItem(calendar.Id, new DateTime(2026, 3, 20, 9, 0, 0), "Tapped"));
|
||||
|
||||
var viewModel = CreateViewModel(calendarService.Object, preferencesService.Object, new DateOnly(2026, 3, 20));
|
||||
|
||||
viewModel.Receive(new CalendarItemRightTappedMessage(itemViewModel));
|
||||
|
||||
viewModel.DisplayDetailsCalendarItemViewModel.Should().BeSameAs(itemViewModel);
|
||||
}
|
||||
|
||||
private static CalendarPageViewModel CreateViewModel(
|
||||
ICalendarService calendarService,
|
||||
IPreferencesService preferencesService,
|
||||
@@ -330,6 +347,17 @@ public class CalendarPageViewModelTests
|
||||
IPreferencesService preferencesService,
|
||||
DateOnly today,
|
||||
IAccountCalendarStateService accountCalendarStateService)
|
||||
=> CreateViewModel(calendarService, preferencesService, today, accountCalendarStateService, navigationService: Mock.Of<INavigationService>());
|
||||
|
||||
private static CalendarPageViewModel CreateViewModel(
|
||||
ICalendarService calendarService,
|
||||
IPreferencesService preferencesService,
|
||||
DateOnly today,
|
||||
IAccountCalendarStateService accountCalendarStateService,
|
||||
INavigationService? navigationService = null,
|
||||
INativeAppService? nativeAppService = null,
|
||||
IWinoRequestDelegator? requestDelegator = null,
|
||||
IMailDialogService? dialogService = null)
|
||||
{
|
||||
var statePersistenceService = new Mock<IStatePersistanceService>();
|
||||
statePersistenceService.SetupAllProperties();
|
||||
@@ -339,13 +367,13 @@ public class CalendarPageViewModelTests
|
||||
return new CalendarPageViewModel(
|
||||
statePersistenceService.Object,
|
||||
calendarService,
|
||||
Mock.Of<INavigationService>(),
|
||||
navigationService ?? Mock.Of<INavigationService>(),
|
||||
Mock.Of<IKeyPressService>(),
|
||||
Mock.Of<INativeAppService>(),
|
||||
nativeAppService ?? Mock.Of<INativeAppService>(),
|
||||
accountCalendarStateService,
|
||||
preferencesService,
|
||||
Mock.Of<IWinoRequestDelegator>(),
|
||||
Mock.Of<IMailDialogService>(),
|
||||
requestDelegator ?? Mock.Of<IWinoRequestDelegator>(),
|
||||
dialogService ?? Mock.Of<IMailDialogService>(),
|
||||
new TestDateContextProvider("en-US", today),
|
||||
new CalendarRangeTextFormatter());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Wino.Core.Domain.Entities.Calendar;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Services;
|
||||
using Xunit;
|
||||
|
||||
namespace Wino.Core.Tests.Services;
|
||||
|
||||
public class CalendarContextMenuItemServiceTests
|
||||
{
|
||||
private readonly CalendarContextMenuItemService _service = new();
|
||||
|
||||
[Fact]
|
||||
public void GetContextMenuItems_ForEditableSingleEvent_ReturnsOpenShowAsAndDeleteAsPrimary()
|
||||
{
|
||||
var calendarItem = new CalendarItem
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Title = "Editable single event",
|
||||
ShowAs = CalendarItemShowAs.Busy
|
||||
};
|
||||
|
||||
var items = _service.GetContextMenuItems(calendarItem);
|
||||
|
||||
items.Should().HaveCount(3);
|
||||
items.Should().ContainSingle(item => item.Action.ActionType == CalendarContextMenuActionType.Open && item.IsPrimary);
|
||||
items.Should().ContainSingle(item => item.Action.ActionType == CalendarContextMenuActionType.ShowAs && item.IsPrimary);
|
||||
items.Should().ContainSingle(item => item.Action.ActionType == CalendarContextMenuActionType.Delete && item.IsPrimary);
|
||||
items.Should().NotContain(item => item.Action.ActionType == CalendarContextMenuActionType.Respond);
|
||||
|
||||
var showAsItem = items.Single(item => item.Action.ActionType == CalendarContextMenuActionType.ShowAs);
|
||||
showAsItem.Children.Should().HaveCount(5);
|
||||
showAsItem.Children.Select(child => child.Action.ShowAs).Should().BeEquivalentTo(
|
||||
[
|
||||
CalendarItemShowAs.Free,
|
||||
CalendarItemShowAs.Tentative,
|
||||
CalendarItemShowAs.Busy,
|
||||
CalendarItemShowAs.OutOfOffice,
|
||||
CalendarItemShowAs.WorkingElsewhere
|
||||
]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetContextMenuItems_ForLockedRecurringChild_ReturnsRespondDeleteViewSeriesAndJoinOnline()
|
||||
{
|
||||
var calendarItem = new CalendarItem
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Title = "Recurring invite",
|
||||
IsLocked = true,
|
||||
RecurringCalendarItemId = Guid.NewGuid(),
|
||||
HtmlLink = "https://contoso.example/meeting"
|
||||
};
|
||||
|
||||
var items = _service.GetContextMenuItems(calendarItem);
|
||||
|
||||
items.Should().ContainSingle(item => item.Action.ActionType == CalendarContextMenuActionType.Open && item.IsPrimary);
|
||||
items.Should().ContainSingle(item => item.Action.ActionType == CalendarContextMenuActionType.Respond && item.IsPrimary);
|
||||
items.Should().ContainSingle(item => item.Action.ActionType == CalendarContextMenuActionType.Delete && item.IsPrimary);
|
||||
items.Should().ContainSingle(item => item.Action.ActionType == CalendarContextMenuActionType.Open && item.Action.TargetType == CalendarEventTargetType.Series && !item.IsPrimary);
|
||||
items.Should().ContainSingle(item => item.Action.ActionType == CalendarContextMenuActionType.JoinOnline && !item.IsPrimary);
|
||||
|
||||
var respondItem = items.Single(item => item.Action.ActionType == CalendarContextMenuActionType.Respond);
|
||||
respondItem.Children.Should().HaveCount(2);
|
||||
respondItem.Children.Select(child => child.Action.TargetType).Should().BeEquivalentTo([CalendarEventTargetType.Single, CalendarEventTargetType.Series]);
|
||||
respondItem.Children.Should().OnlyContain(child => child.Children.Count == 3);
|
||||
|
||||
var deleteItem = items.Single(item => item.Action.ActionType == CalendarContextMenuActionType.Delete);
|
||||
deleteItem.Children.Select(child => child.Action.TargetType).Should().BeEquivalentTo([CalendarEventTargetType.Single, CalendarEventTargetType.Series]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user