E5: dimostrazione, prove dell'interfaccia e schermate delle copie automatiche

La dimostrazione mostra le copie automatiche senza avviare il lavoratore:
«Studio Lumen» è automatica con «Solo i nuovi» dall'inizio dei suoi file
più recenti non copiati; un lavoro automatico del motore vero (su un
orologio spostato indietro) ne ha copiati alcuni e un lavoro automatico
interrotto tiene esattamente il resto. «Riconosci le copie già presenti»
gira davvero in «Studio Lumen» (una copia riconosciuta, un file diverso):
in «Disco USB» avrebbe allungato ogni avvio della dimostrazione di 47 s.

Le prove della dimostrazione controllano questi dati e che un lavoratore
di prova riprenda solo il lavoro interrotto. Le prove dell'interfaccia
(nella CI) coprono la domanda «Solo i nuovi», la nota allo spegnimento,
l'etichetta «Automatica dal …», «Riconosci» con il suo lavoro nella
Dashboard, la pausa con i file che aspettano e la conferma di «Usa la
cartella generale». Schermata nuova 32, rifatte 15, 16, 17 e 21, con le
differenze dai mockup in differenze.md e una riga in decisioni.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-04 18:14:07 +01:00
1 parent f8491529ca
commit 94f6b316f6
14 files changed
+754 -16

No files matched your search

