test reorg/filtering
Some checks failed
Dotnet build and test / build (pull_request) Failing after 25s
Some checks failed
Dotnet build and test / build (pull_request) Failing after 25s
This commit is contained in:
parent
2e3f1af6f8
commit
4f95a8840c
75 changed files with 271 additions and 341 deletions
|
|
@ -69,10 +69,7 @@ jobs:
|
|||
YAVSC_API_TEST_NPGSQL_ADMIN_CONNECTION: Host=127.0.0.1;Port=55432;Database=postgres;Username=postgres;Password=postgres;Include Error Detail=true
|
||||
run: |
|
||||
echo "🚀 Lancement des tests..."
|
||||
cd /src/_src && dotnet test \
|
||||
--report-xunit \
|
||||
--report-xunit-html \
|
||||
--report-xunit-html-filename "test-results.html"
|
||||
cd /src/_src && make test
|
||||
TEST_EXIT_CODE=$?
|
||||
echo "Test exit code: $TEST_EXIT_CODE"
|
||||
if [ $TEST_EXIT_CODE -ne 0 ]; then
|
||||
|
|
|
|||
33
Makefile
33
Makefile
|
|
@ -4,6 +4,7 @@ FRAMEWORK=net9.0
|
|||
DESTDIR=/tmp/yavsc
|
||||
APP_PATH=srv/www/yavsc
|
||||
APP_FULL_PATH=$(DESTDIR)/$(APP_PATH)
|
||||
UNITTESTEXTRA= --long-running 8 --filter-trait Category=non-reg --filter-not-trait Speed=Slow --filter-not-trait DependsOn=Native
|
||||
|
||||
all:
|
||||
dotnet build --nologo
|
||||
|
|
@ -19,30 +20,36 @@ src/Yavsc/bin/output/wwwroot:
|
|||
dotnet --project src/Yavsc.Org/Yavsc.Org.csproj publish
|
||||
|
||||
test:
|
||||
ASPNETCORE_ENVIRONMENT=Development dotnet test --report-xunit \
|
||||
--report-xunit-html \
|
||||
--results-directory "test-reports"
|
||||
ASPNETCORE_ENVIRONMENT=Development \
|
||||
TESTINGPLATFORM_EXITCODE_IGNORE="110;1" \
|
||||
dotnet test yavsc.sln \
|
||||
-- --report-xunit \
|
||||
--report-xunit-html \
|
||||
--results-directory "test-reports" \
|
||||
$(UNITTESTEXTRA) || EXITCODE=$$? && echo "🗱💻 Tests failed, exited with code $$EXITCODE";
|
||||
|
||||
test-postit:
|
||||
ASPNETCORE_ENVIRONMENT=Development dotnet test \
|
||||
--report-xunit \
|
||||
--report-xunit-html \
|
||||
--results-directory "test-reports" \
|
||||
--report-xunit-html-filename "postit-test-results.html" \
|
||||
--no-progress \
|
||||
--project src/PostIt/PostIt.Tests/PostIt.Tests.csproj
|
||||
ASPNETCORE_ENVIRONMENT=Development \
|
||||
TESTINGPLATFORM_EXITCODE_IGNORE="110;1" \
|
||||
dotnet test \
|
||||
src/PostIt/PostIt.Tests/PostIt.Tests.csproj \
|
||||
-- --report-xunit \
|
||||
--report-xunit-html \
|
||||
--results-directory "test-reports" \
|
||||
--report-xunit-html-filename "postit-test-results.html" \
|
||||
$(UNITTESTEXTRA) || EXITCODE=$$? && echo "🗱📱 Tests failed, exited with code $$EXITCODE";
|
||||
|
||||
backend-tests: Blogs-backend-test Org-backend-test Api-backend-test
|
||||
Api-backend-test:
|
||||
Blogs-backend-test:
|
||||
Org-backend-test:
|
||||
%-backend-test:
|
||||
ASPNETCORE_ENVIRONMENT=Development dotnet test \
|
||||
ASPNETCORE_ENVIRONMENT=Development dotnet test
|
||||
src/test/Yavsc.$*.Tests/Yavsc.$*.Tests.csproj \
|
||||
--report-xunit \
|
||||
--report-xunit-html \
|
||||
--results-directory "test-reports" \
|
||||
--report-xunit-html-filename "$*-backend-test-results.html" \
|
||||
--project src/test/Yavsc.$*.Tests/Yavsc.$*.Tests.csproj
|
||||
--report-xunit-html-filename "$*-backend-test-results.html"
|
||||
|
||||
watch:
|
||||
dotnet watch -p:Configuration=$(CONFIG) --project src/Yavsc/Yavsc.csproj
|
||||
|
|
|
|||
173
doc/plan-test-cleanup.md
Normal file
173
doc/plan-test-cleanup.md
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
# Plan de nettoyage de la suite PostIt
|
||||
|
||||
## Objectif
|
||||
|
||||
Rendre la suite PostIt plus rapide, plus fiable et plus lisible, sans bloquer le développement quotidien par des tests dépendants d’un matériel, d’un binaire externe ou d’un environnement local spécifique.
|
||||
|
||||
## Problème actuel
|
||||
|
||||
La suite a grossi sans vraie séparation entre :
|
||||
|
||||
- tests rapides et déterministes,
|
||||
- tests UI headless,
|
||||
- tests d’intégration,
|
||||
- tests dépendants de l’environnement,
|
||||
- tests Android / native / device-specific.
|
||||
|
||||
Résultat : la routine par défaut devient bruitée et peu fiable, et les sujets de fond (comportement métier) sont noyés dans des tests exigeants en dépendances système.
|
||||
|
||||
## Plan proposé
|
||||
|
||||
### 1. Séparer la suite par catégorie de dépendance
|
||||
|
||||
Les tests doivent être classés selon leur coût et leur dépendance externe, avec des annotations de classe xUnit du type :
|
||||
|
||||
```csharp
|
||||
[Trait("Category", "Native")]
|
||||
[Trait("Category", "Slow")]
|
||||
public sealed class PodcastNativeCaptureTests
|
||||
```
|
||||
|
||||
Et pour les tests Android :
|
||||
|
||||
```csharp
|
||||
[Trait("Category", "Android")]
|
||||
public class AndroidAppLaunchTests
|
||||
```
|
||||
|
||||
|
||||
- Fast unit tests
|
||||
- Headless UI tests
|
||||
- Integration tests
|
||||
- Native / environment-dependent tests
|
||||
- Android-only tests
|
||||
|
||||
La règle doit être simple : un test ne doit entrer dans la routine par défaut que s’il est exécutable sans matériel, binaire externe ni fichier de test local spécifique.
|
||||
|
||||
### 2. Garder la routine par défaut “portable”
|
||||
|
||||
La suite standard de développement doit couvrir uniquement :
|
||||
|
||||
- les comportements métier,
|
||||
- les flux UI sans environnement spécifique,
|
||||
- les tests reproductibles sans dépendances natives.
|
||||
|
||||
Les tests qui exigent :
|
||||
|
||||
- LibVLC,
|
||||
- ffprobe / codecs,
|
||||
- fichiers médias locaux,
|
||||
- Android emulator / adb,
|
||||
- services device-bound,
|
||||
|
||||
doivent être exclus de la routine standard.
|
||||
|
||||
### 3. Isoler les tests non-portables
|
||||
|
||||
Les tests dépendants de l’environnement doivent être déplacés ou séparés dans une catégorie spécifique, par exemple :
|
||||
|
||||
- `Native`
|
||||
- `Android`
|
||||
- `Slow`
|
||||
|
||||
Cela permet de conserver la signalisation de leur objectif sans polluer la suite principale.
|
||||
|
||||
### 4. Nettoyer les doublons fonctionnels
|
||||
|
||||
Les tests qui vérifient le même comportement avec seulement de légères variantes doivent être regroupés, fusionnés ou simplifiés.
|
||||
|
||||
Règle de qualité :
|
||||
|
||||
- 1 test = 1 comportement clair,
|
||||
- 1 titre = 1 intention claire,
|
||||
- 1 appel de fonction = 1 vérification utile.
|
||||
|
||||
### 5. Structurer les tests par feature et par niveau
|
||||
|
||||
Exemple de structure suggérée :
|
||||
|
||||
- `PostIt.Tests/Fast/`
|
||||
- `PostIt.Tests/Headless/`
|
||||
- `PostIt.Tests/Integration/`
|
||||
- `PostIt.Tests/Native/`
|
||||
- `PostIt.Tests/Android/`
|
||||
|
||||
Cette structure permet de distinguer immédiatement les tests de comportement des tests d’infrastructure.
|
||||
|
||||
### 6. Séparer la CI en deux niveaux
|
||||
|
||||
- CI standard / PR : tests rapides + headless
|
||||
- CI nocturne / full : tests native + Android + integration lourde
|
||||
|
||||
Cela permet d’avoir un cycle de développement rapide sans sacrifier une vraie validation dans les scénarios spécifiques.
|
||||
|
||||
## Catégorisation cible des tests
|
||||
|
||||
Important : les catégories xUnit ne doivent être appliquées qu’aux vraies classes de test. Les `Activity` Android utilisées comme harness de test ne sont pas des classes de test et ne doivent pas porter de `[Trait("Category", ...)]`.
|
||||
|
||||
### Native
|
||||
|
||||
Classes de test xUnit qui dépendent de LibVLC, de fichiers multimédia locaux, de codecs ou d’un support natif Linux/OS spécifique.
|
||||
|
||||
- `LinuxLanCallMediaTests`
|
||||
- `PodcastNativeCaptureTests`
|
||||
- `PodcastReplayTests`
|
||||
- `WebRtcCallViewModelTests` — sous-cas natif activé avec `POSTIT_TEST_NATIVE_WEBRTC=1`
|
||||
|
||||
### Android
|
||||
|
||||
Classes de test xUnit qui tournent sur un contexte Android spécifique, sur `adb`, sur un émulateur ou sur un device Android réel.
|
||||
|
||||
- `AndroidAppLaunchTests`
|
||||
|
||||
### Slow
|
||||
|
||||
Classes de test xUnit lourdes ou lentes, souvent partielles sur le flux média, la capture ou la lecture de données. Elles doivent être explicitement marquées comme `Slow` pour ne pas polluer la suite standard.
|
||||
|
||||
- `PodcastNativeCaptureTests`
|
||||
- `PodcastReplayTests`
|
||||
- `LinuxLanCallMediaTests`
|
||||
- `WebRtcCallViewModelTests` — variante native / réseau / media-heavy
|
||||
|
||||
### Harness Android de support (non test classes)
|
||||
|
||||
Ces classes servent à déclencher un test Android dans un `Activity` dédié, mais elles ne sont pas des classes xUnit de test et ne portent pas de trait de catégorie.
|
||||
|
||||
- `AndroidCameraFrameRotationTestActivity`
|
||||
- `AndroidChatServiceTestActivity`
|
||||
- `AndroidLanCallTestActivity`
|
||||
- `AndroidMarkdownEditorTestActivity`
|
||||
- `AndroidPodcastBlurTestActivity`
|
||||
- `AndroidPodcastCaptureTestActivity`
|
||||
- `AndroidScreenAwakeTestActivity`
|
||||
- `AndroidWebRtcTestActivity`
|
||||
|
||||
### Tests non-portables à sortir de la routine par défaut
|
||||
|
||||
Les classes de test ci-dessous dépendent d’un environnement local spécifique, d’un binaire externe ou d’un matériel Android / native. Elles ne devraient pas faire partie de la routine quotidienne standard.
|
||||
|
||||
- `AndroidAppLaunchTests`
|
||||
- `LinuxLanCallMediaTests`
|
||||
- `PodcastNativeCaptureTests`
|
||||
- `PodcastReplayTests`
|
||||
- `WebRtcCallViewModelTests` — cas native spécifique avec `POSTIT_TEST_NATIVE_WEBRTC=1`
|
||||
|
||||
## Exemples de dépendances qui rendent ces tests non-portables
|
||||
|
||||
- `POSTIT_TEST_MEDIA`
|
||||
- `POSTIT_TEST_TS`
|
||||
- `POSTIT_TEST_REPLAY`
|
||||
- `POSTIT_TEST_NATIVE_WEBRTC`
|
||||
- `adb` / appareil Android connecté
|
||||
- LibVLC installé avec les codecs nécessaires
|
||||
- fichiers vidéo/audio locaux
|
||||
- machines Linux spécifiques
|
||||
|
||||
## État souhaité
|
||||
|
||||
Une suite PostIt propre doit avoir :
|
||||
|
||||
- une routine standard courte et stable,
|
||||
- des tests natifs clairement isolés,
|
||||
- une séparation nette des responsabilités,
|
||||
- un signal de qualité lisible pour les contributeurs.
|
||||
13
package.json
13
package.json
|
|
@ -10,22 +10,13 @@
|
|||
"clean:js": "node esbuild.config.mjs --clean"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aspnet/signalr": "^1.0.27",
|
||||
"bootstrap": "^4.6.2",
|
||||
"dropzone": "^5.9.3",
|
||||
"eonasdan-bootstrap-datetimepicker": "^4.17.49",
|
||||
"hls.js": "1.6.13",
|
||||
"jquery": "^3.7.1",
|
||||
"jquery-timepicker": "^1.3.3",
|
||||
"jquery-ui": "^1.13.3",
|
||||
"jquery-validation": "^1.20.0",
|
||||
"jquery-validation-unobtrusive": "^4.0.0",
|
||||
"moment": "^2.30.1",
|
||||
"quill": "^1.3.7",
|
||||
"showdown": "^2.1.0",
|
||||
"to-markdown": "^3.1.1"
|
||||
"jquery-validation-unobtrusive": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.24.0"
|
||||
"esbuild": "^0.28.2"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using PostIt.ViewModels;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class AboutTermsTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using Yavsc.Api.Client;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class ActivitiesPageViewModelTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using PostIt.Views;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class ActivityNavigationTests
|
||||
{
|
||||
[AvaloniaFact]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PostIt.Helpers;
|
||||
using PostIt.Services;
|
||||
using PostIt.ViewModels;
|
||||
using PostIt.Views;
|
||||
|
|
@ -29,6 +28,7 @@ namespace PostIt.Tests;
|
|||
/// click via <c>button.Command?.Execute(...)</c> + flush
|
||||
/// any async command before asserting.</para>
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class AddCircleMemberDialogTests
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
|
|
@ -13,6 +12,7 @@ using Yavsc.Api.Client;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class AdministrationAccessTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
@ -41,44 +41,6 @@ public class AdministrationAccessTests
|
|||
Assert.Contains("les usages restent consultables", model.StatusMessage);
|
||||
}
|
||||
|
||||
[AvaloniaTheory]
|
||||
[InlineData("Moderator", false)]
|
||||
[InlineData("Administrator", true)]
|
||||
[InlineData("administrator", false)]
|
||||
[InlineData("Performer", false)]
|
||||
[InlineData("moderator", false)]
|
||||
[InlineData("", false)]
|
||||
public async Task Home_administration_visibility_and_command_follow_the_administrator_role(string role, bool allowed)
|
||||
{
|
||||
await using var api = new ProfileTransport(role);
|
||||
var session = new SessionStatusViewModel { Api = api };
|
||||
var vm = new HomePageViewModel(api, api.Settings, session, null!);
|
||||
var page = new HomePage { DataContext = vm };
|
||||
var window = new Window { Content = page };
|
||||
try
|
||||
{
|
||||
window.Show();
|
||||
var button = Assert.Single(page.GetVisualDescendants().OfType<Button>(),
|
||||
button => Equals(button.Content, "Administration"));
|
||||
Assert.False(button.IsVisible);
|
||||
await session.RefreshAsync();
|
||||
Assert.Equal(allowed, session.IsAdministrator);
|
||||
Assert.Equal(allowed, button.IsVisible);
|
||||
Assert.Equal(allowed, vm.OpenAdministration.CanExecute(null));
|
||||
Assert.DoesNotContain(page.GetVisualDescendants().OfType<Button>(),
|
||||
button => Equals(button.Content, "Mon usage / administration"));
|
||||
|
||||
session.Api = null;
|
||||
session.Refresh();
|
||||
Assert.False(button.IsVisible);
|
||||
Assert.False(vm.OpenAdministration.CanExecute(null));
|
||||
}
|
||||
finally
|
||||
{
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Late_role_response_cannot_restore_access_after_logout()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
|
|
@ -13,6 +12,7 @@ using Yavsc.Api.Client;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class AdministrationToolsTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ namespace PostIt.Tests;
|
|||
/// Skip conditions: the package is not installed on the connected device,
|
||||
/// or no device is connected via adb.
|
||||
/// </summary>
|
||||
[Trait("Category", "Platform-Android")]
|
||||
[Trait("Platform", "Android")]
|
||||
[Trait("Category", "non-reg")]
|
||||
public class AndroidAppLaunchTests
|
||||
{
|
||||
private const string PackageName = "fr.pschneider.postit";
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ namespace PostIt.Tests;
|
|||
/// it reaches production.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class BearerScopeTests
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ using Yavsc.Models.Haircut;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class BillingCommandPageViewModelTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using Yavsc.Api.Client;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class BillingQueriesPageViewModelTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ namespace PostIt.Tests;
|
|||
/// (relative, authority-less) instead of
|
||||
/// <c>https://{authority}/files/{user}/blogs/{id}/{name}</c>.</para>
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class BlogAttachmentLinkTests
|
||||
{
|
||||
[Theory]
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ namespace PostIt.Tests;
|
|||
/// it actually manifested in production.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class BlogPostAuthorDtoTests
|
||||
{
|
||||
private static readonly JsonSerializerOptions CaseInsensitiveJson
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ using SkiaSharp;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class BlogReaderTests
|
||||
{
|
||||
private static BlogPostDto Post(string article = "Texte du billet.") => new()
|
||||
|
|
@ -139,57 +140,6 @@ public class BlogReaderTests
|
|||
}
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Reader_initialization_and_empty_selection_do_not_report_binding_errors()
|
||||
{
|
||||
var vm = CreateViewModel();
|
||||
await vm.InitializeAsync();
|
||||
var post = Post();
|
||||
vm.Posts.Add(post);
|
||||
vm.FilteredPosts.Add(post);
|
||||
var previousSink = Logger.Sink;
|
||||
var sink = new RecordingLogSink();
|
||||
Logger.Sink = sink;
|
||||
Window? window = null;
|
||||
try
|
||||
{
|
||||
var page = new BlogsPage();
|
||||
var reader = page.FindControl<MarkdownScrollViewer>("ArticleReader")!;
|
||||
var engine = Assert.IsAssignableFrom<IMarkdownEngine2>(reader.Engine);
|
||||
Assert.NotNull(engine.HyperlinkCommand);
|
||||
Assert.False(engine.HyperlinkCommand.CanExecute("https://example.test/"));
|
||||
page.DataContext = vm;
|
||||
var nav = new NavigationPage();
|
||||
await nav.PushAsync(page);
|
||||
window = new Window { Width = 800, Height = 700, Content = nav };
|
||||
window.Show();
|
||||
Dispatcher.UIThread.RunJobs();
|
||||
Assert.Empty(vm.ReaderTitle);
|
||||
Assert.Null(vm.ReaderDateModified);
|
||||
Assert.Same(vm.OpenResourceCommand, engine.HyperlinkCommand);
|
||||
Assert.IsType<BlogImageResolver>(reader.Plugins.PathResolver);
|
||||
|
||||
vm.SelectedPost = post;
|
||||
Dispatcher.UIThread.RunJobs();
|
||||
Assert.Equal(post.Title, vm.ReaderTitle);
|
||||
Assert.Equal(post.DateModified, vm.ReaderDateModified);
|
||||
|
||||
vm.SelectedPost = null;
|
||||
page.DataContext = null;
|
||||
Dispatcher.UIThread.RunJobs();
|
||||
Assert.Empty(vm.ReaderTitle);
|
||||
Assert.Null(vm.ReaderDateModified);
|
||||
Assert.NotNull(engine.HyperlinkCommand);
|
||||
Assert.False(engine.HyperlinkCommand.CanExecute("https://example.test/"));
|
||||
Assert.DoesNotContain(sink.Entries, entry => entry.Area == LogArea.Binding);
|
||||
}
|
||||
finally
|
||||
{
|
||||
window?.Close();
|
||||
Logger.Sink = previousSink;
|
||||
}
|
||||
}
|
||||
|
||||
[AvaloniaTheory]
|
||||
[InlineData(360, 800, false)]
|
||||
[InlineData(1000, 420, true)]
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using PostIt.Services;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class BlogResourceServiceTests
|
||||
{
|
||||
private const string Authority = "https://yavsc.pschneider.fr";
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using Yavsc.Abstract.Chat.Calls;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class CallSignalingClientTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using PostIt.Android.Services;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class CameraFrameClockTests
|
||||
{
|
||||
[Theory]
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using PostIt.Android.Services;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class CameraFrameOrientationTests
|
||||
{
|
||||
[Theory]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using System.Net.Http;
|
||||
using PostIt.Models;
|
||||
using PostIt.ViewModels;
|
||||
using Yavsc;
|
||||
|
|
@ -6,6 +5,7 @@ using Yavsc.Api.Client;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class EstimateEditionPageViewModelTests
|
||||
{
|
||||
private static BillingQuerySummaryDto SampleQuery() => new()
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using Yavsc.Api.Client;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class EstimateListPageViewModelTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using PostIt.Controls;
|
||||
using PostIt.ViewModels;
|
||||
using Yavsc.Api.Client;
|
||||
|
|
@ -19,6 +16,7 @@ namespace PostIt.Tests;
|
|||
/// <c>TestApp</c> makes <c>GoBackAsync</c> a no-op, so the success paths
|
||||
/// run to completion without navigation side effects.
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class EstimateValidationPageViewModelTests
|
||||
{
|
||||
private static EstimateDto SampleEstimate(long? commandId = 42) => new()
|
||||
|
|
@ -252,4 +250,4 @@ public class EstimateValidationPageViewModelTests
|
|||
|
||||
public ValueTask DisposeAsync() => ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using System.Net.Http;
|
||||
using Yavsc.Api.Client;
|
||||
|
||||
namespace PostIt.Tests;
|
||||
|
|
@ -9,6 +8,7 @@ namespace PostIt.Tests;
|
|||
/// the PostIt signature payload, using a recording fake
|
||||
/// <see cref="IYavscApiClient"/> (no network).
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class FrontOfficeApiClientTests
|
||||
{
|
||||
private static QueryAcceptanceRequestDto SampleBody() => new()
|
||||
|
|
@ -154,4 +154,4 @@ public class FrontOfficeApiClientTests
|
|||
|
||||
public ValueTask DisposeAsync() => ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
using System.Net.Http;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.VisualTree;
|
||||
using PostIt.Services;
|
||||
using PostIt.ViewModels;
|
||||
using PostIt.Views;
|
||||
using Yavsc.Abstract.Models.Messaging;
|
||||
using Yavsc.Api.Client;
|
||||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class HomePageNotificationsTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
@ -164,56 +161,6 @@ public class HomePageNotificationsTests
|
|||
Assert.Null(transport.LastMethod);
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Home_page_loads_on_navigation_and_renders_wrapped_titles_and_bodies()
|
||||
{
|
||||
var transport = new NotificationTransport
|
||||
{
|
||||
Response = Task.FromResult(new List<Notification> { Note(1, "Notification title") })
|
||||
};
|
||||
var vm = CreateViewModel(transport);
|
||||
var page = new HomePage { DataContext = vm };
|
||||
var nav = new NavigationPage();
|
||||
var window = new Window { Content = nav, Width = 320, Height = 450 };
|
||||
try
|
||||
{
|
||||
window.Show();
|
||||
await nav.PushAsync(page);
|
||||
window.UpdateLayout();
|
||||
|
||||
Assert.Single(vm.Notifications);
|
||||
var texts = page.GetVisualDescendants().OfType<TextBlock>().ToArray();
|
||||
Assert.Contains(texts, t => t.Text == "Notification title"
|
||||
&& t.TextWrapping == Avalonia.Media.TextWrapping.Wrap);
|
||||
Assert.Contains(texts, t => t.Text == "Notification body"
|
||||
&& t.TextWrapping == Avalonia.Media.TextWrapping.Wrap);
|
||||
var refresh = Assert.Single(page.GetVisualDescendants().OfType<Button>(),
|
||||
b => b.Command == vm.RefreshNotificationsCommand);
|
||||
Assert.True(refresh.IsEnabled);
|
||||
var dismiss = Assert.Single(page.GetVisualDescendants().OfType<Button>(),
|
||||
b => b.Command == vm.DismissNotificationCommand);
|
||||
Assert.Same(vm.Notifications[0], dismiss.CommandParameter);
|
||||
Assert.Equal("Close", dismiss.Content);
|
||||
Assert.True(dismiss.IsVisible);
|
||||
Assert.True(dismiss.IsEnabled);
|
||||
Assert.Contains(page.GetVisualDescendants().OfType<ScrollViewer>(),
|
||||
s => s.Extent.Height > s.Viewport.Height);
|
||||
|
||||
await nav.PushAsync(new ContentPage());
|
||||
transport.Response = Task.FromResult(new List<Notification> { Note(2, "Updated title") });
|
||||
await nav.PopAsync();
|
||||
Assert.Equal(2, Assert.Single(vm.Notifications).Id);
|
||||
await vm.DismissNotificationCommand.ExecuteAsync(vm.Notifications[0]);
|
||||
window.UpdateLayout();
|
||||
Assert.Empty(vm.Notifications);
|
||||
Assert.Null(transport.LastMethod);
|
||||
}
|
||||
finally
|
||||
{
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private static HomePageViewModel CreateViewModel(NotificationTransport transport,
|
||||
SessionStatusViewModel? session = null)
|
||||
=> new(null!, new Settings(), session ?? new SessionStatusViewModel(),
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using PostIt.ViewModels;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class HomePageProviderFlowTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
using System.Net.Http;
|
||||
using Yavsc.Api.Client;
|
||||
using Yavsc.Billing;
|
||||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class InvoicesApiClientTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using Yavsc.Abstract.Chat.Calls;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class LanCallViewModelTests
|
||||
{
|
||||
[AvaloniaFact]
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ using PostIt.Services;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("DependsOn", "Native")]
|
||||
[Trait("Speed", "Slow")]
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class LinuxLanCallMediaTests(ITestOutputHelper output)
|
||||
{
|
||||
public static bool HasFixture => OperatingSystem.IsLinux() &&
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ using PostIt.Services;
|
|||
using PostIt.ViewModels;
|
||||
using PostIt.Views;
|
||||
using PostIt.Views.Blogs;
|
||||
using PostIt.Helpers;
|
||||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
|
|
@ -50,6 +49,7 @@ namespace PostIt.Tests;
|
|||
/// stack.</item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class MainPageButtonsTests
|
||||
{
|
||||
[AvaloniaFact]
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ using Avalonia.VisualTree;
|
|||
using Yavsc.Blogspot;
|
||||
using Yavsc.Api.Client;
|
||||
using PostIt.ViewModels;
|
||||
using PostIt.Views;
|
||||
using PostIt.Views.Blogs;
|
||||
namespace PostIt.Tests;
|
||||
|
||||
|
|
@ -30,6 +29,7 @@ namespace PostIt.Tests;
|
|||
/// pass once the VM owns a dedicated <c>Title</c>/<c>Article</c>
|
||||
/// buffer that the XAML binds to and the Save command consumes.</para>
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class MainPageSaveTests
|
||||
{
|
||||
[AvaloniaFact]
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ using PostIt.Views.Blogs;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class MarkdownEditorScrollTests
|
||||
{
|
||||
private static readonly string LongArticle =
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ using PostIt.Services;
|
|||
using PostIt.ViewModels;
|
||||
using PostIt.ViewModels.Chat;
|
||||
using PostIt.Views;
|
||||
using Yavsc.Api.Client;
|
||||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class MessagingSessionTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ namespace PostIt.Tests;
|
|||
/// <c>ExecutionTask</c> to completion, to avoid blocking on the
|
||||
/// (platform-dependent) picker.</para>
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class MyFilesPageHeadlessTests
|
||||
{
|
||||
private static (MyFilesPage page, MyFilesViewModel vm, StubFsApi api) CreatePage()
|
||||
|
|
@ -205,4 +206,4 @@ public class MyFilesPageHeadlessTests
|
|||
|
||||
public ValueTask DisposeAsync() => ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using PostIt.Services;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class NominatimReverseGeocodingServiceTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
@ -69,4 +70,4 @@ public class NominatimReverseGeocodingServiceTests
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using Yavsc.Api.Client;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class PerformerDonationSettingsTests
|
||||
{
|
||||
[Theory]
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ using Yavsc.Api.Client;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "not-ending")]
|
||||
public sealed class PodcastBroadcasterTests
|
||||
{
|
||||
[Theory]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.Json;
|
||||
using LibVLCSharp.Shared;
|
||||
using PostIt.Services;
|
||||
|
|
@ -10,18 +8,18 @@ using Yavsc.Api.Client;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("DependsOn", "Native")]
|
||||
[Trait("Speed", "Slow")]
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class PodcastNativeCaptureTests(ITestOutputHelper output)
|
||||
{
|
||||
public static bool HasFixture => File.Exists(Environment.GetEnvironmentVariable("POSTIT_TEST_MEDIA"));
|
||||
|
||||
[Theory(Skip = "Set POSTIT_TEST_MEDIA to a local video with audio and install LibVLC with H.264/AAC encoders.", SkipUnless = nameof(HasFixture))]
|
||||
[InlineData(false)]
|
||||
[InlineData(true)]
|
||||
public async Task LibVLC_produces_complete_H264_AAC_HLS_segments_without_external_encoder(bool preview)
|
||||
[Fact(Skip = "Set POSTIT_TEST_MEDIA to a local video with audio and install LibVLC with H.264/AAC encoders.", SkipUnless = nameof(HasFixture))]
|
||||
public async Task LibVLC_produces_complete_H264_AAC_HLS_segments_without_external_encoder()
|
||||
{
|
||||
var root = Path.Combine(Path.GetTempPath(), $"postit native's hls {Guid.NewGuid():N}");
|
||||
Directory.CreateDirectory(root);
|
||||
var pixels = preview ? Marshal.AllocHGlobal(640 * 480 * 4) : IntPtr.Zero;
|
||||
try
|
||||
{
|
||||
Core.Initialize();
|
||||
|
|
@ -29,24 +27,12 @@ public sealed class PodcastNativeCaptureTests(ITestOutputHelper output)
|
|||
"--avcodec-hw=none", "--avcodec-threads=2");
|
||||
using var media = new Media(vlc, new Uri(Path.GetFullPath(Environment.GetEnvironmentVariable("POSTIT_TEST_MEDIA")!)));
|
||||
using var player = new MediaPlayer(vlc);
|
||||
var displayed = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
if (preview)
|
||||
{
|
||||
player.SetVideoFormat("RV32", 640, 480, 640 * 4);
|
||||
player.SetVideoCallbacks((_, planes) =>
|
||||
{
|
||||
Marshal.WriteIntPtr(planes, pixels);
|
||||
return IntPtr.Zero;
|
||||
}, null, (_, _) => displayed.TrySetResult());
|
||||
}
|
||||
PodcastBroadcaster.ConfigureOutput(media, root, preview);
|
||||
PodcastBroadcaster.ConfigureOutput(media, root);
|
||||
var ended = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
player.EndReached += (_, _) => ended.TrySetResult();
|
||||
player.EncounteredError += (_, _) => ended.TrySetException(new InvalidOperationException("LibVLC encoding failed."));
|
||||
Assert.True(player.Play(media));
|
||||
output.WriteLine($"Encoding started (preview={preview}).");
|
||||
if (preview)
|
||||
await displayed.Task.WaitAsync(TimeSpan.FromSeconds(10), TestContext.Current.CancellationToken);
|
||||
output.WriteLine("Encoding started.");
|
||||
await ended.Task.WaitAsync(TimeSpan.FromSeconds(45), TestContext.Current.CancellationToken);
|
||||
output.WriteLine("End reached; stopping player.");
|
||||
player.Stop();
|
||||
|
|
@ -88,7 +74,6 @@ public sealed class PodcastNativeCaptureTests(ITestOutputHelper output)
|
|||
}
|
||||
finally
|
||||
{
|
||||
if (pixels != IntPtr.Zero) Marshal.FreeHGlobal(pixels);
|
||||
Directory.Delete(root, recursive: true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using Yavsc.Abstract.Streaming;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class PodcastPreferencesTests
|
||||
{
|
||||
[AvaloniaFact]
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ using Yavsc.Api.Client;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("DependsOn", "Native")]
|
||||
[Trait("Speed", "Slow")]
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class PodcastReplayTests
|
||||
{
|
||||
private static readonly Guid Id = Guid.NewGuid();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using Yavsc.Api.Client;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class PodcastScheduleTests
|
||||
{
|
||||
[AvaloniaFact]
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using Yavsc.Api.Client;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class PodcastTests
|
||||
{
|
||||
private static readonly Guid Id = Guid.Parse("9e2f6d47-2b9a-47ae-a870-073980bf2628");
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ namespace PostIt.Tests;
|
|||
/// <see cref="BlogAclApiClient"/> / <see cref="CircleApiClient"/>
|
||||
/// talking to it.</para>
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class PostAclDialogTests
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ using PostIt.Views.Blogs;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class PostItViewModelTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using Yavsc.Api.Client;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class ProviderOngoingRequestsPageViewModelTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using Yavsc.Api.Client;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class RdvPageHeadlessTests
|
||||
{
|
||||
[AvaloniaFact]
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using PostIt.Views.Commands;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class RdvPageTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
@ -27,4 +28,4 @@ public class RdvPageTests
|
|||
|
||||
Assert.False(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using Yavsc.Api.Client;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class ResourceUsageApiClientTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ using Yavsc.Api.Client;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class ResourceUsageReliefPageTests
|
||||
{
|
||||
private static ResourceUsageSummary Usage(string id, decimal consumption, decimal credits = 0m) => new()
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ namespace PostIt.Tests;
|
|||
/// even when Avalonia has not booted, otherwise the 2nd instance
|
||||
/// flashes its own MainWindow before shutting down.
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class SchemeUrlDetectorTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using PostIt.Services;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class ScreenAwakeRequestsTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -1,116 +0,0 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.VisualTree;
|
||||
using PostIt.ViewModels;
|
||||
using PostIt.Views;
|
||||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// UI tests for <see cref="SessionStatusBanner"/>. Mounted inside
|
||||
/// a real <see cref="MainView"/> via the headless Avalonia
|
||||
/// platform declared in <c>TestApp.cs</c>.
|
||||
///
|
||||
/// <para>The pattern is the one that <c>UnitTest1.MainPage_Should_Load</c>
|
||||
/// established: a test attribute <c>[AvaloniaFact]</c> (from
|
||||
/// <c>Avalonia.Headless.XUnit</c>) instead of plain <c>[Fact]</c>,
|
||||
/// <c>new MainWindow()</c>, <c>window.Show()</c>. The AvaloniaFact
|
||||
/// attribute schedules the test body inside a dispatcher, which
|
||||
/// is the precondition for the headless Window's
|
||||
/// <c>PlatformManager.CreateWindow()</c> to find a registered
|
||||
/// service. A plain <c>[Fact]</c> test that calls
|
||||
/// <c>new Window().Show()</c> throws because the harness has not
|
||||
/// been initialised for that thread.</para>
|
||||
///
|
||||
/// <para>These tests set the DataContext directly on the banner
|
||||
/// mounted in the window. The production code path is exercised
|
||||
/// end-to-end by the manual launch, not here.</para>
|
||||
/// </summary>
|
||||
public class SessionStatusBannerTests : IDisposable
|
||||
{
|
||||
private MainWindow? _window;
|
||||
|
||||
[AvaloniaFact]
|
||||
public void Banner_renders_four_buttons_in_the_visual_tree()
|
||||
{
|
||||
SessionStatusBanner banner = CreateBanner();
|
||||
|
||||
var buttons = banner.GetVisualDescendants()
|
||||
.OfType<Button>()
|
||||
.ToList();
|
||||
|
||||
Assert.Equal(4, buttons.Count);
|
||||
Assert.Contains(buttons, b => b.Content as string == "Se déconnecter");
|
||||
Assert.Contains(buttons, b => b.Content as string == "Se connecter");
|
||||
Assert.Contains(buttons, b => b.Content as string == "Paramètres");
|
||||
Assert.Contains(buttons, b => b.Content as string == "À propos");
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public void Banner_login_button_is_visible_when_logged_out()
|
||||
{
|
||||
SessionStatusBanner banner = CreateBanner();
|
||||
|
||||
var login = banner.GetVisualDescendants()
|
||||
.OfType<Button>()
|
||||
.Single(b => b.Content as string == "Se connecter");
|
||||
|
||||
// The XAML binds IsVisible to IsLoggedOut. After Show,
|
||||
// the binding has been evaluated.
|
||||
Assert.True(login.IsVisible);
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public void Banner_logout_button_is_hidden_when_logged_out()
|
||||
{
|
||||
SessionStatusBanner banner = CreateBanner();
|
||||
|
||||
Assert.False(Assert.IsType<SessionStatusViewModel>(banner.DataContext).IsLoggedIn);
|
||||
var logout = banner.GetVisualDescendants()
|
||||
.OfType<Button>()
|
||||
.Single(b => b.Content as string == "Se déconnecter");
|
||||
|
||||
Assert.False(logout.IsVisible);
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public void Banner_settings_button_is_visible_regardless_of_session()
|
||||
{
|
||||
SessionStatusBanner banner = CreateBanner();
|
||||
|
||||
var settings = banner.GetVisualDescendants()
|
||||
.OfType<Button>()
|
||||
.Single(b => b.Content as string == "Paramètres");
|
||||
|
||||
// Paramètres has no IsVisible binding and is always shown.
|
||||
Assert.True(settings.IsVisible);
|
||||
}
|
||||
|
||||
private SessionStatusBanner CreateBanner()
|
||||
{
|
||||
_window = new MainWindow();
|
||||
_window.Show();
|
||||
var banner = _window.GetVisualDescendants()
|
||||
.OfType<SessionStatusBanner>()
|
||||
.Single();
|
||||
banner.DataContext = new SessionStatusViewModel();
|
||||
return banner;
|
||||
}
|
||||
|
||||
public void Dispose() => _window?.Close();
|
||||
|
||||
[AvaloniaFact]
|
||||
public void Banner_session_label_reflects_DataContext()
|
||||
{
|
||||
SessionStatusBanner banner = CreateBanner();
|
||||
var label = banner.GetVisualDescendants()
|
||||
.OfType<TextBlock>()
|
||||
.First(t => t.Text == "Déconnecté" || t.Text == "Connecté");
|
||||
|
||||
// Default SessionLabel is "Déconnecté" until Refresh()
|
||||
// is called with a valid session. This pins the default
|
||||
// so a future refactor that breaks the initial value
|
||||
// (e.g. by removing the field initialiser) is caught.
|
||||
Assert.Equal("Déconnecté", label.Text);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ using System.Text.Json;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class SettingsLoadTests
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ namespace PostIt.Tests;
|
|||
/// when a template is applied; see
|
||||
/// <see cref="Pointer_handlers_attach_when_capture_area_is_set"/>.
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class SignaturePadControlTests
|
||||
{
|
||||
// --- SignaturePadData (pure) ---------------------------------------
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ namespace PostIt.Tests;
|
|||
/// control is render-agnostic, and the rendering is plain Polyline
|
||||
/// reconstruction that we'll exercise manually in PostIt.Desktop.
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class SignaturePageViewModelTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ namespace PostIt.Tests;
|
|||
/// if the message control regresses to a plain <c>TextBlock</c>,
|
||||
/// selectability is lost and the test fails.
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class StatusBarTests
|
||||
{
|
||||
[AvaloniaFact]
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ using Yavsc.Api.Client;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class SubscriptionsPageTests
|
||||
{
|
||||
[AvaloniaFact]
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using PostIt.Services;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class TransportStreamCaptureTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
using Avalonia.Headless.XUnit;
|
||||
using PostIt.Views;
|
||||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
public class MainPageTests
|
||||
{
|
||||
[AvaloniaFact]
|
||||
public void MainPage_Should_Load()
|
||||
{
|
||||
var window = new MainView();
|
||||
Assert.NotNull(window);
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,9 @@ using Yavsc.Abstract.Chat.Calls;
|
|||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("DependsOn", "Native")]
|
||||
[Trait("Speed", "Slow")]
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class WebRtcCallViewModelTests
|
||||
{
|
||||
private static readonly CallIceServer[] Turn = [new(["turn:localhost:3478"], "temporary", "password")];
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ namespace PostIt.Tests;
|
|||
/// Uses the project's <see cref="OIDCStubAuthority"/> for the IdP and
|
||||
/// a tiny in-process HTTP listener for the API server side.
|
||||
/// </summary>
|
||||
[Trait("Category", "Integration")]
|
||||
[Trait("Category", "non-reg")]
|
||||
public class YavscApiClientTests
|
||||
{
|
||||
[Theory]
|
||||
|
|
|
|||
Loading…
Reference in a new issue