fix(数据): 支持大体积 AppData 并修正默认状态

关键改动:

- 后端显式注册 10mb JSON/urlencoded body parser,支持较大的 AppData 写入

- 前端版本派生数据缺失状态时默认 planned,而不是 released

- 增加请求体限制和版本默认状态测试

Co-Authored-By: Codex GPT-5 <codex@openai.com>
This commit is contained in:
Script Generator
2026-07-02 19:19:43 +08:00
parent 68b768788b
commit 121114af6a
5 changed files with 87 additions and 3 deletions

View File

@@ -0,0 +1,38 @@
import { configureHttpBodyParsers, DEFAULT_HTTP_BODY_LIMIT } from './http-body-limit';
jest.mock('express', () => ({
json: jest.fn(() => 'json-parser'),
urlencoded: jest.fn(() => 'urlencoded-parser'),
}));
const express = jest.requireMock('express') as {
json: jest.Mock;
urlencoded: jest.Mock;
};
describe('configureHttpBodyParsers', () => {
beforeEach(() => {
jest.clearAllMocks();
});
it('registers JSON and urlencoded parsers with a large AppData-safe limit', () => {
const app = { use: jest.fn() };
configureHttpBodyParsers(app as never);
expect(DEFAULT_HTTP_BODY_LIMIT).toBe('10mb');
expect(express.json).toHaveBeenCalledWith({ limit: '10mb' });
expect(express.urlencoded).toHaveBeenCalledWith({ extended: true, limit: '10mb' });
expect(app.use).toHaveBeenNthCalledWith(1, 'json-parser');
expect(app.use).toHaveBeenNthCalledWith(2, 'urlencoded-parser');
});
it('allows overriding the body limit for deployments with larger documents', () => {
const app = { use: jest.fn() };
configureHttpBodyParsers(app as never, '25mb');
expect(express.json).toHaveBeenCalledWith({ limit: '25mb' });
expect(express.urlencoded).toHaveBeenCalledWith({ extended: true, limit: '25mb' });
});
});