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; /// /// 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. /// [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("jobs-scheduled"); Assert.SequenceEqual(["Archive scan", "Index backup", "Housekeeping", "Workspace clean-up", "Weekly integrity check", "Monthly orphans report"], schedules.Rows.Select(r => r.Name)); var items = app.FindAll().Where(i => i.DataContext is ScheduleRowViewModel && i.IsVisible).ToList(); Assert.Count(6, items); foreach (var item in items) { var row = (ScheduleRowViewModel)item.DataContext; Assert.Equal(row.AccessibleName, AutomationProperties.GetName(item)); var controls = Descendants(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