diff --git a/CHANGELOG.md b/CHANGELOG.md index 04d0e3902..6aa88a585 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,22 @@ ### Added +* [Yavsc.Api] Preserve `application/problem+json` for resource-usage relief errors instead of overriding it with a JSON-only Produces attribute; document success/error media types in OpenAPI and verify error payloads. Restore the haircut and grouped-haircut commands removed from the test seed while retaining its three catalog prestations, with repeated-reset coverage. + +* [Yavsc.Api/Tests] Reset the anchored shared SQLite in-memory database by dropping and recreating its tables before seeding, avoiding duplicate user emails across tests. Restore foreign-key enforcement after cleanup and cover repeated resets with a regression test; leave PostgreSQL cleanup unchanged. + +* [Yavsc/Tests] Apply the class-level `Category=non-reg` trait to all test classes in Yavsc.Org.Tests, Yavsc.Api.Tests, Yavsc.Blogs.Tests and Yavsc.Server.Tests, including inherited tests, while preserving existing traits. Remove the empty Services class. + +* [PostIt/Tests] Add an xUnit collection fixture owning a headless UI session and its thread, with shared window creation, layout, closing and binding cleanup even after failures. Migrate the subscription page binding test as a pilot; retain per-dispatch application isolation and the parallelism guard during coexistence with legacy headless tests. + +* [PostIt/Tests] Disable parallel execution of test collections sharing the Avalonia runtime and static platform state, preventing cross-thread headless initialization and test-case cleanup failures when UI and ordinary tests run together. + +* [PostIt/Calls] Move WebRTC and direct SRTP controls out of the text chat into a dedicated call page, opened for a selected room member or an incoming invitation. Include resolved room-member names in chat snapshots for call targeting, without replacing internal connection identifiers. Preserve the call when leaving the chat for that page and hang up when leaving the call page. + +* [PostIt/Contacts] Add a Contacts page listing circle members and their associated circles, with duplicate members merged. Presence and calling contacts outside a shared chat room are not yet implemented. + +* [PostIt/Calls] Restore the direct IPv4/IPv6 VLC/SRTP call panel alongside WebRTC on supported platforms, route invitations to the matching transport, and retain explicit IP disclosure consent and server privacy policy. Add transport routing and lifecycle regressions. + * [PostIt/Administration] Add an administrator-only consumption relief page reachable from Administration: select a user at their limit, preview and confirm an arbitrary point erasure up to current consumption. Protect the quota-exempt API with the Administrator policy, serialize adjustments with accounting, reject stale confirmations, preserve technical counters and disk quotas, and audit the actor. Add API, service, client and responsive-page regressions. * [PostIt] Upgrade Avalonia to 12.1.6 and align the headless and native Skia test rendering packages. diff --git a/Makefile b/Makefile index e3fb5b686..2b5589cdd 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ src/Yavsc/bin/output/wwwroot: test: ASPNETCORE_ENVIRONMENT=Development \ - TESTINGPLATFORM_EXITCODE_IGNORE="110;1" \ + TESTINGPLATFORM_EXITCODE_IGNORE="110" \ dotnet test yavsc.sln \ -- --report-xunit \ --report-xunit-html \ @@ -30,7 +30,7 @@ test: test-postit: ASPNETCORE_ENVIRONMENT=Development \ - TESTINGPLATFORM_EXITCODE_IGNORE="110;1" \ + TESTINGPLATFORM_EXITCODE_IGNORE="110" \ dotnet test \ src/PostIt/PostIt.Tests/PostIt.Tests.csproj \ -- --report-xunit \ diff --git a/doc/architecture/audio-video-calls.md b/doc/architecture/audio-video-calls.md index 7b9affd29..540c9da0d 100644 --- a/doc/architecture/audio-video-calls.md +++ b/doc/architecture/audio-video-calls.md @@ -5,11 +5,18 @@ Ce document décrit l'architecture cible, l'implementation native actuelle et l'historique du transport direct. La préférence de confidentialité est persistée et éditable dans le profil. -La signalisation est intégrée au chat, désactivée par défaut. La page du chat -utilise maintenant **WebRTC natif sur Android et Desktop Linux**, avec -ICE/STUN/TURN et masquage IP impose par la politique serveur. L'ancien -transport VLC/SRTP n'est plus raccorde a cette page. Les groupes et les -clients navigateur ne sont pas implementes. +La signalisation est intégrée au chat, désactivée par défaut. Une page d'appel +separee propose **WebRTC natif** et le transport direct VLC/SRTP sur Android et +Desktop Linux. WebRTC utilise ICE/STUN/TURN et le masquage IP impose par la +politique serveur. Le mode SRTP direct ne masque pas les adresses IP et exige +que cette preference soit desactivee pour les deux participants. Les groupes +et les clients navigateur ne sont pas implementes. +Depuis le chat textuel, selectionner un membre present puis « Ouvrir l'appel » +prepare le pair sans demarrer les medias. Les invitations entrantes disposent +d'un bouton pour ouvrir cette meme page sans selection de membre. Passer du +chat a la page d'appel ne raccroche pas ; quitter la page d'appel termine les +medias. Un salon commun reste requis ; les capacites distantes et les appels +depuis Contacts ne sont pas encore raccordes. Il complète la [topologie de PostIt](postit.md) et les [mécanismes de notification existants](notifications.md). La cible couvre : @@ -52,7 +59,11 @@ La cible couvre : terminent l'appel explicitement. Il n'y a pas d'ICE restart/renegociation automatique ni de migration transparente d'un appel existant. -Le panneau ne demande plus d'adresse ni de port RTP manuel. Sans masquage, +Le panneau WebRTC ne demande pas d'adresse ni de port RTP manuel. Le panneau +SRTP direct demande une adresse locale, un port UDP pair et le consentement au +partage d'adresse ; il requiert HTTPS pour proteger les cles de signalisation. +Les invitations sont dirigees vers le panneau correspondant, sans bascule +automatique entre transports. Sans masquage, un consentement explicite au partage IP reste requis. Activer le masquage dans le profil pendant un appel fait terminer cet appel par le serveur : il faut rappeler pour appliquer la nouvelle politique. @@ -115,10 +126,10 @@ la camera avant et le microphone Android reels, des sources Linux synthetiques et un coturn TCP local via USB ; la camera et la sortie audio Linux materielles, TURN/TLS et les reseaux Internet distincts restent a verifier. -## Historique : premiere implementation SRTP direct IPv4/IPv6 +## Implementation SRTP direct IPv4/IPv6 -Les paragraphes suivants decrivent le transport precedent, conserve dans le -code et ses tests mais non propose par le panneau d'appel actuel. +Les paragraphes suivants decrivent le transport direct historique, de nouveau +propose a cote de WebRTC dans la page d'appel. Les adresses IPv4 publiques directement assignees a une interface locale active sont egalement disponibles, avec la meme validation unicast cote client, @@ -188,10 +199,12 @@ de fichier média temporaire ou de moteur WebRTC Android ajouté. H.264/AAC. La version Debian 13 a été utilisée pour les essais Linux. Les deux comptes doivent être présents dans la même salle existante et ne pas se bloquer mutuellement. -3. Dans « Appel direct IPv4/IPv6 (LAN/VPN ou IP publique) », actualiser les périphériques, - sélectionner la caméra, le microphone et une IPv4 privée locale - accessible depuis le pair. Les adresses RFC1918 et de bouclage sont - acceptées ; pas de DNS, IPv6 ou adresse publique. Le bouclage sert aux +3. Selectionner le destinataire dans les membres presents du chat puis + « Ouvrir l'appel ». Dans la section « Appel direct IPv4/IPv6 SRTP », + actualiser les périphériques, sélectionner la caméra, le microphone et + une adresse locale accessible depuis le pair. Les adresses IPv4 privées + ou publiques assignées et les IPv6 globales ou ULA sont acceptées, pas + les noms DNS ni les adresses link-local. Le bouclage sert aux essais sur un même hôte, pas à joindre un second poste. 4. Choisir un port UDP **pair entre 1024 et 65534**, par défaut 5004. Autoriser l'entrée UDP sur ce port **et le suivant** depuis le pair dans @@ -199,7 +212,7 @@ de fichier média temporaire ou de moteur WebRTC Android ajouté. Les deux ports doivent être disponibles. Deux clients sur la même adresse doivent utiliser des paires distinctes. Aucun pare-feu n'est modifié automatiquement. -5. Saisir le pseudo exact du destinataire, confirmer la divulgation de +5. Verifier le pseudo du destinataire selectionne, confirmer la divulgation de l'adresse IP locale (LAN/VPN ou publique), puis appeler. Le destinataire choisit ses propres périphériques et son adresse, confirme et accepte explicitement. Aucun accès à la caméra/microphone ne commence avant l'acceptation ; diff --git a/doc/testing.md b/doc/testing.md index 7a8d1eba2..f1ed2bbd0 100644 --- a/doc/testing.md +++ b/doc/testing.md @@ -31,6 +31,92 @@ bug : ils doivent être **rouges avant le fix, verts après**, et continuer à **casser** si quelqu'un revert le fix. Pas de test qui passe à vide. +## Selection des tests serveur + +Toutes les classes de tests des projets `Yavsc.Org.Tests`, `Yavsc.Api.Tests`, +`Yavsc.Blogs.Tests` et `Yavsc.Server.Tests`, sous `src/test/`, portent +`[Trait("Category", "non-reg")]`, y compris celles qui heritent de tests. +Conserver ce trait sur toute nouvelle classe de tests ; les fixtures et +les helpers sans tests n'en ont pas besoin. Les autres traits restent inchanges. + +Avec le runner Microsoft.Testing.Platform et le SDK .NET 10 : + +```bash +dotnet test --project src/test/Yavsc.Org.Tests/Yavsc.Org.Tests.csproj \ + --filter-trait 'Category=non-reg' +``` + +Remplacer le projet pour executer les trois autres suites. Le trait couvre +aussi les tests d'integration qui requierent leurs services/configurations ; +il ne supprime ni ces prerequis ni les exclusions d'autres traits. +Ajouter `--list-tests` pour verifier la selection sans executer les tests. + +### Remise a zero SQLite des tests API + +`ApiWebServerFixture` conserve une connexion d'ancrage vers la base SQLite +en memoire partagee. `EnsureDeleted()` ne vide pas cette base tant que cette +connexion reste ouverte. Le reset supprime donc les tables, puis recree +explicitement le schema avant le peuplement ; `EnsureCreated()` seul ne suffit +pas car SQLite conserve sa table interne `sqlite_sequence`. +Les cles etrangeres sont desactivees uniquement pendant la suppression et +reactivees en `finally`. Le nettoyage PostgreSQL reste distinct. + +`ResetAndSeedHaircutGraph()` inclut le catalogue de trois prestations, une +commande `brush` et une commande groupee `mbrush`, toutes deux pour Alice. +Les tests de facturation s'appuient sur ces commandes initiales ; les tests +CRUD creent et manipulent leurs propres commandes par identifiant. + +## Isolation des tests PostIt + +L'assemblee `src/PostIt/PostIt.Tests` execute ses collections xUnit sans +parallelisme. Les tests `[AvaloniaFact]`/`[AvaloniaTheory]` reinitialisent le +runtime Avalonia entre tests ; des tests ordinaires utilisent aussi +`App.Current` et les delegates statiques de `Platform`. Leur execution +concurrente peut creer le dispatcher sur un autre thread ou utiliser une +application appartenant a un test headless en cours, avec une erreur de +thread UI signalee comme `Test Case Cleanup`. + +Conserver provisoirement cette isolation dans `Fixtures/TestApp.cs`. Les tests qui exercent +intentionnellement plusieurs operations concurrentes peuvent toujours le faire +dans leur propre methode ; les autres assemblees de tests ne sont pas affectees. + +### Migration progressive vers une fixture UI + +La collection `[Collection(AvaloniaUiCollection.Name)]` fournit +`AvaloniaUiFixture` par injection de constructeur. La fixture possede sa +session `HeadlessUnitTestSession`, initialise le runtime sur son thread UI et +arrete ce thread a la fin de la collection. Les tests migres utilisent `[Fact]` +ou `[Theory]`, pas `[AvaloniaFact]` : la fixture assure elle-meme le dispatch. + +`RunAsync` execute du code sur le thread UI. `WithWindowAsync` cree le contenu +et la fenetre sur ce thread, affiche la fenetre, effectue le layout, puis la +ferme et detache ses bindings en `finally`, meme si une assertion echoue : + +```csharp +[Collection(AvaloniaUiCollection.Name)] +public sealed class ExampleTests(AvaloniaUiFixture ui) +{ + [Fact] + public Task Page_is_visible() => ui.WithWindowAsync( + () => new TextBlock { Text = "Example" }, + window => + { + Assert.True(window.IsVisible); + return Task.CompletedTask; + }, + TestContext.Current.CancellationToken, + width: 640, height: 480); +} +``` + +Le pilote est `SubscriptionsPageTests`. Le thread est conserve pour la +collection, mais l'application reste isolee **par dispatch** : conserver une +application unique des maintenant changerait l'isolation des anciens tests +et risquerait de partager navigation, services et preferences. Ne pas conserver +de controles entre dispatchs dans les tests metier. La protection globale +contre le parallelisme reste necessaire tant que les autres consommateurs +d'Avalonia et de l'etat statique ne sont pas migres. + ## EF Core en test Pour les tests qui ont besoin d'un `ApplicationDbContext`, on diff --git a/src/PostIt/PostIt.Tests/AvaloniaUiFixtureTests.cs b/src/PostIt/PostIt.Tests/AvaloniaUiFixtureTests.cs new file mode 100644 index 000000000..533322207 --- /dev/null +++ b/src/PostIt/PostIt.Tests/AvaloniaUiFixtureTests.cs @@ -0,0 +1,71 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Threading; + +namespace PostIt.Tests; + +[Trait("Category", "non-reg")] +[Collection(AvaloniaUiCollection.Name)] +public sealed class AvaloniaUiFixtureTests(AvaloniaUiFixture ui) +{ + [Fact] + public async Task Dispatches_share_the_UI_thread_but_isolate_the_application() + { + Application? firstApplication = null; + var firstThread = 0; + await ui.RunAsync(() => + { + Dispatcher.UIThread.VerifyAccess(); + firstApplication = Application.Current; + firstThread = Environment.CurrentManagedThreadId; + return Task.CompletedTask; + }, TestContext.Current.CancellationToken); + await ui.RunAsync(() => + { + Dispatcher.UIThread.VerifyAccess(); + Assert.Equal(firstThread, Environment.CurrentManagedThreadId); + Assert.NotNull(firstApplication); + Assert.NotNull(Application.Current); + Assert.NotSame(firstApplication, Application.Current); + return Task.CompletedTask; + }, TestContext.Current.CancellationToken); + } + + [Theory] + [InlineData(false)] + [InlineData(true)] + public async Task Windows_are_closed_and_unbound_even_when_the_test_fails(bool fail) + { + var expectedFailure = new InvalidOperationException("Test failure"); + Window? opened = null; + Control? content = null; + var run = ui.WithWindowAsync(() => + { + Dispatcher.UIThread.VerifyAccess(); + content = new TextBlock { DataContext = new object(), Text = "Fixture" }; + return content; + }, window => + { + opened = window; + Assert.True(window.IsVisible); + Assert.Equal(640, window.Width); + Assert.Equal(480, window.Height); + return fail ? Task.FromException(expectedFailure) : Task.CompletedTask; + }, TestContext.Current.CancellationToken, width: 640, height: 480); + + if (fail) + Assert.Same(expectedFailure, await Assert.ThrowsAsync(() => run)); + else + await run; + + // The controls still belong to the fixture's UI thread after their application is disposed. + await ui.RunAsync(() => + { + Assert.NotNull(opened); + Assert.False(opened.IsVisible); + Assert.Null(opened.Content); + Assert.Null(content!.DataContext); + return Task.CompletedTask; + }, TestContext.Current.CancellationToken); + } +} diff --git a/src/PostIt/PostIt.Tests/CallTransportRoutingTests.cs b/src/PostIt/PostIt.Tests/CallTransportRoutingTests.cs new file mode 100644 index 000000000..2df357c97 --- /dev/null +++ b/src/PostIt/PostIt.Tests/CallTransportRoutingTests.cs @@ -0,0 +1,182 @@ +using Avalonia.Headless.XUnit; +using Avalonia.Controls; +using PostIt.Views.Chat; +using PostIt.Services; +using PostIt.ViewModels; +using PostIt.ViewModels.Chat; +using Yavsc.Abstract.Chat.Calls; + +namespace PostIt.Tests; + +[Trait("Category", "non-reg")] +public sealed class CallTransportRoutingTests +{ + [AvaloniaTheory] + [InlineData(CallTransports.LanSrtp)] + [InlineData(CallTransports.WebRtc)] + public async Task Incoming_calls_are_handled_only_by_the_matching_transport(string transport) + { + var signaling = new Signaling(); + await using var lan = new LanCallViewModel(signaling); + await using var webRtc = new WebRtcCallViewModel(signaling); + var call = new CallSession(Guid.NewGuid(), "General", "alice", "bob", false, + DateTimeOffset.UtcNow.AddMinutes(1), transport); + + signaling.Invite(call); + await WaitAsync(() => lan.Incoming || webRtc.Incoming); + + Assert.Equal(transport == CallTransports.LanSrtp, lan.Incoming); + Assert.Equal(transport == CallTransports.WebRtc, webRtc.Incoming); + Assert.Empty(signaling.EndedCalls); + + if (lan.Incoming) await lan.HangupAsync(); + else await webRtc.HangupAsync(); + Assert.Equal([call.Id], signaling.EndedCalls); + Assert.False(lan.Busy); + Assert.False(webRtc.Busy); + } + + [AvaloniaFact] + public async Task Unknown_transport_is_rejected_once_without_starting_either_call() + { + var signaling = new Signaling(); + await using var lan = new LanCallViewModel(signaling); + await using var webRtc = new WebRtcCallViewModel(signaling); + var call = new CallSession(Guid.NewGuid(), "General", "alice", "bob", false, + DateTimeOffset.UtcNow.AddMinutes(1), "unknown"); + + signaling.Invite(call); + await WaitAsync(() => signaling.EndedCalls.Count != 0); + + Assert.Equal([call.Id], signaling.EndedCalls); + Assert.False(lan.Busy); + Assert.False(webRtc.Busy); + } + + [AvaloniaTheory] + [InlineData(CallTransports.LanSrtp)] + [InlineData(CallTransports.WebRtc)] + public async Task Chat_updates_both_rooms_and_disconnects_the_active_transport(string transport) + { + var signaling = new Signaling(); + var chat = new ChatViewModel(settings: new Settings()); + var lan = new LanCallViewModel(signaling); + var webRtc = new WebRtcCallViewModel(signaling); + chat.LanCall = lan; + chat.VideoCall = webRtc; + chat.SelectedRoom = "General"; + Assert.Equal("General", lan.Room); + Assert.Equal("General", webRtc.Room); + + var call = new CallSession(Guid.NewGuid(), "General", "alice", "bob", false, + DateTimeOffset.UtcNow.AddMinutes(1), transport); + signaling.Invite(call); + await WaitAsync(() => lan.Incoming || webRtc.Incoming); + await chat.DisconnectAsync(); + + Assert.Equal([call.Id], signaling.EndedCalls); + Assert.Null(chat.LanCall); + Assert.Null(chat.VideoCall); + Assert.False(lan.Busy); + Assert.False(webRtc.Busy); + signaling.Invite(call); + Assert.False(lan.Incoming); + Assert.False(webRtc.Incoming); + } + + private static async Task WaitAsync(Func condition) + { + using var timeout = CancellationTokenSource.CreateLinkedTokenSource(TestContext.Current.CancellationToken); + timeout.CancelAfter(TimeSpan.FromSeconds(5)); + while (!condition()) await Task.Delay(10, timeout.Token); + } + + [AvaloniaFact] + public async Task Selecting_a_room_member_prepares_both_transports_without_inviting() + { + var signaling = new Signaling(); + await using var lan = new LanCallViewModel(signaling); + await using var webRtc = new WebRtcCallViewModel(signaling); + var chat = new ChatViewModel(settings: new Settings()) + { + LanCall = lan, VideoCall = webRtc, IsConnected = true, SelectedRoom = "General", + FocusedUsers = new() + }; + chat.FocusedUsers.Add("bob"); + Assert.False(chat.OpenCallCommand.CanExecute(null)); + chat.SelectedUser = "bob"; + Assert.True(chat.OpenCallCommand.CanExecute(null)); + var page = chat.PrepareCallPage(); + Assert.Same(chat, page.Chat); + Assert.Equal("bob", lan.Target); + Assert.Equal("bob", webRtc.Target); + Assert.False(lan.Busy); + Assert.False(webRtc.Busy); + chat.FocusedUsers.Remove("bob"); + Assert.Null(chat.SelectedUser); + Assert.False(chat.OpenCallCommand.CanExecute(null)); + chat.FocusedUsers.Add("bob"); + chat.SelectedUser = "bob"; + chat.SelectedRoom = "Other"; + Assert.Null(chat.SelectedUser); + Assert.False(chat.OpenCallCommand.CanExecute(null)); + } + + [AvaloniaTheory] + [InlineData(CallTransports.LanSrtp)] + [InlineData(CallTransports.WebRtc)] + public async Task Leaving_text_chat_preserves_invitation_and_leaving_call_page_ends_it(string transport) + { + var signaling = new Signaling(); + await using var lan = new LanCallViewModel(signaling); + await using var webRtc = new WebRtcCallViewModel(signaling); + var chat = new ChatViewModel(settings: new Settings()) + { + LanCall = lan, VideoCall = webRtc, IsConnected = true, SelectedRoom = "General", + FocusedUsers = new() + }; + var call = new CallSession(Guid.NewGuid(), "General", "alice", "bob", false, + DateTimeOffset.UtcNow.AddMinutes(1), transport); + signaling.Invite(call); + await WaitAsync(() => lan.Incoming || webRtc.Incoming); + Assert.True(chat.ShowCallCommand.CanExecute(null)); + var window = new Window { Content = new ChatPage { DataContext = chat } }; + try + { + window.Show(); + window.Content = new CallPage { DataContext = new CallPageViewModel(chat) }; + Assert.Empty(signaling.EndedCalls); + Assert.True(lan.Incoming || webRtc.Incoming); + window.Content = null; + await WaitAsync(() => signaling.EndedCalls.Count != 0); + Assert.Equal([call.Id], signaling.EndedCalls); + Assert.False(lan.Busy); + Assert.False(webRtc.Busy); + } + finally { window.Close(); } + } + + private sealed class Signaling : IWebRtcCallSignaling + { + public event Action? Invitation; + public event Action? Accepted; + public event Action? Ended; + public event Action? Signal; + public event Action? Interrupted; + public List EndedCalls { get; } = []; + + public void Invite(CallSession call) => Invitation?.Invoke(call); + public Task InviteAsync(string room, string user, CancellationToken ct = default) => + throw new NotSupportedException(); + public Task InviteLanAsync(string room, string user, CancellationToken ct = default) => + throw new NotSupportedException(); + public Task AcceptAsync(Guid callId, CancellationToken ct = default) => throw new NotSupportedException(); + public Task EndAsync(Guid callId, CancellationToken ct = default) + { + EndedCalls.Add(callId); + return Task.CompletedTask; + } + public Task SendAsync(Guid callId, CallSignal signal, CancellationToken ct = default) => + throw new NotSupportedException(); + } +} diff --git a/src/PostIt/PostIt.Tests/ContactsPageViewModelTests.cs b/src/PostIt/PostIt.Tests/ContactsPageViewModelTests.cs new file mode 100644 index 000000000..9b8bae890 --- /dev/null +++ b/src/PostIt/PostIt.Tests/ContactsPageViewModelTests.cs @@ -0,0 +1,61 @@ +using System.Net; +using System.Text.Json; +using PostIt.ViewModels; +using Yavsc.Api.Client; + +namespace PostIt.Tests; + +[Trait("Category", "non-reg")] +public sealed class ContactsPageViewModelTests +{ + [Fact] + public async Task Contacts_are_deduplicated_and_show_all_their_circles() + { + await using var api = new FakeApi(); + var vm = new ContactsPageViewModel(new CircleApiClient(api, "https://example.test/")); + await vm.RefreshAsync(); + var contact = Assert.Single(vm.Contacts); + Assert.Equal("bob-id", contact.Id); + Assert.Equal("Bob", contact.DisplayName); + Assert.Equal("Amis, Travail", contact.Circles); + } + + [Fact] + public async Task Missing_circle_is_reported_instead_of_showing_incomplete_contacts() + { + await using var api = new FakeApi { MissingCircle = true }; + var vm = new ContactsPageViewModel(new CircleApiClient(api, "https://example.test/")); + await vm.RefreshAsync(); + Assert.Empty(vm.Contacts); + Assert.Contains("n'est plus disponible", vm.Status); + Assert.False(vm.IsBusy); + } + + private sealed class FakeApi : IYavscApiClient + { + public HttpClient Http { get; } = new(); + public bool MissingCircle { get; init; } + + public Task CallAsync(HttpMethod method, string path, object? body = null, CancellationToken ct = default) + { + string json = path switch + { + "circle" => """[{"id":1,"name":"Travail"},{"id":2,"name":"Amis"}]""", + "circle/1/members" => """[{"id":"bob-id","userName":"bob","fullName":"Bob"}]""", + "circle/2/members" when MissingCircle => "null", + "circle/2/members" => """[{"id":"bob-id","userName":"bob","fullName":"Bob"}]""", + _ => throw new HttpRequestException("Unexpected path", null, HttpStatusCode.NotFound) + }; + return Task.FromResult(JsonSerializer.Deserialize(json, + new JsonSerializerOptions { PropertyNameCaseInsensitive = true })!); + } + + public Task CallAsync(HttpMethod method, string path, Func contentFactory, CancellationToken ct = default) => + throw new NotSupportedException(); + public Task CallAsync(HttpMethod method, string path, object? body = null, CancellationToken ct = default) => + throw new NotSupportedException(); + public Task CallAsync(HttpMethod method, string path, Func contentFactory, CancellationToken ct = default) => + throw new NotSupportedException(); + public ValueTask DisposeAsync() { Http.Dispose(); return ValueTask.CompletedTask; } + } +} diff --git a/src/PostIt/PostIt.Tests/Fixtures/AvaloniaUiFixture.cs b/src/PostIt/PostIt.Tests/Fixtures/AvaloniaUiFixture.cs new file mode 100644 index 000000000..4ce291c64 --- /dev/null +++ b/src/PostIt/PostIt.Tests/Fixtures/AvaloniaUiFixture.cs @@ -0,0 +1,69 @@ +using Avalonia.Controls; +using Avalonia.Headless; +using Avalonia.Threading; + +namespace PostIt.Tests; + +[CollectionDefinition(Name, DisableParallelization = true)] +public sealed class AvaloniaUiCollection : ICollectionFixture +{ + public const string Name = "Avalonia UI"; +} + +public sealed class AvaloniaUiFixture : IAsyncLifetime +{ + private HeadlessUnitTestSession? _session; + + public async ValueTask InitializeAsync() + { + _session = HeadlessUnitTestSession.StartNew(typeof(TestAppBuilder), AvaloniaTestIsolationLevel.PerTest); + try + { + await RunAsync(() => Task.CompletedTask, CancellationToken.None); + } + catch + { + await DisposeAsync(); + throw; + } + } + + public async Task RunAsync(Func action, CancellationToken ct) + { + var session = _session ?? throw new InvalidOperationException("La fixture Avalonia n'est pas initialisee."); + await session.Dispatch(async () => + { + await action(); + return true; + }, ct); + } + + public Task WithWindowAsync(Func createContent, Func test, CancellationToken ct, + double width = 800, double height = 600) => RunAsync(async () => + { + var window = new Window { Width = width, Height = height }; + try + { + window.Content = createContent(); + window.Show(); + Dispatcher.UIThread.RunJobs(); + window.UpdateLayout(); + await test(window); + } + finally + { + window.Close(); + if (window.Content is Control content) content.DataContext = null; + window.Content = null; + window.DataContext = null; + Dispatcher.UIThread.RunJobs(); + } + }, ct); + + public async ValueTask DisposeAsync() + { + if (_session is not { } session) return; + _session = null; + await session.DisposeAsync(); + } +} diff --git a/src/PostIt/PostIt.Tests/Fixtures/TestApp.cs b/src/PostIt/PostIt.Tests/Fixtures/TestApp.cs index b23f2985b..50d51a83a 100644 --- a/src/PostIt/PostIt.Tests/Fixtures/TestApp.cs +++ b/src/PostIt/PostIt.Tests/Fixtures/TestApp.cs @@ -2,6 +2,8 @@ using Avalonia; using Avalonia.Headless; [assembly: AvaloniaTestApplication(typeof(PostIt.Tests.TestAppBuilder))] +// Ordinary tests also use App.Current and Platform while headless tests reset the shared runtime. +[assembly: Xunit.CollectionBehavior(DisableTestParallelization = true)] namespace PostIt.Tests; diff --git a/src/PostIt/PostIt.Tests/SubscriptionsPageTests.cs b/src/PostIt/PostIt.Tests/SubscriptionsPageTests.cs index 8690c686a..2191eaa85 100644 --- a/src/PostIt/PostIt.Tests/SubscriptionsPageTests.cs +++ b/src/PostIt/PostIt.Tests/SubscriptionsPageTests.cs @@ -2,7 +2,6 @@ using System.Net.Http; using System.Text.Json; using System.Globalization; using Avalonia.Controls; -using Avalonia.Headless.XUnit; using PostIt.ViewModels; using PostIt.Views; using Yavsc.Abstract.Resources; @@ -11,29 +10,33 @@ using Yavsc.Api.Client; namespace PostIt.Tests; [Trait("Category", "non-reg")] -public sealed class SubscriptionsPageTests +[Collection(AvaloniaUiCollection.Name)] +public sealed class SubscriptionsPageTests(AvaloniaUiFixture ui) { - [AvaloniaFact] + [Fact] public async Task Page_binds_server_offers_prices_and_balance() { await using var api = new FakeApi(); var model = Model(api); - await model.InitializeAsync(); - var page = new SubscriptionsPage { DataContext = model }; - Assert.IsType(new ViewLocator().Build(model)); - var selector = page.FindControl("OfferSelector")!; - Assert.Equal(2, selector.ItemCount); - Assert.Equal(1.2m, model.SelectedOffer?.PriceIncludingTax); - Assert.Equal($"Prix TTC : {1.2m.ToString("F2", CultureInfo.CurrentCulture)} EUR / mois", - page.FindControl("OfferPrice")!.Text); - selector.SelectedIndex = 1; - Assert.Equal("Premium", model.SelectedOffer?.Pack); - Assert.Equal($"Prix TTC : {2.4m.ToString("F2", CultureInfo.CurrentCulture)} EUR / mois", - page.FindControl("OfferPrice")!.Text); - Assert.Equal(45m, model.Usage?.Consumption); - Assert.Null(model.StatusMessage); - Assert.True(model.SubscribeCommand.CanExecute(null)); - Assert.False(model.CancelSubscriptionCommand.CanExecute(null)); + await ui.WithWindowAsync(() => new SubscriptionsPage { DataContext = model }, async window => + { + await model.InitializeAsync(); + var page = Assert.IsType(window.Content); + Assert.IsType(new ViewLocator().Build(model)); + var selector = page.FindControl("OfferSelector")!; + Assert.Equal(2, selector.ItemCount); + Assert.Equal(1.2m, model.SelectedOffer?.PriceIncludingTax); + Assert.Equal($"Prix TTC : {1.2m.ToString("F2", CultureInfo.CurrentCulture)} EUR / mois", + page.FindControl("OfferPrice")!.Text); + selector.SelectedIndex = 1; + Assert.Equal("Premium", model.SelectedOffer?.Pack); + Assert.Equal($"Prix TTC : {2.4m.ToString("F2", CultureInfo.CurrentCulture)} EUR / mois", + page.FindControl("OfferPrice")!.Text); + Assert.Equal(45m, model.Usage?.Consumption); + Assert.Null(model.StatusMessage); + Assert.True(model.SubscribeCommand.CanExecute(null)); + Assert.False(model.CancelSubscriptionCommand.CanExecute(null)); + }, TestContext.Current.CancellationToken); } [Fact] diff --git a/src/PostIt/PostIt/Helpers/ServiceCollectionHelpers.cs b/src/PostIt/PostIt/Helpers/ServiceCollectionHelpers.cs index e041dd074..a139971f6 100644 --- a/src/PostIt/PostIt/Helpers/ServiceCollectionHelpers.cs +++ b/src/PostIt/PostIt/Helpers/ServiceCollectionHelpers.cs @@ -81,9 +81,11 @@ public static class ServiceCollectionHelpers AddReusablePage(); AddReusablePage(); AddReusablePage(); + services.AddTransient(); AddReusablePage(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -129,6 +131,7 @@ public static class ServiceCollectionHelpers services.AddTransient(); services.AddSingleton(); services.AddSingleton(); + services.AddTransient(); services.AddSingleton(); services.AddTransient(); diff --git a/src/PostIt/PostIt/Models/ChatRoomInfo.cs b/src/PostIt/PostIt/Models/ChatRoomInfo.cs index 548371157..6e270bfbd 100644 --- a/src/PostIt/PostIt/Models/ChatRoomInfo.cs +++ b/src/PostIt/PostIt/Models/ChatRoomInfo.cs @@ -7,5 +7,6 @@ namespace PostIt.ViewModels.Chat { public string? Name { get; set; } public List Users { get; set; } = new(); + public List? UserNames { get; set; } } } diff --git a/src/PostIt/PostIt/ViewLocator.cs b/src/PostIt/PostIt/ViewLocator.cs index 93e890759..dd498ce6d 100644 --- a/src/PostIt/PostIt/ViewLocator.cs +++ b/src/PostIt/PostIt/ViewLocator.cs @@ -55,6 +55,7 @@ public class ViewLocator : IDataTemplate AddCircleMemberDialogViewModel => services.GetRequiredService(), ConfirmationDialogViewModel => services.GetRequiredService(), CirclesPageViewModel => services.GetRequiredService(), + ContactsPageViewModel => services.GetRequiredService(), PostAclDialogViewModel => services.GetRequiredService(), BillingQueriesPageViewModel => services.GetRequiredService(), BillingQueryDetailsPageViewModel => services.GetRequiredService(), @@ -69,6 +70,7 @@ public class ViewLocator : IDataTemplate AdministrationPageViewModel => services.GetRequiredService(), ResourceUsageReliefPageViewModel => services.GetRequiredService(), ChatViewModel => services.GetRequiredService(), + CallPageViewModel => services.GetRequiredService(), null => new TextBlock { Text = "No view for " }, _ => new TextBlock { Text = $"No view for {data.GetType().Name}" } }; diff --git a/src/PostIt/PostIt/ViewModels/ACL/ContactsPageViewModel.cs b/src/PostIt/PostIt/ViewModels/ACL/ContactsPageViewModel.cs new file mode 100644 index 000000000..080c9ba12 --- /dev/null +++ b/src/PostIt/PostIt/ViewModels/ACL/ContactsPageViewModel.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using Yavsc.Api.Client; +using Yavsc.Api.Client.Dtos; + +namespace PostIt.ViewModels; + +public sealed record ContactEntry(string Id, string UserName, string DisplayName, string Circles); + +public partial class ContactsPageViewModel(CircleApiClient client) : ViewModelBase +{ + public ObservableCollection Contacts { get; } = []; + + [ObservableProperty] + public partial bool IsBusy { get; set; } + + [ObservableProperty] + public partial string Status { get; set; } = "Pret."; + + public override bool CanNavigateNext { get; protected set; } = false; + public override bool CanNavigatePrevious { get; protected set; } = true; + + [RelayCommand] + public async Task RefreshAsync() + { + IsBusy = true; + try + { + var circles = await client.GetMyCirclesAsync() + ?? throw new InvalidOperationException("Le serveur n'a pas renvoye les cercles."); + var members = new List<(CircleDto Circle, CircleMemberDto Member)>(); + foreach (var circle in circles) + { + var list = await client.GetMembersAsync(circle.Id) + ?? throw new InvalidOperationException($"Le cercle {circle.Name} n'est plus disponible."); + members.AddRange(list.Select(member => (circle, member))); + } + var contacts = members.GroupBy(item => item.Member.Id, StringComparer.Ordinal) + .Select(group => + { + var member = group.First().Member; + if (string.IsNullOrWhiteSpace(member.Id) || string.IsNullOrWhiteSpace(member.UserName)) + throw new InvalidOperationException("Un membre de cercle n'a pas d'identifiant ou de pseudo."); + return new ContactEntry(member.Id, member.UserName, + string.IsNullOrWhiteSpace(member.FullName) ? member.UserName : member.FullName, + string.Join(", ", group.Select(item => item.Circle.Name).Distinct().OrderBy(name => name))); + }) + .OrderBy(contact => contact.DisplayName, StringComparer.CurrentCultureIgnoreCase) + .ToArray(); + Contacts.Clear(); + foreach (var contact in contacts) Contacts.Add(contact); + Status = $"{Contacts.Count} contact(s)."; + } + catch (Exception error) + { + Contacts.Clear(); + Status = $"Impossible de charger les contacts : {error.Message}"; + } + finally { IsBusy = false; } + } +} diff --git a/src/PostIt/PostIt/ViewModels/Chat/CallPageViewModel.cs b/src/PostIt/PostIt/ViewModels/Chat/CallPageViewModel.cs new file mode 100644 index 000000000..7d4a8d69d --- /dev/null +++ b/src/PostIt/PostIt/ViewModels/Chat/CallPageViewModel.cs @@ -0,0 +1,12 @@ +using System.Threading.Tasks; + +namespace PostIt.ViewModels.Chat; + +public sealed class CallPageViewModel(ChatViewModel chat) : ViewModelBase +{ + public ChatViewModel Chat { get; } = chat; + public override bool CanNavigateNext { get; protected set; } = false; + public override bool CanNavigatePrevious { get; protected set; } = true; + + public Task HangupAsync() => Chat.HangupCallsAsync(); +} diff --git a/src/PostIt/PostIt/ViewModels/Chat/ChatViewModel.cs b/src/PostIt/PostIt/ViewModels/Chat/ChatViewModel.cs index bd4d6d8c6..c9ee665d4 100644 --- a/src/PostIt/PostIt/ViewModels/Chat/ChatViewModel.cs +++ b/src/PostIt/PostIt/ViewModels/Chat/ChatViewModel.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Collections.Specialized; using System.Threading.Tasks; using System.Threading; using CommunityToolkit.Mvvm.ComponentModel; @@ -59,9 +60,21 @@ namespace PostIt.ViewModels.Chat public bool SupportsVideoCalls => Platform.CreateWebRtcMedia != null || (OperatingSystem.IsLinux() && !OperatingSystem.IsAndroid()); + public bool SupportsLanCalls => Platform.CreateLanCallMedia != null || + (OperatingSystem.IsLinux() && !OperatingSystem.IsAndroid()); + [ObservableProperty] + [NotifyCanExecuteChangedFor(nameof(OpenCallCommand), nameof(ShowCallCommand))] public partial WebRtcCallViewModel? VideoCall { get; set; } + [ObservableProperty] + [NotifyCanExecuteChangedFor(nameof(OpenCallCommand), nameof(ShowCallCommand))] + public partial LanCallViewModel? LanCall { get; set; } + + [ObservableProperty] + [NotifyCanExecuteChangedFor(nameof(OpenCallCommand))] + public partial string? SelectedUser { get; set; } + [ObservableProperty] public partial string CurrentRoom { get; set; } = "General"; @@ -73,6 +86,7 @@ namespace PostIt.ViewModels.Chat [ObservableProperty] [NotifyCanExecuteChangedFor(nameof(SendMessageCommand))] + [NotifyCanExecuteChangedFor(nameof(OpenCallCommand), nameof(ShowCallCommand))] public partial bool IsConnected { get; set; } = false; [ObservableProperty] @@ -86,6 +100,7 @@ namespace PostIt.ViewModels.Chat // alors les notifications système. [ObservableProperty] [NotifyCanExecuteChangedFor(nameof(SendMessageCommand))] + [NotifyCanExecuteChangedFor(nameof(OpenCallCommand))] public partial string? SelectedRoom { get; set; } // Notifications globales (connexion, erreurs de join, ...) @@ -104,15 +119,87 @@ namespace PostIt.ViewModels.Chat [ObservableProperty] public partial ObservableCollection FocusedUsers { get; set; } = _noUsers; + partial void OnFocusedUsersChanging(ObservableCollection value) => + FocusedUsers.CollectionChanged -= OnFocusedUsersCollectionChanged; + + partial void OnFocusedUsersChanged(ObservableCollection value) + { + value.CollectionChanged += OnFocusedUsersCollectionChanged; + OpenCallCommand.NotifyCanExecuteChanged(); + } + + private void OnFocusedUsersCollectionChanged(object? sender, NotifyCollectionChangedEventArgs args) + { + if (SelectedUser != null && !FocusedUsers.Contains(SelectedUser)) SelectedUser = null; + OpenCallCommand.NotifyCanExecuteChanged(); + } + + private void UpdateRoomUsers(string type, string room, string user) + { + if (!_usersByRoom.TryGetValue(room, out var users)) return; + if (string.Equals(type, NotificationTypes.UserJoin, StringComparison.OrdinalIgnoreCase)) + { + if (!users.Contains(user)) users.Add(user); + } + else if (string.Equals(type, NotificationTypes.UserPart, StringComparison.OrdinalIgnoreCase) || + string.Equals(type, NotificationTypes.Kick, StringComparison.OrdinalIgnoreCase)) + { + var separator = user.IndexOf(':'); + users.Remove(separator < 0 ? user : user[..separator]); + } + } + partial void OnSelectedRoomChanged(string? value) { + SelectedUser = null; if (VideoCall != null) VideoCall.Room = value ?? ""; + if (LanCall != null) LanCall.Room = value ?? ""; FocusedMessages = value != null && _messagesByRoom.TryGetValue(value, out var msgs) ? msgs : _systemMessages; FocusedUsers = value != null && _usersByRoom.TryGetValue(value, out var users) ? users : _noUsers; } + private bool CanShowCall() => IsConnected && (VideoCall != null || LanCall != null); + + private bool CanOpenCall() => CanShowCall() && SelectedRoom != null && + !string.IsNullOrWhiteSpace(SelectedUser) && FocusedUsers.Contains(SelectedUser); + + internal CallPageViewModel PrepareCallPage() + { + if (!CanOpenCall()) + throw new InvalidOperationException("Selectionnez un utilisateur present dans le salon et connectez le chat."); + if (VideoCall?.Busy != true && LanCall?.Busy != true) + { + if (VideoCall != null) VideoCall.Target = SelectedUser!; + if (LanCall != null) LanCall.Target = SelectedUser!; + } + return new CallPageViewModel(this); + } + + [RelayCommand(CanExecute = nameof(CanOpenCall))] + private Task OpenCallAsync() => NavigateToCallAsync(configureTarget: true); + + [RelayCommand(CanExecute = nameof(CanShowCall))] + private Task ShowCallAsync() => NavigateToCallAsync(configureTarget: false); + + private async Task NavigateToCallAsync(bool configureTarget) + { + try + { + var app = App.Current as App ?? throw new InvalidOperationException("Application indisponible."); + var page = configureTarget ? PrepareCallPage() : new CallPageViewModel(this); + await app.PushPageAsync(page); + } + catch (Exception error) { Log($"Impossible d'ouvrir l'appel : {error.Message}"); } + } + + public async Task HangupCallsAsync() + { + if (VideoCall != null) await VideoCall.HangupAsync(); + if (LanCall != null) await LanCall.HangupAsync(); + } + // Trace une notification système dans la vue courante // (et dans le journal global pour consultation ultérieure). private void Log(string line) @@ -160,7 +247,7 @@ namespace PostIt.ViewModels.Chat if (_transport == null || room == null) return; try { - if (VideoCall != null) await VideoCall.HangupAsync(); + await HangupCallsAsync(); await _transport.LeaveAsync(room); JoinedRooms.Remove(room); _messagesByRoom.Remove(room); @@ -210,12 +297,8 @@ namespace PostIt.ViewModels.Chat private async Task DisconnectCoreAsync() { Exception? callError = null; - if (VideoCall != null) - { - try { await VideoCall.DisposeAsync(); } - catch (Exception error) { callError = error; } - finally { VideoCall = null; } - } + try { await DisposeCallViewModelsAsync(); } + catch (Exception error) { callError = error; } Calls?.Dispose(); Calls = null; try @@ -239,6 +322,24 @@ namespace PostIt.ViewModels.Chat } } + private async Task DisposeCallViewModelsAsync() + { + Exception? callError = null; + if (VideoCall != null) + { + try { await VideoCall.DisposeAsync(); } + catch (Exception error) { callError = error; } + finally { VideoCall = null; } + } + if (LanCall != null) + { + try { await LanCall.DisposeAsync(); } + catch (Exception error) { callError = callError == null ? error : new AggregateException(callError, error); } + finally { LanCall = null; } + } + if (callError != null) throw callError; + } + public async Task ConnectAsync() { if (_api?.IsSigningOut == true) @@ -269,13 +370,12 @@ namespace PostIt.ViewModels.Chat return; if (_connection != null) { - if (VideoCall != null) + try { await DisposeCallViewModelsAsync(); } + finally { - await VideoCall.DisposeAsync(); - VideoCall = null; + Calls?.Dispose(); + Calls = null; } - Calls?.Dispose(); - Calls = null; } Status = new StatusNotice("Connexion en cours...", StatusSeverity.Info, new RelayCheckCommand("Vérifier la connexion", async () => await CheckConnectionAsync())); @@ -298,9 +398,15 @@ namespace PostIt.ViewModels.Chat Calls = new CallSignalingClient(_connection); if (SupportsVideoCalls) VideoCall = new WebRtcCallViewModel(Calls, settings: _settings) { Room = SelectedRoom ?? "" }; - else - Calls.Invitation += call => PostForCurrentSession(() => - Log($"Invitation audio-vidéo de {call.Caller} dans {call.RoomName} ; transport non disponible sur cette plateforme.")); + if (SupportsLanCalls) + LanCall = new LanCallViewModel(Calls, settings: _settings) { Room = SelectedRoom ?? "" }; + Calls.Invitation += call => + { + if ((call.Transport == Yavsc.Abstract.Chat.Calls.CallTransports.LanSrtp && !SupportsLanCalls) || + (call.Transport != Yavsc.Abstract.Chat.Calls.CallTransports.LanSrtp && !SupportsVideoCalls)) + PostForCurrentSession(() => + Log($"Invitation audio-vidéo de {call.Caller} dans {call.RoomName} ; transport non disponible sur cette plateforme.")); + }; Calls.Ended += call => PostForCurrentSession(() => Log($"Appel terminé : {call.Reason}.")); @@ -324,9 +430,7 @@ namespace PostIt.ViewModels.Chat roomLog.Add($"*{user} a interagi avec le salon {room} (Action: {type})"); else Log($"*{user} a interagi avec le salon {room} (Action: {type})"); - if (type == "UserJoin" && _usersByRoom.TryGetValue(room, out var users) - && !users.Contains(user)) - users.Add(user); + UpdateRoomUsers(type, room, user); }); }); @@ -395,7 +499,7 @@ namespace PostIt.ViewModels.Chat roomLog = _messagesByRoom[roomName] = new(); roomLog.Add($"Salon rejoint avec succès : {roomName}"); var users = _usersByRoom[roomName] = new(); - foreach (var u in roomInfo.Users) users.Add(u); + foreach (var u in roomInfo.UserNames ?? roomInfo.Users) users.Add(u); if (!JoinedRooms.Contains(roomName)) JoinedRooms.Add(roomName); SelectedRoom = roomName; diff --git a/src/PostIt/PostIt/ViewModels/Chat/LanCallViewModel.cs b/src/PostIt/PostIt/ViewModels/Chat/LanCallViewModel.cs index b1a182e09..45175a697 100644 --- a/src/PostIt/PostIt/ViewModels/Chat/LanCallViewModel.cs +++ b/src/PostIt/PostIt/ViewModels/Chat/LanCallViewModel.cs @@ -243,22 +243,22 @@ public partial class LanCallViewModel : ObservableObject, IAsyncDisposable return RunAsync(() => StopAsync("Appel termine.", true)); } - private void OnInvitation(CallSession call) => Queue(async () => + private void OnInvitation(CallSession call) { - if (call.Transport != CallTransports.LanSrtp) + if (call.Transport != CallTransports.LanSrtp) return; + Queue(async () => { - await _signaling.EndAsync(call.Id, _lifetime.Token); - Status = "Invitation WebRTC non prise en charge par le mode LAN."; - return; - } - if (_call != null) throw new InvalidOperationException("Invitation concurrente inattendue."); - if (call.RelayOnly) throw new InvalidOperationException("Le mode LAN ne peut pas masquer les adresses IP."); - _call = call; - Busy = true; - Incoming = true; - Status = $"{call.Caller} propose un appel SRTP dans {call.RoomName}. Acceptez ou refusez."; - await Task.CompletedTask; - }); + if (_call != null) throw new InvalidOperationException("Invitation concurrente inattendue."); + if (call.RelayOnly) throw new InvalidOperationException("Le mode LAN ne peut pas masquer les adresses IP."); + _call = call; + Room = call.RoomName; + Target = call.Caller; + Busy = true; + Incoming = true; + Status = $"{call.Caller} propose un appel SRTP dans {call.RoomName}. Acceptez ou refusez."; + await Task.CompletedTask; + }); + } private void OnAccepted(CallAccepted accepted) => Queue(async () => { diff --git a/src/PostIt/PostIt/ViewModels/Chat/WebRtcCallViewModel.cs b/src/PostIt/PostIt/ViewModels/Chat/WebRtcCallViewModel.cs index 76ff80f50..f45851337 100644 --- a/src/PostIt/PostIt/ViewModels/Chat/WebRtcCallViewModel.cs +++ b/src/PostIt/PostIt/ViewModels/Chat/WebRtcCallViewModel.cs @@ -156,22 +156,28 @@ public partial class WebRtcCallViewModel : ObservableObject, IAsyncDisposable return RunAsync(() => StopAsync("Appel termine.", true)); } - private void OnInvitation(CallSession call) => Queue(async () => + private void OnInvitation(CallSession call) { - if (call.Transport != CallTransports.WebRtc || _call is not null) + if (call.Transport == CallTransports.LanSrtp) return; + Queue(async () => { - await _signaling.EndAsync(call.Id, _lifetime.Token); - Status = "Invitation refusee : transport incompatible ou appel deja en cours."; - return; - } - _call = call; - _caller = false; - _callLifetime = CancellationTokenSource.CreateLinkedTokenSource(_lifetime.Token); - Busy = Incoming = true; - Status = $"{call.Caller} propose un appel dans {call.RoomName}. " - + (call.RelayOnly ? "Masquage IP : relais TURN obligatoire. " : "Mode direct : consentement au partage IP requis. ") - + "Acceptez ou refusez."; - }); + if (call.Transport != CallTransports.WebRtc || _call is not null) + { + await _signaling.EndAsync(call.Id, _lifetime.Token); + Status = "Invitation refusee : transport incompatible ou appel deja en cours."; + return; + } + _call = call; + Room = call.RoomName; + Target = call.Caller; + _caller = false; + _callLifetime = CancellationTokenSource.CreateLinkedTokenSource(_lifetime.Token); + Busy = Incoming = true; + Status = $"{call.Caller} propose un appel dans {call.RoomName}. " + + (call.RelayOnly ? "Masquage IP : relais TURN obligatoire. " : "Mode direct : consentement au partage IP requis. ") + + "Acceptez ou refusez."; + }); + } private void OnAccepted(CallAccepted accepted) => Queue(async () => { diff --git a/src/PostIt/PostIt/ViewModels/Layout/HomePageViewModel.cs b/src/PostIt/PostIt/ViewModels/Layout/HomePageViewModel.cs index 5600854f0..8e1457237 100644 --- a/src/PostIt/PostIt/ViewModels/Layout/HomePageViewModel.cs +++ b/src/PostIt/PostIt/ViewModels/Layout/HomePageViewModel.cs @@ -78,6 +78,7 @@ public class HomePageViewModel : ViewModelBase OpenPerformerConfiguration = new AsyncRelayCommand(OpenPerformerConfigurationAsync); OpenAdministration = new AsyncRelayCommand(OpenAdministrationAsync, () => SessionStatus.IsAdministrator); OpenChat = new AsyncRelayCommand(OpenChatAsync); + OpenContacts = new AsyncRelayCommand(OpenContactsAsync); OpenPodcasts = new AsyncRelayCommand(async () => { var app = Application.Current as App ?? throw new InvalidOperationException("Application indisponible."); @@ -89,6 +90,7 @@ public class HomePageViewModel : ViewModelBase public IAsyncRelayCommand OpenChat { get; } + public IAsyncRelayCommand OpenContacts { get; } public IAsyncRelayCommand OpenPodcasts { get; } public bool SupportsPodcasts => Platform.IsPodcastSupported; public IAsyncRelayCommand OpenBlogs { get; } @@ -264,6 +266,15 @@ public class HomePageViewModel : ViewModelBase } + private async Task OpenContactsAsync() + { + var app = Application.Current as App ?? throw new InvalidOperationException("Application indisponible."); + var vm = app.ServiceProvider?.GetRequiredService() + ?? throw new InvalidOperationException("Page contacts indisponible."); + await app.PushPageAsync(vm); + await vm.RefreshAsync(); + } + /// /// Ouvre la page « Mes fichiers » (espace de stockage personnel), /// servie par le host Blogs via api/v1/fs. diff --git a/src/PostIt/PostIt/Views/ACL/ContactsPage.axaml b/src/PostIt/PostIt/Views/ACL/ContactsPage.axaml new file mode 100644 index 000000000..3917714ed --- /dev/null +++ b/src/PostIt/PostIt/Views/ACL/ContactsPage.axaml @@ -0,0 +1,23 @@ + + + +[Trait("Category", "non-reg")] [Collection("Yavsc Api")] public sealed class EstimateAttachmentsApiTests : IClassFixture { diff --git a/src/test/Yavsc.Api.Tests/EstimatePdfGenerationTests.cs b/src/test/Yavsc.Api.Tests/EstimatePdfGenerationTests.cs index e0f156048..75aee6cfc 100644 --- a/src/test/Yavsc.Api.Tests/EstimatePdfGenerationTests.cs +++ b/src/test/Yavsc.Api.Tests/EstimatePdfGenerationTests.cs @@ -20,6 +20,7 @@ namespace Yavsc.Api.Test; // The PDF test requires the system `lualatex` (and the TeX Live packages // listed in the README runtime-deps section) on the host running the // tests. On hosts without lualatex it skips cleanly rather than failing. +[Trait("Category", "non-reg")] public sealed class EstimatePdfGenerationTests { // A provider signature: a downstroke, a cross, and a tap (dot). diff --git a/src/test/Yavsc.Api.Tests/Fixtures/ApiWebServerFixture.cs b/src/test/Yavsc.Api.Tests/Fixtures/ApiWebServerFixture.cs index 0e807de19..8b1a5fcf5 100644 --- a/src/test/Yavsc.Api.Tests/Fixtures/ApiWebServerFixture.cs +++ b/src/test/Yavsc.Api.Tests/Fixtures/ApiWebServerFixture.cs @@ -1,7 +1,9 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage; using Microsoft.Extensions.DependencyInjection; using Microsoft.IdentityModel.Tokens; using Npgsql; @@ -375,7 +377,44 @@ public sealed class ApiWebServerFixture : WebHostFixture return; } - db.Database.EnsureDeleted(); + // EnsureDeleted cannot clear a shared in-memory database kept alive by the anchor. + db.Database.OpenConnection(); + try + { + using var command = db.Database.GetDbConnection().CreateCommand(); + command.CommandText = "SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT GLOB 'sqlite_*';"; + var tables = new List(); + using (var reader = command.ExecuteReader()) + { + while (reader.Read()) + tables.Add(reader.GetString(0)); + } + command.CommandText = "PRAGMA foreign_keys = OFF;"; + command.ExecuteNonQuery(); + try + { + using var transaction = db.Database.BeginTransaction(); + command.Transaction = transaction.GetDbTransaction(); + foreach (var table in tables) + { + command.CommandText = $"DROP TABLE \"{table.Replace("\"", "\"\"")}\";"; + command.ExecuteNonQuery(); + } + transaction.Commit(); + } + finally + { + command.Transaction = null; + command.CommandText = "PRAGMA foreign_keys = ON;"; + command.ExecuteNonQuery(); + } + } + finally + { + db.Database.CloseConnection(); + } + // SQLite retains sqlite_sequence, so EnsureCreated would incorrectly see an existing schema. + db.GetService().CreateTables(); } public void ResetAndSeedRdvQueryGraph() @@ -491,6 +530,46 @@ public sealed class ApiWebServerFixture : WebHostFixture db.HairPrestation.AddRange(prestation1, prestation2, prestation3); db.SaveChanges(); + + db.HairCutQueries.Add(new HairCutQuery + { + ActivityCode = "brush", + ClientId = "alice", + PerformerId = "alice", + Consent = true, + UserCreated = "alice", + UserModified = "alice", + DateCreated = DateTime.UtcNow, + DateModified = DateTime.UtcNow, + EventDate = DateTime.UtcNow.AddDays(3), + Location = location, + PrestationId = prestation1.Id, + Prestation = prestation1, + AdditionalInfo = "Coupe test", + Status = Yavsc.QueryStatus.Inserted, + Description = "Haircut seed", + }); + + db.HairMultiCutQueries.Add(new HairMultiCutQuery + { + ActivityCode = "mbrush", + ClientId = "alice", + PerformerId = "alice", + Consent = true, + UserCreated = "alice", + UserModified = "alice", + DateCreated = DateTime.UtcNow, + DateModified = DateTime.UtcNow, + EventDate = DateTime.UtcNow.AddDays(4), + Location = location, + Prestations = new List + { + new() { PrestationId = prestation1.Id, Prestation = prestation1 }, + new() { PrestationId = prestation2.Id, Prestation = prestation2 }, + }, + Status = Yavsc.QueryStatus.Inserted, + }); + db.SaveChanges(); } public override void Dispose() diff --git a/src/test/Yavsc.Api.Tests/FrontOfficeApiControllerTests.cs b/src/test/Yavsc.Api.Tests/FrontOfficeApiControllerTests.cs index 14880bb7d..adae6c338 100644 --- a/src/test/Yavsc.Api.Tests/FrontOfficeApiControllerTests.cs +++ b/src/test/Yavsc.Api.Tests/FrontOfficeApiControllerTests.cs @@ -14,6 +14,7 @@ using Yavsc.Services; namespace Yavsc.Api.Test; +[Trait("Category", "non-reg")] [Collection("Yavsc Api")] public sealed class FrontOfficeApiControllerTests : IClassFixture { diff --git a/src/test/Yavsc.Api.Tests/FrontOfficeQueryAttachmentsApiTests.cs b/src/test/Yavsc.Api.Tests/FrontOfficeQueryAttachmentsApiTests.cs index d4438ef4e..75116b7e8 100644 --- a/src/test/Yavsc.Api.Tests/FrontOfficeQueryAttachmentsApiTests.cs +++ b/src/test/Yavsc.Api.Tests/FrontOfficeQueryAttachmentsApiTests.cs @@ -26,6 +26,7 @@ namespace Yavsc.Api.Test; /// belong to the caller, and listing is open to both parties /// (client/provider) plus admin. A third party is refused. /// +[Trait("Category", "non-reg")] [Collection("Yavsc Api")] public sealed class FrontOfficeQueryAttachmentsApiTests : IClassFixture { diff --git a/src/test/Yavsc.Api.Tests/HairCutQueryApiControllerTests.cs b/src/test/Yavsc.Api.Tests/HairCutQueryApiControllerTests.cs index e5032fa33..44227dee5 100644 --- a/src/test/Yavsc.Api.Tests/HairCutQueryApiControllerTests.cs +++ b/src/test/Yavsc.Api.Tests/HairCutQueryApiControllerTests.cs @@ -15,6 +15,7 @@ using Yavsc.Tests.Shared; namespace Yavsc.Api.Test; +[Trait("Category", "non-reg")] [Collection("Yavsc Api")] public sealed class HairCutQueryApiControllerTests : IClassFixture { diff --git a/src/test/Yavsc.Api.Tests/HairMultiCutQueryApiControllerTests.cs b/src/test/Yavsc.Api.Tests/HairMultiCutQueryApiControllerTests.cs index 8d940b8b1..02e0afbd6 100644 --- a/src/test/Yavsc.Api.Tests/HairMultiCutQueryApiControllerTests.cs +++ b/src/test/Yavsc.Api.Tests/HairMultiCutQueryApiControllerTests.cs @@ -11,6 +11,7 @@ using Yavsc.Tests.Shared; namespace Yavsc.Api.Test; +[Trait("Category", "non-reg")] [Collection("Yavsc Api")] public sealed class HairMultiCutQueryApiControllerTests : IClassFixture { diff --git a/src/test/Yavsc.Api.Tests/HomeControllerTests.cs b/src/test/Yavsc.Api.Tests/HomeControllerTests.cs index d119bc797..83498b108 100644 --- a/src/test/Yavsc.Api.Tests/HomeControllerTests.cs +++ b/src/test/Yavsc.Api.Tests/HomeControllerTests.cs @@ -14,6 +14,7 @@ using Yavsc.Models.Workflow; namespace Yavsc.Api.Test; +[Trait("Category", "non-reg")] [Collection("Yavsc Api")] public sealed class HomeControllerTests : IClassFixture { diff --git a/src/test/Yavsc.Api.Tests/InvoiceApiTests.cs b/src/test/Yavsc.Api.Tests/InvoiceApiTests.cs index 8719bc341..16724abc8 100644 --- a/src/test/Yavsc.Api.Tests/InvoiceApiTests.cs +++ b/src/test/Yavsc.Api.Tests/InvoiceApiTests.cs @@ -15,6 +15,7 @@ using Yavsc.Tests.Shared; namespace Yavsc.Api.Test; +[Trait("Category", "non-reg")] [Collection("Yavsc Api")] public sealed class InvoiceApiTests(ApiWebServerFixture fixture) : IClassFixture { diff --git a/src/test/Yavsc.Api.Tests/LiveProcessorTests.cs b/src/test/Yavsc.Api.Tests/LiveProcessorTests.cs index 85249f13e..fb4a3b775 100644 --- a/src/test/Yavsc.Api.Tests/LiveProcessorTests.cs +++ b/src/test/Yavsc.Api.Tests/LiveProcessorTests.cs @@ -9,6 +9,7 @@ using Yavsc.Services; namespace Yavsc.Api.Test; +[Trait("Category", "non-reg")] public sealed class LiveProcessorTests : IDisposable { private readonly string _root = Path.Combine(Path.GetTempPath(), $"yavsc-podcast-unit-{Guid.NewGuid():N}"); diff --git a/src/test/Yavsc.Api.Tests/PerformerDonationSettingsTests.cs b/src/test/Yavsc.Api.Tests/PerformerDonationSettingsTests.cs index b7672ede1..b6412ab4f 100644 --- a/src/test/Yavsc.Api.Tests/PerformerDonationSettingsTests.cs +++ b/src/test/Yavsc.Api.Tests/PerformerDonationSettingsTests.cs @@ -13,6 +13,7 @@ using Yavsc.Tests.Shared; namespace Yavsc.Api.Test; +[Trait("Category", "non-reg")] [Collection("Yavsc Api")] public sealed class PerformerDonationSettingsTests(ApiWebServerFixture fixture) : IClassFixture { diff --git a/src/test/Yavsc.Api.Tests/PodcastControllerTests.cs b/src/test/Yavsc.Api.Tests/PodcastControllerTests.cs index ba2e374ab..6bde4e6b7 100644 --- a/src/test/Yavsc.Api.Tests/PodcastControllerTests.cs +++ b/src/test/Yavsc.Api.Tests/PodcastControllerTests.cs @@ -9,6 +9,7 @@ using Yavsc.Tests.Shared; namespace Yavsc.Api.Test; +[Trait("Category", "non-reg")] [Collection("Yavsc Api")] public sealed class PodcastControllerTests(ApiWebServerFixture fixture) : IClassFixture { diff --git a/src/test/Yavsc.Api.Tests/PodcastObsTests.cs b/src/test/Yavsc.Api.Tests/PodcastObsTests.cs index 1688e4582..653019fa2 100644 --- a/src/test/Yavsc.Api.Tests/PodcastObsTests.cs +++ b/src/test/Yavsc.Api.Tests/PodcastObsTests.cs @@ -17,6 +17,7 @@ using Yavsc.Settings; namespace Yavsc.Api.Test; +[Trait("Category", "non-reg")] public sealed class PodcastObsTests : IAsyncDisposable { private static CancellationToken Ct => TestContext.Current.CancellationToken; diff --git a/src/test/Yavsc.Api.Tests/PodcastReplayTests.cs b/src/test/Yavsc.Api.Tests/PodcastReplayTests.cs index a978bf505..0c390f968 100644 --- a/src/test/Yavsc.Api.Tests/PodcastReplayTests.cs +++ b/src/test/Yavsc.Api.Tests/PodcastReplayTests.cs @@ -9,6 +9,7 @@ using Yavsc.Services; namespace Yavsc.Api.Test; +[Trait("Category", "non-reg")] public sealed class PodcastReplayTests : IDisposable { private readonly string _root = Path.Combine(Path.GetTempPath(), $"yavsc-replay-{Guid.NewGuid():N}"); diff --git a/src/test/Yavsc.Api.Tests/PodcastScheduleTests.cs b/src/test/Yavsc.Api.Tests/PodcastScheduleTests.cs index 1aa762c0c..3b87e8b6e 100644 --- a/src/test/Yavsc.Api.Tests/PodcastScheduleTests.cs +++ b/src/test/Yavsc.Api.Tests/PodcastScheduleTests.cs @@ -10,6 +10,7 @@ using Yavsc.Models; namespace Yavsc.Api.Test; +[Trait("Category", "non-reg")] [Collection("Yavsc Api")] public sealed class PodcastScheduleTests(ApiWebServerFixture fixture) : IClassFixture { diff --git a/src/test/Yavsc.Api.Tests/RdvQueryApiControllerTests.cs b/src/test/Yavsc.Api.Tests/RdvQueryApiControllerTests.cs index f14b50aad..779fa12ea 100644 --- a/src/test/Yavsc.Api.Tests/RdvQueryApiControllerTests.cs +++ b/src/test/Yavsc.Api.Tests/RdvQueryApiControllerTests.cs @@ -11,6 +11,7 @@ using Yavsc.Services; namespace Yavsc.Api.Test; +[Trait("Category", "non-reg")] [Collection("Yavsc Api")] public sealed class RdvQueryApiControllerTests : IClassFixture { diff --git a/src/test/Yavsc.Api.Tests/ResourceUsageApiControllerTests.cs b/src/test/Yavsc.Api.Tests/ResourceUsageApiControllerTests.cs index 694b8f624..008e16162 100644 --- a/src/test/Yavsc.Api.Tests/ResourceUsageApiControllerTests.cs +++ b/src/test/Yavsc.Api.Tests/ResourceUsageApiControllerTests.cs @@ -12,6 +12,7 @@ using Yavsc.Tests.Shared; namespace Yavsc.Api.Test; +[Trait("Category", "non-reg")] [Collection("Yavsc Api")] public sealed class ResourceUsageApiControllerTests : IClassFixture { diff --git a/src/test/Yavsc.Api.Tests/ResourceUsageReliefApiTests.cs b/src/test/Yavsc.Api.Tests/ResourceUsageReliefApiTests.cs index 1177948a3..3c40b83c3 100644 --- a/src/test/Yavsc.Api.Tests/ResourceUsageReliefApiTests.cs +++ b/src/test/Yavsc.Api.Tests/ResourceUsageReliefApiTests.cs @@ -14,6 +14,7 @@ using Yavsc.Tests.Shared; namespace Yavsc.Api.Test; +[Trait("Category", "non-reg")] [Collection("Yavsc Api")] public sealed class ResourceUsageReliefApiTests(ApiWebServerFixture fixture) : IClassFixture { @@ -75,6 +76,7 @@ public sealed class ResourceUsageReliefApiTests(ApiWebServerFixture fixture) : I var request = new EraseResourceUsageRequest { Points = 200.12545678m, ExpectedCredits = 0m }; using var response = await admin.PostAsJsonAsync($"{Root}/{id}/erase", request, Ct); Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("application/json", response.Content.Headers.ContentType?.MediaType); Assert.True(response.Headers.CacheControl?.NoStore); var summary = await response.Content.ReadFromJsonAsync(Ct); Assert.NotNull(summary); @@ -105,6 +107,10 @@ public sealed class ResourceUsageReliefApiTests(ApiWebServerFixture fixture) : I using var response = await client.PostAsync($"{Root}/{id}/erase", body, Ct); Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); Assert.Equal("application/problem+json", response.Content.Headers.ContentType?.MediaType); + var problem = await response.Content.ReadFromJsonAsync(Ct); + Assert.NotNull(problem); + Assert.Equal((int)response.StatusCode, problem.Status); + Assert.False(string.IsNullOrWhiteSpace(problem.Title)); using var scope = fixture.Services.CreateScope(); Assert.Equal(0m, (await scope.ServiceProvider.GetRequiredService() .ResourceUsageRecords.SingleAsync(r => r.UserId == id, Ct)).CreditPoints); @@ -127,6 +133,10 @@ public sealed class ResourceUsageReliefApiTests(ApiWebServerFixture fixture) : I }, Ct); Assert.Equal(status, response.StatusCode); Assert.Equal("application/problem+json", response.Content.Headers.ContentType?.MediaType); + var problem = await response.Content.ReadFromJsonAsync(Ct); + Assert.NotNull(problem); + Assert.Equal((int)status, problem.Status); + Assert.False(string.IsNullOrWhiteSpace(problem.Title)); } [Fact] @@ -151,5 +161,10 @@ public sealed class ResourceUsageReliefApiTests(ApiWebServerFixture fixture) : I Assert.False(string.IsNullOrWhiteSpace(operation.GetProperty("summary").GetString())); foreach (var status in new[] { "200", "400", "401", "403", "404", "409" }) Assert.True(operation.GetProperty("responses").TryGetProperty(status, out _)); + Assert.True(operation.GetProperty("responses").GetProperty("200").GetProperty("content") + .TryGetProperty("application/json", out _)); + foreach (var status in new[] { "400", "404", "409" }) + Assert.True(operation.GetProperty("responses").GetProperty(status).GetProperty("content") + .TryGetProperty("application/problem+json", out _)); } } diff --git a/src/test/Yavsc.Api.Tests/SiteAdministrationApiTests.cs b/src/test/Yavsc.Api.Tests/SiteAdministrationApiTests.cs index b632fd5e7..cf5e3d5c0 100644 --- a/src/test/Yavsc.Api.Tests/SiteAdministrationApiTests.cs +++ b/src/test/Yavsc.Api.Tests/SiteAdministrationApiTests.cs @@ -16,6 +16,7 @@ using Yavsc.Tests.Shared; namespace Yavsc.Api.Test; +[Trait("Category", "non-reg")] [Collection("Yavsc Api")] public sealed class SiteAdministrationApiTests(ApiWebServerFixture fixture) : IClassFixture { diff --git a/src/test/Yavsc.Blogs.Tests/BlogAclApiTests.cs b/src/test/Yavsc.Blogs.Tests/BlogAclApiTests.cs index e47ab4e57..19cfb3069 100644 --- a/src/test/Yavsc.Blogs.Tests/BlogAclApiTests.cs +++ b/src/test/Yavsc.Blogs.Tests/BlogAclApiTests.cs @@ -35,6 +35,7 @@ namespace Yavsc.Blogs.Tests; /// (the existing BlogPost and Circle) are not /// attached to the DbContext in the same change-tracker graph. /// +[Trait("Category", "non-reg")] [Collection("Yavsc Blogs")] public sealed class BlogAclApiTests : IClassFixture { diff --git a/src/test/Yavsc.Blogs.Tests/BlogApiMappedClaimsTests.cs b/src/test/Yavsc.Blogs.Tests/BlogApiMappedClaimsTests.cs index be2793bf3..0129ba8aa 100644 --- a/src/test/Yavsc.Blogs.Tests/BlogApiMappedClaimsTests.cs +++ b/src/test/Yavsc.Blogs.Tests/BlogApiMappedClaimsTests.cs @@ -12,6 +12,7 @@ using Yavsc.Blogs.Tests.Fixtures; namespace Yavsc.Blogs.Tests; +[Trait("Category", "non-reg")] [Collection("JwtClaimMapping")] public sealed class BlogApiMappedClaimsTests : IClassFixture diff --git a/src/test/Yavsc.Blogs.Tests/BlogApiSmokeTests.cs b/src/test/Yavsc.Blogs.Tests/BlogApiSmokeTests.cs index 2fd42e2fe..371b22efb 100644 --- a/src/test/Yavsc.Blogs.Tests/BlogApiSmokeTests.cs +++ b/src/test/Yavsc.Blogs.Tests/BlogApiSmokeTests.cs @@ -9,6 +9,7 @@ namespace Yavsc.Blogs.Tests; /// surface. The first behavioural test (GET /api/v1/blog returns /// 200) lands in a follow-up commit. /// +[Trait("Category", "non-reg")] [Collection("Yavsc Blogs")] public sealed class BlogApiSmokeTests : IClassFixture { diff --git a/src/test/Yavsc.Blogs.Tests/BlogApiTests.cs b/src/test/Yavsc.Blogs.Tests/BlogApiTests.cs index 13b5edb1b..9f1e1598e 100644 --- a/src/test/Yavsc.Blogs.Tests/BlogApiTests.cs +++ b/src/test/Yavsc.Blogs.Tests/BlogApiTests.cs @@ -26,6 +26,7 @@ namespace Yavsc.Blogs.Tests; /// header (or sending a token signed with the wrong key) gets a /// 401 back from the framework. /// +[Trait("Category", "non-reg")] [Collection("Yavsc Blogs")] public sealed class BlogApiTests : IClassFixture { diff --git a/src/test/Yavsc.Blogs.Tests/BlogSpotServiceIndexTests.cs b/src/test/Yavsc.Blogs.Tests/BlogSpotServiceIndexTests.cs index fa1b9c379..2d4954969 100644 --- a/src/test/Yavsc.Blogs.Tests/BlogSpotServiceIndexTests.cs +++ b/src/test/Yavsc.Blogs.Tests/BlogSpotServiceIndexTests.cs @@ -28,6 +28,7 @@ namespace Yavsc.Blogs.Tests; /// ) is resolved from DI and run /// end-to-end — no mocking. /// +[Trait("Category", "non-reg")] [Collection("Yavsc Blogs")] public sealed class BlogSpotServiceIndexTests : IClassFixture { diff --git a/src/test/Yavsc.Blogs.Tests/CircleMembersApiTests.cs b/src/test/Yavsc.Blogs.Tests/CircleMembersApiTests.cs index a7c3001b4..825acaadd 100644 --- a/src/test/Yavsc.Blogs.Tests/CircleMembersApiTests.cs +++ b/src/test/Yavsc.Blogs.Tests/CircleMembersApiTests.cs @@ -30,6 +30,7 @@ namespace Yavsc.Blogs.Tests; /// through the DbContext the same way the production code /// would. /// +[Trait("Category", "non-reg")] [Collection("JwtClaimMapping")] public sealed class CircleMembersApiTests : IClassFixture { diff --git a/src/test/Yavsc.Blogs.Tests/CreateMultipartContentTests.cs b/src/test/Yavsc.Blogs.Tests/CreateMultipartContentTests.cs index 698a2369c..f80814b65 100644 --- a/src/test/Yavsc.Blogs.Tests/CreateMultipartContentTests.cs +++ b/src/test/Yavsc.Blogs.Tests/CreateMultipartContentTests.cs @@ -47,6 +47,7 @@ namespace Yavsc.Blogs.Tests; /// [Collection("Yavsc Blogs")] + IClassFixture so the /// one shared host serves both legs without spinning a second one. /// +[Trait("Category", "non-reg")] [Collection("Yavsc Blogs")] public sealed class CreateMultipartContentTests : IClassFixture { diff --git a/src/test/Yavsc.Blogs.Tests/FileSystemApiTests.cs b/src/test/Yavsc.Blogs.Tests/FileSystemApiTests.cs index 3b88e8d8b..93789305a 100644 --- a/src/test/Yavsc.Blogs.Tests/FileSystemApiTests.cs +++ b/src/test/Yavsc.Blogs.Tests/FileSystemApiTests.cs @@ -35,6 +35,7 @@ namespace Yavsc.Blogs.Tests; /// download endpoint lives here and not on the API host. /// /// +[Trait("Category", "non-reg")] [Collection("Yavsc Blogs")] public sealed class FileSystemApiTests : IClassFixture { diff --git a/src/test/Yavsc.Blogs.Tests/FilterFileNameTests.cs b/src/test/Yavsc.Blogs.Tests/FilterFileNameTests.cs index c97338781..cba050b58 100644 --- a/src/test/Yavsc.Blogs.Tests/FilterFileNameTests.cs +++ b/src/test/Yavsc.Blogs.Tests/FilterFileNameTests.cs @@ -8,6 +8,7 @@ using Yavsc.Server.Helpers; namespace Yavsc.Blogs.Tests; +[Trait("Category", "non-reg")] public sealed class FilterFileNameTests { [Theory] diff --git a/src/test/Yavsc.Blogs.Tests/IBlogPostWireShapeTests.cs b/src/test/Yavsc.Blogs.Tests/IBlogPostWireShapeTests.cs index bb38725cd..2b5a4eb53 100644 --- a/src/test/Yavsc.Blogs.Tests/IBlogPostWireShapeTests.cs +++ b/src/test/Yavsc.Blogs.Tests/IBlogPostWireShapeTests.cs @@ -29,6 +29,7 @@ namespace Yavsc.Blogs.Tests; /// where it manifested in production (PostIt showing a published /// post's status as false). /// +[Trait("Category", "non-reg")] public sealed class IBlogPostWireShapeTests { private static readonly JsonSerializerOptions WebDefaults diff --git a/src/test/Yavsc.Blogs.Tests/PublishEndpointTests.cs b/src/test/Yavsc.Blogs.Tests/PublishEndpointTests.cs index 113707caa..bf8527c02 100644 --- a/src/test/Yavsc.Blogs.Tests/PublishEndpointTests.cs +++ b/src/test/Yavsc.Blogs.Tests/PublishEndpointTests.cs @@ -25,6 +25,7 @@ namespace Yavsc.Blogs.Tests; /// in-memory ApplicationDbContext, JWT bearer auth /// via . /// +[Trait("Category", "non-reg")] [Collection("Yavsc Blogs")] public sealed class PublishEndpointTests : IClassFixture { diff --git a/src/test/Yavsc.Org.Tests/ComputeKidTests.cs b/src/test/Yavsc.Org.Tests/ComputeKidTests.cs index 61aa5260f..d284ca391 100644 --- a/src/test/Yavsc.Org.Tests/ComputeKidTests.cs +++ b/src/test/Yavsc.Org.Tests/ComputeKidTests.cs @@ -21,6 +21,7 @@ namespace Yavsc.Org.Tests; /// encoding of the thumbprint, which is independent of the key /// type and the cert issuer. /// +[Trait("Category", "non-reg")] public class ComputeKidTests : IDisposable { private readonly string _tempDir; diff --git a/src/test/Yavsc.Org.Tests/Controllers/ClientControllerCollectionTests.cs b/src/test/Yavsc.Org.Tests/Controllers/ClientControllerCollectionTests.cs index 264eff64d..bf511982a 100644 --- a/src/test/Yavsc.Org.Tests/Controllers/ClientControllerCollectionTests.cs +++ b/src/test/Yavsc.Org.Tests/Controllers/ClientControllerCollectionTests.cs @@ -21,6 +21,7 @@ namespace Yavsc.Org.Tests.Controllers; /// production policy to honour that header, sidestepping the login flow /// (which is itself not exercised by these tests). /// +[Trait("Category", "non-reg")] [Collection("Yavsc Server")] public class ClientControllerCollectionTests : IClassFixture { diff --git a/src/test/Yavsc.Org.Tests/Controllers/CommandFormsControllerTests.cs b/src/test/Yavsc.Org.Tests/Controllers/CommandFormsControllerTests.cs index 621663285..b8eb3bd7d 100644 --- a/src/test/Yavsc.Org.Tests/Controllers/CommandFormsControllerTests.cs +++ b/src/test/Yavsc.Org.Tests/Controllers/CommandFormsControllerTests.cs @@ -5,6 +5,7 @@ using Xunit; namespace Yavsc.Org.Tests.Controllers; +[Trait("Category", "non-reg")] public class CommandFormsControllerTests : IClassFixture { private readonly TestWebApplicationFactory _factory; diff --git a/src/test/Yavsc.Org.Tests/Controllers/CommentsApiIntegrationTests.cs b/src/test/Yavsc.Org.Tests/Controllers/CommentsApiIntegrationTests.cs index 39d649311..114687c9c 100644 --- a/src/test/Yavsc.Org.Tests/Controllers/CommentsApiIntegrationTests.cs +++ b/src/test/Yavsc.Org.Tests/Controllers/CommentsApiIntegrationTests.cs @@ -10,6 +10,7 @@ using Xunit; namespace Yavsc.Org.Tests.Controllers; +[Trait("Category", "non-reg")] public class CommentsApiIntegrationTests : IClassFixture { private readonly TestWebApplicationFactory _factory; diff --git a/src/test/Yavsc.Org.Tests/Controllers/CommentsControllerTests.cs b/src/test/Yavsc.Org.Tests/Controllers/CommentsControllerTests.cs index 0954cdd27..684c54833 100644 --- a/src/test/Yavsc.Org.Tests/Controllers/CommentsControllerTests.cs +++ b/src/test/Yavsc.Org.Tests/Controllers/CommentsControllerTests.cs @@ -9,6 +9,7 @@ using Xunit; namespace Yavsc.Org.Tests.Controllers; +[Trait("Category", "non-reg")] public class CommentsControllerTests { [Fact] diff --git a/src/test/Yavsc.Org.Tests/Controllers/PerformerDonationTests.cs b/src/test/Yavsc.Org.Tests/Controllers/PerformerDonationTests.cs index f9098b18e..512ff919b 100644 --- a/src/test/Yavsc.Org.Tests/Controllers/PerformerDonationTests.cs +++ b/src/test/Yavsc.Org.Tests/Controllers/PerformerDonationTests.cs @@ -19,6 +19,7 @@ using Xunit; namespace Yavsc.Org.Tests.Controllers; +[Trait("Category", "non-reg")] public sealed class PerformerDonationTests : IClassFixture { private readonly Factory _factory; diff --git a/src/test/Yavsc.Org.Tests/Controllers/PodcastWebTests.cs b/src/test/Yavsc.Org.Tests/Controllers/PodcastWebTests.cs index 65314510e..ca8223043 100644 --- a/src/test/Yavsc.Org.Tests/Controllers/PodcastWebTests.cs +++ b/src/test/Yavsc.Org.Tests/Controllers/PodcastWebTests.cs @@ -25,6 +25,7 @@ using Xunit; namespace Yavsc.Org.Tests.Controllers; +[Trait("Category", "non-reg")] public sealed class PodcastWebTests : IClassFixture { private readonly Factory _factory; diff --git a/src/test/Yavsc.Org.Tests/Controllers/ResourceSubscriptionControllerTests.cs b/src/test/Yavsc.Org.Tests/Controllers/ResourceSubscriptionControllerTests.cs index b06f9d0b5..c8fb933e8 100644 --- a/src/test/Yavsc.Org.Tests/Controllers/ResourceSubscriptionControllerTests.cs +++ b/src/test/Yavsc.Org.Tests/Controllers/ResourceSubscriptionControllerTests.cs @@ -22,6 +22,7 @@ using Xunit; namespace Yavsc.Org.Tests.Controllers; +[Trait("Category", "non-reg")] public sealed class ResourceSubscriptionControllerTests : IClassFixture { private readonly Factory _factory; diff --git a/src/test/Yavsc.Org.Tests/Controllers/ResourceUsageTermsTests.cs b/src/test/Yavsc.Org.Tests/Controllers/ResourceUsageTermsTests.cs index 054a28697..dfff8f4e4 100644 --- a/src/test/Yavsc.Org.Tests/Controllers/ResourceUsageTermsTests.cs +++ b/src/test/Yavsc.Org.Tests/Controllers/ResourceUsageTermsTests.cs @@ -6,6 +6,7 @@ using Xunit; namespace Yavsc.Org.Tests.Controllers; +[Trait("Category", "non-reg")] public sealed class ResourceUsageTermsTests { [Fact] diff --git a/src/test/Yavsc.Org.Tests/Controllers/TestWebApplicationFactoryIsolationTests.cs b/src/test/Yavsc.Org.Tests/Controllers/TestWebApplicationFactoryIsolationTests.cs index f1507bf49..1f5c521ad 100644 --- a/src/test/Yavsc.Org.Tests/Controllers/TestWebApplicationFactoryIsolationTests.cs +++ b/src/test/Yavsc.Org.Tests/Controllers/TestWebApplicationFactoryIsolationTests.cs @@ -27,6 +27,7 @@ namespace Yavsc.Org.Tests.Controllers; /// straight to the DbContext is the same code path the production /// code uses, so it is the right surface to assert against. /// +[Trait("Category", "non-reg")] public class TestWebApplicationFactoryIsolationTests { [Fact] diff --git a/src/test/Yavsc.Org.Tests/DictionnaireMetierTests.cs b/src/test/Yavsc.Org.Tests/DictionnaireMetierTests.cs index 2bb99b072..892945aba 100644 --- a/src/test/Yavsc.Org.Tests/DictionnaireMetierTests.cs +++ b/src/test/Yavsc.Org.Tests/DictionnaireMetierTests.cs @@ -6,6 +6,7 @@ using Xunit; namespace Yavsc.Org.Tests; +[Trait("Category", "non-reg")] public class DictionnaireMetierTests { [Fact] diff --git a/src/test/Yavsc.Org.Tests/Mandatory/BatchTests.cs b/src/test/Yavsc.Org.Tests/Mandatory/BatchTests.cs index 33065e013..b4a4a9e6c 100644 --- a/src/test/Yavsc.Org.Tests/Mandatory/BatchTests.cs +++ b/src/test/Yavsc.Org.Tests/Mandatory/BatchTests.cs @@ -8,6 +8,7 @@ using Yavsc.Server.Models.IT; namespace Yavsc.Org.Tests { + [Trait("Category", "non-reg")] [Collection("Yavsc Server")] [Trait("regression", "oui")] public abstract class BaseTestContext : IClassFixture, IDisposable diff --git a/src/test/Yavsc.Org.Tests/Mandatory/Remoting.cs b/src/test/Yavsc.Org.Tests/Mandatory/Remoting.cs index 5caf905b4..a83083341 100644 --- a/src/test/Yavsc.Org.Tests/Mandatory/Remoting.cs +++ b/src/test/Yavsc.Org.Tests/Mandatory/Remoting.cs @@ -8,6 +8,7 @@ using Yavsc.Server.Helpers; namespace Yavsc.Org.Tests { + [Trait("Category", "non-reg")] [Collection("Yavsc Server")] [Trait("regression", "oui")] public class Remoting : BaseTestContext, IClassFixture diff --git a/src/test/Yavsc.Org.Tests/Mandatory/Services.cs b/src/test/Yavsc.Org.Tests/Mandatory/Services.cs deleted file mode 100644 index 8dc0aad36..000000000 --- a/src/test/Yavsc.Org.Tests/Mandatory/Services.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Yavsc.Org.Tests.Mandatory; -using Xunit; - -[Collection("Yavsc Server")] -[Trait("regression", "oui")] -public class Services : BaseTestContext, IClassFixture -{ - public Services(ITestOutputHelper output, WebServerFixture fixture) : base(output, fixture) - { - - } -} diff --git a/src/test/Yavsc.Org.Tests/NonRegression/AbstractTests.cs b/src/test/Yavsc.Org.Tests/NonRegression/AbstractTests.cs index 398542375..b367c974d 100644 --- a/src/test/Yavsc.Org.Tests/NonRegression/AbstractTests.cs +++ b/src/test/Yavsc.Org.Tests/NonRegression/AbstractTests.cs @@ -4,6 +4,7 @@ using Xunit; namespace Yavsc { + [Trait("Category", "non-reg")] [Collection("Yavsc Abstract tests")] [Trait("regression", "II")] public class AbstractTests diff --git a/src/test/Yavsc.Org.Tests/NonRegression/ApplicationUserDisplayTemplateTests.cs b/src/test/Yavsc.Org.Tests/NonRegression/ApplicationUserDisplayTemplateTests.cs index 553d73e83..c281b6999 100644 --- a/src/test/Yavsc.Org.Tests/NonRegression/ApplicationUserDisplayTemplateTests.cs +++ b/src/test/Yavsc.Org.Tests/NonRegression/ApplicationUserDisplayTemplateTests.cs @@ -14,6 +14,7 @@ using Xunit; /// statiquement que le cshtml ne porte plus l'accès fautif. Si /// quelqu'un revert la ligne, ce test casse. /// +[Trait("Category", "non-reg")] public class ApplicationUserDisplayTemplateTests { [Fact] diff --git a/src/test/Yavsc.Org.Tests/NonRegression/AvatarFallbackTests.cs b/src/test/Yavsc.Org.Tests/NonRegression/AvatarFallbackTests.cs index 7513e43e6..465eb1e31 100644 --- a/src/test/Yavsc.Org.Tests/NonRegression/AvatarFallbackTests.cs +++ b/src/test/Yavsc.Org.Tests/NonRegression/AvatarFallbackTests.cs @@ -6,6 +6,7 @@ using Xunit; /// for missing files. The pipeline falls back to static defaults under /// /images/Users/icon_user*.png. /// +[Trait("Category", "non-reg")] public class AvatarFallbackTests : IClassFixture { private readonly TestWebApplicationFactory _factory; diff --git a/src/test/Yavsc.Org.Tests/NonRegression/BillingServiceTests.cs b/src/test/Yavsc.Org.Tests/NonRegression/BillingServiceTests.cs index 6504be24d..8faf4e141 100644 --- a/src/test/Yavsc.Org.Tests/NonRegression/BillingServiceTests.cs +++ b/src/test/Yavsc.Org.Tests/NonRegression/BillingServiceTests.cs @@ -17,6 +17,7 @@ namespace Yavsc // breaking the idempotency count assertion (a flaky failure that // surfaces whenever the fixture's timing shifts). Pinning the class // to the same collection serializes it with the host build. + [Trait("Category", "non-reg")] [Collection("Yavsc Server")] [Trait("regression", "II")] public class BillingServiceTests diff --git a/src/test/Yavsc.Org.Tests/NonRegression/Database.cs b/src/test/Yavsc.Org.Tests/NonRegression/Database.cs index d079ec51c..ea19f93e8 100644 --- a/src/test/Yavsc.Org.Tests/NonRegression/Database.cs +++ b/src/test/Yavsc.Org.Tests/NonRegression/Database.cs @@ -2,6 +2,7 @@ namespace Yavsc.Org.Tests.Mandatory { using Xunit; + [Trait("Category", "non-reg")] [Collection("Database")] [Trait("regression", "II")] [Trait("dev", "wip")] diff --git a/src/test/Yavsc.Org.Tests/NonRegression/EMailling.cs b/src/test/Yavsc.Org.Tests/NonRegression/EMailling.cs index d71e7682d..ef3fe8925 100644 --- a/src/test/Yavsc.Org.Tests/NonRegression/EMailling.cs +++ b/src/test/Yavsc.Org.Tests/NonRegression/EMailling.cs @@ -20,6 +20,7 @@ namespace Yavsc.Org.Tests { + [Trait("Category", "non-reg")] [Collection("EMaillingTeststCollection")] [Trait("regression", "II")] public class EMaillingTests : IClassFixture diff --git a/src/test/Yavsc.Org.Tests/NonRegression/FileServerUrlHelpersTests.cs b/src/test/Yavsc.Org.Tests/NonRegression/FileServerUrlHelpersTests.cs index 88224b577..6e8cfa0cf 100644 --- a/src/test/Yavsc.Org.Tests/NonRegression/FileServerUrlHelpersTests.cs +++ b/src/test/Yavsc.Org.Tests/NonRegression/FileServerUrlHelpersTests.cs @@ -3,6 +3,7 @@ using Yavsc.Abstract.Files; namespace Yavsc.Org.Tests.NonRegression; using Xunit; +[Trait("Category", "non-reg")] public class FileServerUrlHelpersTests { [Fact] diff --git a/src/test/Yavsc.Org.Tests/NonRegression/OidcSeedTests.cs b/src/test/Yavsc.Org.Tests/NonRegression/OidcSeedTests.cs index af449ae71..56f49867a 100644 --- a/src/test/Yavsc.Org.Tests/NonRegression/OidcSeedTests.cs +++ b/src/test/Yavsc.Org.Tests/NonRegression/OidcSeedTests.cs @@ -18,6 +18,7 @@ namespace Yavsc /// must reference an ApiResource, and the seed's translation to /// SQL must stay valid. /// + [Trait("Category", "non-reg")] [Trait("regression", "OIDC seed")] public class OidcSeedTests { diff --git a/src/test/Yavsc.Org.Tests/NonRegression/PerformerCodeInputValidationTests.cs b/src/test/Yavsc.Org.Tests/NonRegression/PerformerCodeInputValidationTests.cs index 4b934baa2..27849f87d 100644 --- a/src/test/Yavsc.Org.Tests/NonRegression/PerformerCodeInputValidationTests.cs +++ b/src/test/Yavsc.Org.Tests/NonRegression/PerformerCodeInputValidationTests.cs @@ -5,6 +5,7 @@ using Xunit; namespace Yavsc.Tests.NonRegression; +[Trait("Category", "non-reg")] public class PerformerCodeInputValidationTests { [Fact] diff --git a/src/test/Yavsc.Org.Tests/NonRegression/SetActivityCountryValidationViewTests.cs b/src/test/Yavsc.Org.Tests/NonRegression/SetActivityCountryValidationViewTests.cs index 3001ad6e5..39e2ecc18 100644 --- a/src/test/Yavsc.Org.Tests/NonRegression/SetActivityCountryValidationViewTests.cs +++ b/src/test/Yavsc.Org.Tests/NonRegression/SetActivityCountryValidationViewTests.cs @@ -7,6 +7,7 @@ namespace Yavsc.Org.Tests.NonRegression; /// - client-side SIREN validation is wired to country-specific regex rules /// - controller exposes the validation catalog to the view /// +[Trait("Category", "non-reg")] public class SetActivityCountryValidationViewTests { [Fact] diff --git a/src/test/Yavsc.Org.Tests/NonRegression/UserDisplayHelpersTests.cs b/src/test/Yavsc.Org.Tests/NonRegression/UserDisplayHelpersTests.cs index c20270cc8..b2f9a891d 100644 --- a/src/test/Yavsc.Org.Tests/NonRegression/UserDisplayHelpersTests.cs +++ b/src/test/Yavsc.Org.Tests/NonRegression/UserDisplayHelpersTests.cs @@ -17,6 +17,7 @@ namespace Yavsc.Org.Tests.NonRegression; /// donnée partielle. Ces tests couvrent les trois formes de /// "donnée absente" : user null, UserName vide, UserName whitespace. /// +[Trait("Category", "non-reg")] public class UserDisplayHelpersTests { [Fact] diff --git a/src/test/Yavsc.Org.Tests/Services/FileSystemAuthManagerTests.cs b/src/test/Yavsc.Org.Tests/Services/FileSystemAuthManagerTests.cs index ff532390f..623c58a84 100644 --- a/src/test/Yavsc.Org.Tests/Services/FileSystemAuthManagerTests.cs +++ b/src/test/Yavsc.Org.Tests/Services/FileSystemAuthManagerTests.cs @@ -8,6 +8,7 @@ using Xunit; namespace Yavsc.Org.Tests.Services; +[Trait("Category", "non-reg")] public class FileSystemAuthManagerTests { [Fact] diff --git a/src/test/Yavsc.Org.Tests/Smoke/AccountSmokeTests.cs b/src/test/Yavsc.Org.Tests/Smoke/AccountSmokeTests.cs index 4a7600596..42bab8ec9 100644 --- a/src/test/Yavsc.Org.Tests/Smoke/AccountSmokeTests.cs +++ b/src/test/Yavsc.Org.Tests/Smoke/AccountSmokeTests.cs @@ -23,6 +23,7 @@ namespace Yavsc.Org.Tests.Smoke; /// entire pipeline (routing + Razor + IdentityServer + EF + DI) /// is wired correctly end-to-end. /// +[Trait("Category", "non-reg")] public class AccountSmokeTests : IClassFixture { private readonly TestWebApplicationFactory _factory; diff --git a/src/test/Yavsc.Org.Tests/Smoke/BlogSmokeTests.cs b/src/test/Yavsc.Org.Tests/Smoke/BlogSmokeTests.cs index e1aedcf0e..a51a46176 100644 --- a/src/test/Yavsc.Org.Tests/Smoke/BlogSmokeTests.cs +++ b/src/test/Yavsc.Org.Tests/Smoke/BlogSmokeTests.cs @@ -16,6 +16,7 @@ namespace Yavsc.Org.Tests.Smoke; /// doc/architecture/decoupage-organisation.md. The smoke /// here asserts the front-end side of the BC. /// +[Trait("Category", "non-reg")] public class BlogSmokeTests : BaseTestContext, IClassFixture { private readonly TestWebApplicationFactory _factory; diff --git a/src/test/Yavsc.Org.Tests/StaticAssetsPathsTests.cs b/src/test/Yavsc.Org.Tests/StaticAssetsPathsTests.cs index d8cbd9b35..825955550 100644 --- a/src/test/Yavsc.Org.Tests/StaticAssetsPathsTests.cs +++ b/src/test/Yavsc.Org.Tests/StaticAssetsPathsTests.cs @@ -24,6 +24,7 @@ using Xunit; /// Once the WebServerFixture is stable in CI, this test can be /// deleted. /// +[Trait("Category", "non-reg")] public class StaticAssetsPathsTests { private readonly ITestOutputHelper _output; diff --git a/src/test/Yavsc.Server.Tests/AccountWithdrawalTests.cs b/src/test/Yavsc.Server.Tests/AccountWithdrawalTests.cs index 8121244fd..017a49a60 100644 --- a/src/test/Yavsc.Server.Tests/AccountWithdrawalTests.cs +++ b/src/test/Yavsc.Server.Tests/AccountWithdrawalTests.cs @@ -13,6 +13,7 @@ using Yavsc.Web.Services; namespace Yavsc.Server.Tests; +[Trait("Category", "non-reg")] public sealed class AccountWithdrawalTests : IDisposable { private readonly string root = Path.Combine(Path.GetTempPath(), "yavsc-withdrawal-" + Guid.NewGuid().ToString("N")); diff --git a/src/test/Yavsc.Server.Tests/BlogSpotServiceDetailsTests.cs b/src/test/Yavsc.Server.Tests/BlogSpotServiceDetailsTests.cs index 713957804..128e053ba 100644 --- a/src/test/Yavsc.Server.Tests/BlogSpotServiceDetailsTests.cs +++ b/src/test/Yavsc.Server.Tests/BlogSpotServiceDetailsTests.cs @@ -26,6 +26,7 @@ namespace Yavsc.Server.Tests; /// before the one reads through, /// mirroring the per-request DbContext lifetime in production. /// +[Trait("Category", "non-reg")] [Collection("Yavsc Server")] public sealed class BlogSpotServiceDetailsTests : IClassFixture { diff --git a/src/test/Yavsc.Server.Tests/CallConnectionPresenceTests.cs b/src/test/Yavsc.Server.Tests/CallConnectionPresenceTests.cs index bf633f831..8389a8523 100644 --- a/src/test/Yavsc.Server.Tests/CallConnectionPresenceTests.cs +++ b/src/test/Yavsc.Server.Tests/CallConnectionPresenceTests.cs @@ -5,6 +5,7 @@ using Yavsc.Services; namespace Yavsc.Server.Tests; +[Trait("Category", "non-reg")] public sealed class CallConnectionPresenceTests { [Fact] diff --git a/src/test/Yavsc.Server.Tests/CallHubTests.cs b/src/test/Yavsc.Server.Tests/CallHubTests.cs index cc07f3572..b71f0cbe8 100644 --- a/src/test/Yavsc.Server.Tests/CallHubTests.cs +++ b/src/test/Yavsc.Server.Tests/CallHubTests.cs @@ -17,6 +17,7 @@ using Yavsc.ViewModels.Chat; namespace Yavsc.Server.Tests; +[Trait("Category", "non-reg")] public sealed class CallHubTests { private sealed class Fixture : IDisposable @@ -88,6 +89,51 @@ public sealed class CallHubTests public HttpContext? HttpContext { get; set; } = context; } + [Fact] + public async Task Room_snapshot_resolves_all_members_without_changing_internal_connection_ids() + { + using var f = new Fixture(); + f.Connections.OnConnected("alice-2", "alice", false); + f.Connections.RoomInfo.Users.AddRange(["bob-1", "alice-2"]); + f.Connections.RoomInfo.Ops.Add("alice-1"); + using var hub = f.Hub("alice", "alice-1"); + hub.Groups = new Groups(); + hub.Clients = new RoomClients(f.Delivery); + + var snapshot = await hub.Join("General"); + + Assert.Equal(["bob", "alice"], snapshot.UserNames); + Assert.Equal(["bob-1", "alice-2"], snapshot.Users); + Assert.Equal(["alice-1"], snapshot.Ops); + Assert.Null(f.Connections.RoomInfo.UserNames); + Assert.NotSame(f.Connections.RoomInfo.Users, snapshot.Users); + Assert.Same(snapshot, Assert.Single(f.Delivery.Messages).Arguments[0]); + } + + private sealed class Groups : IGroupManager + { + public Task AddToGroupAsync(string connectionId, string groupName, CancellationToken ct = default) => + Task.CompletedTask; + public Task RemoveFromGroupAsync(string connectionId, string groupName, CancellationToken ct = default) => + throw new NotSupportedException(); + } + + private sealed class RoomClients(RecordingCallHub delivery) : IHubCallerClients + { + public IClientProxy Caller => delivery.Client("alice-1"); + public IClientProxy All => throw new NotSupportedException(); + public IClientProxy Others => throw new NotSupportedException(); + public IClientProxy AllExcept(IReadOnlyList ids) => throw new NotSupportedException(); + public IClientProxy Client(string id) => throw new NotSupportedException(); + public IClientProxy Clients(IReadOnlyList ids) => throw new NotSupportedException(); + public IClientProxy Group(string name) => throw new NotSupportedException(); + public IClientProxy GroupExcept(string name, IReadOnlyList ids) => throw new NotSupportedException(); + public IClientProxy Groups(IReadOnlyList names) => throw new NotSupportedException(); + public IClientProxy OthersInGroup(string name) => throw new NotSupportedException(); + public IClientProxy User(string id) => throw new NotSupportedException(); + public IClientProxy Users(IReadOnlyList ids) => throw new NotSupportedException(); + } + [Fact] public async Task Invitation_requires_existing_accounts_presence_and_the_authenticated_connection() { @@ -174,6 +220,7 @@ public sealed class CallHubTests private sealed class Connections : IConnexionManager { public HashSet Present { get; } = ["alice", "bob"]; + public ChatRoomInfo RoomInfo { get; } = new() { Name = "General" }; private readonly Dictionary _names = []; public string GetUserName(string cxId) => _names.GetValueOrDefault(cxId)!; public bool IsConnected(string user) => _names.ContainsValue(user); @@ -189,7 +236,11 @@ public sealed class CallHubTests public bool DeOp(string room, string user) => throw new NotSupportedException(); public bool Hop(string room, string user) => throw new NotSupportedException(); public bool DeHop(string room, string user) => throw new NotSupportedException(); - public bool TryGetChanInfo(string room, out ChatRoomInfo info) => throw new NotSupportedException(); + public bool TryGetChanInfo(string room, out ChatRoomInfo info) + { + info = RoomInfo; + return room == RoomInfo.Name; + } public IEnumerable ListChannels(string pattern) => throw new NotSupportedException(); } } diff --git a/src/test/Yavsc.Server.Tests/CallLanSignalingTests.cs b/src/test/Yavsc.Server.Tests/CallLanSignalingTests.cs index d6616de1a..c0a84ae1e 100644 --- a/src/test/Yavsc.Server.Tests/CallLanSignalingTests.cs +++ b/src/test/Yavsc.Server.Tests/CallLanSignalingTests.cs @@ -7,6 +7,7 @@ using Yavsc.Settings; namespace Yavsc.Server.Tests; +[Trait("Category", "non-reg")] public sealed class CallLanSignalingTests { private static LanCallEndpoint Endpoint(string address = "192.168.1.2", int port = 5004) => diff --git a/src/test/Yavsc.Server.Tests/CallSignalingTests.cs b/src/test/Yavsc.Server.Tests/CallSignalingTests.cs index 0124c4b60..140d016a4 100644 --- a/src/test/Yavsc.Server.Tests/CallSignalingTests.cs +++ b/src/test/Yavsc.Server.Tests/CallSignalingTests.cs @@ -10,6 +10,7 @@ using Yavsc.Settings; namespace Yavsc.Server.Tests; +[Trait("Category", "non-reg")] public sealed class CallSignalingTests { private const string Sdp = "v=0\r\no=- 1 1 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111\r\nc=IN IP4 0.0.0.0\r\n"; diff --git a/src/test/Yavsc.Server.Tests/FrontmatterParserTests.cs b/src/test/Yavsc.Server.Tests/FrontmatterParserTests.cs index 95d38bee6..91ca4a074 100644 --- a/src/test/Yavsc.Server.Tests/FrontmatterParserTests.cs +++ b/src/test/Yavsc.Server.Tests/FrontmatterParserTests.cs @@ -2,6 +2,7 @@ using Yavsc.Server.Services; namespace Yavsc.Server.Tests; +[Trait("Category", "non-reg")] public class FrontmatterParserTests { [Fact] diff --git a/src/test/Yavsc.Server.Tests/PayPalSubscriptionGatewayTests.cs b/src/test/Yavsc.Server.Tests/PayPalSubscriptionGatewayTests.cs index 956773020..e3b31a4f9 100644 --- a/src/test/Yavsc.Server.Tests/PayPalSubscriptionGatewayTests.cs +++ b/src/test/Yavsc.Server.Tests/PayPalSubscriptionGatewayTests.cs @@ -8,6 +8,7 @@ using Yavsc.Web.Services; namespace Yavsc.Server.Tests; +[Trait("Category", "non-reg")] public sealed class PayPalSubscriptionGatewayTests { private static CancellationToken Ct => TestContext.Current.CancellationToken; diff --git a/src/test/Yavsc.Server.Tests/PayPalTransactionVerifierTests.cs b/src/test/Yavsc.Server.Tests/PayPalTransactionVerifierTests.cs index cc29691d4..d6ae43caf 100644 --- a/src/test/Yavsc.Server.Tests/PayPalTransactionVerifierTests.cs +++ b/src/test/Yavsc.Server.Tests/PayPalTransactionVerifierTests.cs @@ -5,6 +5,7 @@ using Yavsc.Services; namespace Yavsc.Server.Tests; +[Trait("Category", "non-reg")] public sealed class PayPalTransactionVerifierTests { private static CancellationToken Ct => TestContext.Current.CancellationToken; diff --git a/src/test/Yavsc.Server.Tests/PaymentSummaryTests.cs b/src/test/Yavsc.Server.Tests/PaymentSummaryTests.cs index d05ec4752..527b6dbff 100644 --- a/src/test/Yavsc.Server.Tests/PaymentSummaryTests.cs +++ b/src/test/Yavsc.Server.Tests/PaymentSummaryTests.cs @@ -9,6 +9,7 @@ using Yavsc.Services; namespace Yavsc.Server.Tests; +[Trait("Category", "non-reg")] public class PaymentSummaryTests { [Theory] diff --git a/src/test/Yavsc.Server.Tests/ResourceSubscriptionTests.cs b/src/test/Yavsc.Server.Tests/ResourceSubscriptionTests.cs index 0539e301a..327878043 100644 --- a/src/test/Yavsc.Server.Tests/ResourceSubscriptionTests.cs +++ b/src/test/Yavsc.Server.Tests/ResourceSubscriptionTests.cs @@ -11,6 +11,7 @@ using Yavsc.Web.Services; namespace Yavsc.Server.Tests; +[Trait("Category", "non-reg")] public sealed class ResourceSubscriptionTests { private static readonly DateTimeOffset Start = new(2026, 1, 31, 12, 0, 0, TimeSpan.Zero); diff --git a/src/test/Yavsc.Server.Tests/ResourceUsageTests.cs b/src/test/Yavsc.Server.Tests/ResourceUsageTests.cs index 8870b9b8c..f443a8e15 100644 --- a/src/test/Yavsc.Server.Tests/ResourceUsageTests.cs +++ b/src/test/Yavsc.Server.Tests/ResourceUsageTests.cs @@ -12,6 +12,7 @@ using Yavsc.Abstract.Resources; namespace Yavsc.Server.Tests; +[Trait("Category", "non-reg")] public sealed class ResourceUsageTests { [Theory]