fix(mobile): bouton mode lecture visible uniquement fichier ouvert (BUG-016)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user