Refine local backup modal and permission flow
All checks were successful
Deploy Sokko G / deploy (push) Successful in 17s

This commit is contained in:
Shinuwa 2026-09-25 11:35:31 +02:00
parent ee823d2c37
commit 69e3b8ef2f
4 changed files with 19 additions and 12 deletions

View file

@ -1,5 +1,5 @@
// Rôle : couvre les parcours navigateur principaux des toolboxes locales.
/* global window, navigator, CustomEvent, FileSystemDirectoryHandle */
/* global window, document, navigator, CustomEvent, FileSystemDirectoryHandle */
import { expect, test } from "@playwright/test";
import path from "node:path";
import { fileURLToPath } from "node:url";
@ -247,9 +247,11 @@ test("opens the local automatic backup settings modal", async ({ page }) => {
const dialog = page.getByRole("dialog", { name: "Sauvegarde automatique" });
await expect(dialog).toBeVisible();
expect((await dialog.boundingBox()).width).toBeGreaterThan(700);
expect(await dialog.evaluate((element) => window.getComputedStyle(element).scrollbarColor)).toContain("88, 55, 174");
await expect(dialog.getByText("Cette fonctionnalité n’est pas disponible dans tous les navigateurs.")).toBeVisible();
await expect(dialog.getByText("Opera GX", { exact: true })).toBeVisible();
await expect(dialog.getByText("Fonctionnement de l’autorisation", { exact: true })).toBeVisible();
await expect(dialog.getByText("Comment fonctionne la sauvegarde", { exact: true })).toBeVisible();
await expect(dialog.getByText("la popup système ne peut apparaître qu’après un clic de votre part.")).toBeVisible();
await expect(dialog.getByText("10 versions sont conservées.", { exact: true })).toBeVisible();
await expect(dialog.getByText("Dossier configuré :", { exact: true })).toBeVisible();
@ -275,6 +277,7 @@ test("offers an actionable backup alert without requesting permission at startup
await page.addInitScript(() => {
window.backupPermissionRequests = 0;
window.backupPermissionGranted = false;
window.backupReminderVisibleAtPermissionRequest = true;
Object.defineProperty(FileSystemDirectoryHandle.prototype, "queryPermission", {
configurable: true,
value: async () => window.backupPermissionGranted ? "granted" : "prompt"
@ -283,6 +286,7 @@ test("offers an actionable backup alert without requesting permission at startup
configurable: true,
value: async () => {
window.backupPermissionRequests += 1;
window.backupReminderVisibleAtPermissionRequest = document.body.textContent.includes("Des modifications ont été détectées dans vos toolboxes.");
window.backupPermissionGranted = true;
return "granted";
}
@ -302,6 +306,7 @@ test("offers an actionable backup alert without requesting permission at startup
await reminder.getByRole("button", { name: "Sauvegarder", exact: true }).click();
await expect(reminder).toHaveCount(0);
expect(await page.evaluate(() => window.backupPermissionRequests)).toBe(1);
expect(await page.evaluate(() => window.backupReminderVisibleAtPermissionRequest)).toBe(false);
await expect.poll(async () => page.evaluate(async () => {
const db = await import("/src/utils/indexedDbStorage.js");
return (await db.getSetting("autoBackup", {})).hasUnsavedChanges;