test(app): reproduce stale embedded Markdown images

This commit is contained in:
paseo-bot[bot]
2026-10-12 21:26:02 +02:00
parent f518e18a72
commit a7d665515f
@@ -0,0 +1,33 @@
import { writeFile } from "node:fs/promises";
import path from "node:path";
import { expect, test } from "../support/fixtures";
import { openFileExplorer, openFileFromExplorer } from "../support/helpers/file-explorer";
const FIRST = Buffer.from(
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAusB9Y9ZQmcAAAAASUVORK5CYII=",
"base64",
);
const SECOND = Buffer.from(
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=",
"base64",
);
test("embedded Markdown image reflects a file replacement while Preview stays open", async ({
page,
withWorkspace,
}) => {
const workspace = await withWorkspace({ prefix: "markdown-image-refresh-" });
const imagePath = path.join(workspace.repoPath, "hero.png");
await writeFile(imagePath, FIRST);
await writeFile(path.join(workspace.repoPath, "guide.md"), "# Guide\n\n![hero](./hero.png)\n");
await workspace.navigateTo();
await openFileExplorer(page);
await openFileFromExplorer(page, "guide.md");
const image = page.getByRole("img", { name: "hero", exact: true }).locator("img");
await expect
.poll(() => image.evaluate((element: HTMLImageElement) => element.naturalWidth))
.toBeGreaterThan(0);
const initialSource = await image.getAttribute("src");
await writeFile(imagePath, SECOND);
await expect.poll(() => image.getAttribute("src"), { timeout: 5000 }).not.toBe(initialSource);
});