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:
@@ -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: ' 页面标题 ',
|
||||
|
||||
Reference in New Issue
Block a user