Nouveautés dans l'app, et « Tout effacer » synchronisé : cet appareil ou partout (2d)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0ea0ea109f
commit
8ebdca0c30
@@ -332,6 +332,18 @@ function check(scheme, cond, msg) {
|
||||
ok(await page.getByText("Premier pas").isVisible(), "succès « Premier pas »");
|
||||
await shot("14-progression", true);
|
||||
|
||||
// ---- nouveautés : une ligne discrète après une mise à jour, puis plus rien -----------
|
||||
await go("#/");
|
||||
ok(await page.locator(".news-line").isVisible(), "accueil : ligne des nouveautés pour qui utilisait déjà l'app");
|
||||
await page.locator(".news-line a").click();
|
||||
await settle();
|
||||
ok(page.url().endsWith("#/nouveautes") && await page.locator("h1").textContent() === "Nouveautés" && await page.locator(".news").count() >= 3, "page des nouveautés, par date");
|
||||
await shot("19a-nouveautes", true);
|
||||
await go("#/");
|
||||
ok(await page.locator(".news-line").count() === 0, "nouveautés vues : plus de ligne");
|
||||
await go("#/profil");
|
||||
ok(await page.getByRole("link", { name: "Nouveautés de l'app" }).isVisible(), "profil : entrée permanente vers les nouveautés");
|
||||
|
||||
// ---- bibliothèque : filtres dans l'adresse, fiche, retour (ADR 0009) -------------
|
||||
await go("#/");
|
||||
await page.getByRole("link", { name: /Bibliothèque/ }).click();
|
||||
@@ -885,6 +897,21 @@ async function syncJourney(browser, base) {
|
||||
ok(await until(() => inPage(b, async () => (await import("./main.js")).store.getState().proposals.length === 1)), "B reçoit la proposition de l'IA");
|
||||
await b.screenshot({ path: `${outDir}/${scheme}-25-b-relie.png`, fullPage: true });
|
||||
|
||||
// ---- « Tout effacer » synchronisé (2d) : deux boutons ; partout, B suit ----------
|
||||
await goto(a, "#/donnees");
|
||||
ok(await a.getByRole("button", { name: "Effacer cet appareil" }).isVisible() && await a.getByRole("button", { name: "Tout effacer partout" }).isVisible(), "synchro active : effacer cet appareil, ou partout");
|
||||
await a.getByRole("button", { name: "Tout effacer partout" }).click();
|
||||
await a.locator("dialog[open]").getByRole("button", { name: "Continuer" }).click();
|
||||
await a.locator("dialog[open]").getByRole("button", { name: "Tout effacer partout" }).click();
|
||||
ok(await until(() => a.getByRole("button", { name: "Créer mon programme" }).isVisible()), "A effacé, synchro coupée");
|
||||
ok(await inPage(a, async () => (await import("./main.js")).sync.getStatus().hasKey) === false, "A : plus de clé");
|
||||
// B rouvre l'app : la synchro de l'ouverture apprend que le journal est effacé.
|
||||
await b.reload();
|
||||
await b.waitForSelector("h1");
|
||||
ok(await until(() => inPage(b, async () => (await import("./main.js")).store.getEvents().length === 0)), "B effacé à sa synchro suivante");
|
||||
ok(await until(() => b.getByRole("button", { name: "Créer mon programme" }).isVisible()), "B revient à l'accueil vierge");
|
||||
ok(await inPage(b, async () => (await import("./main.js")).sync.getStatus().hasKey) === false, "B : plus de clé");
|
||||
|
||||
ok(errors.length === 0, "aucune erreur dans la console" + (errors.length ? " : " + errors.join(" | ") : ""));
|
||||
for (const x of [A, B, C]) await x.ctx.close();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// Les nouveautés : des dates de mise en production, du plus récent au plus ancien,
|
||||
// et des phrases pour l'utilisateur, sans jargon technique.
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { CHANGELOG, LATEST, newsToShow } from "../../app/domain/changelog.js";
|
||||
|
||||
test("une entrée par date de mise en production, de la plus récente à la plus ancienne", () => {
|
||||
assert.ok(CHANGELOG.length >= 3);
|
||||
const dates = CHANGELOG.map((e) => e.date);
|
||||
for (const d of dates) assert.match(d, /^\d{4}-\d{2}-\d{2}$/);
|
||||
assert.deepEqual([...dates].sort().reverse(), dates);
|
||||
assert.equal(new Set(dates).size, dates.length, "une seule entrée par date");
|
||||
assert.equal(LATEST, dates[0]);
|
||||
});
|
||||
|
||||
test("des phrases pour l'utilisateur : complètes, courtes, sans jargon technique", () => {
|
||||
const jargon = /\b(MR|ADR|MCP|API|JSON|SDK|localStorage|IndexedDB|commit|merge|refacto\w*|lot \d\w?|bug|test|zstd|serveur|OAuth|événement)\b/i;
|
||||
for (const e of CHANGELOG) {
|
||||
assert.ok(e.items.length >= 1, e.date);
|
||||
for (const item of e.items) {
|
||||
assert.doesNotMatch(item, jargon, `${e.date} : « ${item} »`);
|
||||
assert.match(item, /^[A-ZÀ-ÖØ-Ý«]/u, `${e.date} : commence par une majuscule : « ${item} »`);
|
||||
assert.match(item, /[.!…]$/, `${e.date} : finit par un point : « ${item} »`);
|
||||
assert.ok(item.length <= 240, `${e.date} : trop long : « ${item} »`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("la ligne de l'accueil : pour qui utilisait l'app avant la mise à jour et n'a pas encore vu", () => {
|
||||
assert.equal(newsToShow(null, "2026-11-01", "2026-11-23"), true);
|
||||
assert.equal(newsToShow("2026-11-18", "2026-11-01", "2026-11-23"), true);
|
||||
assert.equal(newsToShow("2026-11-23", "2026-11-01", "2026-11-23"), false, "déjà vues");
|
||||
assert.equal(newsToShow(null, "2026-11-23", "2026-11-23"), false, "arrivé avec cette version : rien de nouveau pour lui");
|
||||
assert.equal(newsToShow(null, null, "2026-11-23"), false, "pas encore de journal");
|
||||
});
|
||||
@@ -144,3 +144,35 @@ test("limite de requêtes : par adresse, en fenêtre, et non contournable par un
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("relais : « Tout effacer partout » vide le journal, et le dit aux autres appareils (410)", async () => {
|
||||
const s = await startServer();
|
||||
try {
|
||||
await push(s, ID, TOKEN, [blob(1), blob(2)]);
|
||||
let r = await s.fetch(`/api/journals/${ID}/events`, { method: "DELETE", headers: auth("mauvaise-cle") });
|
||||
assert.equal(r.status, 403, "une autre clé ne peut pas effacer");
|
||||
r = await s.fetch(`/api/journals/${ID}/events`, { method: "DELETE", headers: auth(TOKEN) });
|
||||
assert.equal(r.status, 200);
|
||||
assert.deepEqual(await r.json(), { erased: true });
|
||||
r = await s.fetch(`/api/journals/${ID}/events`, { headers: auth(TOKEN) });
|
||||
assert.equal(r.status, 410, "lecture : effacé");
|
||||
assert.equal((await r.json()).error, "erased");
|
||||
r = await push(s, ID, TOKEN, [blob(3)]);
|
||||
assert.equal(r.status, 410, "un autre appareil ne recrée pas le journal");
|
||||
r = await s.fetch(`/api/journals/${ID}/events`, { method: "DELETE", headers: auth(TOKEN) });
|
||||
assert.equal(r.status, 200, "effacer deux fois ne change rien");
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("relais : un journal effacé le reste après redémarrage, et n'est plus « possédé »", async () => {
|
||||
const dir = tmp();
|
||||
const relay = createRelay(dir);
|
||||
await relay.append(ID, TOKEN, [blob(1)]);
|
||||
await relay.erase(ID, TOKEN);
|
||||
const again = createRelay(dir);
|
||||
await assert.rejects(again.read(ID, TOKEN, 0), (e) => /** @type {any} */ (e).status === 410);
|
||||
assert.equal(await again.owns(ID, TOKEN), false);
|
||||
assert.equal(fs.readFileSync(path.join(dir, "journals", ID + ".jsonl"), "utf8").split("\n").filter(Boolean).length, 1, "seul l'en-tête reste");
|
||||
});
|
||||
|
||||
@@ -104,3 +104,26 @@ test("erreurs : réseau absent, clé d'accès refusée ; un seul sync() à la fo
|
||||
await a;
|
||||
assert.equal(calls, 2, "une lecture, un envoi");
|
||||
});
|
||||
|
||||
test("« Tout effacer partout » : l'autre appareil reçoit « erased », et oublier permet de tout relire", async () => {
|
||||
const s = await startServer();
|
||||
try {
|
||||
const syncKey = generateSyncKey();
|
||||
const pc = memoryStore();
|
||||
const phone = memoryStore();
|
||||
await pc.add([weight("pc", "2026-11-01", 80)]);
|
||||
const syncPc = createSync({ store: pc, syncKey, baseUrl: s.base });
|
||||
const syncPhone = createSync({ store: phone, syncKey, baseUrl: s.base });
|
||||
await syncPc.sync();
|
||||
await syncPhone.sync();
|
||||
await syncPc.erase();
|
||||
await assert.rejects(syncPhone.sync(), (e) => e instanceof SyncError && e.code === "erased");
|
||||
// Oublier : une clé réactivée relirait tout depuis le début.
|
||||
const { journalId } = await deriveKeys(syncKey);
|
||||
assert.ok(phone.meta.get("sync:" + journalId));
|
||||
await syncPhone.forget();
|
||||
assert.equal(phone.meta.get("sync:" + journalId), null);
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user