A running job now says what it does now: "Verifying photo 812 of 2,400 · Harbour sunset · sequence 3 of 41". A paused or failed job says where it stopped. The line appears in the Jobs table under the target, in the job bar (at most 60 characters, the item dropped first, the bar text also its tooltip), in the Archive's recent maintenance (refreshed at most twice a second), in the editor's server-job line and in the sync tooltip. Byte jobs now count sizes in the bar. While connected, the Server section lists the server's running and paused jobs, live through the jobs API and the jobProgress events. Pause, Resume and Cancel are offered only to an account that manages the archive, which is what the server requires to act on someone else's job; for any other account the list is read-only. The list hides while nothing runs, and the capture gains a server-jobs scene. The admin panel's Jobs page and dashboard show the same line under the target and update it with every progress event. The steps, parts and sub-steps are in English and Italian, and an unknown step shows its counts only. Refs #65 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
3.5 KiB
C#
61 lines
3.5 KiB
C#
using System.Net.Http.Json;
|
|
using System.Text.RegularExpressions;
|
|
using Chronos.Core.Model;
|
|
using Chronos.Data.Jobs;
|
|
using Chronos.Protocol;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Server.Tests.Hosting;
|
|
|
|
/// <summary>
|
|
/// What a job does now in the admin panel (owner review 5, #65; <c>Admin/web/jobs.js</c>): the Jobs page and the dashboard
|
|
/// draw the status line under the target and move it with every progress event, and every step, part and sub-step the
|
|
/// server can send is worded in English and Italian.
|
|
/// </summary>
|
|
[Category("server")]
|
|
public sealed class AdminJobDetailTests(TestContext context)
|
|
{
|
|
private static readonly string[] MaintenanceSteps = ["Leases", "Temp", "Packs", "Duplicates", "Vacuum"];
|
|
|
|
[Test]
|
|
public async Task TheJobsPageAndTheDashboardShowTheStatusLine()
|
|
{
|
|
await using var server = await TestServer.StartAsync(context);
|
|
var jobs = await server.Client.GetStringAsync("/admin/jobs.js");
|
|
foreach (var helper in new[] { "statusText(detail)", "rowStatus(job)", "speedText(kind, rate)", "leftText(seconds)", "targetCell(job)", "statusLine(job)", "updateStatus(row, job)" })
|
|
Assert.Contains($"export function {helper}", jobs);
|
|
// Items are data: they read in their own direction, and the whole line is the tooltip.
|
|
Assert.Contains(@"<span class=""progress-detail"" dir=""auto"" title=""${attr(tip)}"">", jobs);
|
|
foreach (var page in new[] { "/admin/pages/jobs.js", "/admin/pages/dashboard.js" })
|
|
{
|
|
var text = await server.Client.GetStringAsync(page);
|
|
Assert.Contains(@"<span class=""target-cell"" role=""cell"">${targetCell(j)}</span>", text);
|
|
Assert.Contains("if (e.detail) job.detail = e.detail;", text);
|
|
Assert.Contains("updateStatus(row, job);", text);
|
|
Assert.True(!text.Contains(" style=", StringComparison.Ordinal), "inline style");
|
|
}
|
|
Assert.Contains(".progress-detail {", await server.Client.GetStringAsync("/admin/admin.css"));
|
|
}
|
|
|
|
[Test]
|
|
public async Task EveryStepAndPartIsInEnglishAndItalian()
|
|
{
|
|
await using var server = await TestServer.StartAsync(context);
|
|
var jobs = await server.Client.GetStringAsync("/admin/jobs.js");
|
|
var en = Assert.NotNull(await server.Client.GetFromJsonAsync("/api/v1/i18n/en", ProtocolJson.Default.DictionaryStringString));
|
|
var it = Assert.NotNull(await server.Client.GetFromJsonAsync("/api/v1/i18n/it", ProtocolJson.Default.DictionaryStringString));
|
|
var keys = Regex.Matches(jobs, @"""(Admin\.[A-Za-z]+(?:\.[A-Za-z]+)*)""").Select(m => m.Groups[1].Value).ToList();
|
|
Assert.Contains("Admin.Job.Detail.StoppedAt", keys);
|
|
// The keys built from what the server sends.
|
|
keys.AddRange(Enum.GetValues<JobStep>().Where(s => s != JobStep.None).Select(s => $"Admin.Job.Step.{s}"));
|
|
keys.AddRange(Enum.GetValues<JobPartUnit>().Where(u => u != JobPartUnit.None).Select(u => $"Admin.Job.Part.{u}"));
|
|
keys.AddRange(MaintenanceSteps.Select(s => $"Admin.Job.Maintenance.Step.{s}"));
|
|
foreach (var key in keys.Distinct())
|
|
Assert.True(en.ContainsKey(key) && it.ContainsKey(key), key);
|
|
// The step and the unit keys are the wire names in PascalCase, as the panel builds them.
|
|
Assert.Equal("copy-photo", JobWire.Step(JobStep.CopyPhoto));
|
|
Assert.Equal("Copia foto {0} di {1}", it["Admin.Job.Step.CopyPhoto.Count"]);
|
|
Assert.Equal("Verifying photo {0} of {1}", en["Admin.Job.Step.Verify.Count"]);
|
|
}
|
|
}
|