refacto App.Name and settings cleanup
This commit is contained in:
parent
852f684d82
commit
68a2364de2
42 changed files with 578 additions and 236 deletions
|
|
@ -77,7 +77,7 @@ public class AdministrationToolsTests(AvaloniaUiFixture ui)
|
|||
[Fact]
|
||||
public void Client_form_retains_every_scalar_field_and_validates_numeric_input()
|
||||
{
|
||||
var settings = new ClientSettings { ClientId = "postit", ClientName = "PostIt", AccessTokenLifetime = 900,
|
||||
var settings = new ClientSettings { ClientId = "postit", ClientName = App.AppName, AccessTokenLifetime = 900,
|
||||
ConsentLifetime = null, RequireConsent = true, PairWiseSubjectSalt = null };
|
||||
var fields = AdministrationFieldViewModel.From(settings);
|
||||
Assert.Equal(typeof(ClientSettings).GetProperties().Length, fields.Count);
|
||||
|
|
|
|||
|
|
@ -230,52 +230,6 @@ public class BlogReaderTests(AvaloniaUiFixture ui)
|
|||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[Fact]
|
||||
public Task Resizing_between_portrait_and_landscape_preserves_the_editor_and_draft()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var vm = CreateViewModel();
|
||||
await vm.InitializeAsync();
|
||||
vm.SelectedPost = Post();
|
||||
vm.EditPostCommand.Execute(null);
|
||||
vm.DraftArticle = "Brouillon conservé pendant le redimensionnement.";
|
||||
var document = vm.DraftArticleDocument;
|
||||
var page = new BlogsPage { DataContext = vm };
|
||||
var editor = page.FindControl<Grid>("PostEditor")!;
|
||||
var nav = new NavigationPage();
|
||||
await nav.PushAsync(page);
|
||||
var window = new Window { Width = 360, Height = 800, Content = nav };
|
||||
try
|
||||
{
|
||||
window.Show();
|
||||
foreach (var size in new[] { new Size(360, 800), new Size(1000, 420), new Size(600, 600), new Size(599, 600), new Size(360, 800) })
|
||||
{
|
||||
window.Width = size.Width;
|
||||
window.Height = size.Height;
|
||||
Dispatcher.UIThread.RunJobs();
|
||||
window.UpdateLayout();
|
||||
AvaloniaHeadlessPlatform.ForceRenderTimerTick();
|
||||
|
||||
var wide = size.Width >= size.Height;
|
||||
Assert.Equal(wide ? 0 : 4, Grid.GetRow(editor));
|
||||
Assert.Equal(wide ? 3 : 1, Grid.GetRowSpan(editor));
|
||||
Assert.Null(NavigationPage.GetBarHeightOverride(page));
|
||||
Assert.Same(editor, page.FindControl<Grid>("PostEditor"));
|
||||
Assert.True(editor.IsVisible);
|
||||
Assert.False(page.FindControl<Grid>("PostReader")!.IsVisible);
|
||||
Assert.True(vm.IsEditing);
|
||||
Assert.True(vm.IsDraftModified);
|
||||
Assert.Equal("Brouillon conservé pendant le redimensionnement.", vm.DraftArticle);
|
||||
Assert.Same(document, vm.DraftArticleDocument);
|
||||
Assert.Equal(42, vm.SelectedPost!.Id);
|
||||
Assert.True(editor.Bounds.Width > 0 && editor.Bounds.Height > 0);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
window.Close();
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[Fact]
|
||||
public Task Image_http_failure_is_logged_with_its_url_and_is_not_swallowed()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ using System.Text;
|
|||
using System.Text.Json;
|
||||
using Avalonia;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PostIt.Helpers;
|
||||
using PostIt.Services;
|
||||
using PostIt.ViewModels;
|
||||
using PostIt.Views;
|
||||
|
|
|
|||
|
|
@ -147,43 +147,7 @@ public sealed class SessionAuthenticationTests(AvaloniaUiFixture ui)
|
|||
finally { File.Delete(path); }
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[Fact]
|
||||
public async Task Modal_restores_the_previous_page_and_focus_after_silent_recovery()
|
||||
{
|
||||
var path = Path.Combine(Path.GetTempPath(), $"postit-session-{Guid.NewGuid():N}.json");
|
||||
try
|
||||
{
|
||||
var store = new TokenStore(path);
|
||||
store.Save(new RefreshTokenRecord("access", "refresh", DateTimeOffset.UtcNow.AddMinutes(10)));
|
||||
await using var api = new ProfileApi(new Settings(), store);
|
||||
var session = new SessionStatusViewModel { Api = api };
|
||||
session.Refresh();
|
||||
await ui.WithWindowAsync(() => new MainView
|
||||
{
|
||||
DataContext = new HomePageViewModel(api, api.Settings, session, null!)
|
||||
}, async window =>
|
||||
{
|
||||
var root = Assert.IsType<MainView>(window.Content);
|
||||
var editor = new TextBox { Text = "Brouillon conservé" };
|
||||
var page = new ContentPage { Content = editor };
|
||||
await root.NavRoot.PushAsync(page, null);
|
||||
Dispatcher.UIThread.RunJobs();
|
||||
window.UpdateLayout();
|
||||
Assert.True(editor.Focus());
|
||||
session.SetError("Session temporairement indisponible");
|
||||
Dispatcher.UIThread.RunJobs();
|
||||
Assert.True(root.LoginButton.IsFocused);
|
||||
session.Refresh();
|
||||
Dispatcher.UIThread.RunJobs();
|
||||
Assert.False(root.AuthenticationModal.IsVisible);
|
||||
Assert.True(root.NavRoot.IsEnabled);
|
||||
Assert.True(editor.IsFocused);
|
||||
Assert.Same(page, root.NavRoot.NavigationStack.Last());
|
||||
Assert.Equal("Brouillon conservé", editor.Text);
|
||||
}, TestContext.Current.CancellationToken);
|
||||
}
|
||||
finally { File.Delete(path); }
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public Task Revoked_background_session_opens_the_modal_and_login_recovers()
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class SettingsLoadTests
|
|||
// Skip if a user-level file exists (CI / different dev machines).
|
||||
var userConfigPath = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
"PostIt",
|
||||
App.AppName,
|
||||
"postit-settings.json");
|
||||
if (File.Exists(userConfigPath))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue