Owner review 1, phase 3a (docs/requests/2026-10-15-owner-review-1.md, R1). The desktop rail is 200 px wide, so the section names fit in every language, and collapses to 48 px of icons with its ≡ button or Ctrl+B. Collapsed, each icon's tooltip names its section before saying what it is for, while screen readers keep the name and the description. The choice is written to the settings file the moment it changes (nothing else restarts) and survives Settings › Reset all and Import; Ctrl+B waits behind the first-run dialog like Ctrl+1…6, and a held key toggles once. The admin panel's sidebar is 256 px and collapses to icons the same way, with its own ≡ button or Ctrl+B (on the physical key where the layout's B types no Latin letter, so Cyrillic, Greek, Hebrew and Arabic layouts work). The choice is kept in the browser, for the page when the browser refuses storage, and the tables fit their columns again after each toggle. At 900 px and below it stays the top bar and Ctrl+B stays the browser's. The wider rail leaves 49-72 px less for every screen at the 1200 px minimum. Six adversarial review rounds found what that cut, and in every shipped language no action is cut off now: the Jobs columns share their width (Target and Progress give way first, Kind/Where/State capped on wide windows), the editor's preview tools take a second line, a server job's Cancel has its own header column, the Archive tree keeps a year's label, the Import rows and result, the certificates and cache rows and the frame table fit. Headers, titles and cells that may be shortened end in an ellipsis and show their text in their tooltip; state tooltips start with the state, and their explanations were reworded not to repeat it (a queued job "waits for its turn", jobs running one at a time). The crop-result tool sits beside Crop mask, disabled with its reason while the mask is off. Tests check these rows in all 38 languages at 1200 px; the App test program now shuts WPF down in order, so its exit no longer crashes after every test passed. Phase 3 lands as two commits: R7 (the Edit section) edits the same shell files and follows. Also updates BRIEF (12.1, 14.8, 24), DECISIONS, CHANGELOG, STATUS, the request file, DESIGN and the mockups; every new or reworded string is in all 38 languages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
211 lines
12 KiB
C#
211 lines
12 KiB
C#
using System.Windows;
|
|
using System.Windows.Automation;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using Titano.App.Infrastructure;
|
|
using Titano.App.Sections;
|
|
using Titano.App.Server;
|
|
using Titano.App.Shell;
|
|
using Titano.App.Tests.Windows;
|
|
using Titano.Core.Localization;
|
|
using Titano.Core.Model;
|
|
using Titano.Data.Sync;
|
|
using Titano.Testing;
|
|
using Titano.Ui.Controls;
|
|
|
|
namespace Titano.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);
|
|
Assert.SequenceEqual([SyncAction.OpenWithProxies, SyncAction.DownloadOriginals], 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);
|
|
}
|