fix(mobile): bouton mode lecture visible uniquement fichier ouvert (BUG-016)
CI / lint (push) Successful in 1m10s
CI / security (push) Successful in 46s
CI / test (push) Successful in 2m23s
CI / build (push) Successful in 41s
CI / e2e (push) Successful in 10m28s

This commit is contained in:
2026-09-12 22:44:15 -04:00
parent cb07b92543
commit d47fcbf2be
7 changed files with 95 additions and 4 deletions
+31
View File
@@ -14,6 +14,7 @@ import { strict as assert } from "node:assert";
import { JSDOM } from "jsdom";
import { fileURLToPath, pathToFileURL } from "node:url";
import path from "node:path";
import { state } from "../../frontend/js/state.js";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
@@ -62,6 +63,7 @@ const {
initMobileEditor,
toggleReadingMode,
isReadingMode,
updateReadingButtonVisibility,
} = mod;
let testCount = 0;
@@ -223,5 +225,34 @@ test("reading mode exposes enter and exit controls", () => {
assert.ok(w.document.getElementById("me-reading-exit"), "exit button exists");
});
test("reading button only shows while a file is open", () => {
const btn = w.document.getElementById("me-reading-btn");
state.currentPath = null;
updateReadingButtonVisibility();
assert.ok(btn.hidden, "hidden without an open file");
state.currentPath = "Notes/note.md";
updateReadingButtonVisibility();
assert.ok(!btn.hidden, "shown when a file is open");
state.currentPath = null;
updateReadingButtonVisibility();
assert.ok(btn.hidden, "hidden again once the file is closed");
});
test("reading button is hidden while the assistant panel is open", () => {
const btn = w.document.getElementById("me-reading-btn");
const panel = w.document.createElement("div");
panel.className = "bookslm-panel open";
w.document.body.appendChild(panel);
state.currentPath = "Notes/note.md";
updateReadingButtonVisibility();
assert.ok(btn.hidden, "hidden while the assistant is expanded");
panel.classList.add("hidden");
updateReadingButtonVisibility();
assert.ok(!btn.hidden, "shown again once the assistant is collapsed");
panel.remove();
state.currentPath = null;
updateReadingButtonVisibility();
});
console.log(`\n${passCount}/${testCount} tests passed\n`);
process.exit(passCount === testCount ? 0 : 1);