feat: owner review 2 phase 4b: mass conversion after import #13
No files matched your search
@@ -88,7 +88,7 @@ Dependencies point one way: `Core` ← `Core.Windows`, `Data`, `Protocol` ← `S
|
||||
| `Server/Api`, `Server/Events` | Endpoint groups (`XxxEndpoints.Map`; `ScheduleEndpoints`: `/api/v1/schedules`; `LibraryEndpoints`: the Library filters' facets, sequence thumbnail, photo delete, bulk delete/retag/jobs; `TrashEndpoints`: list, restore, empty), API errors, the WebSocket `EventHub` |
|
||||
| `Server/Security` | Accounts, password hashing, tokens, session cookies, login guard, access rules, audit log |
|
||||
| `Server/Storage`, `Server/Jobs` | Archive and processing modules, uploads (`UploadMaintenance`: recovery at start, and the sweep that is the `uploads` clean-up step), render store; `JobEngineHost`, `SchedulerHost` (the `Scheduler` on the engine, started after it; archive.json read every 10 minutes whatever the scan schedule does; every schedule change and run published as a `scheduleChanged` event) and `ServerScheduleHost` (time zone, archive refreshed from archive.json, system schedules), render node service, monitor and availability |
|
||||
| `Server/Hosting`, `Server/Admin/web` | `ServerHost`, `ServerLogging` (console and file levels the logging filters read at every line, the file sink's limits, the engine's level; applied again when Settings › Logs is saved), certificates, discovery beacon, embedded static files (`EmbeddedStaticFiles`: `no-cache` and a content ETag, so an upgrade never mixes old and new modules), Windows service (start and stop failures in the Application event log); the admin panel (ES modules, one per page; `schedules.js` is the Jobs page's Scheduled tab; the Library's views in `pages/library/`: `sequence.js` a sequence and its photo viewer, `trash.js` the archive's trash, `shared.js` cards, selection and grid keyboard; `upload.js` the upload dialog the Library opens on demand, hashing in the module worker `hash-worker.js` with the in-house incremental SHA-256 of `sha256.js`, self-tested before its first use, and sending the capture time `capture-time.js` reads: the Exif DateTimeOriginal of a JPEG or TIFF-based file, else the file's time) |
|
||||
| `Server/Hosting`, `Server/Admin/web` | `ServerHost`, `ServerLogging` (console and file levels the logging filters read at every line, the file sink's limits, the engine's level; applied again when Settings › Logs is saved), certificates, discovery beacon, embedded static files (`EmbeddedStaticFiles`: `no-cache` and a content ETag, so an upgrade never mixes old and new modules), Windows service (start and stop failures in the Application event log); the admin panel (ES modules, one per page; `schedules.js` is the Jobs page's Scheduled tab; the Library's views in `pages/library/`: `sequence.js` a sequence and its photo viewer, `trash.js` the archive's trash, `shared.js` cards, selection, grid keyboard and the retry of thumbnails a finished job may have built; `upload.js` the upload dialog the Library opens on demand, hashing in the module worker `hash-worker.js` with the in-house incremental SHA-256 of `sha256.js`, self-tested before its first use, and sending the capture time `capture-time.js` reads: the Exif DateTimeOriginal of a JPEG or TIFF-based file, else the file's time) |
|
||||
|
||||
### 2.5 Hosts
|
||||
|
||||
|
||||
+1
-1
@@ -770,7 +770,7 @@
|
||||
<data name="Admin.Trash.PlanItem" xml:space="preserve"><value>{0} · {1} · {2}</value><comment>invariant; an entry's kind, title and size</comment></data>
|
||||
<data name="Admin.Trash.Restore" xml:space="preserve"><value>Restore</value></data>
|
||||
<data name="Admin.Trash.RestorePhotos.Tip" xml:space="preserve"><value>Put the photos back into their sequence (a new one if it is gone); each is checked against its SHA-256 first</value></data>
|
||||
<data name="Admin.Trash.RestoreSequence.Tip" xml:space="preserve"><value>Put the sequence back into its folder and the library; its photos are checked against their SHA-256 first</value></data>
|
||||
<data name="Admin.Trash.RestoreSequence.Tip" xml:space="preserve"><value>Move the sequence's folder back into the library as it is (next to its old place if that is taken); its photos are not hash-checked: Verify does that</value></data>
|
||||
<data name="Admin.Trash.RestoredNew.one" xml:space="preserve"><value>{0} photo restored into a new sequence.</value><comment>long</comment></data>
|
||||
<data name="Admin.Trash.RestoredNew.other" xml:space="preserve"><value>{0} photos restored into a new sequence.</value><comment>long</comment></data>
|
||||
<data name="Admin.Trash.RestoredPhotos.one" xml:space="preserve"><value>{0} photo is back in {1}.</value><comment>long</comment></data>
|
||||
|
||||
@@ -767,7 +767,7 @@
|
||||
<data name="Admin.Trash.Photos" xml:space="preserve"><value>Foto</value></data>
|
||||
<data name="Admin.Trash.Restore" xml:space="preserve"><value>Ripristina</value></data>
|
||||
<data name="Admin.Trash.RestorePhotos.Tip" xml:space="preserve"><value>Rimetti le foto nella loro sequenza (una nuova se non c'è più); prima ognuna viene controllata con il suo SHA-256</value></data>
|
||||
<data name="Admin.Trash.RestoreSequence.Tip" xml:space="preserve"><value>Rimetti la sequenza nella sua cartella e nella libreria; prima le sue foto vengono controllate con il loro SHA-256</value></data>
|
||||
<data name="Admin.Trash.RestoreSequence.Tip" xml:space="preserve"><value>Riporta la cartella della sequenza nella libreria così com'è (accanto al suo vecchio posto se è occupato); le sue foto non vengono controllate con l'hash: lo fa Verifica</value></data>
|
||||
<data name="Admin.Trash.RestoredNew.one" xml:space="preserve"><value>{0} foto ripristinata in una nuova sequenza.</value><comment>long</comment></data>
|
||||
<data name="Admin.Trash.RestoredNew.other" xml:space="preserve"><value>{0} foto ripristinate in una nuova sequenza.</value><comment>long</comment></data>
|
||||
<data name="Admin.Trash.RestoredPhotos.one" xml:space="preserve"><value>{0} foto è di nuovo in {1}.</value><comment>long</comment></data>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { t, plural, applyStrings } from "../i18n.js";
|
||||
import { escapeHtml, attr, formatBytes, formatNumber, toast, errorText, confirmDialog, formDialog, markInvalid, emptyState, routeParams, redraw } from "../ui.js";
|
||||
import { icons } from "../icons.js";
|
||||
import { BULK_LIMIT, factsLine, captureText, cameraLabel, statusChips, lazyImage, watchImages, Selection, selectableGrid, chunks, saveFile, sequencesCsv, today, tagList, coverUrl } from "./library/shared.js";
|
||||
import { BULK_LIMIT, factsLine, captureText, cameraLabel, statusChips, lazyImage, watchImages, Selection, selectableGrid, chunks, saveFile, sequencesCsv, today, tagList, coverUrl, listed } from "./library/shared.js";
|
||||
import { renderSequence } from "./library/sequence.js";
|
||||
import { renderTrash } from "./library/trash.js";
|
||||
|
||||
@@ -137,7 +137,15 @@ async function renderList(root, { api, setMeta, actions, onEvent }, params) {
|
||||
open: (key) => {
|
||||
location.hash = `#/library?id=${encodeURIComponent(key)}`;
|
||||
},
|
||||
onChange: syncSelection,
|
||||
onChange: () => {
|
||||
// "Select all" holds while sequences beyond the loaded rows stay selected; once none does (Esc, Ctrl+A, every card
|
||||
// unticked) the selection is the loaded rows' again: Select all comes back and a refresh drops sequences gone.
|
||||
if (matching) {
|
||||
const loaded = new Set(rows.map((r) => r.id));
|
||||
if ([...selection.ids].every((id) => loaded.has(id))) matching = null;
|
||||
}
|
||||
syncSelection();
|
||||
},
|
||||
});
|
||||
|
||||
function setFilter(name, value) {
|
||||
@@ -481,10 +489,11 @@ async function renderList(root, { api, setMeta, actions, onEvent }, params) {
|
||||
}
|
||||
const body = [plural("Admin.Library.DeleteBody", going.length, plural("Admin.Dashboard.PhotoCount", plan.photos), formatBytes(plan.bytes)),
|
||||
blocked.length > 0 ? plural("Admin.Library.DeleteBlocked", blocked.length) : ""].filter(Boolean).join(" ");
|
||||
// Those that stay first, with their reasons; the title and the body count them all.
|
||||
const confirmed = await confirmDialog({
|
||||
title: plural("Admin.Library.DeleteTitle", going.length),
|
||||
body,
|
||||
list: [...going.map((i) => titles.get(i.id) ?? i.id), ...blocked.map((i) => t("Admin.Library.BlockedItem", titles.get(i.id) ?? i.id, i.message ?? i.reason))],
|
||||
list: listed([...blocked.map((i) => t("Admin.Library.BlockedItem", titles.get(i.id) ?? i.id, i.message ?? i.reason)), ...going.map((i) => titles.get(i.id) ?? i.id)]),
|
||||
confirm: t("Admin.Library.DeleteConfirm"),
|
||||
confirmTip: t("Admin.Library.DeleteConfirm.Tip"),
|
||||
cancel: t("Admin.Common.Keep"),
|
||||
@@ -522,6 +531,8 @@ async function renderList(root, { api, setMeta, actions, onEvent }, params) {
|
||||
root.querySelector("#q").value = "";
|
||||
listHash = filters.sort === "newest" ? "#/library" : `#/library?sort=${filters.sort}`;
|
||||
history.replaceState(null, "", listHash);
|
||||
selection.clear();
|
||||
matching = null;
|
||||
load();
|
||||
root.querySelector("#q").focus();
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
import { t, plural, applyStrings } from "../../i18n.js";
|
||||
import { escapeHtml, attr, formatBytes, formatNumber, formatDateTime, toast, errorText, confirmDialog, emptyState, escapeReverts, redraw } from "../../ui.js";
|
||||
import { icons } from "../../icons.js";
|
||||
import { captureText, cameraLabel, spanText, statusChips, lazyImage, watchImages, Selection, selectableGrid, tagList, coverUrl } from "./shared.js";
|
||||
import { captureText, cameraLabel, spanText, statusChips, lazyImage, watchImages, retryImages, Selection, selectableGrid, tagList, coverUrl, listed, JOB_ENDED } from "./shared.js";
|
||||
|
||||
const FRAME_PAGE = 500;
|
||||
/** Deleting more photos than this asks for their number to be typed. */
|
||||
const TYPED_ABOVE = 20;
|
||||
/** Names a delete dialog lists; the count in its title says how many there are in all. */
|
||||
const LISTED = 500;
|
||||
/** How long after a job ended the page reads the sequence again; one read covers every job that ended meanwhile. */
|
||||
const AFTER_JOB_MS = 1500;
|
||||
/** FrameFlags bits the viewer and the tiles name. */
|
||||
const FLAGS = [[1, "Missing"], [2, "Corrupt"], [4, "Duplicate"], [8, "Excluded"]];
|
||||
const MAX_TAGS = 50;
|
||||
@@ -22,6 +22,7 @@ export async function renderSequence(root, { api, setMeta, actions, onEvent }, i
|
||||
let renders = [];
|
||||
let generation = 0;
|
||||
let timer = null;
|
||||
let jobTimer = null;
|
||||
/** Set once this page deleted the sequence, or saw it go: its deletion event then says nothing more. */
|
||||
let leaving = false;
|
||||
const selection = new Selection();
|
||||
@@ -343,7 +344,7 @@ export async function renderSequence(root, { api, setMeta, actions, onEvent }, i
|
||||
const confirmed = await confirmDialog({
|
||||
title: plural("Admin.Sequence.DeletePhotosTitle", plan.photos),
|
||||
body: plural("Admin.Sequence.DeletePhotosBody", plan.photos, formatBytes(plan.bytes)),
|
||||
list: names.length > LISTED ? [...names.slice(0, LISTED), "…"] : names,
|
||||
list: listed(names),
|
||||
confirm: t("Admin.Sequence.DeletePhotosConfirm"),
|
||||
confirmTip: t("Admin.Sequence.DeletePhotosConfirm.Tip"),
|
||||
cancel: t("Admin.Common.Keep"),
|
||||
@@ -535,7 +536,24 @@ export async function renderSequence(root, { api, setMeta, actions, onEvent }, i
|
||||
location.hash = back;
|
||||
}
|
||||
|
||||
/**
|
||||
* After a job ended: thumbnail, proxy, verify and analysis jobs send no sequenceChanged, so the facts and status chips
|
||||
* are read again and the cover and photos that had no thumbnail yet are asked for again.
|
||||
*/
|
||||
async function afterJob() {
|
||||
jobTimer = null;
|
||||
if (!root.isConnected || leaving) return;
|
||||
await reload(false);
|
||||
if (root.isConnected && !leaving) retryImages(root);
|
||||
}
|
||||
|
||||
onEvent((e) => {
|
||||
if (e.type === "jobState") {
|
||||
// The event names no sequence: any job that ended may have worked on this one. The timer is not pushed back by the
|
||||
// next one, so a busy queue still refreshes the page every AFTER_JOB_MS.
|
||||
if (JOB_ENDED.has(e.state) && jobTimer === null) jobTimer = setTimeout(afterJob, AFTER_JOB_MS);
|
||||
return;
|
||||
}
|
||||
if (e.type !== "sequenceChanged" || e.sequenceId !== id) return;
|
||||
if (e.change === "deleted") {
|
||||
gone();
|
||||
|
||||
@@ -10,6 +10,17 @@ export const STATUS = { analysed: 1, deep: 2, proxies: 4, thumbs: 8, verified: 1
|
||||
/** Ids one bulk request may name (LibraryEndpoints.MaxBulkIds). */
|
||||
export const BULK_LIMIT = 1000;
|
||||
|
||||
/** Names a delete dialog lists; the count in its title says how many there are in all. */
|
||||
export const LISTED = 500;
|
||||
|
||||
/** The jobState states after which a job does nothing more. */
|
||||
export const JOB_ENDED = new Set(["done", "failed", "cancelled"]);
|
||||
|
||||
/** A dialog's list cut to LISTED lines and "…", so a delete of thousands never builds thousands of nodes. */
|
||||
export function listed(lines) {
|
||||
return lines.length > LISTED ? [...lines.slice(0, LISTED), "…"] : lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* A camera's name as the desktop and the server's facets give it (PathTemplate.CameraName): the make's brand once,
|
||||
* "Canon EOS R5" (Canon + Canon EOS R5), "Nikon Z 8" (NIKON CORPORATION + NIKON Z 8), "SONY ILCE-7M4".
|
||||
@@ -82,6 +93,21 @@ export function watchImages(root) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The images under root that had nothing to show (a thumbnail not built yet) asked for again, once a job that may have
|
||||
* built them ended: under an address the browser has not tried, so its first answer is not reused.
|
||||
*/
|
||||
export function retryImages(root) {
|
||||
root.querySelectorAll("img.failed").forEach((img) => {
|
||||
const url = new URL(img.getAttribute("src"), location.href);
|
||||
url.searchParams.set("retry", String(Date.now()));
|
||||
img.classList.remove("failed");
|
||||
img.setAttribute("data-fallback", "");
|
||||
img.src = url.pathname + url.search;
|
||||
});
|
||||
watchImages(root);
|
||||
}
|
||||
|
||||
/** A sequence's cover thumbnail; its address changes with the cover and the photos, so a browser's copy never shows an old one. */
|
||||
export function coverUrl(s) {
|
||||
return `/api/v1/sequences/${encodeURIComponent(s.id)}/thumb?v=${s.heroFrameId ?? "first"}-${s.framesVersion}`;
|
||||
|
||||
@@ -5,13 +5,23 @@
|
||||
import { t, plural, applyStrings } from "../../i18n.js";
|
||||
import { escapeHtml, attr, formatBytes, formatNumber, formatDateTime, toast, errorText, confirmDialog, emptyState, redraw, fitColumns } from "../../ui.js";
|
||||
import { icons } from "../../icons.js";
|
||||
import { JOB_ENDED } from "./shared.js";
|
||||
|
||||
/** Ended jobs the page remembers (their ids and last states), oldest dropped first. */
|
||||
const ENDED_KEPT = 100;
|
||||
|
||||
export async function renderTrash(root, { api, setMeta, actions, onEvent }, { back }) {
|
||||
let entries = [];
|
||||
let bytes = 0;
|
||||
/** The empty-trash job this page queued, followed until it ends. */
|
||||
let emptyJob = null;
|
||||
/**
|
||||
* The last jobState of jobs that ended while the page was open: the worker can claim the emptying and end it before
|
||||
* the POST that queued it has answered, so the page looks the job up here once it has its id.
|
||||
*/
|
||||
const ended = new Map();
|
||||
let timer = null;
|
||||
let jobTimer = null;
|
||||
|
||||
actions.innerHTML = `
|
||||
<a class="btn" href="${attr(back)}" data-i18n-title="Admin.Trash.Back.Tip">${icons.back}<span data-i18n="Admin.Trash.Back"></span></a>
|
||||
@@ -84,6 +94,8 @@ export async function renderTrash(root, { api, setMeta, actions, onEvent }, { ba
|
||||
} catch (err) {
|
||||
toast(errorText(err), true);
|
||||
if (button.isConnected) button.disabled = false;
|
||||
// The entry is gone (emptied or restored elsewhere): the list shows the trash as it is now.
|
||||
if (err.status === 404) await load();
|
||||
return;
|
||||
}
|
||||
const lines = [result.kind === "sequence" ? t("Admin.Trash.RestoredSequence", entry.title)
|
||||
@@ -123,8 +135,13 @@ export async function renderTrash(root, { api, setMeta, actions, onEvent }, { ba
|
||||
if (!confirmed) return;
|
||||
try {
|
||||
const job = await api.post("/api/v1/archive/trash/empty", { names: null, dryRun: false, fingerprint: plan.fingerprint });
|
||||
emptyJob = job.id;
|
||||
toast(t("Admin.Trash.EmptyQueued"));
|
||||
// Its end may have come over the events before this answer did.
|
||||
const end = ended.get(job.id);
|
||||
if (end) emptyEnded(end);
|
||||
else {
|
||||
emptyJob = job.id;
|
||||
toast(t("Admin.Trash.EmptyQueued"));
|
||||
}
|
||||
} catch (err) {
|
||||
// trash_changed: something entered or left the trash since it was measured; it is shown as it is now.
|
||||
toast(errorText(err), true);
|
||||
@@ -134,12 +151,28 @@ export async function renderTrash(root, { api, setMeta, actions, onEvent }, { ba
|
||||
}
|
||||
}
|
||||
|
||||
/** The emptying this page queued ended: its toast; the caller shows the trash again. */
|
||||
function emptyEnded(e) {
|
||||
emptyJob = null;
|
||||
if (e.state === "done") toast(t("Admin.Trash.Emptied"));
|
||||
else toast(e.error || t("Admin.Trash.EmptyFailed"), true);
|
||||
}
|
||||
|
||||
onEvent((e) => {
|
||||
if (e.type === "jobState" && e.jobId === emptyJob && (e.state === "done" || e.state === "failed" || e.state === "cancelled")) {
|
||||
emptyJob = null;
|
||||
if (e.state === "done") toast(t("Admin.Trash.Emptied"));
|
||||
else toast(e.error || t("Admin.Trash.EmptyFailed"), true);
|
||||
load();
|
||||
if (e.type === "jobState" && JOB_ENDED.has(e.state)) {
|
||||
ended.set(e.jobId, e);
|
||||
if (ended.size > ENDED_KEPT) ended.delete(ended.keys().next().value);
|
||||
if (e.jobId === emptyJob) {
|
||||
emptyEnded(e);
|
||||
load();
|
||||
} else if (jobTimer === null) {
|
||||
// An emptying started elsewhere (another tab, the desktop) sends no sequenceChanged. The timer is not pushed
|
||||
// back by the next job, so a busy queue still shows the trash again.
|
||||
jobTimer = setTimeout(() => {
|
||||
jobTimer = null;
|
||||
if (root.isConnected) load();
|
||||
}, 1500);
|
||||
}
|
||||
} else if (e.type === "sequenceChanged") {
|
||||
// A deletion or a restore elsewhere changes what the trash holds.
|
||||
clearTimeout(timer);
|
||||
|
||||
@@ -190,10 +190,11 @@ public sealed partial class SystemEndpointTests(TestContext context)
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AdminPanelListsTheLibraryAndLoadsTheWebUploadOnDemand()
|
||||
public async Task AdminPanelListsTheLibraryAndImportsTheWebUploadOnlyDynamically()
|
||||
{
|
||||
// Owner review 2, R6: the Library comes right after the Dashboard. The web upload (R3) is a module of its own that the
|
||||
// Library imports on demand (Upload, and a sequence's Add photos), so a page that never uploads never loads it.
|
||||
// Owner review 2, R6: the Library comes right after the Dashboard. The web upload (R3) is a module of its own that
|
||||
// only the Library list and a sequence import, and only dynamically (never statically): the other pages never load
|
||||
// it, and the Library still works, without Upload and Add photos, when the module does not load.
|
||||
await using var server = await TestServer.StartAsync(context);
|
||||
var app = await server.Client.GetStringAsync("/admin/app.js");
|
||||
var top = MenuPages(app)[0];
|
||||
@@ -222,11 +223,83 @@ public sealed partial class SystemEndpointTests(TestContext context)
|
||||
Assert.Contains("openUpload({ api, sequence: seq, onDone: ", modules["pages/library/sequence.js"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheTrashPageSeesAnEmptyingThatEndedBeforeItsPostAnswered()
|
||||
{
|
||||
// The worker claims an emptying as soon as it is queued and can end it before the browser has read the 202: the page
|
||||
// keeps the last state of the jobs that ended and looks its own job up there before it starts following it.
|
||||
await using var server = await TestServer.StartAsync(context);
|
||||
var trash = await server.Client.GetStringAsync("/admin/pages/library/trash.js");
|
||||
Assert.Contains("ended.set(e.jobId, e)", trash);
|
||||
var lookedUp = trash.IndexOf("ended.get(job.id)", StringComparison.Ordinal);
|
||||
var followed = trash.IndexOf("emptyJob = job.id", StringComparison.Ordinal);
|
||||
Assert.True(lookedUp > 0 && followed > lookedUp, "the queued job is looked up among the ended ones before it is followed");
|
||||
// An emptying started elsewhere sends no sequenceChanged: any job that ends shows the trash again, and a restore
|
||||
// of an entry that is gone (404) does too.
|
||||
Assert.True(Regex.IsMatch(trash, @"e\.type === ""jobState"" && JOB_ENDED\.has\(e\.state\)"), "every ended job is seen");
|
||||
Assert.True(Regex.IsMatch(trash, @"if \(err\.status === 404\) await load\(\);"), "a restore of a gone entry reloads the trash");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ASequencePageRefreshesAfterJobsAndAsksAgainForMissingThumbnails()
|
||||
{
|
||||
// Thumbnail, proxy, verify and analysis jobs send no sequenceChanged: when any job ends, the sequence page reads the
|
||||
// sequence again (facts, status chips) and asks again, past the browser's first answer, for the images that failed.
|
||||
await using var server = await TestServer.StartAsync(context);
|
||||
var sequence = await server.Client.GetStringAsync("/admin/pages/library/sequence.js");
|
||||
var shared = await server.Client.GetStringAsync("/admin/pages/library/shared.js");
|
||||
Assert.True(Regex.IsMatch(sequence, @"e\.type === ""jobState""\) \{\s+(//[^\n]*\s+)*if \(JOB_ENDED\.has\(e\.state\) && jobTimer === null\) jobTimer = setTimeout\(afterJob"),
|
||||
"an ended job schedules one refresh, not pushed back by the next");
|
||||
Assert.True(Regex.IsMatch(sequence, @"async function afterJob\(\) \{[^}]*await reload\(false\);[^}]*retryImages\(root\);", RegexOptions.Singleline),
|
||||
"the refresh reads the sequence again, then retries the cover and the photos");
|
||||
Assert.Contains(@"export const JOB_ENDED = new Set([""done"", ""failed"", ""cancelled""]);", shared);
|
||||
Assert.True(Regex.IsMatch(shared, @"export function retryImages\(root\) \{\s+root\.querySelectorAll\(""img\.failed""\)[^}]*searchParams\.set\(""retry"",", RegexOptions.Singleline),
|
||||
"a retried image gets an address the browser has not tried");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheTrashsRestoreTooltipsSayWhatIsChecked()
|
||||
{
|
||||
// A photo entry is hashed against its record before it goes back; a sequence entry is moved back as a folder and
|
||||
// nothing is hashed (SequenceTrash.RestoreAsync), so its tooltip must not promise a check.
|
||||
await using var server = await TestServer.StartAsync(context);
|
||||
foreach (var (culture, verify) in new[] { ("en", "Verify"), ("it", "Verifica") })
|
||||
{
|
||||
var strings = Assert.NotNull(await server.Client.GetFromJsonAsync($"/api/v1/i18n/{culture}", ProtocolJson.Default.DictionaryStringString));
|
||||
Assert.Contains("SHA-256", strings["Admin.Trash.RestorePhotos.Tip"]);
|
||||
var sequence = strings["Admin.Trash.RestoreSequence.Tip"];
|
||||
Assert.False(sequence.Contains("SHA-256", StringComparison.Ordinal), $"{culture}: {sequence}");
|
||||
// The check it does not make is named, with the job that makes it.
|
||||
Assert.Contains(verify, sequence);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheLibraryListDropsSelectAllWhenNoUnloadedSequenceStaysSelectedAndCapsItsDeleteList()
|
||||
{
|
||||
await using var server = await TestServer.StartAsync(context);
|
||||
var library = await server.Client.GetStringAsync("/admin/pages/library.js");
|
||||
var sequence = await server.Client.GetStringAsync("/admin/pages/library/sequence.js");
|
||||
var shared = await server.Client.GetStringAsync("/admin/pages/library/shared.js");
|
||||
// Esc and Ctrl+A in the grid change the selection through onChange: once no selected sequence lies beyond the loaded
|
||||
// rows, "Select all" no longer holds, so its button comes back and a live refresh prunes the selection again.
|
||||
Assert.True(Regex.IsMatch(library, @"onChange: \(\) => \{.*?if \(matching\) \{.*?\[\.\.\.selection\.ids\]\.every\(\(id\) => loaded\.has\(id\)\)\) matching = null;.*?syncSelection\(\);", RegexOptions.Singleline),
|
||||
"the grid's onChange drops matching");
|
||||
Assert.True(Regex.IsMatch(library, @"function clearFilters\(\) \{(?:(?!\n \}).)*selection\.clear\(\);\s+matching = null;", RegexOptions.Singleline),
|
||||
"clearing the filters clears the selection as setFilter does");
|
||||
// A delete of thousands of sequences or photos lists at most LISTED names (the dialog's title counts them all); the
|
||||
// sequences that stay come first, with their reasons.
|
||||
Assert.True(Regex.IsMatch(shared, @"export const LISTED = 500;"), "LISTED");
|
||||
Assert.True(Regex.IsMatch(library, @"list: listed\(\[\.\.\.blocked\.map\("), "the sequences' delete list is capped, blocked first");
|
||||
Assert.Contains("list: listed(names),", sequence);
|
||||
Assert.False(Regex.IsMatch(library + sequence, @"list: \[\.\.\."), "an uncapped delete list");
|
||||
}
|
||||
|
||||
/// <summary>The admin panel's modules from app.js and the menu's pages along their static imports, with their source.</summary>
|
||||
private static async Task<Dictionary<string, string>> ModulesAsync(TestServer server)
|
||||
{
|
||||
var app = await server.Client.GetStringAsync("/admin/app.js");
|
||||
// The upload dialog is a module the Library opens on demand (owner review 2, R3); its hash worker is named by a URL.
|
||||
// The upload dialog is a module the Library imports dynamically (owner review 2, R3); its hash worker is named by a URL.
|
||||
var pending = new Queue<string>(MenuPages(app).SelectMany(group => group).Select(p => $"pages/{p}.js").Prepend("upload.js").Prepend("app.js"));
|
||||
var seen = new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
while (pending.TryDequeue(out var module))
|
||||
|
||||
Reference in new issue
Block a user