+1
View File
@@ -683,3 +683,4 @@ Ogni scelta tecnica presa strada facendo, con data e motivo (specifica §15).
| 2026-12-04 | Tappa E5, il servizio delle copie (`ExportService`): le partenze automatiche (`TryStartAutomaticAsync`, `TryResumeAutomaticAsync`) **non lanciano mai eccezioni perché Febe è occupata**: rispondono «occupato» (un lavoro, una sessione del motore, un cambio di cartella, un altro lavoro lungo), «niente da fare» (senza prendere il cancello, così la conversione della libreria non si ferma per nulla) o «ferme»; registrano solo i file da scrivere (niente «già copiato», «Tolto», «Superato»), un lavoro per cartella, e riprendono solo lavori automatici di cartelle ancora automatiche e non in pausa. Le partenze di Alberto («Copia in…», «Riprendi», «Controlla le copie», «Riprova») prendono il cancello con `EnterAsync` e aspettano che il lavoro automatico spostato abbia salvato i suoi stati (al più `StopWait` = 10 s, tempo reale). **I cambi di cartella passano da `ChangeDestinationAsync`**: le partenze automatiche stanno lontane dal primo momento, il lavoro automatico di quella cartella si ferma, poi il cambio, poi i lavori automatici di cartelle non più automatiche o tolte diventano «annullato»; un lavoro automatico non finito non blocca più il cambio di cartella né «Togli la cartella» (uno di Alberto sì). La copia stessa annulla un lavoro automatico la cui cartella non è più automatica, all'inizio e a ogni gruppo. **«Interrompi»** di una copia automatica ferma le copie automatiche per un'ora (`AutomaticHoldTime`), in memoria nel servizio; «Riprendi ora» toglie la sosta. Una cartella in pausa con un lavoro in pausa torna disponibile solo se il disco ha posto per il prossimo file più il margine; senza misura dello spazio la pausa si toglie come prima. «Copia automatica in … finita» solo se il lavoro ha copiato, adottato o non è riuscito qualcosa. Il segnale della copia automatica parte dal nucleo quando una cartella si accende, prende tipi in più, si toglie una cartella propria o si riaccende «Esporta questo account» (`ExportEnvironment.AutoSignal`), non dall'API. Un percorso troppo lungo dà la nota `PathTooLong`. La fine di Febe aspetta il lavoro al più `StopWait` | Risposte 48, 49, 50, 52, 53 e 54 di Alberto. Un rifiuto con eccezione non serve a chi riprova da solo a ogni passata; una partenza che non trova nulla non deve fermare la conversione. Serializzare i cambi nel nucleo chiude la finestra in cui la copia automatica potrebbe ripartire fra l'arresto e il salvataggio. La sosta sta nel servizio, che le partenze consultano, perché il servizio è l'unico punto da cui partono; in memoria come chiede la risposta 53. Riprendere una pausa per spazio senza posto la rimetterebbe subito in pausa. Il segnale nel nucleo vale per ogni via di salvataggio, non solo per l'API, e le prove lo osservano con un'istanza loro. Un limite in tempo reale alla chiusura evita che una lettura bloccata su una condivisione caduta tenga aperta Febe; il lavoro rimasto «in corso» diventa «interrotto» all'avvio dopo, come dopo un arresto improvviso |
| 2026-12-04 | Tappa E5, «Riconosci le copie già presenti» (`ExportService.RecognizeAsync`, partenza di Alberto da una cartella): un lavoro di tipo «Riconosci», riprendibile, su ogni file dovuto alla cartella che non è «Copiato» (senza «da quando»; «Una copia sola» vale) e sui fotogrammi che hanno già una riga lì. Per ogni file Febe guarda il percorso dello schema e «nome (2)» … «nome (50)», nella forma che la cartella chiede adesso e come originale, ciascuna con la sua identità (una copia byte per byte si registra Intera/Originale); prima i percorsi, poi la lunghezza, poi lo SHA-256 (con la conversione rifatta solo se un file c'è), mai per dimensione o nome soltanto. Un file uguale si registra «Adottato»: la riga «Non riuscito» della stessa identità diventa la copia, una riga orfana si ricollega, una «Superato» con gli stessi byte torna «Copiato». **Un «Tolto» resta «Tolto»** anche se il file è tornato identico (non si guarda nemmeno; un lavoro ripreso dopo un «Tolto» lo salta). Un fotogramma si confronta con i byte che la sua riga ha registrato, altrimenti si ricava di nuovo dal video; i fotogrammi mai registrati non si cercano. Non scrive, non rinomina e non toglie file (neppure i `.part` lasciati da altri), una cartella che non risponde mette in pausa senza segnare nulla, e scrive solo il suo evento (`esportazione-riconosci`: «Riconosciute N copie già presenti in …», informazione quando nessuna). Il resoconto conta «Non c'è nella cartella» e «Nel percorso c'è un altro file»; solo il secondo è fra i problemi. Lo spazio libero non si chiede per un «Riconosci» in pausa | Risposta 51 di Alberto (b: come proposto, ma un «Tolto» resta «Tolto»). Provare prima i percorsi evita letture e conversioni dove non c'è nulla; ogni forma con la sua identità rispetta il vincolo fra variante e SHA-256 della copia; riusare la riga «Non riuscito» evita una seconda riga corrente. Contare «Non c'è» fra i problemi riempirebbe il resoconto di una cartella che non ha mai avuto copie. Una conversione fatta da codificatori più vecchi esce «diversa»: la copia successiva scrive il file accanto, con un nome libero, e quello che c'era resta |
| 2026-12-04 | Tappa E5, il lavoratore delle copie automatiche (`AutoExportWorker`, in `Febe.Core/Export`): un ciclo solo, avviato dalla composizione nell'avvio normale (mai nella dimostrazione, mai in un avvio con problemi), fermato **per primo** alla chiusura, prima dell'interfaccia e del motore, con il lavoro automatico interrotto (al più 5 s, tempo reale). Il giro di recupero gira all'avvio e poi ogni ora (`IClock`, nessuna variazione casuale: il lavoratore non tocca Instagram); il sonno dura al più 5 minuti, così dopo una sospensione del PC il giro arriva in ritardo una volta sola. Ogni riga di `_febe.jsonl` dà un segnale (in `LibraryIngest`, anche per le righe scritte in ritardo, un'istanza propria nelle prove): la passata parte **due minuti dopo l'ultimo segnale** (al più 15 minuti di rinvio se i file continuano ad arrivare), subito con un segnale urgente (cartella accesa, «Riprendi ora»); un segnale che arriva durante una passata non si perde. Una passata, in ordine: al giro i lavori automatici orfani diventano «annullato»; la sosta di «Interrompi» la ferma fino alla sua fine (il giro dovuto resta in attesa e parte allora); una sessione del motore, un lavoro lungo di Alberto, «Cerca i video fermi» o una sua copia la fanno aspettare (riprova ogni 5 s e la Dashboard dice perché); al giro ogni cartella in pausa si riprova (le copie fatte a mano «In pausa» restano di Alberto); poi riprende i lavori automatici non finiti (quelli fermati da un errore o in pausa solo al giro), altrimenti un lavoro per ogni cartella automatica non in pausa e senza un lavoro automatico non finito, con le voci la cui riga del giornale è ancora da scrivere tenute fuori. Finito un lavoro automatico, una passata segue **solo** se il lavoro è stato fermato (i suoi lavori «interrotto» senza errore) o se aveva ripreso lavori invece di cercare file nuovi; il lavoratore aspetta la fine del lavoro (`ExportService.AutomaticWork`) invece di riprovare. Un lavoro finito non ne fa partire un altro da solo | Risposte 49, 50, 53 e 54 di Alberto; come la conversione della libreria (decisione del 30/11) niente `BackgroundService` e niente lavoratore nella dimostrazione. Il segnale alla fine di ogni lavoro proposto dal progetto, con un file che c'è nella base dati ma non sul disco (o un «Non riuscito» che non cambia), avrebbe fatto un lavoro ogni due minuti per sempre: così quei file tornano solo al giro, una volta all'ora, la conseguenza accettata con la risposta 50. Riprendere da soli i lavori fermati dai lavori di Alberto è la risposta 49 («riparte da sola dopo»), senza aspettare il giro. Fermare il lavoratore per primo evita che una sessione che finisce durante la chiusura faccia partire una copia |
| 2026-12-04 | Tappa E5, **dimostrazione**: «Studio Lumen» è automatica con «Solo i nuovi» dall'ora in cui cominciano i suoi file più recenti non ancora copiati (una ventina, scelti dai dati, non un'ora fissa); un lavoro automatico del motore vero, eseguito su un orologio spostato indietro, ne copia la parte più vecchia (solo foto: i video della dimostrazione sono un file solo che non è quello registrato e non riuscirebbero), e un lavoro automatico «interrotto» tiene il resto, così ciò che le copie automatiche farebbero è esattamente quel lavoro. «Riconosci le copie già presenti» gira davvero, tre ore prima, in «Studio Lumen» (una copia identica di una foto più vecchia riconosciuta, un'altra immagine al posto di un'altra foto «diversa»). Il lavoratore resta spento nella dimostrazione | Il progetto proponeva un «Riconosci» in «Disco USB»: lì cerca circa 28.000 file e allungava di 47 s ogni avvio della dimostrazione (e quindi ogni prova dell'interfaccia); in «Studio Lumen» sono 200. Un «dal» successivo all'ultimo file (la proposta) avrebbe reso incoerente il lavoro automatico «interrotto», che deve avere file nuovi da copiare |
Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 KiB

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 KiB

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

+55 -3
View File
@@ -41,7 +41,7 @@ solo per l'interfaccia di Febe (§10.7).
| `doppioni-download.png` | `/doppioni` | confronto di `miniature/09-importa-revisione.png` (§9.5) |
| `primo-avvio.png` | `/libreria?scena=scollegato`, libreria vuota disegnata dal passo `benvenuto.js` | (nessuno: §10.3) |
| `errore-configurazione.png` | `/libreria?scena=errore` | (nessuno) |
| `15-impostazioni-esportazione.png` | `/impostazioni/esportazione`, 1440 × 1470 (presa il 27/11 da Windows, come le righe seguenti fino alla 21; tutte rifatte il 28/11 con i formati della tappa E3) | composta da `docs/mockup/08-impostazioni-generali.png` e `miniature/07-limiti-e-comportamento.png` |
| `15-impostazioni-esportazione.png` | `/impostazioni/esportazione`, 1440 × 1470 (presa il 27/11 da Windows, come le righe seguenti fino alla 21; tutte rifatte il 28/11 con i formati della tappa E3; 15, 16, 17 e 21 rifatte il 4/12 con la tappa E5) | composta da `docs/mockup/08-impostazioni-generali.png` e `miniature/07-limiti-e-comportamento.png` |
| `15-impostazioni-esportazione-docker.png` | `/impostazioni/esportazione?veste=docker`, con la nota su `/esporta` | come sopra |
| `16-destinazione.png` | `/impostazioni/esportazione`, «Modifica…» della cartella generale, «Uno schema suo» con il primo schema cambiato (passo `destinazione.js`), 1440 × 1000 | composta dal mockup 08 («Nomi dei file», «Risultato») e dai dialoghi di `miniature/13-foglio-di-stile.png` |
| `17-account-copie-esterne.png` | `/account/3/impostazioni` (@studio.lumen.demo, cartella sua), scorsa fino a «Cartella» (passo `account-copie.js`), 1440 × 1000 | composta da `miniature/05-account-impostazioni.png` |
@@ -62,6 +62,7 @@ solo per l'interfaccia di Febe (§10.7).
| `29-libreria-video-fermi.png` | `/libreria?tipo=fermi` | composta da `docs/mockup/01-libreria.png` |
| `30-video-fermi-selezione.png` | `/libreria?account=2` (@marta.demo), «Seleziona», cinque video e quattro elementi di foto, «Cerca i video fermi» (passo `video-fermi-selezione.js`), 1440 × 1000 | composta dai dialoghi del 13 sopra `docs/mockup/01-libreria.png` |
| `31-dashboard-video-fermi.png` | `/dashboard/esportazione`, la ricerca di tutti i video della libreria al lavoro (passo `dashboard-video-fermi.js`, l'unico che avvia qualcosa: un'analisi; viene per ultima) | composta da `miniature/06-attivita.png` e dal passo 2 dell'importazione (mockup 09) |
| `32-destinazione-automatica.png` | `/impostazioni/esportazione`, «Modifica…» della cartella generale, «Copie automatiche in questa cartella» accesa: la domanda «Che cosa fare dei file già in libreria?» (passo `destinazione-automatica.js`; nessun salvataggio), 1440 × 1000 (presa il 4/12 da Windows) | composta dai dialoghi di `miniature/13-foglio-di-stile.png` e dalle leve di `miniature/07-limiti-e-comportamento.png` |
## Differenze che restano
@@ -246,8 +247,8 @@ visualizzatore, scheda della Dashboard) girano solo nella CI, con Chromium: qui
parte dei formati, Impostazioni → Esportazione non aveva «Formati delle copie» né «Conversione della libreria», e
«Copia in…» non aveva la riga del formato: sono arrivati con la tappa E3, e le schermate 15–21 sono state rifatte il
28/11 con loro (qui sotto, «Formati e fotogrammi»).
- **«Automatica» non c'è (E5).** La scelta si conserva ma non si mostra, con la domanda «Solo i nuovi»: senza il giro
orario della tappa E5 un interruttore acceso non farebbe nulla.
- **«Automatica» non c'era nelle schermate del 27/11:** è arrivata con la tappa E5, con «Riconosci le copie già
presenti» (qui sotto, «Esportazione automatica»).
- **«Fotogrammi…» e «Fotogramma» non c'erano (E3)** nelle schermate del 27/11: né nella barra della selezione della
Libreria e della scheda account, né nel visualizzatore. Sono arrivati con la tappa E3 (qui sotto; nella 20 rifatta
il 28/11 la foto non ha «Fotogramma», che è solo dei video).
@@ -438,6 +439,57 @@ Differenze:
sessione) nella conferma e nella Dashboard, il riepilogo a lavoro finito e l'avviso breve con «Mostra i video fermi», il
tema scuro, la finestra stretta e il telefono delle parti nuove.
### Esportazione automatica (tappa E5, issue #58, dal 4 dicembre 2026)
Neanche queste parti hanno un mockup (§10.3 «Schermate dell'esportazione»): sono composte dai mockup esistenti, come
dice la tabella. Il 4 dicembre la schermata nuova `32-destinazione-automatica` è stata presa, e le cinque che mostrano
le parti nuove (`15-impostazioni-esportazione`, `15-impostazioni-esportazione-docker`, `16-destinazione`,
`17-account-copie-esterne`, `21-dashboard-esportazione`) rifatte, con il programma delle schermate da Windows
(`tools/Febe.Schermate`, browser senza finestra, scala 1,25), una alla volta con `una`, su una dimostrazione appena
avviata (`--demo --porta 8490`). Misure: 1440 × 900; 1440 × 1470 per la 15; 1440 × 1000 per le finestre (16, 32) e la
scheda account (17). Nessun passo salva, copia o riconosce: la 32 accende la leva e lascia la domanda aperta. Poi le
schermate sono state messe accanto ai mockup da cui nascono. Le prove dell'interfaccia
(`ExportInterfaceTests.Automatic.cs`) girano nella CI; il 4/12 sono state eseguite anche qui, con Chrome in Windows.
Differenze:
- **Finestra della cartella** (dialoghi del 13, 32): una parte «Automatica» dopo «Nomi dei file», con il titolo, una
riga d'aiuto e la leva «Copie automatiche in questa cartella» come quelle di `miniature/07-limiti-e-comportamento.png`.
Accesa (o accesa con un'altra cartella) chiede in grassetto «Che cosa fare dei file già in libreria?», con due tondi
come quelli di «Nomi dei file»: «Solo i nuovi», scelto, e «Copia anche i N già in libreria» con lo spazio. Il conto
arriva dopo qualche secondo («Conto i file già in libreria…»). La parte sta in fondo a una finestra già lunga: nella 16
non si vede, nella 32 la finestra è scorsa fino a lei.
- **Impostazioni → Esportazione** (mockup 08 e 07, 15): sotto la cartella generale, accanto ai conteggi, due pulsanti,
«Controlla le copie» e «Riconosci le copie già presenti» (icona della lente). Nella tabella delle cartelle degli
account la colonna «Copie» ha i conteggi e, sotto, gli stessi due pulsanti senza bordo, uno sopra l'altro; sotto il
percorso la riga dei tipi finisce con «· Automatica dal 4 dicembre». La cartella generale della dimostrazione non è
automatica.
- **Scheda account → Copie esterne** (mockup 05, 17): accanto a «Nella sua cartella» l'etichetta azzurra «Automatica dal
4 dicembre» con l'icona `refresh-cw`, come le etichette del mockup 05. Sotto il campo, i conteggi della cartella
(«20 copiati») con «Controlla le copie» e «Riconosci le copie già presenti», poi la riga dei file dell'account («170 su
656 non ancora copiati») con «Copia in…»: sono due conti diversi, le copie che la cartella ha e i file dell'account che
le mancano.
- **Dashboard → Esportazione** (mockup 06 e passo 2 del 09, 21): in «Da riprendere» il lavoro automatico ha l'etichetta
«Automatica» prima del testo; in «Ultimi lavori» il nome è «Copia automatica in Studio Lumen» con l'etichetta dopo, e
«Riconoscimento delle copie in Studio Lumen» per «Riconosci» (più in basso, fuori dalla schermata). La dimostrazione
non avvia le copie automatiche (decisione del 4 dicembre 2026), quindi sotto «Nessuna copia al lavoro» non c'è la riga
«Copie automatiche: prossimo giro di recupero …» e le righe automatiche di «Da riprendere» non dicono «riprende da sola
…»: le controllano le prove dell'API.
- **Contenuti dimostrativi.** «Studio Lumen» è automatica con «Solo i nuovi» dall'ora in cui cominciano i suoi file più
recenti non ancora copiati (nella dimostrazione sono di oggi, quindi «dal 4 dicembre» è il giorno in cui la
dimostrazione parte). Un lavoro automatico del motore, di poco prima, ne ha copiati alcuni; un altro, fermato
dall'ultima chiusura, ha gli altri («0 di 6 file»): le copie automatiche, se girassero, farebbero solo lui. Un
«Riconosci» di tre ore prima ha riconosciuto una copia e trovato un file diverso fra circa 200. Numeri e ore cambiano con
l'ora in cui parte la dimostrazione.
- **Confronto con le immagini** (4 dicembre): parte «Automatica», leva e tondi della 32 hanno intestazione, misure e
colori delle parti del 13 e della leva del 07; etichette e pulsanti di 15, 17 e 21 sono quelli del foglio di stile e
del mockup 05. Nessuna differenza da segnalare oltre a quelle qui sopra; nessun ritocco.
- **Senza schermata** (guardate solo dalle prove dell'interfaccia): la riga delle copie automatiche nella Dashboard e
«Riprendi ora», «riprende da sola …», una copia di Alberto ferma la cui cartella risponde di nuovo, la pausa «da
oggi» con «N file aspettano questa cartella.» e «Riprova», la nota «Spegnendo…», «N file in più si copieranno da
soli», le note per un account spento e per una cartella sua mentre la generale è automatica, la conferma di «Usa la
cartella generale» con i file che andranno da soli, il resoconto di «Riconosci», il tema scuro, la finestra stretta e
il telefono delle parti nuove.
### Carattere e icone (dal 18 novembre 2026)
Mockup e schermate di questa cartella sono stati presi con il carattere Archivo e le icone Lucide, che dal 18 novembre
+216 -10
View File
@@ -14,8 +14,13 @@ namespace Febe.Web.Demo;
/// «Studio Lumen» for @studio.lumen.demo, @il.porto.demo not exported, and for @marta.demo about two thirds of its
/// photos copied by the real engine (a completed job with its report), one «Tolto», one «Superato» and one «Errore»,
/// and a job left «interrotto» for the Dashboard; tappa E3 adds a copy converted to PNG, a frame of a video and two
/// conversions of the library («Convertito», «Non si converte»). Everything lives in the demo's temporary folder, whose «esporta» is
/// the demo's <c>/esporta</c>: the counts, the marks and the «Copie» filter come from the same rows the engine wrote.
/// conversions of the library («Convertito», «Non si converte»). Tappa E5: «Studio Lumen» is «Automatica» since a past
/// instant, with an automatic job that copied part of its new files (by the real engine) and one left «interrotto» with
/// the rest, and a «Riconosci le copie già presenti» (by the real engine) that recognised one copy and found one
/// different file. The demo never runs the automatic worker (decision of 4 December 2026, as for the conversion
/// of the library): what the automatic copies would do next is only the interrupted job. Everything lives in the demo's
/// temporary folder, whose «esporta» is the demo's <c>/esporta</c>: the counts, the marks and the «Copie» filter come
/// from the same rows the engine wrote.
/// </summary>
public static class DemoExport
{
@@ -59,19 +64,26 @@ public static class DemoExport
}
var files = new DemoFileResolver(world);
await using var service = new ExportService(new ExportEnvironment
var gate = new LongWorkGate();
// The jobs of the past (tappa E5) are run by a service whose clock is moved back: their times, copies and events
// are those of the engine at that instant. A private signal: nothing listens to it in the demo.
ExportService NewService(IClock at) => new(new ExportEnvironment
{
Storage = database,
Layout = () => layout,
DataFolder = data.Root,
Clock = clock,
Clock = at,
Root = options,
ResolveSource = files.Resolve,
Disk = new DemoExportDisk(),
Session = NoEngineSession.Instance,
Gate = new LongWorkGate(),
Gate = gate,
AutoSignal = new AutoExportSignal(),
});
await using var service = NewService(clock);
var accounts = await database.Accounts.ListAsync(ct).ConfigureAwait(false);
var marta = accounts.FirstOrDefault(a => a.Username == CopiedAccount);
var studio = accounts.FirstOrDefault(a => a.Username == OwnFolderAccount);
@@ -79,11 +91,12 @@ public static class DemoExport
var general = (await service.Destinations.CreateAsync(
new DestinationSpec(ExportScope.General, null, GeneralFolder, GeneralFolder, ContentTypes.All, null, null, null),
ct).ConfigureAwait(false)).Destination;
ExportDestination? own = null;
if (studio is not null)
{
await service.Destinations.CreateAsync(
own = (await service.Destinations.CreateAsync(
new DestinationSpec(ExportScope.Account, studio.Id, OwnFolder, OwnFolder, ContentTypes.PostPhotos | ContentTypes.PostVideos, null, null, null),
ct).ConfigureAwait(false);
ct).ConfigureAwait(false)).Destination;
}
if (porto is not null)
@@ -111,10 +124,10 @@ public static class DemoExport
if (studio is not null)
{
var own = await PhotosAsync(database, studio, world, ct).ConfigureAwait(false);
if (own.Count > 0)
var ownPhotos = await PhotosAsync(database, studio, world, ct).ConfigureAwait(false);
if (ownPhotos.Count > 0)
{
await service.StartAsync(new ExportJobRequest(new ExportSelection.Media([.. own.Take(Math.Max(1, own.Count / 2)).Select(p => p.Media.Id)])), ct).ConfigureAwait(false);
await service.StartAsync(new ExportJobRequest(new ExportSelection.Media([.. ownPhotos.Take(Math.Max(1, ownPhotos.Count / 2)).Select(p => p.Media.Id)])), ct).ConfigureAwait(false);
await service.WaitAsync(ct).ConfigureAwait(false);
}
}
@@ -132,6 +145,189 @@ public static class DemoExport
await FrameAsync(database, world, general, marta, clock, ct).ConfigureAwait(false);
await ConversionsAsync(root, database, world, [.. rest.Skip(FormatsFrom + 1).Take(2)], clock, ct).ConfigureAwait(false);
// Tappa E5: the automatic copies of «Studio Lumen», and «Riconosci le copie già presenti» there.
if (own is not null && studio is not null)
{
await AutomaticAsync(database, own, NewService, clock, ct).ConfigureAwait(false);
await RecognizeAsync(database, world, own, studio, NewService, clock, ct).ConfigureAwait(false);
}
}
/// <summary>How many files of «Studio Lumen» are «new» for its automatic copies: the newest ones not copied yet.</summary>
private const int AutomaticFiles = 24;
/// <summary>
/// «Studio Lumen» becomes «Automatica» with «Solo i nuovi» at the instant its newest files not copied yet start
/// (about <see cref="AutomaticFiles"/> of them). An automatic job of the real engine, at a past instant, copies the
/// older part (only photos: the demo's videos are one shared file that is not the one recorded, and would fail); a
/// job left «interrotto» by the last stop holds the rest, so what the automatic copies would do next is exactly that
/// job (the worker never runs in the demo).
/// </summary>
private static async Task AutomaticAsync(FebeDatabase database, ExportDestination own, Func<IClock, ExportService> newService, IClock clock, CancellationToken ct)
{
var exports = database.Exports;
var now = clock.Now;
// The files of the folder not copied yet, newest first.
var all = await AutomaticFilesAsync(database, new ExportSelection.Automatic([new(own.Id, null)], [], Round: true), ct).ConfigureAwait(false);
if (all.Count == 0)
{
return;
}
// The «new» files: the newest ones, until there are enough of them and at least two entries made only of photos.
var count = 0;
var photoEntries = 0;
DateTimeOffset since = default;
foreach (var entry in all.GroupBy(f => f.Candidate.EntryId).OrderByDescending(g => g.Max(f => f.SavedAt)))
{
count += entry.Count();
photoEntries += entry.All(f => f.Candidate.MediaKind == MediaKind.Photo) ? 1 : 0;
since = entry.Min(f => f.SavedAt);
if (count >= AutomaticFiles && photoEntries >= 2)
{
break;
}
}
await exports.UpdateDestinationAsync(own with { Automatic = true, AutomaticSince = since }, ct).ConfigureAwait(false);
own = (await exports.GetDestinationAsync(own.Id, ct).ConfigureAwait(false))!;
var scope = new ExportSelection.AutomaticScope(own.Id, own.AutomaticSince);
var fresh = await AutomaticFilesAsync(database, new ExportSelection.Automatic([scope], [], Round: true), ct).ConfigureAwait(false);
// The older half of the entries made only of photos went with an automatic job; the others are held back from it.
var byEntry = fresh.GroupBy(f => f.Candidate.EntryId).ToList();
var copied = byEntry.Where(g => g.All(f => f.Candidate.MediaKind == MediaKind.Photo))
.OrderBy(g => g.Max(f => f.SavedAt))
.Take(Math.Max(1, byEntry.Count(g => g.All(f => f.Candidate.MediaKind == MediaKind.Photo)) / 2))
.ToList();
var copiedIds = copied.Select(g => g.Key).ToHashSet();
if (copied.Count > 0)
{
var newest = copied.Max(g => g.Max(f => f.SavedAt));
var at = newest + TimeSpan.FromMinutes(5) < now - TimeSpan.FromMinutes(30) ? newest + TimeSpan.FromMinutes(5) : now - TimeSpan.FromMinutes(30);
if (at < newest)
{
at = newest + TimeSpan.FromSeconds(1) < now ? newest + TimeSpan.FromSeconds(1) : now - TimeSpan.FromMinutes(2);
}
await using var past = newService(new ShiftedClock(clock, at - now));
var held = byEntry.Select(g => g.Key).Where(id => !copiedIds.Contains(id)).ToList();
var start = await past.TryStartAutomaticAsync(new ExportSelection.Automatic([scope], held, Round: true), ct).ConfigureAwait(false);
if (start.Outcome == AutoExportStartOutcome.Started)
{
await past.WaitAsync(ct).ConfigureAwait(false);
}
}
// What is left is the job «interrotto»: one item per file to write (the first file of each picture, as planned).
var left = await AutomaticFilesAsync(database, new ExportSelection.Automatic([scope], [], Round: true), ct).ConfigureAwait(false);
var items = left.Select(f => f.Candidate).Where(c => c.Sha256 is not null)
.GroupBy(c => c.Sha256!, StringComparer.Ordinal)
.Select(g => g.OrderBy(c => c.MediaId).First())
.OrderBy(c => c.MediaId)
.ToList();
if (items.Count == 0)
{
return;
}
var lastRun = (await exports.ListRunsAsync(ct).ConfigureAwait(false)).Where(r => r.DestinationId == own.Id).Select(r => r.StartedAt).DefaultIfEmpty(now - TimeSpan.FromHours(2)).Max();
var started = left.Max(f => f.SavedAt) + TimeSpan.FromMinutes(2);
started = started < lastRun + TimeSpan.FromMinutes(10) ? lastRun + TimeSpan.FromMinutes(10) : started;
started = started > now - TimeSpan.FromMinutes(1) ? now - TimeSpan.FromMinutes(1) : started;
var run = await exports.CreateRunAsync(
new ExportRun { DestinationId = own.Id, Origin = ExportRunOrigin.Automatic, State = ExportRunState.Interrupted, StartedAt = started, CompletedAt = null },
ct).ConfigureAwait(false);
await exports.AddItemsAsync(
[.. items.Select(c => new ExportItem { RunId = run.Id, MediaId = c.MediaId, AccountId = c.AccountId, SourceSha256 = c.Sha256 })],
ct).ConfigureAwait(false);
}
/// <summary>The files an automatic selection gives, with the instant each was saved in the library.</summary>
private static async Task<List<(ExportCandidate Candidate, DateTimeOffset SavedAt)>> AutomaticFilesAsync(FebeDatabase database, ExportSelection.Automatic selection, CancellationToken ct)
{
var files = new List<(ExportCandidate, DateTimeOffset)>();
long after = 0;
while (true)
{
var page = await database.Exports.ListCandidatesAsync(selection, after, 1000, ct).ConfigureAwait(false);
foreach (var candidate in page)
{
if (await database.Media.GetAsync(candidate.MediaId, ct).ConfigureAwait(false) is { DownloadedAt: { } saved })
{
files.Add((candidate, saved));
}
}
if (page.Count < 1000)
{
return files;
}
after = page[^1].MediaId;
}
}
/// <summary>
/// «Riconosci le copie già presenti» in «Studio Lumen», three hours ago, by the real engine: a byte copy of an older
/// photo of @studio.lumen.demo at the path its copy would take is recognised («già presente, riconosciuto»), the path
/// of another one holds a different picture («diverso»), and every other file not copied yet is «non trovato». It
/// writes nothing. In the own folder, not in «Disco USB»: there it would look for some 28.000 files at every start of
/// the demo. The two photos are not «new» for the automatic copies, which keep their interrupted job as it is.
/// </summary>
private static async Task RecognizeAsync(
FebeDatabase database,
DemoWorld world,
ExportDestination own,
Account studio,
Func<IClock, ExportService> newService,
IClock clock,
CancellationToken ct)
{
own = (await database.Exports.GetDestinationAsync(own.Id, ct).ConfigureAwait(false))!;
var fresh = (await AutomaticFilesAsync(database, new ExportSelection.Automatic([new(own.Id, own.AutomaticSince)], [], Round: true), ct).ConfigureAwait(false))
.Select(f => f.Candidate.Sha256).ToHashSet(StringComparer.Ordinal);
var older = (await AutomaticFilesAsync(database, new ExportSelection.Automatic([new(own.Id, null)], [], Round: true), ct).ConfigureAwait(false))
.Where(f => f.Candidate.MediaKind == MediaKind.Photo && !fresh.Contains(f.Candidate.Sha256))
.OrderBy(f => f.SavedAt);
// Two posts (the path of a post needs no highlight) of two pictures, whose paths are free.
var placed = new List<(Media Media, string Path)>();
foreach (var (candidate, _) in older)
{
if (placed.Count == 2)
{
break;
}
if (candidate.Sha256 is { } sha && placed.All(p => p.Media.Sha256 != sha) && world.Pictures.TryGetValue(sha, out var source) && File.Exists(source)
&& await database.Media.GetAsync(candidate.MediaId, ct).ConfigureAwait(false) is { } photo
&& await database.Entries.GetAsync(photo.EntryId, ct).ConfigureAwait(false) is { Kind: EntryKind.Post } entry)
{
var relative = ExportPaths.RelativePathFor(own, ExportPaths.Segments(own, LibraryNaming.Default, studio, entry, photo, null, false, world.Zone));
var target = Path.Combine(own.RootPath, LibraryLayout.ToPlatform(relative));
if (!File.Exists(target))
{
placed.Add((photo, target));
}
}
}
if (placed.Count == 2)
{
// The first: the very bytes of the library. The second: another picture of the demo, with the same name.
Directory.CreateDirectory(Path.GetDirectoryName(placed[0].Path)!);
File.Copy(world.Pictures[placed[0].Media.Sha256!], placed[0].Path, overwrite: false);
var other = world.Pictures.First(p => p.Key != placed[1].Media.Sha256 && p.Key != placed[0].Media.Sha256 && File.Exists(p.Value)).Value;
Directory.CreateDirectory(Path.GetDirectoryName(placed[1].Path)!);
File.Copy(other, placed[1].Path, overwrite: false);
}
await using var past = newService(new ShiftedClock(clock, -TimeSpan.FromHours(3)));
await past.RecognizeAsync(own.Id, ct).ConfigureAwait(false);
await past.WaitAsync(ct).ConfigureAwait(false);
}
/// <summary>The instant the demo's frame copy was asked at; the demo video shows its 10th picture then (1.125 s).</summary>
@@ -445,6 +641,16 @@ public sealed class DemoExportMounts(string root) : IExportMounts
public IReadOnlyList<ExportMount> All() => [_mount];
}
/// <summary>The demo's clock moved by a fixed time: the jobs of the past the demo seeds (tappa E5) run on it.</summary>
internal sealed class ShiftedClock(IClock inner, TimeSpan shift) : IClock
{
public DateTimeOffset Now => inner.Now + shift;
public TimeZoneInfo LocalZone => inner.LocalZone;
public Task Delay(TimeSpan time, CancellationToken ct) => inner.Delay(time, ct);
}
/// <summary>The demo's disks: 1,8 TB free, no file size limit.</summary>
public sealed class DemoExportDisk : IExportDisk
{
+138
View File
@@ -4,11 +4,16 @@ using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using Febe.Core.Abstractions;
using Febe.Core.Domain;
using Febe.Core.Export;
using Febe.Core.Library;
using Febe.Core.Storage;
using Febe.Tests.Support;
using Febe.Tests.Web.Support;
using Febe.Web.Demo;
using Febe.Web.Export;
using Microsoft.Extensions.DependencyInjection;
namespace Febe.Tests.Web;
@@ -287,4 +292,137 @@ public sealed class DemoExportTests
Assert.AreEqual(0, jpg.Int("converted"), jpg.ToString());
Assert.IsFalse(jpg.Bool("lossy"), "a JPG already JPG is copied as it is, never encoded again");
}
/// <summary>
/// Tappa E5: «Studio Lumen» is «Automatica» with «Solo i nuovi» since a past instant; an automatic job of the engine
/// copied part of the new files and a job left «interrotto» holds exactly the rest (what the automatic copies would do
/// next); a «Riconosci» there recognised one copy, found one different file and wrote nothing. The demo
/// runs no worker: the overview has no automatic status and counts only Alberto's jobs to resume.
/// </summary>
[TestMethod]
[Timeout(300_000, CooperativeCancellation = true)]
public async Task TheDemoSeedsTheAutomaticCopiesAndARecognition()
{
var ct = TestContext.CancellationToken;
using var temp = new TempFolder("demo-export-automatica");
await using var demo = await DemoHost.StartAsync(new DemoOptions(0, TestZones.Rome, temp.Path), ct);
using var client = new HttpClient { BaseAddress = demo.Address, Timeout = TimeSpan.FromSeconds(60) };
async Task<JsonElement> GetAsync(string path)
{
using var response = await client.GetAsync(path, ct);
var text = await response.Content.ReadAsStringAsync(ct);
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, $"{path}: {text}");
return JsonDocument.Parse(text).RootElement.Clone();
}
var now = demo.App.Services.GetRequiredService<IClock>().Now;
var exports = demo.Storage.Exports;
var destinations = await exports.ListDestinationsAsync(includeRetired: false, ct);
var own = destinations.Single(d => d.Scope == ExportScope.Account);
var general = destinations.Single(d => d.Scope == ExportScope.General);
Assert.AreEqual(DemoExport.OwnFolder, own.Label);
Assert.IsTrue(own.Automatic, "«Studio Lumen» is «Automatica»");
Assert.IsNotNull(own.AutomaticSince, "with «Solo i nuovi»");
Assert.IsLessThan(now, own.AutomaticSince.Value, "since a past instant");
Assert.IsFalse(general.Automatic, "«Disco USB» is not");
// One automatic job finished (by the engine: real copies of files saved since then), one left «interrotto».
var runs = await exports.ListRunsAsync(ct);
var automatic = runs.Where(r => r.Origin == ExportRunOrigin.Automatic).ToList();
Assert.IsTrue(automatic.All(r => r.DestinationId == own.Id && r.Kind == ExportRunKind.Copy), "only the automatic folder has automatic jobs");
var finished = automatic.Single(r => r.State == ExportRunState.Completed);
var stopped = automatic.Single(r => r.State != ExportRunState.Completed);
Assert.AreEqual(ExportRunState.Interrupted, stopped.State);
Assert.IsNull(stopped.LastError, "stopped by the last stop: it resumes at any pass");
Assert.IsGreaterThan(finished.StartedAt, stopped.StartedAt, "the interrupted job is the newer one");
Assert.IsLessThan(now, finished.StartedAt, "a job of the past");
var done = await exports.GetRunSummaryAsync(finished.Id, ct);
Assert.IsGreaterThan(0, done.ByState.GetValueOrDefault(ExportItemState.Copied), "the automatic job copied");
Assert.AreEqual(done.Total, done.ByState.GetValueOrDefault(ExportItemState.Copied), "only files to write, all written");
foreach (var item in await exports.ListItemsAsync(new ExportItemQuery { RunId = finished.Id, Limit = 10_000 }, ct))
{
var media = await demo.Storage.Media.GetAsync(item.MediaId!.Value, ct);
Assert.IsGreaterThanOrEqualTo(own.AutomaticSince.Value, media!.DownloadedAt!.Value, "a file saved since «Automatica» went on");
}
var pending = await exports.ListItemsAsync(new ExportItemQuery { RunId = stopped.Id, Limit = 10_000 }, ct);
Assert.IsNotEmpty(pending);
Assert.IsTrue(pending.All(i => i.State == ExportItemState.Pending), "nothing of it done yet");
// What the automatic copies would do next is exactly that job: the files to copy are its files, in a round too.
foreach (var round in new[] { false, true })
{
var selection = new ExportSelection.Automatic([new(own.Id, own.AutomaticSince)], [], round);
var candidates = await exports.ListCandidatesAsync(selection, 0, 10_000, ct);
CollectionAssert.AreEquivalent(
pending.Select(i => i.SourceSha256).ToArray(),
candidates.Select(c => c.Sha256).Distinct().ToArray(),
$"round {round}: the new files not copied yet are those of the interrupted job");
}
// «Riconosci le copie già presenti» in «Studio Lumen»: one recognised, one different, the others not there.
var recognize = runs.Single(r => r.Kind == ExportRunKind.Recognize);
Assert.AreEqual((own.Id, ExportRunOrigin.Manual, ExportRunState.Completed), (recognize.DestinationId, recognize.Origin, recognize.State));
var report = await GetAsync($"/api/export/runs/{recognize.Id}/report");
Assert.AreEqual(1, report.GetProperty("byState").Int("adopted"), report.ToString());
Assert.AreEqual(1, report.Int("different"), report.ToString());
Assert.IsGreaterThan(0, report.Int("notFound"), report.ToString());
Assert.AreEqual(0, report.GetProperty("byState").Int("copied"), "«Riconosci» writes nothing");
var adopted = (await exports.ListItemsAsync(new ExportItemQuery { RunId = recognize.Id, State = ExportItemState.Adopted }, ct)).Single();
var row = await exports.GetCopyAsync(adopted.CopyId!.Value, ct);
Assert.AreEqual((ExportCopyState.Copied, ExportCopyOrigin.Adopted), (row!.State, row.Origin));
var events = await demo.Storage.Events.ListAsync(new() { Limit = 500 }, ct);
Assert.AreEqual(1, events.Count(e => e.Code == ExportText.RecognizeEventCode), "its own event");
Assert.IsTrue(events.Any(e => e.Code == "esportazione-completata" && e.Message.StartsWith("Copia automatica in Studio Lumen finita", StringComparison.Ordinal)), "the automatic job's event");
// The interface: the folder says since when, the lists know the automatic jobs, the demo has no automatic status.
var overview = await GetAsync("/api/export");
Assert.AreEqual(JsonValueKind.Null, overview.GetProperty("automatic").ValueKind, "no worker in the demo");
Assert.AreEqual(1, overview.Int("unfinishedRuns"), "only Alberto's job to resume counts");
var ownDto = overview.Items("own").Single();
Assert.IsTrue(ownDto.Bool("automatic"));
Assert.AreEqual(JsonValueKind.Object, ownDto.GetProperty("automaticSince").ValueKind);
Assert.IsFalse(overview.GetProperty("general").Bool("automatic"));
var unfinished = (await GetAsync("/api/export/runs?unfinished=true")).EnumerateArray().ToList();
Assert.HasCount(2, unfinished);
Assert.AreEqual("automatic", unfinished.Single(r => r.Long("id") == stopped.Id).Str("origin"));
var recent = (await GetAsync("/api/export/runs?limit=20")).EnumerateArray().ToList();
Assert.AreEqual("recognize", recent.Single(r => r.Long("id") == recognize.Id).Str("kind"));
Assert.AreEqual("automatic", recent.Single(r => r.Long("id") == finished.Id).Str("origin"));
}
/// <summary>
/// The demo never starts the automatic worker, and has nothing for it but its interrupted job: a worker of the test on
/// the demo's database resumes that job at its first pass, then finds nothing to copy.
/// </summary>
[TestMethod]
[Timeout(300_000, CooperativeCancellation = true)]
public async Task TheDemoSeedHasNothingToCopyAutomaticallyButItsInterruptedJob()
{
var ct = TestContext.CancellationToken;
using var temp = new TempFolder("demo-export-niente-da-copiare");
await using var demo = await DemoHost.StartAsync(new DemoOptions(0, TestZones.Rome, temp.Path), ct);
var services = demo.App.Services;
var demoWorker = services.GetRequiredService<AutoExportWorker>();
Assert.IsFalse(demoWorker.Running, "the demo does not start the worker");
var hub = services.GetRequiredService<ExportHub>();
var worker = new AutoExportWorker(new AutoExportEnvironment
{
Storage = demo.Storage,
Clock = services.GetRequiredService<IClock>(),
Service = hub.GetAsync,
Signal = new AutoExportSignal(),
Gate = services.GetRequiredService<LongWorkGate>(),
});
var stopped = (await demo.Storage.Exports.ListUnfinishedRunsAsync(ct)).Single(r => r.Origin == ExportRunOrigin.Automatic);
Assert.AreEqual(AutoExportPass.Started, await worker.RunOnceAsync(round: false, ct), "the interrupted job is resumed");
await (await hub.GetAsync(ct)).WaitAsync(ct);
Assert.AreEqual(ExportRunState.Completed, (await demo.Storage.Exports.GetRunAsync(stopped.Id, ct))!.State);
Assert.IsEmpty((await demo.Storage.Exports.ListUnfinishedRunsAsync(ct)).Where(r => r.Origin == ExportRunOrigin.Automatic));
Assert.AreEqual(AutoExportPass.NothingToDo, await worker.RunOnceAsync(round: false, ct), "then nothing is new");
Assert.IsFalse(demoWorker.Running);
}
}
@@ -0,0 +1,315 @@
using Febe.Core.Domain;
using Febe.Tests.Support;
using Febe.Tests.Web.Support;
using Febe.Web.Demo;
namespace Febe.Tests.Web;
/// <summary>
/// Tappa E5 in a real browser, on the demo (spec §4.10 «Esportazione automatica», §10.3): «Automatica» in the dialog of a
/// folder (turned on it asks «Solo i nuovi» or «Copia anche gli N», with N what «Copia in…» would write; turned off and
/// on it asks again; with another folder it asks again; turned off while an automatic job is unfinished it says the copy
/// stops), the label «Automatica dal …» of a folder, «Riconosci le copie già presenti» from the folder with its job in the
/// Dashboard, the automatic jobs in «Ultimi lavori» and «Da riprendere», the pause of a folder with the files that wait,
/// and what «Usa la cartella generale» says while the general folder is automatic. The demo runs no automatic worker:
/// there is no status line of the automatic copies (decision of 4 December 2026). Chromium only (CI).
/// </summary>
public sealed partial class ExportInterfaceTests
{
/// <summary>The dialog of a folder.</summary>
private const string FolderDialog = "document.querySelector('.dialogo.destinazione')";
/// <summary>The switch «Automatica» of the dialog.</summary>
private const string AutoSwitch = FolderDialog + ".querySelector('.parte-automatica input[role=switch]')";
/// <summary>What the dialog says under the switch.</summary>
private const string AutoBox = FolderDialog + ".querySelector('.parte-automatica .automatica-scelta')";
/// <summary>The two answers of «Che cosa fare dei file già in libreria?».</summary>
private const string AutoChoices = AutoBox + ".querySelectorAll('input[name=automatica-esistenti]')";
/// <summary>N of «Copia anche i N già in libreria» (the Italian thousands separator taken away).</summary>
private const string AlsoCount = "Number(" + AutoBox + ".querySelector('input[value=all]').closest('label').textContent.match(/Copia anche i ([\\d.]+) già in libreria/)[1].replace(/\\./g, ''))";
/// <summary>The line of the general folder under its path (types, names, «Automatica dal …»).</summary>
private const string GeneralDescription = "document.querySelector('.cartella-impostazioni .descrizione-copie')?.textContent || ''";
/// <summary>The general folder as the API gives it.</summary>
private static readonly string GeneralFolder = Get("/api/export") + ".then((j) => j.general)";
/// <summary>
/// The files «Copia in…» would write in the general folder, account by account (the planner, not the count of the
/// dialog): what «Copia anche gli N» must count when the folder keeps its copies.
/// </summary>
private static readonly string PlannedInGeneral = "(async () => { const g = (" + GeneralFolder + ").then((x) => x.id); const id = await g; "
+ "const accounts = (await " + Get("/api/accounts") + ").accounts; let n = 0; "
+ "for (const a of accounts) { const p = await fetch('/api/export/plan', { method: 'POST', headers: { 'Content-Type': 'application/json', Accept: 'application/json' }, body: JSON.stringify({ accountId: a.id, copyAgain: false }) }).then((r) => r.json()); "
+ "for (const d of p.destinations || []) if (d.id === id) n += d.files; } return n; })()";
[TestMethod]
public async Task TheFolderDialogAsksOnlyNewWhenAutomaticIsTurnedOnAndAgainAfterOff()
{
await using var ui = await UiBrowser.StartAsync(1440, 900);
using var temp = new TempFolder("automatica-dialogo-ui");
await using var demo = await DemoHost.StartAsync(new DemoOptions(0, TestZones.Rome, temp.Path));
await RecordNoticesAsync(ui);
await ui.OpenAsync(new Uri(demo.Address, "/impostazioni/esportazione"));
await ui.WaitAsync($"({General}) !== '' && ({GeneralDescription}) !== ''", "la cartella generale");
Assert.IsFalse((await ui.EvalAsync(GeneralDescription)).GetString()!.Contains("Automatica", StringComparison.Ordinal), "«Disco USB» is not automatic in the demo");
var planned = (await ui.EvalAsync(PlannedInGeneral)).GetInt32();
Assert.IsGreaterThan(0, planned, "the demo has files not copied in «Disco USB»");
// On: the question, «Solo i nuovi» first; «Copia anche gli N» counts what «Copia in…» would write, with the space.
await OpenGeneralDialogAsync(ui);
Assert.IsFalse((await ui.EvalAsync($"{AutoSwitch}.checked")).GetBoolean());
Assert.AreEqual(0, (await ui.EvalAsync($"{AutoChoices}.length")).GetInt32(), "off: no question");
await ui.EvalAsync($"{AutoSwitch}.click()");
await ui.WaitAsync($"{AutoChoices}.length === 2", "la domanda «Solo i nuovi» " + ui.Report());
Assert.AreEqual("Che cosa fare dei file già in libreria?", (await ui.EvalAsync($"{AutoBox}.querySelector('.domanda-automatica').textContent")).GetString());
Assert.AreEqual("new", (await ui.EvalAsync($"[...{AutoChoices}].find((i) => i.checked).value")).GetString(), "«Solo i nuovi» is the proposal");
StringAssert.StartsWith((await ui.EvalAsync($"{AutoBox}.querySelector('input[value=new]').closest('label').textContent")).GetString(), "Solo i nuovi");
Assert.AreEqual(planned, (await ui.EvalAsync(AlsoCount)).GetInt32(), "N is what «Copia in…» would write in the folder");
StringAssert.Contains((await ui.EvalAsync($"{AutoBox}.querySelector('input[value=all]').closest('label').textContent")).GetString(), "Circa ");
// «Solo i nuovi», saved: the folder is automatic from now on, and says since when.
await SaveFolderDialogAsync(ui);
await ui.WaitAsync(Shown("Automatica accesa: da adesso si copiano da soli i file nuovi."), "l'avviso dell'accensione");
await ui.WaitAsync($"{GeneralFolder}.then((g) => g.automatic === true && g.automaticSince !== null)", "automatica sul server, con l'istante");
await ui.WaitAsync($"({GeneralDescription}).includes('· Automatica dal ')", "«Automatica dal …» sotto la cartella");
// Opened again: on, the same folder: it says since when and asks nothing.
await OpenGeneralDialogAsync(ui);
Assert.IsTrue((await ui.EvalAsync($"{AutoSwitch}.checked")).GetBoolean());
await ui.WaitAsync($"{AutoBox}.textContent.includes('Automatica dal ') && {AutoBox}.textContent.includes('copia i file salvati in libreria da allora')", "«Automatica dal …» nel dialogo");
Assert.AreEqual(0, (await ui.EvalAsync($"{AutoChoices}.length")).GetInt32(), "no question while it stays on");
// Off: no automatic job of this folder is unfinished, so no note; saved, it forgets the answer.
await ui.EvalAsync($"{AutoSwitch}.click()");
await ui.WaitAsync($"{AutoBox}.textContent === ''", "spenta: niente da dire");
Assert.IsTrue((await ui.EvalAsync($"{FolderDialog}.querySelector('.spegnere') === null")).GetBoolean());
await SaveFolderDialogAsync(ui);
await ui.WaitAsync($"{GeneralFolder}.then((g) => g.automatic === false && g.automaticSince === null)", "spenta sul server");
await ui.WaitAsync($"!({GeneralDescription}).includes('Automatica')", "nessuna «Automatica» sotto la cartella");
// On again: the question comes back; «Copia anche gli N» stores no instant.
await OpenGeneralDialogAsync(ui);
await ui.EvalAsync($"{AutoSwitch}.click()");
await ui.WaitAsync($"{AutoChoices}.length === 2", "la domanda di nuovo");
Assert.AreEqual(planned, (await ui.EvalAsync(AlsoCount)).GetInt32());
await ui.EvalAsync($"{AutoBox}.querySelector('input[value=all]').click()");
await SaveFolderDialogAsync(ui);
await ui.WaitAsync("window.__notices.some((n) => /^Automatica accesa: [\\d.]+ file da copiare; la copia parte fra poco, mai durante una sessione del motore\\.$/.test(n.text))", "l'avviso con il numero dei file");
Assert.AreEqual(planned, (await ui.EvalAsync("Number(window.__notices.findLast((n) => /^Automatica accesa: [\\d.]+ file/.test(n.text)).text.match(/([\\d.]+) file/)[1].replace(/\\./g, ''))")).GetInt32());
await ui.WaitAsync($"{GeneralFolder}.then((g) => g.automatic === true && g.automaticSince === null)", "tutti i file dovuti, nessun istante");
await ui.WaitAsync($"({GeneralDescription}).endsWith('· Automatica')", "«Automatica» sotto la cartella");
await OpenGeneralDialogAsync(ui);
await ui.WaitAsync($"{AutoBox}.textContent.includes('Automatica: copia tutti i file dovuti.')", "«copia tutti i file dovuti»");
await CancelFolderDialogAsync(ui);
Assert.IsTrue((await ui.EvalAsync(NoErrorNotice)).GetBoolean(), "nessun avviso di errore: " + (await ui.EvalAsync("JSON.stringify(window.__notices)")).GetString());
}
[TestMethod]
public async Task TheAutomaticFolderOfAnAccountSaysSinceWhenWhatStopsAndWhatGoesToTheGeneralFolder()
{
await using var ui = await UiBrowser.StartAsync(1440, 900);
using var temp = new TempFolder("automatica-account-ui");
await using var demo = await DemoHost.StartAsync(new DemoOptions(0, TestZones.Rome, temp.Path));
await RecordNoticesAsync(ui);
var studio = (await demo.Storage.Accounts.ListAsync()).Single(a => a.Username == DemoExport.OwnFolderAccount);
var own = (await demo.Storage.Exports.ListDestinationsAsync(includeRetired: false)).Single(d => d.Scope == ExportScope.Account);
Assert.IsTrue(own.Automatic, "the demo's own folder is automatic");
// The card (Docker look: the dialog browses the folders of /esporta): the label «Automatica dal …» next to the kind
// of folder, and what can be done with the folder.
await ui.OpenAsync(new Uri(demo.Address, $"/account/{studio.Id}/impostazioni?veste=docker"));
const string Block = "document.querySelector('.copie-esterne')";
await ui.WaitAsync($"{Block}?.querySelector('.riga-etichetta .et.accento') != null", "l'etichetta «Automatica» " + ui.Report());
StringAssert.StartsWith((await ui.EvalAsync($"{Block}.querySelector('.riga-etichetta .et.accento').textContent")).GetString(), "Automatica dal ");
StringAssert.Contains((await ui.EvalAsync($"{Block}.querySelector('.riga-etichetta').textContent")).GetString(), "Nella sua cartella");
var buttons = await ui.EvalAsync<string[]>($"[...{Block}.querySelectorAll('.stato-copie button')].map((b) => b.textContent.trim())");
CollectionAssert.AreEqual(new[] { "Controlla le copie", "Riconosci le copie già presenti" }, buttons);
// The dialog: on since a day; turned off, the automatic job left unfinished stops, and it says so before saving.
Assert.IsTrue((await ui.EvalAsync(ClickText(".copie-esterne .cartella", "button", "Modifica"))).GetBoolean());
await ui.WaitAsync($"{AutoSwitch} != null && {AutoBox}.textContent.includes('Automatica dal ')", "il dialogo con «Automatica dal …»");
Assert.IsTrue((await ui.EvalAsync($"{AutoSwitch}.checked")).GetBoolean());
await ui.EvalAsync($"{AutoSwitch}.click()");
await ui.WaitAsync($"{FolderDialog}.querySelector('.spegnere') != null", "la nota «Spegnendo…» " + ui.Report());
Assert.AreEqual(
"Spegnendo, la copia automatica di questa cartella si ferma e i file che restavano non si copiano da soli; quelli già copiati restano.",
(await ui.EvalAsync($"{FolderDialog}.querySelector('.spegnere').textContent.trim()")).GetString());
// On again with the same folder: nothing to ask. Another folder is a new destination: the question comes back,
// and counts the files the new folder would have (none copied there yet).
await ui.EvalAsync($"{AutoSwitch}.click()");
await ui.WaitAsync($"{AutoBox}.textContent.includes('Automatica dal ') && {FolderDialog}.querySelector('.spegnere') === null", "di nuovo accesa");
Assert.AreEqual(0, (await ui.EvalAsync($"{AutoChoices}.length")).GetInt32());
await ui.WaitAsync($"{FolderDialog}.querySelector('.sfoglia-voce') != null", "le cartelle");
await ui.EvalAsync($"[...{FolderDialog}.querySelectorAll('.sfoglia-voce')].find((b) => b.textContent.trim() === 'Chiavetta').click()");
await ui.WaitAsync($"{AutoChoices}.length === 2", "la domanda per la cartella nuova " + ui.Report());
var elsewhere = await PreviewInDockerAsync(ui, own.Id, studio.Id, string.Empty);
Assert.AreEqual(elsewhere, (await ui.EvalAsync(AlsoCount)).GetInt32(), "the count of a folder with no copies");
var stillThere = await PreviewInDockerAsync(ui, own.Id, studio.Id, DemoExport.OwnFolder);
Assert.IsGreaterThan(stillThere, elsewhere, "the copies made in «Studio Lumen» do not count in another folder");
await CancelFolderDialogAsync(ui);
var kept = await demo.Storage.Exports.GetDestinationAsync(own.Id);
Assert.AreEqual((true, own.AutomaticSince, own.RootPath), (kept!.Automatic, kept.AutomaticSince, kept.RootPath), "«Annulla» changes nothing");
// The general folder automatic: «Usa la cartella generale» says how many files of the account will go there.
var put = await ui.EvalAsync(
"(async () => { const g = await " + GeneralFolder + "; const r = await fetch('/api/export/destinations/' + g.id, { method: 'PUT', headers: { 'Content-Type': 'application/json', Accept: 'application/json' }, "
+ "body: JSON.stringify({ scope: 'general', accountId: null, path: g.rootPath, label: null, types: g.types, namingScheme: g.namingScheme, highlightNamingScheme: g.highlightNamingScheme, "
+ "profileNamingScheme: g.profileNamingScheme, automatic: true, onlyNew: false, photoFormat: g.photoFormat || 'general', videoFormat: g.videoFormat || 'general' }) }); return r.status; })()");
Assert.AreEqual(200, put.GetInt32(), "the general folder turned automatic");
var goes = (await ui.EvalAsync(Post("/api/export/automatic-preview", $"{{ \"mode\": \"removeOwn\", \"accountId\": {studio.Id} }}"))).GetProperty("files").GetInt32();
Assert.IsGreaterThan(0, goes);
await ui.OpenAsync(new Uri(demo.Address, $"/account/{studio.Id}/impostazioni?veste=docker"));
await ui.WaitAsync($"{Block}?.querySelector('.riga-etichetta .et.accento') != null", "la scheda di nuovo");
Assert.IsTrue((await ui.EvalAsync(ClickText(".copie-esterne .cartella", "button", "Usa la cartella generale"))).GetBoolean());
await ui.WaitAsync("document.querySelector('.dialogo .togli-automatica') != null", "la conferma con i file che andranno da soli " + ui.Report());
var said = (await ui.EvalAsync("document.querySelector('.dialogo .togli-automatica').textContent.trim()")).GetString()!;
StringAssert.EndsWith(said, $"file di @{DemoExport.OwnFolderAccount} andranno da soli nella cartella generale.", said);
Assert.AreEqual(goes, int.Parse(said.Split(' ')[0].Replace(".", string.Empty, StringComparison.Ordinal), System.Globalization.CultureInfo.InvariantCulture), said);
await ui.EvalAsync("[...document.querySelectorAll('.dialogo footer button')].find((b) => b.textContent.trim() === 'Annulla').click()");
await ui.WaitAsync("document.querySelector('.dialogo .togli-automatica') === null", "la conferma si chiude");
Assert.IsFalse((await demo.Storage.Exports.GetDestinationAsync(own.Id))!.IsRetired, "«Annulla» keeps the own folder");
}
[TestMethod]
public async Task TheDashboardMarksAutomaticJobsAndRecognizeStartsFromTheFolder()
{
await using var ui = await UiBrowser.StartAsync(1440, 900);
using var temp = new TempFolder("automatica-dashboard-ui");
await using var demo = await DemoHost.StartAsync(new DemoOptions(0, TestZones.Rome, temp.Path));
await RecordNoticesAsync(ui);
var stopped = (await demo.Storage.Exports.ListUnfinishedRunsAsync()).Single(r => r.Origin == ExportRunOrigin.Automatic);
var stoppedTotal = (await demo.Storage.Exports.GetRunSummaryAsync(stopped.Id)).Total;
// The engine tab counts only Alberto's job to resume: the automatic one resumes by itself.
await ui.OpenAsync(new Uri(demo.Address, "/dashboard"));
await ui.WaitAsync("[...document.querySelectorAll('.avviso')].some((a) => a.textContent.includes('da riprendere'))", "l'avviso della copia da riprendere");
StringAssert.Contains((await ui.EvalAsync("[...document.querySelectorAll('.avviso')].find((a) => a.textContent.includes('da riprendere')).textContent")).GetString(), "1 copia da riprendere.");
// «Da riprendere»: both jobs, the automatic one with its label; no status line of the automatic copies (no worker).
await ui.OpenAsync(new Uri(demo.Address, "/dashboard/esportazione"));
await ui.WaitAsync("document.querySelectorAll('.esportazione-dashboard .riga-riprendi').length === 2 && document.querySelector('.esportazione-dashboard .elenco-attivita li') !== null", "«Da riprendere» " + ui.Report());
const string AutomaticRow = "[...document.querySelectorAll('.riga-riprendi')].find((r) => r.querySelector('.et.accento'))";
StringAssert.Contains((await ui.EvalAsync($"({AutomaticRow}).textContent")).GetString(), $"Automatica Copia in Studio Lumen interrotta: 0 di {stoppedTotal} file fatti.");
Assert.IsTrue((await ui.EvalAsync("[...document.querySelectorAll('.riga-riprendi')].some((r) => !r.querySelector('.et') && r.textContent.includes('Copia in Disco USB interrotta'))")).GetBoolean(), "Alberto's job, without a label");
Assert.IsTrue((await ui.EvalAsync("[...document.querySelectorAll('.esportazione-dashboard h2')].some((x) => x.textContent === 'Da riprendere') && [...document.querySelectorAll('button')].some((b) => b.textContent.includes('Riprendi tutte'))")).GetBoolean());
StringAssert.Contains((await ui.EvalAsync("document.querySelector('.copia-in-corso').textContent")).GetString(), "Nessuna copia al lavoro");
Assert.IsTrue((await ui.EvalAsync("document.querySelector('.stato-automatiche') === null && !document.body.textContent.includes('giro di recupero')")).GetBoolean(), "the demo shows no automatic status");
// «Ultimi lavori»: the automatic job with its label, the recognition with its name and its resoconto.
const string Rows = "[...document.querySelectorAll('.esportazione-dashboard .elenco-attivita li')]";
Assert.IsTrue((await ui.EvalAsync($"{Rows}.some((li) => li.querySelector('b').textContent.startsWith('Copia automatica in Studio Lumen') && li.querySelector('b .et.accento')?.textContent === 'Automatica')")).GetBoolean(), "the automatic job in «Ultimi lavori»");
const string Recognized = $"{Rows}.find((li) => li.querySelector('b').textContent === 'Riconoscimento delle copie in Studio Lumen')";
await ui.EvalAsync($"({Recognized}).querySelector('button').click()");
await ui.WaitAsync("document.querySelector('.dialogo.resoconto-copia .riepilogo-copia') !== null", "il resoconto del riconoscimento");
Assert.AreEqual("Resoconto: Riconoscimento delle copie in Studio Lumen", (await ui.EvalAsync("document.querySelector('.dialogo.resoconto-copia h2').textContent")).GetString());
var summary = (await ui.EvalAsync("document.querySelector('.dialogo.resoconto-copia .riepilogo-copia').textContent")).GetString()!;
StringAssert.Contains(summary, "1 già presente, riconosciuto", summary);
StringAssert.Contains(summary, "non trovati", summary);
StringAssert.Contains(summary, "1 diverso", summary);
StringAssert.Contains((await ui.EvalAsync("document.querySelector('.dialogo.resoconto-copia .problemi-copia').textContent")).GetString(), "Nel percorso c'è un altro file", "the different file is a problem to look at");
await ui.EvalAsync("document.querySelector('.dialogo.resoconto-copia header button').click()");
await ui.WaitAsync("document.querySelector('.dialogo.resoconto-copia') === null", "il resoconto si chiude");
// «Riconosci le copie già presenti» from the folder's row of Impostazioni: a job of its own, which writes nothing.
var folder = Path.Combine(demo.Root, "esporta");
var before = Tree(folder);
await ui.OpenAsync(new Uri(demo.Address, "/impostazioni/esportazione"));
await ui.WaitAsync("document.querySelector('.cartelle-copie tbody tr button') !== null", "la riga della cartella di @studio.lumen.demo");
Assert.IsTrue((await ui.EvalAsync(ClickText(".cartelle-copie tbody tr", "button", "Riconosci le copie già presenti"))).GetBoolean());
await ui.WaitAsync(Shown("Riconoscimento avviato"), "l'avviso del riconoscimento " + ui.Report());
StringAssert.Contains((await ui.EvalAsync("window.__notices.findLast((n) => n.text.includes('Riconoscimento avviato')).text")).GetString(), "Nessun file viene toccato.");
await ui.EvalAsync(FollowNoticeLink);
await ui.WaitAsync("location.pathname === '/dashboard/esportazione'", "la Dashboard");
await ui.WaitAsync(
$"{Get("/api/export/runs?limit=1")}.then((r) => r[0].kind === 'recognize' && r[0].id > {stopped.Id} && r[0].state === 'completed')",
"il nuovo riconoscimento finito");
await ui.WaitAsync($"{Rows}[0]?.querySelector('b').textContent === 'Riconoscimento delle copie in Studio Lumen'", "il riconoscimento in cima agli ultimi lavori");
CollectionAssert.AreEqual(before, Tree(folder), "«Riconosci» writes, renames and deletes nothing");
Assert.IsTrue((await ui.EvalAsync(NoErrorNotice)).GetBoolean(), "nessun avviso di errore: " + (await ui.EvalAsync("JSON.stringify(window.__notices)")).GetString());
}
[TestMethod]
public async Task APausedFolderSaysSinceWhenAndHowManyFilesWait()
{
await using var ui = await UiBrowser.StartAsync(1440, 900);
using var temp = new TempFolder("automatica-pausa-ui");
await using var demo = await DemoHost.StartAsync(new DemoOptions(0, TestZones.Rome, temp.Path));
await RecordNoticesAsync(ui);
var general = (await demo.Storage.Exports.GetGeneralDestinationAsync())!;
// The stick goes away; «Riprova» (from the API) finds the folder gone and the folder goes in pause.
var away = general.RootPath + " staccato";
Directory.Move(general.RootPath, away);
await ui.OpenAsync(new Uri(demo.Address, "/impostazioni/esportazione"));
await ui.WaitAsync($"({General}) !== ''", "la cartella generale");
await ui.EvalAsync($"fetch('/api/export/destinations/{general.Id}/resume', {{ method: 'POST', headers: {{ Accept: 'application/json' }} }}).then((r) => r.status)");
await ui.WaitAsync($"{GeneralFolder}.then((g) => g.pausedAt !== null)", "la cartella in pausa sul server");
var waiting = (await ui.EvalAsync($"{GeneralFolder}.then((g) => g.waiting)")).GetInt32();
Assert.IsGreaterThan(0, waiting, "the job left interrupted waits for the folder");
// Impostazioni: since when and why, how many files wait, «Riprova»; no rounds to announce in the demo.
await ui.OpenAsync(new Uri(demo.Address, "/impostazioni/esportazione"));
await ui.WaitAsync("document.querySelector('.cartella-impostazioni .pausa-copie') !== null", "la pausa della cartella " + ui.Report());
var pause = (await ui.EvalAsync("document.querySelector('.cartella-impostazioni .pausa-copie').textContent")).GetString()!;
StringAssert.StartsWith(pause, "In pausa da oggi: ", pause);
StringAssert.Contains(pause, waiting == 1 ? "1 file aspetta questa cartella." : $"{waiting} file aspettano questa cartella.", pause);
Assert.IsTrue((await ui.EvalAsync("[...document.querySelectorAll('.cartella-impostazioni .pausa-copie button')].some((b) => b.textContent.includes('Riprova'))")).GetBoolean(), "«Riprova»");
Assert.IsTrue((await ui.EvalAsync("document.querySelector('.pausa-giro') === null")).GetBoolean(), "no automatic worker in the demo: no rounds to announce");
StringAssert.Contains((await ui.EvalAsync("document.querySelector('.cartella-impostazioni .stato-copie').textContent")).GetString(), "copiati", "the counts stay in pause");
// The engine tab: the folder in pause, since files wait for it.
await ui.OpenAsync(new Uri(demo.Address, "/dashboard"));
await ui.WaitAsync("[...document.querySelectorAll('.avviso')].some((a) => a.textContent.includes('Disco USB è in pausa'))", "l'avviso della cartella in pausa");
// The stick comes back: «Riprova» takes the pause away.
Directory.Move(away, general.RootPath);
await ui.OpenAsync(new Uri(demo.Address, "/impostazioni/esportazione"));
await ui.WaitAsync("document.querySelector('.cartella-impostazioni .pausa-copie button') !== null", "«Riprova»");
Assert.IsTrue((await ui.EvalAsync(ClickText(".cartella-impostazioni .pausa-copie", "button", "Riprova"))).GetBoolean());
await ui.WaitAsync($"{GeneralFolder}.then((g) => g.pausedAt === null)", "la pausa tolta sul server");
await ui.WaitAsync("document.querySelector('.cartella-impostazioni .pausa-copie') === null", "la pausa tolta nella pagina");
}
/// <summary>«Copia anche gli N» of the own folder of an account turned on with a folder of /esporta («» for another one).</summary>
private static async Task<int> PreviewInDockerAsync(UiBrowser ui, long destinationId, long accountId, string path)
{
var body = System.Text.Json.JsonSerializer.Serialize(new { mode = "switchOn", destinationId, scope = "account", accountId, path, types = new[] { "postFoto", "postVideo" } });
var answer = await ui.EvalAsync(
"fetch('/api/export/automatic-preview', { method: 'POST', headers: { 'Content-Type': 'application/json', Accept: 'application/json', 'X-Febe-Veste': 'docker' }, "
+ $"body: {Js(body)} }}).then((r) => r.json())");
return answer.GetProperty("files").GetInt32();
}
private static async Task OpenGeneralDialogAsync(UiBrowser ui)
{
Assert.IsTrue((await ui.EvalAsync(ClickText(".cartella-impostazioni", "button", "Modifica"))).GetBoolean(), "«Modifica…»");
await ui.WaitAsync($"{AutoSwitch} != null && /liberi/.test({FolderDialog}.querySelector('.controllo-cartella').textContent)", "il dialogo con «Automatica» e il controllo della cartella");
}
private static async Task SaveFolderDialogAsync(UiBrowser ui)
{
const string Save = FolderDialog + ".querySelector('footer .btn.primo')";
await ui.WaitAsync($"!{Save}.disabled", "«Salva» attivo");
await ui.EvalAsync($"{Save}.click()");
await ui.WaitAsync($"{FolderDialog} === null", "il dialogo si chiude dopo il salvataggio");
}
private static async Task CancelFolderDialogAsync(UiBrowser ui)
{
await ui.EvalAsync($"[...{FolderDialog}.querySelectorAll('footer button')].find((b) => b.textContent === 'Annulla').click()");
await ui.WaitAsync($"{FolderDialog} === null", "il dialogo si chiude");
}
/// <summary>Every file under a folder: relative path, length and time of the last write.</summary>
private static string[] Tree(string folder) =>
[.. Directory.EnumerateFiles(folder, "*", SearchOption.AllDirectories)
.Select(f => new FileInfo(f))
.Select(f => $"{Path.GetRelativePath(folder, f.FullName)}|{f.Length}|{f.LastWriteTimeUtc.Ticks}")
.Order(StringComparer.Ordinal)];
}
+6 -3
View File
@@ -357,10 +357,13 @@ public sealed partial class ExportInterfaceTests
await ui.EvalAsync("document.querySelector('.dialogo.resoconto-copia header button').click()");
await ui.WaitAsync("document.querySelector('.dialogo.resoconto-copia') === null", "il resoconto si chiude");
// «Riprendi»: the job goes on (the demo copies at once) and leaves «Da riprendere».
Assert.IsTrue((await ui.EvalAsync(ClickText(".riga-riprendi", "button", "Riprendi"))).GetBoolean());
// «Riprendi» of Alberto's job: it goes on (the demo copies at once) and leaves «Da riprendere». Tappa E5: the
// automatic job of «Studio Lumen» left unfinished by the demo stays there (ExportInterfaceTests.Automatic.cs).
const string Manual = "[...document.querySelectorAll('.esportazione-dashboard .riga-riprendi')].find((r) => r.textContent.includes('Copia in Disco USB'))";
Assert.IsTrue((await ui.EvalAsync($"(() => {{ const b = [...({Manual}).querySelectorAll('button')].find((x) => x.textContent.includes('Riprendi')); b.click(); return true; }})()")).GetBoolean());
// The notice lasts 4 s: it is looked for among those shown.
await ui.WaitAsync(Shown("ripresa"), "«Copia ripresa»");
await ui.WaitAsync("document.querySelector('.esportazione-dashboard .riga-riprendi') === null", "niente più da riprendere " + ui.Report());
await ui.WaitAsync($"({Manual}) === undefined", "niente più da riprendere di Alberto " + ui.Report());
Assert.IsTrue((await ui.EvalAsync("[...document.querySelectorAll('.esportazione-dashboard .riga-riprendi')].every((r) => r.querySelector('.et.accento'))")).GetBoolean(), "only the automatic job is left");
}
}
+5
View File
@@ -71,6 +71,11 @@ internal static class Shots
new("/libreria?tema=chiaro", "25-copia-in-formati.png", 1440, 1000, Step: "copia-in-formati.js"),
new("/impostazioni/esportazione?tema=chiaro", "26-conversione-libreria.png", Step: "conversione-libreria.js"),
// Part 6: copie automatiche (tappa E5, spec §4.10 and §10.3, composed from the dialogs of mockup 13). 15–17 and 21
// above show «Automatica dal …», «Riconosci le copie già presenti» and the automatic jobs the demo seeds. The step
// turns the switch on without saving. Before part 5, whose last screenshot starts a job.
new("/impostazioni/esportazione?tema=chiaro", "32-destinazione-automatica.png", 1440, 1000, Step: "destinazione-automatica.js"),
// Part 5: video fermi (tappa E4, spec §4.10 and §10.3, composed from mockups 02, 13, 01 and 06). The last one starts
// «Cerca i video fermi» (an analysis, nothing is copied or written): it comes after every screenshot above.
new("/libreria?tipo=fermi&tema=chiaro", "27-visualizzatore-video-fermo.png", Step: "visualizzatore-video-fermo.js"),
@@ -0,0 +1,18 @@
// «Automatica» in the dialog of the general folder of Impostazioni → Esportazione (spec §4.10, tappa E5; composed from
// the dialogs of mockup 13): the switch turned on asks «Che cosa fare dei file già in libreria?» with «Solo i nuovi»
// first and «Copia anche i N già in libreria». Nothing is saved: closed, the folder stays as it was.
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const until = async (test, tries = 300) => { for (let i = 0; i < tries && !test(); i++) await sleep(100); return test(); };
const edit = () => [...document.querySelectorAll('.cartella-impostazioni .btn')].find((b) => b.textContent.includes('Modifica'));
await until(edit);
edit().click();
const dialog = () => document.querySelector('.dialogo.destinazione');
const part = () => dialog() && dialog().querySelector('.parte-automatica');
await until(() => part() && /liberi/.test(dialog().querySelector('.controllo-cartella')?.textContent || ''));
part().querySelector('input[role=switch]').click();
// The count of the files already in the library takes a few seconds on the demo's 18.000 entries.
await until(() => part().querySelectorAll('input[name=automatica-esistenti]').length === 2);
part().scrollIntoView({ block: 'end' });
await sleep(500);
document.activeElement?.blur();
return part().querySelector('.automatica-scelta')?.textContent;