|
@@ -1,5 +1,6 @@
|
|
|
import { TestBed } from '@angular/core/testing';
|
|
import { TestBed } from '@angular/core/testing';
|
|
|
import { ChatService, isAttachmentEcho } from './chat.service';
|
|
import { ChatService, isAttachmentEcho } from './chat.service';
|
|
|
|
|
+import { setServerUploadLimit } from './upload-limits';
|
|
|
import { FmodeApi } from './api/fmode-api';
|
|
import { FmodeApi } from './api/fmode-api';
|
|
|
import { LiveService } from './live.service';
|
|
import { LiveService } from './live.service';
|
|
|
import { MatrixClientService, MxMessage } from './matrix-client.service';
|
|
import { MatrixClientService, MxMessage } from './matrix-client.service';
|
|
@@ -956,16 +957,33 @@ describe('ChatService', () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
/* 大小限制(2026-11-10):选文件时就拦,超限项不进暂存区 */
|
|
/* 大小限制(2026-11-10):选文件时就拦,超限项不进暂存区 */
|
|
|
- it('🔴 超过 20MB 的文件在 stageFiles 阶段被拒并提示', async () => {
|
|
|
|
|
|
|
+ it('🔴 超过服务端上限的文件在 stageFiles 阶段被拒并提示', async () => {
|
|
|
realMode();
|
|
realMode();
|
|
|
await svc.open('agent-node-lj-test');
|
|
await svc.open('agent-node-lj-test');
|
|
|
|
|
+ /*
|
|
|
|
|
+ * 🔴 2026-11-13:上限不再写死 20MB,而是由服务端 `m.upload.size` 决定。
|
|
|
|
|
+ * 这里显式设成 20MB 来验证拦截逻辑本身(真实环境实测为 32MB)。
|
|
|
|
|
+ */
|
|
|
|
|
+ setServerUploadLimit(20 * 1024 * 1024);
|
|
|
const big = new File([new Uint8Array(8)], 'big.zip');
|
|
const big = new File([new Uint8Array(8)], 'big.zip');
|
|
|
Object.defineProperty(big, 'size', { value: 21 * 1024 * 1024 });
|
|
Object.defineProperty(big, 'size', { value: 21 * 1024 * 1024 });
|
|
|
|
|
|
|
|
svc.stageFiles([big]);
|
|
svc.stageFiles([big]);
|
|
|
|
|
|
|
|
expect(svc.pendingFiles().length).toBe(0);
|
|
expect(svc.pendingFiles().length).toBe(0);
|
|
|
- expect(svc.error()).toContain('超过单个附件上限');
|
|
|
|
|
|
|
+ expect(svc.error()).toContain('超过平台单文件上限');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('🔴 未探测到服务端上限 → 不拦截(用户裁决:不要凭空拦住)', async () => {
|
|
|
|
|
+ realMode();
|
|
|
|
|
+ await svc.open('agent-node-lj-test');
|
|
|
|
|
+ setServerUploadLimit(null);
|
|
|
|
|
+ const big = new File([new Uint8Array(8)], 'huge.zip');
|
|
|
|
|
+ Object.defineProperty(big, 'size', { value: 500 * 1024 * 1024 });
|
|
|
|
|
+
|
|
|
|
|
+ svc.stageFiles([big]);
|
|
|
|
|
+
|
|
|
|
|
+ expect(svc.pendingFiles().length).toBe(1);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('未超限的文件正常进入暂存区', async () => {
|
|
it('未超限的文件正常进入暂存区', async () => {
|
|
@@ -982,6 +1000,7 @@ describe('ChatService', () => {
|
|
|
it('多选时只挡掉超限的,合格的照常暂存', async () => {
|
|
it('多选时只挡掉超限的,合格的照常暂存', async () => {
|
|
|
realMode();
|
|
realMode();
|
|
|
await svc.open('agent-node-lj-test');
|
|
await svc.open('agent-node-lj-test');
|
|
|
|
|
+ setServerUploadLimit(20 * 1024 * 1024); // 显式设上限,见上方说明
|
|
|
const small = file();
|
|
const small = file();
|
|
|
const big = new File([new Uint8Array(8)], 'big.zip');
|
|
const big = new File([new Uint8Array(8)], 'big.zip');
|
|
|
Object.defineProperty(big, 'size', { value: 30 * 1024 * 1024 });
|
|
Object.defineProperty(big, 'size', { value: 30 * 1024 * 1024 });
|