fix(mindspace): 修复删除时无法解析 MySQL JSON 导致页面复活

source_snapshot_json 在 mysql2 中已是对象,JSON.parse 失败会使 relative_path 丢失、工作区 HTML 未清理;同步后页面重新出现。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-06-30 01:39:47 +08:00
parent 2f6a52151a
commit 06eb129a28
3 changed files with 39 additions and 10 deletions
+10
View File
@@ -2,6 +2,16 @@ import assert from 'node:assert/strict';
import test from 'node:test';
import { pageInternals } from './mindspace-pages.mjs';
test('parseJsonColumn accepts mysql json objects and strings', () => {
const objectValue = { relative_path: 'public/demo.html', auto_synced: true };
assert.deepEqual(pageInternals.parseJsonColumn(objectValue), objectValue);
assert.deepEqual(
pageInternals.parseJsonColumn(JSON.stringify(objectValue)),
objectValue,
);
assert.deepEqual(pageInternals.parseJsonColumn(null, { ok: true }), { ok: true });
});
test('normalizePageInput trims values and constrains templates', () => {
const result = pageInternals.normalizePageInput({
title: ' 页面标题 ',