test(ai): rendre le test du menu mention non flaky (nettoyage d'etat + attente du fetch)
This commit is contained in:
@@ -1363,6 +1363,14 @@ async function main() {
|
||||
// ── 39. Accented `@` mentions + all-vault fallback (BUG-008) ──
|
||||
await test("mention menu accepts accents and searches all vaults without a vault", async () => {
|
||||
localStorage.clear();
|
||||
document.body.replaceChildren();
|
||||
const stateMod = await import(pathToFileURL(path.join(JS_DIR, "state.js")).href);
|
||||
const prevVaults = stateMod.state.allVaults;
|
||||
const prevSelected = stateMod.state.selectedContextVault;
|
||||
const prevCurrent = stateMod.state.currentVault;
|
||||
stateMod.state.allVaults = [];
|
||||
stateMod.state.selectedContextVault = null;
|
||||
stateMod.state.currentVault = null;
|
||||
let lastUrl = "";
|
||||
globalThis.fetch = async (url) => {
|
||||
lastUrl = String(url);
|
||||
@@ -1382,13 +1390,21 @@ async function main() {
|
||||
ta.value = "@café";
|
||||
ta.selectionStart = ta.selectionEnd = 5;
|
||||
b._onComposerInput();
|
||||
await sleep(20);
|
||||
const menu = b._panel.querySelector(".bookslm-mention-menu");
|
||||
let waited = 0;
|
||||
while (!lastUrl.includes("tree-search") && waited < 500) {
|
||||
await sleep(20);
|
||||
waited += 20;
|
||||
}
|
||||
assert.ok(!menu.classList.contains("hidden"), "accented mention keeps the menu open");
|
||||
assert.ok(lastUrl.includes("vault=all"), "no vault -> searches all vaults");
|
||||
assert.ok(lastUrl.includes("vault=all"),
|
||||
`no vault -> searches all vaults (got last fetch "${lastUrl}")`);
|
||||
assert.equal(menu.querySelectorAll(".bookslm-menu-item").length, 1);
|
||||
b._panel.remove();
|
||||
localStorage.clear();
|
||||
stateMod.state.allVaults = prevVaults;
|
||||
stateMod.state.selectedContextVault = prevSelected;
|
||||
stateMod.state.currentVault = prevCurrent;
|
||||
});
|
||||
|
||||
// ── 40. Keyboard navigation in the command menu (BUG-007) ──
|
||||
|
||||
Reference in New Issue
Block a user