fix(front-submit): let drafts save with partial content

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Opus 5 committed 2026-11-07 00:58:13 +08:00
1 parent 4a119358ca
commit 5f31c58df2
5 files changed
+29 -9

No files matched your search

@@ -66,6 +66,19 @@ test('stale autosave requests are rejected instead of overwriting', () => {
assert.match(appSource, /status === 409/);
});
test('drafts save with partial content instead of being rejected', () => {
// 只写标题、或正文只有图片/表格/代码块时,也必须能存草稿。
assert.match(saveTrait, /请先写点什么再保存/);
const draftBranch = saveTrait.indexOf('if (!$is_draft) {');
const titleGuard = saveTrait.indexOf("if ($title === '') {");
assert.ok(draftBranch !== -1 && titleGuard !== -1, 'draft branch and title guard both exist');
assert.ok(draftBranch < titleGuard, 'title/content requirements only apply to submit');
// 前端空文档不再发保存请求。
assert.match(appSource, /const hasDocument = /);
assert.match(appSource, /if \(!hasDocument\) \{\s*return true;/);
assert.match(appSource, /img\|table\|pre\|hr\|iframe\|video/);
});
test('paid payload is validated before any post write', () => {
const prepareAt = saveTrait.indexOf('prepare_pay_meta');
const insertAt = saveTrait.indexOf('wp_insert_post');