test: make thumbnail refresh assertion portable
Memind CI / Test, build, and release guards (push) Successful in 1m50s

This commit is contained in:
john
2026-07-27 09:43:43 +08:00
parent 291178d2c3
commit 6b479c16f9
+5 -5
View File
@@ -51,6 +51,9 @@ test('ensureWorkspaceHtmlThumbnail refreshes sidecars when the same html filenam
await fs.writeFile(htmlPath, originalHtml, 'utf8');
const originalSvg = await ensureWorkspaceHtmlThumbnail(root, 'same-page.html', originalHtml);
assert.match(originalSvg, /登鹳雀楼/);
await new Promise((resolve) => queueMicrotask(resolve));
await new Promise((resolve) => setImmediate(resolve));
const originalPng = await fs.readFile(path.join(root, 'same-page.thumbnail.png'));
const updatedHtml = `<!doctype html><html><head>
<title>长安月 · 唐风诗韵</title>
@@ -64,9 +67,6 @@ test('ensureWorkspaceHtmlThumbnail refreshes sidecars when the same html filenam
await new Promise((resolve) => queueMicrotask(resolve));
await new Promise((resolve) => setImmediate(resolve));
const [svgStat, pngStat] = await Promise.all([
fs.stat(path.join(root, 'same-page.thumbnail.svg')),
fs.stat(path.join(root, 'same-page.thumbnail.png')),
]);
assert.ok(pngStat.mtimeMs >= svgStat.mtimeMs);
const updatedPng = await fs.readFile(path.join(root, 'same-page.thumbnail.png'));
assert.notDeepEqual(updatedPng, originalPng);
});