From 1979749b31631bf751c498329639d9717b164dbb Mon Sep 17 00:00:00 2001 From: Christian Bager Bach Houmann Date: Sat, 24 Oct 2026 17:29:44 +0200 Subject: [PATCH 1/3] test(e2e): click a sliding element only once its animation is done clickWhenStill clicked once two samples 100 ms apart gave the same centre. Under CPU load a settings page's slide-in and a phone menu's slide-up can stall across two samples, so the click landed mid-transition: on the page behind a sliding page, or below an 844 px window where the phone menu starts. It now also waits until no animation moves the element and the element is what a click at its centre hits. Fixes #2220 --- tests/e2e/uiHelpers.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/e2e/uiHelpers.ts b/tests/e2e/uiHelpers.ts index 4c09e320f..76e0948e7 100644 --- a/tests/e2e/uiHelpers.ts +++ b/tests/e2e/uiHelpers.ts @@ -162,21 +162,35 @@ export async function closeOpenPrompts(obsidian: ObsidianClient) { /** * A real click in the middle of the visible element matching `selector`, once - * it stops moving: a settings page slides in when it opens or is returned to. + * it is still, no animation moves it, and it is what a click there hits: a + * settings page slides in when it opens or is returned to, and a phone menu + * slides up from below the screen. Under load an animation can stall between + * two samples, so holding still alone does not mean it is done. */ export async function clickWhenStill(obsidian: ObsidianClient, selector: string) { // The last two samples go into the timeout, so a failure says whether the - // element was missing, hidden, or still moving. + // element was missing, hidden, animating, covered, or still moving. let previous = ""; let last = ""; const point = await obsidian.waitFor(async () => { - const sample = await obsidian.dev.evalJson<{ x: number; y: number } | "absent" | "hidden">(`(() => { + const sample = await obsidian.dev.evalJson<{ x: number; y: number } | string>(`(() => { + ${DESCRIBE_ELEMENT} const all = [...document.querySelectorAll(${jsLiteral(selector)})]; const el = all.find((el) => el.getClientRects().length > 0); if (!el) return all.length > 0 ? "hidden" : "absent"; + // Scroll-driven and endless animations never finish, so they cannot be waited out. + const moving = document.getAnimations().find((animation) => + animation.playState === "running" && animation.timeline instanceof DocumentTimeline + && animation.effect?.getComputedTiming().endTime !== Infinity + && animation.effect.target?.contains(el)); + if (moving) return "animating " + describe(moving.effect.target); el.scrollIntoView({ block: "nearest" }); const rect = el.getBoundingClientRect(); - return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 }; + const x = rect.left + rect.width / 2; + const y = rect.top + rect.height / 2; + const hit = document.elementFromPoint(x, y); + if (!el.contains(hit)) return "covered by " + describe(hit); + return { x, y }; })()`); const key = JSON.stringify(sample); const settled = typeof sample === "object" && key === last; From 90c3c0b0cae4d0ed097b241208ad5168e513b788 Mon Sep 17 00:00:00 2001 From: Christian Bager Bach Houmann Date: Sat, 24 Oct 2026 17:29:44 +0200 Subject: [PATCH 2/3] test(e2e): save the enabled plugins before the phone spec reloads the app Obsidian writes community-plugins.json a second after a plugin is turned on or off, and a reload drops that pending write. The harness turns QuickAdd off and on around every spec, so a dev:mobile reload inside that second came back with an empty plugin list and no QuickAdd, failing the file and every later run on that instance. Refs #2218 --- tests/e2e/choice-builder-pages-phone.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/e2e/choice-builder-pages-phone.test.ts b/tests/e2e/choice-builder-pages-phone.test.ts index 97e02f88e..4c3f48f3a 100644 --- a/tests/e2e/choice-builder-pages-phone.test.ts +++ b/tests/e2e/choice-builder-pages-phone.test.ts @@ -21,6 +21,10 @@ let size: number[] = []; async function emulateMobile(on: boolean) { const { obsidian } = getContext(); const enabled = await obsidian.dev.evalJson("Object.keys(app.plugins.plugins)"); + // Obsidian saves the enabled plugins a second after a plugin is turned on + // or off, as the harness does around every spec, and a reload drops that + // save. A reload inside that second would come back without QuickAdd. + await obsidian.dev.evalJsonAsync("app.plugins.saveConfig().then(() => true)"); await obsidian.execText("dev:mobile", on ? { on: true } : { off: true }); await obsidian.waitFor(() => obsidian.dev.evalJson( `document.body.classList.contains("is-mobile") === ${on} && Boolean(app.plugins.plugins.quickadd?.api)`, From ff6331f32377a94e2a22a3810f3bad7bbe2bff3e Mon Sep 17 00:00:00 2001 From: Christian Bager Bach Houmann Date: Sat, 24 Oct 2026 17:40:40 +0200 Subject: [PATCH 3/3] test: let e2e specs flush the enabled-plugins config The guard against app.json writes also matched app.plugins.saveConfig(), which writes community-plugins.json. --- tests/e2e-vault-config.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/e2e-vault-config.test.ts b/tests/e2e-vault-config.test.ts index b50349952..5bbf866b2 100644 --- a/tests/e2e-vault-config.test.ts +++ b/tests/e2e-vault-config.test.ts @@ -5,13 +5,14 @@ import { expect, it } from "vitest"; const ROOT = resolve(__dirname, ".."); const E2E = join(ROOT, "tests/e2e"); +// `app.plugins.saveConfig()` writes community-plugins.json, not app.json. it("sets vault options in e2e specs without writing app.json", () => { const hits = readdirSync(E2E, { recursive: true, encoding: "utf8" }) .filter((file) => file.endsWith(".ts")) .flatMap((file) => readFileSync(join(E2E, file), "utf8") .split("\n") - .flatMap((line, i) => (/\b(setConfig|saveConfig|requestSaveConfig)\s*\(/.test(line) ? [`${relative(ROOT, join(E2E, file))}:${i + 1}`] : [])), + .flatMap((line, i) => (/(?