feat(image): complete reviewed generation delivery
Memind CI / Test, build, and release guards (pull_request) Successful in 2m47s
Memind CI / Test, build, and release guards (pull_request) Successful in 2m47s
This commit is contained in:
@@ -40,3 +40,33 @@ test('ensureWorkspaceHtmlThumbnail schedules raster png sidecar', async () => {
|
||||
await new Promise((resolve) => setImmediate(resolve));
|
||||
await fs.access(path.join(root, 'demo.thumbnail.png'));
|
||||
});
|
||||
|
||||
test('ensureWorkspaceHtmlThumbnail refreshes sidecars when the same html filename is overwritten', async () => {
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'workspace-thumb-refresh-'));
|
||||
const htmlPath = path.join(root, 'same-page.html');
|
||||
const originalHtml = `<!doctype html><html><head>
|
||||
<title>登鹳雀楼 · 王之涣</title>
|
||||
<meta name="mindspace-cover" content='{"tag":"文学","subtitle":"白日依山尽"}' />
|
||||
</head><body><h1>登鹳雀楼</h1></body></html>`;
|
||||
await fs.writeFile(htmlPath, originalHtml, 'utf8');
|
||||
const originalSvg = await ensureWorkspaceHtmlThumbnail(root, 'same-page.html', originalHtml);
|
||||
assert.match(originalSvg, /登鹳雀楼/);
|
||||
|
||||
const updatedHtml = `<!doctype html><html><head>
|
||||
<title>长安月 · 唐风诗韵</title>
|
||||
<meta name="mindspace-cover" content='{"tag":"文化","subtitle":"原创唐诗 · 长安月色"}' />
|
||||
</head><body><h1>长安月</h1></body></html>`;
|
||||
await fs.writeFile(htmlPath, updatedHtml, 'utf8');
|
||||
const updatedSvg = await ensureWorkspaceHtmlThumbnail(root, 'same-page.html', updatedHtml);
|
||||
assert.match(updatedSvg, /长安月/);
|
||||
assert.doesNotMatch(updatedSvg, /登鹳雀楼/);
|
||||
assert.notEqual(updatedSvg, originalSvg);
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user