2026-10-07 12:26:02 +01:00
|
|
|
|
using Yavsc.Abstract.Identity;
|
2026-09-11 12:45:13 +01:00
|
|
|
|
using PostIt.ViewModels;
|
|
|
|
|
|
|
|
|
|
|
|
namespace PostIt.Tests;
|
|
|
|
|
|
|
|
|
|
|
|
public class HomePageProviderFlowTests
|
|
|
|
|
|
{
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void HomePage_exposes_provider_requests_command()
|
|
|
|
|
|
{
|
|
|
|
|
|
var vm = new HomePageViewModel();
|
|
|
|
|
|
|
|
|
|
|
|
Assert.NotNull(vm.OpenProviderRequests);
|
|
|
|
|
|
Assert.True(vm.OpenProviderRequests.CanExecute(null));
|
|
|
|
|
|
}
|
2026-10-07 12:20:26 +01:00
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void HomePage_exposes_profile_command()
|
|
|
|
|
|
{
|
|
|
|
|
|
var vm = new HomePageViewModel();
|
|
|
|
|
|
|
|
|
|
|
|
Assert.NotNull(vm.OpenProfile);
|
|
|
|
|
|
Assert.True(vm.OpenProfile.CanExecute(null));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void HomePage_exposes_performer_configuration_command()
|
|
|
|
|
|
{
|
|
|
|
|
|
var vm = new HomePageViewModel();
|
|
|
|
|
|
|
|
|
|
|
|
Assert.NotNull(vm.OpenPerformerConfiguration);
|
|
|
|
|
|
Assert.True(vm.OpenPerformerConfiguration.CanExecute(null));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void HomePage_exposes_administration_command()
|
|
|
|
|
|
{
|
|
|
|
|
|
var vm = new HomePageViewModel();
|
|
|
|
|
|
|
|
|
|
|
|
Assert.NotNull(vm.OpenAdministration);
|
|
|
|
|
|
Assert.True(vm.OpenAdministration.CanExecute(null));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void Administration_page_filters_users_by_search_text()
|
|
|
|
|
|
{
|
|
|
|
|
|
var vm = new AdministrationPageViewModel();
|
2026-10-07 12:29:16 +01:00
|
|
|
|
vm.Users.Add(new Yavsc.Abstract.Identity.UserInfo { UserId = "1", UserName = "alice", FullName = "Alice Example" });
|
|
|
|
|
|
vm.Users.Add(new Yavsc.Abstract.Identity.UserInfo { UserId = "2", UserName = "bob", FullName = "Bob Jones" });
|
|
|
|
|
|
vm.Users.Add(new Yavsc.Abstract.Identity.UserInfo { UserId = "3", UserName = "carol", FullName = "Carol Smith" });
|
2026-10-07 12:20:26 +01:00
|
|
|
|
|
|
|
|
|
|
vm.SearchText = "ali";
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Single(vm.FilteredUsers);
|
|
|
|
|
|
Assert.Equal("alice", vm.FilteredUsers[0].UserName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-07 12:29:16 +01:00
|
|
|
|
[Fact]
|
|
|
|
|
|
public void Administration_page_filters_users_by_full_name()
|
|
|
|
|
|
{
|
|
|
|
|
|
var vm = new AdministrationPageViewModel();
|
|
|
|
|
|
vm.Users.Add(new Yavsc.Abstract.Identity.UserInfo { UserId = "1", UserName = "alice", FullName = "Alice Example" });
|
|
|
|
|
|
vm.Users.Add(new Yavsc.Abstract.Identity.UserInfo { UserId = "2", UserName = "bob", FullName = "Bob Jones" });
|
|
|
|
|
|
|
|
|
|
|
|
vm.SearchText = "example";
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Single(vm.FilteredUsers);
|
|
|
|
|
|
Assert.Equal("alice", vm.FilteredUsers[0].UserName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-07 12:20:26 +01:00
|
|
|
|
[Fact]
|
|
|
|
|
|
public void UserProfilePage_exposes_full_name_and_address_fields()
|
|
|
|
|
|
{
|
|
|
|
|
|
var vm = new UserProfilePageViewModel();
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal("—", vm.FullName);
|
|
|
|
|
|
Assert.Equal("—", vm.Address);
|
2026-10-07 12:22:49 +01:00
|
|
|
|
Assert.Equal("Non configuré", vm.DedicatedGoogleCalendar);
|
|
|
|
|
|
Assert.Equal("Aucune information bancaire", vm.BankInfoSummary);
|
2026-10-07 12:20:26 +01:00
|
|
|
|
Assert.NotNull(vm.RefreshCommand);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-07 12:26:02 +01:00
|
|
|
|
[Fact]
|
|
|
|
|
|
public void ProfileUpdateRequest_allows_username_updates()
|
|
|
|
|
|
{
|
|
|
|
|
|
var request = new ProfileUpdateRequest
|
|
|
|
|
|
{
|
|
|
|
|
|
UserName = "alice.new"
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal("alice.new", request.UserName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-07 12:20:26 +01:00
|
|
|
|
[Fact]
|
|
|
|
|
|
public void UserProfilePage_can_save_profile_values()
|
|
|
|
|
|
{
|
|
|
|
|
|
var vm = new UserProfilePageViewModel
|
|
|
|
|
|
{
|
2026-10-07 12:26:02 +01:00
|
|
|
|
UserName = "alice.new",
|
2026-10-07 12:20:26 +01:00
|
|
|
|
FullName = "Alice Example",
|
2026-10-07 12:22:49 +01:00
|
|
|
|
Address = "14 rue de l’Érable",
|
|
|
|
|
|
DedicatedGoogleCalendar = "calendar-123",
|
|
|
|
|
|
BankInfoSummary = "FR14 2004 1010 0505 0001 3M02 606"
|
2026-10-07 12:20:26 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Assert.NotNull(vm.SaveProfileCommand);
|
|
|
|
|
|
Assert.True(vm.SaveProfileCommand.CanExecute(null));
|
|
|
|
|
|
}
|
2026-10-07 12:32:17 +01:00
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void UserProfilePage_builds_profile_payload_for_calendar_and_bank_values()
|
|
|
|
|
|
{
|
|
|
|
|
|
var vm = new UserProfilePageViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
UserName = "alice.new",
|
|
|
|
|
|
FullName = "Alice Example",
|
|
|
|
|
|
Address = "14 rue de l’Érable",
|
|
|
|
|
|
DedicatedGoogleCalendar = "calendar-123",
|
|
|
|
|
|
BankInfoSummary = "FR14 2004 1010 0505 0001 3M02 606"
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var payload = vm.BuildProfileUpdateRequest();
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal("alice.new", payload.UserName);
|
|
|
|
|
|
Assert.Equal("calendar-123", payload.GoogleCalendarId);
|
|
|
|
|
|
Assert.Equal("FR14 2004 1010 0505 0001 3M02 606", payload.BankInfoSummary);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void UserProfilePage_turns_placeholder_values_into_empty_payload_fields()
|
|
|
|
|
|
{
|
|
|
|
|
|
var vm = new UserProfilePageViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
UserName = "alice.new",
|
|
|
|
|
|
FullName = "Alice Example",
|
|
|
|
|
|
Address = "14 rue de l’Érable",
|
|
|
|
|
|
DedicatedGoogleCalendar = "Non configuré",
|
|
|
|
|
|
BankInfoSummary = "Aucune information bancaire"
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var payload = vm.BuildProfileUpdateRequest();
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal(string.Empty, payload.GoogleCalendarId);
|
|
|
|
|
|
Assert.Equal(string.Empty, payload.BankInfoSummary);
|
|
|
|
|
|
}
|
2026-10-07 12:35:09 +01:00
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void PerformerConfigurationPage_preserves_current_user_id_in_save_payload()
|
|
|
|
|
|
{
|
|
|
|
|
|
var vm = new PerformerConfigurationPageViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
PerformerId = "user-42",
|
|
|
|
|
|
UserName = "alice",
|
|
|
|
|
|
ExerciseCountryCode = "fr",
|
|
|
|
|
|
SIREN = "123456789",
|
|
|
|
|
|
Website = "https://example.com",
|
|
|
|
|
|
Active = true,
|
|
|
|
|
|
AcceptNotifications = true,
|
|
|
|
|
|
AcceptPublicContact = true,
|
|
|
|
|
|
UseGeoLocalizationToReduceDistanceWithClients = true
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var payload = vm.BuildPerformerProfileSettings();
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal("user-42", payload.PerformerId);
|
|
|
|
|
|
Assert.Equal("alice", payload.UserName);
|
|
|
|
|
|
Assert.Equal("fr", payload.ExerciseCountryCode);
|
|
|
|
|
|
}
|
2026-09-11 12:45:13 +01:00
|
|
|
|
}
|