feat: owner review 2 phase 2: scheduled jobs and log settings (#10)
CI / Build and test (push) Successful in 7m0s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 13m28s
CI / PostgreSQL 16 integration (push) Successful in 5m52s
CI / PostgreSQL 17 integration (push) Successful in 4m50s
CI / Docker image (push) Successful in 1m4s
Release / Server image (push) Successful in 1m35s

- Jobs > Scheduled on the desktop and the admin panel. Every timer that queued work is now a visible system schedule: archive scan, upload clean-up, index backup, job-history and audit clean-ups, desktop housekeeping. New actions: verify, thumbnails, proxies, analysis, maintenance, backup, clean-ups, reports.
- The scheduler: migration 0007, in-house recurrence, compare-and-set claim, catch-up, scan at start.
- Log settings: levels, retention, size parts, total limit, daily or hourly rotation, audit retention, diagnostics share; the server writes Debug/Trace to its files again; logging never fails a job.

Upgrade: CHRONOS_LOG_LEVEL set in an existing container locks both levels; migration 0007 is one-way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #10.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-10-27 11:19:26 +01:00
1 parent 1f089888e8
commit af9eeaab9b
349 files changed
+28341 -1304

No files matched your search

@@ -0,0 +1,117 @@
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using Chronos.App.Jobs;
using Chronos.App.Sections;
using Chronos.App.Shell;
using Chronos.App.Tests.Windows;
using Chronos.Core.Localization;
using Chronos.Testing;
namespace Chronos.App.Tests.Jobs;
/// <summary>
/// Jobs › Scheduled on the capture sample (owner review 2, R10): the tab draws in both themes, every row and control is
/// named and has a tooltip, system rows reset and the user's delete, a schedule's run opens in the Queue tab with its
/// "Scheduled" pill, and the editor opens over the screen.
/// </summary>
[WindowsOnly]
[Serial]
[Timeout(300_000)]
public sealed class ScheduledTabTests
{
[Test]
public Task TheScheduledTabListsTheSchedulesAndLeadsToTheirJobs() => ScreenHost.RunAsync(async () =>
{
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
var shell = app.Shell;
await app.Sample.FillAsync();
await shell.Jobs.ReloadAsync();
var schedules = shell.Jobs.Schedules;
await schedules.Attached;
await schedules.ReloadAsync();
shell.Navigate(SectionKey.Jobs);
shell.Jobs.TabIndex = 1;
await app.ExpectAsync<SchedulesView>("jobs-scheduled");
Assert.SequenceEqual(["Archive scan", "Index backup", "Housekeeping", "Weekly integrity check", "Monthly orphans report"], schedules.Rows.Select(r => r.Name));
var items = app.FindAll<ListBoxItem>().Where(i => i.DataContext is ScheduleRowViewModel && i.IsVisible).ToList();
Assert.Count(5, items);
foreach (var item in items)
{
var row = (ScheduleRowViewModel)item.DataContext;
Assert.Equal(row.AccessibleName, AutomationProperties.GetName(item));
var controls = Descendants<ButtonBase>(item).Where(b => b.IsVisible).ToList();
// The switch, Run now, Edit, and Reset or Delete.
Assert.Count(4, controls);
Assert.True(controls.All(c => c.ToolTip is not null && AutomationProperties.GetName(c).Contains(row.Name, StringComparison.Ordinal)),
$"every control of {row.Name} has a tooltip and names its row");
var last = Descendants<Button>(item).Last(b => b.IsVisible);
Assert.Equal(Loc.L(row.IsSystem ? "Jobs.Schedule.Reset" : "Jobs.Schedule.Delete"), last.Content);
}
// The queue's toolbar gives way to New schedule.
Assert.True(app.FindAll<Button>().Any(b => b.IsVisible && Equals(b.Content, Loc.L("Jobs.Schedule.New"))), "New schedule is on the toolbar");
Assert.False(app.FindAll<TextBox>().Any(t => t.IsVisible && AutomationProperties.GetName(t) == Loc.L("Jobs.Search")), "the queue's search is hidden");
// The weekly check's run waits in the queue: Show in queue opens it there, expanded.
var weekly = schedules.Rows.Single(r => r.Name == "Weekly integrity check");
schedules.Selected = weekly;
await schedules.RunsLoading;
var run = Assert.NotNull(schedules.Runs.SingleOrDefault());
Assert.Equal(weekly.Schedule.LastJobId, run.Id);
await shell.Jobs.ShowJobAsync(run.Id);
Assert.True(shell.Jobs.IsQueue, "the Queue tab is shown");
var shown = shell.Jobs.Rows.Single(r => r.Id == run.Id);
Assert.True(shown.IsExpanded && shown.IsScheduled, "the job is expanded and marked as scheduled");
await app.ExpectAsync<JobsView>("jobs-from-schedule");
var pills = app.FindAll<Border>().Where(b => b.IsVisible && Equals(b.ToolTip, Loc.L("Tooltips.Jobs.Scheduled"))).ToList();
Assert.True(pills.Count >= 1, "a scheduled job carries the pill");
});
[Test]
public Task TheEditorOpensOverTheScreenAndCloses() => ScreenHost.RunAsync(async () =>
{
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
var shell = app.Shell;
await app.Sample.FillAsync();
var schedules = shell.Jobs.Schedules;
await schedules.Attached;
await schedules.ReloadAsync();
shell.Navigate(SectionKey.Jobs);
shell.Jobs.TabIndex = 1;
var weekly = schedules.Rows.Single(r => r.Name == "Weekly integrity check");
weekly.EditCommand.Execute(null);
var editor = Assert.NotNull(schedules.Editor);
Assert.False(shell.Jobs.IsContentEnabled);
await app.ExpectAsync<SchedulesView>("jobs-schedule-editor");
// Weekly, on Sunday at 02:00, verifying 25 % of the sequences unverified for 30 days.
Assert.Equal(2, editor.KindIndex);
Assert.SequenceEqual([DayOfWeek.Sunday], editor.Days.Where(d => d.IsChecked).Select(d => d.Value));
Assert.Equal(("02:00", "30", "25"), (editor.Time.Text, editor.OlderThan.Text, editor.Percent.Text));
var fields = app.FindAll<TextBox>().Where(t => t.IsVisible && t.DataContext is ScheduleEditorViewModel).ToList();
Assert.True(fields.Count >= 4, "name, time, age and share are on screen");
Assert.True(fields.All(t => t.ToolTip is not null && !string.IsNullOrWhiteSpace(AutomationProperties.GetName(t))), "every field is named and has a tooltip");
var toggles = app.FindAll<ToggleButton>().Where(t => t.IsVisible && t.DataContext is ScheduleChoice<DayOfWeek>).ToList();
Assert.Count(7, toggles);
// Unavailable actions are listed disabled: the scheduler answers for this PC.
Assert.True(editor.ActionOptions.Any(a => a.IsAvailable), "actions are available");
editor.CloseCommand.Execute(null);
Assert.Null(schedules.Editor);
Assert.True(shell.Jobs.IsContentEnabled);
});
private static IEnumerable<T> Descendants<T>(DependencyObject node)
where T : DependencyObject
{
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(node); i++)
{
var child = VisualTreeHelper.GetChild(node, i);
if (child is T match) yield return match;
foreach (var nested in Descendants<T>(child)) yield return nested;
}
}
}