CI / Build and test (push) Successful in 12m32s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 19s
Release / Build, test and publish (push) Successful in 17m13s
CI / PostgreSQL 16 integration (push) Successful in 9m1s
CI / PostgreSQL 17 integration (push) Successful in 9m30s
CI / Docker image (push) Successful in 49s
Release / Server image (push) Successful in 1m49s
The Windows hands-on test of v1.1.0 on the development PC (#70). - The App suite runs whole on Windows again. Five stale screen smoke tests are brought up to date. - The Reorganize capture gives the sample sidecars. - Forget fits in the Bulgarian certificate rows. - The job log shows local time. It stays UTC on disk, and lines are dated backwards from the job's end. - The Jobs and Server › Jobs Type column takes a 1* share (90–170 px). - Builds without a tag say 1.1.1. Closes #70 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
212 lines
12 KiB
C#
212 lines
12 KiB
C#
using System.Windows;
|
|
using System.Windows.Automation;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using Chronos.App.Infrastructure;
|
|
using Chronos.App.Sections;
|
|
using Chronos.App.Server;
|
|
using Chronos.App.Shell;
|
|
using Chronos.App.Tests.Windows;
|
|
using Chronos.Core.Localization;
|
|
using Chronos.Core.Model;
|
|
using Chronos.Data.Sync;
|
|
using Chronos.Testing;
|
|
using Chronos.Ui.Controls;
|
|
|
|
namespace Chronos.App.Tests.Server;
|
|
|
|
/// <summary>The Server screen's sync table on the capture sample data: comparison, transfers, conflict and the Library's glyphs.</summary>
|
|
[WindowsOnly]
|
|
[Serial]
|
|
[Timeout(300_000)]
|
|
public sealed class ServerScreenSmokeTests
|
|
{
|
|
[Test]
|
|
public Task TheSyncTableShowsEveryStateOfTheSample() => ScreenHost.RunAsync(async () =>
|
|
{
|
|
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
|
var shell = app.Shell;
|
|
await app.Sample.FillAsync();
|
|
await shell.Library.RefreshAsync();
|
|
await shell.Services.Server.RestoreAsync();
|
|
Assert.NotNull(await shell.Services.Sync.RefreshAsync());
|
|
await app.Sample.CacheProxiesAsync();
|
|
var table = shell.Server.Sync;
|
|
await table.ReloadAsync();
|
|
|
|
// 36 sequences here (6 also on the server) and 2 only on the server; the conflict is listed first.
|
|
Assert.True(table.IsActive);
|
|
Assert.Equal(38, table.Rows.Count);
|
|
Assert.Equal("Holy grail · Monviso", table.Rows[0].Title);
|
|
Assert.True(table.Rows[0].IsConflict);
|
|
Assert.Equal(1, Chip(table, SyncFilter.Conflicts).Count);
|
|
Assert.Equal(2, Chip(table, SyncFilter.Remote).Count);
|
|
Assert.Equal(30, Chip(table, SyncFilter.LocalOnly).Count);
|
|
Assert.Equal(SyncStatus.InSync, Row(table, "Harbour sunset").Entry.Status);
|
|
Assert.Equal(SyncStatus.ServerAhead, Row(table, "Construction cam · week 38").Entry.Status);
|
|
Assert.SequenceEqual([SyncAction.DownloadOriginals], Actions(Row(table, "Construction cam · week 38")));
|
|
Assert.SequenceEqual([SyncAction.Upload], Actions(Row(table, "Milan skyline dusk")));
|
|
Assert.SequenceEqual([SyncAction.GetExports], Actions(Row(table, "Star trails, Colle del Nivolet")));
|
|
var sunrise = Row(table, "Sunrise over Superga");
|
|
Assert.Equal(SyncStatus.ProxiesOnly, sunrise.Entry.Status);
|
|
Assert.Equal(Loc.L("Server.Sync.Proxies"), sunrise.LocalText);
|
|
// A server without projects: open with proxies; the workspace is offered, disabled with the reason (phase 5b).
|
|
Assert.SequenceEqual([SyncAction.OpenWithProxies, SyncAction.DownloadOriginals, SyncAction.OpenInWorkspace], Actions(sunrise));
|
|
Assert.SequenceEqual([SyncAction.Upload], Actions(Row(table, "Clouds over the Langhe")));
|
|
var conflict = Row(table, "Holy grail · Monviso");
|
|
Assert.Equal(StatusKind.Warning, conflict.StateKind);
|
|
Assert.SequenceEqual([SyncAction.KeepMine, SyncAction.TakeServer, SyncAction.SaveBoth], Actions(conflict));
|
|
// The state whole first (its fixed column cuts longer ones), then what differs.
|
|
Assert.Equal(string.Join(Loc.Separator, conflict.StateText, Loc.L("Server.Conflict.Difference", Loc.L("Server.Setting.DeflickerWindow"), "41", "33")),
|
|
conflict.StateToolTip);
|
|
Assert.NotNull(table.LastSyncText);
|
|
Assert.NotNull(table.ArchiveText);
|
|
Assert.True(table.UploadAllCommand.CanExecute(null), "the table filled after the view bound");
|
|
|
|
// Resolving shows the plan first: what differs and which side is overwritten.
|
|
var keepMine = SyncTableViewModel.ConflictRequest(conflict.Entry, SyncAction.KeepMine);
|
|
Assert.True(keepMine.IsDestructive);
|
|
Assert.Contains(Loc.L("Server.Setting.DeflickerWindow"), keepMine.Detail);
|
|
Assert.False(SyncTableViewModel.ConflictRequest(conflict.Entry, SyncAction.SaveBoth).IsDestructive);
|
|
|
|
// The Library shows the real sync state of each local copy, in one word.
|
|
var holyGrail = shell.Library.Items.Single(i => i.Title == "Holy grail · Monviso");
|
|
Assert.Equal(SyncState.Conflict, holyGrail.Sequence.SyncState);
|
|
Assert.Equal(StatusKind.Warning, holyGrail.Statuses[^1].Kind);
|
|
Assert.Contains(shell.Library.Items.Single(i => i.Title == "Harbour sunset").Statuses, s => s.Kind == StatusKind.Synced);
|
|
var milan = shell.Library.Items.Single(i => i.Title == "Milan skyline dusk").Statuses[^1];
|
|
Assert.Equal((StatusKind.Synced, Loc.L("Library.Status.Synced")), (milan.Kind, milan.Text));
|
|
|
|
shell.Navigate(SectionKey.Server);
|
|
await app.ExpectAsync<ServerView>("server");
|
|
|
|
// Tab walks the row buttons of every row: the rows take no focus, the list passes Tab on to their content.
|
|
var list = app.FindAll<ListBox>().Single(l => l.Name == "SyncList");
|
|
Assert.Equal(KeyboardNavigationMode.Continue, KeyboardNavigation.GetTabNavigation(list));
|
|
var rowButtons = app.FindAll<Button>().Where(b => b.DataContext is SyncRowAction && b.IsVisible).ToList();
|
|
Assert.True(rowButtons.Select(b => b.DataContext).OfType<SyncRowAction>().Count() > 3, "buttons of several rows are on screen");
|
|
Assert.True(rowButtons.All(b => b.Focusable && b.IsTabStop), "every row button is a tab stop");
|
|
|
|
// Screen readers: a row reads as its sequence and state, each of the many "Upload" buttons names its sequence.
|
|
foreach (var item in app.FindAll<ListBoxItem>().Where(i => i.DataContext is SyncRow && i.IsVisible))
|
|
{
|
|
var row = (SyncRow)item.DataContext;
|
|
Assert.Equal(row.Title, AutomationProperties.GetName(item));
|
|
Assert.Equal(row.StateText, AutomationProperties.GetItemStatus(item));
|
|
}
|
|
Assert.True(rowButtons.All(b => AutomationProperties.GetName(b) == ((SyncRowAction)b.DataContext).AccessibleName), "row buttons carry their row's name");
|
|
Assert.Equal(Loc.L("Server.Sync.ActionFor", Loc.L("Server.Sync.Action.Upload"), "Clouds over the Langhe"),
|
|
Row(table, "Clouds over the Langhe").Actions.Single().AccessibleName);
|
|
|
|
// The filters are a radio group: the chosen one is checked, so its state reaches screen readers.
|
|
var chips = app.FindAll<RadioButton>().Where(r => r.DataContext is SyncFilterChip).ToList();
|
|
Assert.Count(Enum.GetValues<SyncFilter>().Length, chips);
|
|
Assert.True(chips.All(c => c.IsChecked == ((SyncFilterChip)c.DataContext).IsSelected), "the checked chip is the chosen filter");
|
|
|
|
// While connected the address is read-only text (selectable, not dimmed), kept left to right; status changes are announced.
|
|
var address = app.FindAll<TextBox>().Single(t => t.Name == "AddressBox");
|
|
Assert.True(address.IsEnabled && address.IsReadOnly, "the connected address is read-only, not disabled");
|
|
Assert.Equal(FlowDirection.LeftToRight, address.FlowDirection);
|
|
var known = app.FindAll<Button>().Single(b => b.Name == "KnownButton");
|
|
Assert.False(string.IsNullOrEmpty(AutomationProperties.GetName(known)), "the icon-only button has a name");
|
|
Assert.True(ToolTipService.GetShowOnDisabled(known), "a disabled ▾ still says why");
|
|
Assert.Equal(AutomationLiveSetting.Polite, AutomationProperties.GetLiveSetting(
|
|
app.FindAll<StatusGlyph>().First(g => g.IsVisible && g.Text == shell.Server.StatusText)));
|
|
|
|
// The web admin admits administrators only: the sample user is an editor.
|
|
Assert.False(table.CanOpenAdmin);
|
|
Assert.False(app.FindAll<Button>().Any(b => b.Content as string == Loc.L("Server.Sync.OpenAdmin") && b.IsVisible), "no admin link for an editor");
|
|
|
|
// Transfers in every state: the rows show what moves and offer Pause or Resume.
|
|
await app.Sample.FillSyncAsync();
|
|
await table.ReloadAsync();
|
|
var comet = Row(table, "Comet over the ridge");
|
|
Assert.Equal(SyncStatus.Transferring, comet.Entry.Status);
|
|
Assert.SequenceEqual([SyncAction.Pause], Actions(comet));
|
|
Assert.Contains("46", comet.ServerText);
|
|
Assert.Equal(StatusKind.Queued, Row(table, "Fog lifting, Asti").StateKind);
|
|
// One job at a time (owner review 1): the download halfway waits for the upload.
|
|
Assert.Equal((StatusKind.Queued, Loc.L("Server.Sync.State.Waiting")), (Row(table, "Sunrise over Superga").StateKind, Row(table, "Sunrise over Superga").StateText));
|
|
Assert.SequenceEqual([SyncAction.Resume], Actions(Row(table, "Lake Como storm")));
|
|
await app.ExpectAsync<ServerView>("server-sync");
|
|
|
|
// A reload keeps the row's buttons (focus, tooltips and clicks survive progress and comparisons).
|
|
var pause = comet.Actions[0];
|
|
await table.ReloadAsync();
|
|
Assert.Same(pause, Row(table, "Comet over the ridge").Actions[0]);
|
|
|
|
// The conflict filter leaves the one row waiting for a choice.
|
|
Chip(table, SyncFilter.Conflicts).SelectCommand.Execute(null);
|
|
Assert.Equal("Holy grail · Monviso", Assert.Contains(table.Rows, _ => true).Title);
|
|
Assert.Count(1, table.Rows);
|
|
await app.ExpectAsync<ServerView>("server-conflict");
|
|
|
|
// One row, no scrolling: the header still lines up with the cells (same padding, constant scroll-bar gutter).
|
|
var only = table.Rows[0];
|
|
Assert.Approximately(Left(Text(app, Loc.L("Server.Sync.Column.Local"))), Left(Text(app, only.LocalText)), 1.5, "This PC column");
|
|
Assert.Approximately(Left(Text(app, Loc.L("Server.Sync.Column.State"))),
|
|
Left(app.FindAll<StatusGlyph>().First(g => g.DataContext == only && g.IsVisible)), 1.5, "State column");
|
|
|
|
// No match: one sentence and its one action, which shows every sequence again.
|
|
table.SearchText = "nothing like this";
|
|
Assert.False(table.HasRows);
|
|
Assert.NotNull(table.EmptyText);
|
|
Assert.Equal(SyncEmpty.NoMatch, table.Empty);
|
|
table.ClearFiltersCommand.Execute(null);
|
|
Assert.Equal(string.Empty, table.SearchText);
|
|
Assert.True(Chip(table, SyncFilter.All).IsSelected);
|
|
Assert.Equal(Chip(table, SyncFilter.All).Count, table.Rows.Count);
|
|
|
|
// Another language relabels chips and rows at once.
|
|
UiLanguage.Apply("it");
|
|
try
|
|
{
|
|
Assert.Equal("Tutte · 38", Chip(table, SyncFilter.All).Text);
|
|
}
|
|
finally
|
|
{
|
|
UiLanguage.Apply("en");
|
|
}
|
|
});
|
|
|
|
[Test]
|
|
public Task SigningOutEmptiesTheTable() => ScreenHost.RunAsync(async () =>
|
|
{
|
|
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
|
var shell = app.Shell;
|
|
await app.Sample.FillAsync();
|
|
await shell.Services.Server.RestoreAsync();
|
|
await shell.Services.Sync.RefreshAsync();
|
|
await shell.Server.Sync.ReloadAsync();
|
|
Assert.True(shell.Server.Sync.HasRows);
|
|
|
|
await shell.Services.Server.SignOutAsync();
|
|
Assert.Null(await shell.Services.Sync.RefreshAsync());
|
|
await shell.Server.Sync.ReloadAsync();
|
|
|
|
Assert.False(shell.Server.Sync.IsActive);
|
|
Assert.False(shell.Server.Sync.HasRows);
|
|
Assert.Equal(SyncEmpty.SignedOut, shell.Server.Sync.Empty);
|
|
Assert.False(shell.Server.Sync.UploadAllCommand.CanExecute(null));
|
|
Assert.Equal(Loc.L("Tooltips.Server.Sync.UploadAll.NotConnected"), shell.Server.Sync.UploadAllToolTip);
|
|
shell.Navigate(SectionKey.Server);
|
|
await app.ExpectAsync<ServerView>("server-signedout-table");
|
|
|
|
// Nothing to filter while signed out: chips and search give way to the one action, Connect.
|
|
Assert.False(app.FindAll<RadioButton>().Any(r => r.DataContext is SyncFilterChip && r.IsVisible), "no filter chips while signed out");
|
|
Assert.False(app.FindAll<TextBox>().Any(t => AutomationProperties.GetName(t) == Loc.L("Server.Sync.Search") && t.IsVisible), "no search while signed out");
|
|
Assert.True(app.FindAll<Button>().Any(b => b.Content as string == Loc.L("Server.Connect") && b.IsVisible), "the empty table offers Connect");
|
|
});
|
|
|
|
private static TextBlock Text(ScreenSmokeTests.SampleApp app, string text) => app.FindAll<TextBlock>().First(t => t.Text == text && t.IsVisible);
|
|
|
|
/// <summary>The left edge of an element in window coordinates.</summary>
|
|
private static double Left(FrameworkElement element) => element.TranslatePoint(new Point(0, 0), Window.GetWindow(element)).X;
|
|
|
|
private static SyncFilterChip Chip(SyncTableViewModel table, SyncFilter filter) => table.Chips.Single(c => c.Filter == filter);
|
|
|
|
private static SyncRow Row(SyncTableViewModel table, string title) => table.Rows.Single(r => r.Title == title);
|
|
|
|
private static IEnumerable<SyncAction> Actions(SyncRow row) => row.Actions.Select(a => a.Action);
|
|
}
|