fix: address the owner review 5 review
Setup: a kept 1.0 Uploader no longer fixes the scope and folder, the Remove tooltip promises kept files only with a hashed log, and a single-program setup preselects it. The Uploader always downloads the setup. Sync links move to the server id at every sign-in while folders wait for jobs and open editors; jobs of a pending homes sort still find their projects. A shared library exposes only the shared archive's client-visible jobs and events, render nodes take only client renders, and the share counts as its own while starting. Progress: a new step waits a quarter interval and a trailing timer publishes the last state; the job bar tooltip carries the whole line; Recent maintenance and the Server jobs list pick up jobs that start while they are shown. Refs #64 #65 #66 #67 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
817956e719
commit
f30eb2904a
51 files changed
+895
-122
No files matched your search
@@ -9,6 +9,7 @@ using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data;
|
||||
using Chronos.Data.Archiving;
|
||||
using Chronos.Data.Jobs;
|
||||
using Chronos.Data.Repositories;
|
||||
using Chronos.Testing;
|
||||
using Chronos.Ui.Controls;
|
||||
@@ -260,6 +261,29 @@ public sealed class ArchiveLogicTests
|
||||
Assert.SequenceEqual(new[] { "sunset", "dusk" }, changes.Single().Tags);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AMaintenanceJobQueuedWhileTheScreenIsShownJoinsRecent()
|
||||
{
|
||||
var archive = Guid.NewGuid();
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
IReadOnlyList<Job> jobs = [new Job { Id = Guid.NewGuid(), Kind = JobKind.Scan, State = JobState.Done, TargetIds = [archive], Created = now.AddDays(-1), Finished = now.AddDays(-1) }];
|
||||
var verify = new Job { Id = Guid.NewGuid(), Kind = JobKind.Verify, State = JobState.Queued, TargetIds = [archive], TargetLabel = "Main", Created = now };
|
||||
|
||||
jobs = MaintenanceReports.Track(jobs, verify, archive);
|
||||
Assert.Equal(2, jobs.Count);
|
||||
var running = verify with { State = JobState.Running, Started = now };
|
||||
jobs = MaintenanceReports.Track(jobs, running, archive);
|
||||
Assert.Equal(2, jobs.Count);
|
||||
var live = new Dictionary<Guid, JobProgressInfo> { [verify.Id] = new(verify.Id, JobKind.Verify, "Main", 40, 100, null, null, null) };
|
||||
var recent = MaintenanceReports.Recent(jobs, 5, live);
|
||||
Assert.Equal(verify.Id, recent[0].JobId);
|
||||
Assert.Equal("40 %", recent[0].StateText);
|
||||
|
||||
// Another archive's job, or another kind of job, leaves the list as it is.
|
||||
Assert.Same(jobs, MaintenanceReports.Track(jobs, running with { Id = Guid.NewGuid(), TargetIds = [Guid.NewGuid()] }, archive));
|
||||
Assert.Same(jobs, MaintenanceReports.Track(jobs, running with { Id = Guid.NewGuid(), Kind = JobKind.Render }, archive));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReportsListDuplicatesOrphansAndRecentMaintenance()
|
||||
{
|
||||
|
||||
@@ -96,6 +96,21 @@ public sealed class JobTextTests
|
||||
Assert.Equal("3 / 9", JobText.Counter(JobKind.Scan, 3, 9));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheBarsTooltipHasTheLineWholeWithItsItem()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
var job = Job(JobKind.Verify, JobState.Running, "Archive") with
|
||||
{
|
||||
Detail = new JobDetail(JobStep.Verify, "2024/2024-09-27 Harbour sunset at the old lighthouse", 812, 2_400, 3, 41, JobPartUnit.Sequence),
|
||||
};
|
||||
var entry = new JobEntry(job);
|
||||
// The bar cuts the line at 60 characters, dropping the sequence first; the tooltip names it.
|
||||
Assert.False(JobText.Bar(entry).Contains("Harbour sunset", StringComparison.Ordinal), JobText.Bar(entry));
|
||||
Assert.Equal("Verify · Archive · " + JobText.Status(job.Detail), JobText.BarToolTip(entry));
|
||||
Assert.Contains("Harbour sunset at the old lighthouse", JobText.BarToolTip(entry));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LiveDetailWinsAndStoppedJobsSayWhere()
|
||||
{
|
||||
|
||||
@@ -64,6 +64,24 @@ public sealed class ServerJobsListTests
|
||||
Assert.False(vm.HasRows);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AJobThatStartedBeforeTheEventsOpenedJoinsOnItsProgress()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
var api = new FakeJobsApi();
|
||||
using var vm = new ServerJobsViewModel(() => new ServerJobsAccount("a", false), () => api, new IdleContext());
|
||||
await UpdatedAsync(vm, vm.Refresh);
|
||||
Assert.Empty(vm.Rows);
|
||||
|
||||
// Started between the list and the event socket: its running state was never told, its progress is.
|
||||
var id = api.Add("thumbs", "Lake", "running");
|
||||
await UpdatedAsync(vm, () => api.Events.Writer.TryWrite(new JobProgressEvent(id, 40, 100, 3, 20,
|
||||
new JobDetailDto("thumbs", "Lake", 40, 100))));
|
||||
var row = vm.Rows.Single();
|
||||
Assert.Equal(id, row.Id);
|
||||
Assert.Equal(40d / 100, row.Progress);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AManagingAccountPausesResumesAndCancels()
|
||||
{
|
||||
|
||||
@@ -193,6 +193,24 @@ public sealed class SingleSetupTests(TestContext context)
|
||||
Assert.Null(LegacyProducts.FindUploader(Manifest("ChronosTest" + Guid.NewGuid().ToString("N")[..12])));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ALegacyUploaderLeftInPlaceFixesNeitherTheScopeNorTheFolder()
|
||||
{
|
||||
var manifest = Manifest();
|
||||
var root = context.CreateTempDirectory("legacy-kept");
|
||||
var legacy = Legacy(Path.Combine(root, "Chronos Uploader"), InstallScope.CurrentUser);
|
||||
var elsewhere = Path.Combine(root, "Apps", "Chronos");
|
||||
|
||||
// The Uploader is not installed, so nothing is merged: the switches decide where Chronos goes.
|
||||
var plan = InstallPlan.Resolve(manifest, new SetupArguments { AllUsers = true, Directory = elsewhere, Components = ["Desktop"] }, null, null, legacy);
|
||||
Assert.Equal(InstallScope.AllUsers, plan.Scope);
|
||||
Assert.Equal(elsewhere, plan.Directory);
|
||||
Assert.SequenceEqual(["Chronos"], plan.Components);
|
||||
Assert.True(plan.CanChangeLocation);
|
||||
Assert.Null(plan.LegacyToReplace(plan.Components, plan.Scope, plan.Directory));
|
||||
Assert.True(plan.LocksLocation(["Chronos", "Uploader"]), "ticking the Uploader would replace the legacy one");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[WindowsOnly]
|
||||
public void ReplacingTheLegacyUploaderMovesItsSignInEntryAndKeepsItTurnedOff()
|
||||
@@ -306,6 +324,31 @@ public sealed class SingleSetupTests(TestContext context)
|
||||
Assert.False(replace.CanChangeLocation);
|
||||
Assert.Equal("Replaces Chronos Uploader 1.0.0", replace.ChangesText);
|
||||
Assert.False(replace.IsUninstallAll);
|
||||
|
||||
// Unticked, the Uploader replaces nothing: the folder and the scope can change; ticked again, they are the legacy copy's.
|
||||
var uploader = Assert.Contains(replace.Components, c => c.Id == "Uploader");
|
||||
uploader.IsSelected = false;
|
||||
Assert.True(replace.CanChangeLocation);
|
||||
replace.IsAllUsers = true;
|
||||
replace.Directory = Path.Combine(root, "Apps", "Chronos");
|
||||
uploader.IsSelected = true;
|
||||
Assert.False(replace.CanChangeLocation);
|
||||
Assert.False(replace.IsAllUsers);
|
||||
Assert.Equal(SetupPaths.DefaultDirectory(InstallScope.CurrentUser, manifest.Product), replace.Directory);
|
||||
}
|
||||
|
||||
// Removing a program of a 1.0 installation (its log has no SHA-256) never promises to keep a changed file.
|
||||
var hashed = ServerLog(directory);
|
||||
hashed.FormatVersion = 2;
|
||||
hashed.Components = ["Chronos", "Uploader"];
|
||||
hashed.Hashes["Chronos.Uploader.exe"] = new string('2', 64);
|
||||
foreach (var (log, key) in new[] { (hashed, "Tooltips.Setup.Changes.Remove"), (ServerLog(directory), "Tooltips.Setup.Changes.RemoveUnchecked") })
|
||||
{
|
||||
log.Components = ["Chronos", "Uploader"];
|
||||
using var removal = SetupViewModel.ForInstall(new SetupArguments(), payload, InstallPlan.Resolve(manifest, new SetupArguments(), existing, log, null));
|
||||
Assert.Contains(removal.Components, c => c.Id == "Uploader").IsSelected = false;
|
||||
Assert.Count(1, removal.Changes);
|
||||
Assert.Equal(Loc.L(key), removal.Changes[0].ToolTip);
|
||||
}
|
||||
|
||||
// A new installation with nothing ticked cannot start, and is no uninstall.
|
||||
|
||||
@@ -188,6 +188,15 @@ public sealed class UploaderUpdatesTests(TestContext context)
|
||||
Assert.Equal(UpdateState.Unknown, vm.State);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void APortableUploaderIsOfferedTheSetupTheZipHoldsNoUploader()
|
||||
{
|
||||
// The portable zip carries the desktop app alone: whatever the copy, the Uploader updates through the setup.
|
||||
Assert.False(Host(new Feed(), context.CreateTempDirectory(), []).IsPortable);
|
||||
using var vm = new UpdatesViewModel(Host(new Feed(), context.CreateTempDirectory(), []), new UploaderSettings(), () => { });
|
||||
Assert.Equal(Loc.L("Tooltips.Uploader.Updates.ShowSetup"), vm.ShowSetupToolTip);
|
||||
}
|
||||
|
||||
private UpdatesViewModel Notice(Feed feed, out List<string> revealed)
|
||||
{
|
||||
revealed = [];
|
||||
@@ -197,7 +206,7 @@ public sealed class UploaderUpdatesTests(TestContext context)
|
||||
private static UpdateHost Host(Feed feed, string downloadRoot, List<string> revealed)
|
||||
{
|
||||
var http = new HttpClient(feed, disposeHandler: false);
|
||||
return UploaderUpdates.Host(http, http, Repository, "1.0.0", portable: false, downloadRoot, _ => { }, revealed.Add);
|
||||
return UploaderUpdates.Host(http, http, Repository, "1.0.0", downloadRoot, _ => { }, revealed.Add);
|
||||
}
|
||||
|
||||
private static async Task RunAsync(System.Windows.Input.ICommand command)
|
||||
|
||||
@@ -58,6 +58,25 @@ public sealed class WorkspaceHostTests(TestContext context)
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AProjectOpenInTheEditorIsHeldUntilItsSourceCloses()
|
||||
{
|
||||
var installed = AppEnvironment.From(AppPaths.Resolve(context.CreateTempDirectory("app"), context.CreateTempDirectory("local"), []));
|
||||
var host = new WorkspaceHost(installed, new AppSettings(), () => { }, () => null, () => null, () => null);
|
||||
var project = Guid.CreateVersion7();
|
||||
Assert.False(host.HasProjectsInEditor);
|
||||
|
||||
// The same project in two editors, then each closing (one twice): held until the last one closes.
|
||||
var first = host.HoldInEditor(project);
|
||||
var second = host.HoldInEditor(project);
|
||||
Assert.True(host.HasProjectsInEditor, "a server's home does not move under an open editor");
|
||||
first.Dispose();
|
||||
first.Dispose();
|
||||
Assert.True(host.HasProjectsInEditor, "the second editor still has it");
|
||||
second.Dispose();
|
||||
Assert.False(host.HasProjectsInEditor);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheWorkspaceSettingsSurviveTheSettingsFile()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user