|
|
@@ -58,22 +58,22 @@ describe('DeviceService', () => {
|
|
|
it('/messages 与 /tabs 按端落点(桌面进会话、移动进消息列表)', () => {
|
|
|
expect(make(DESKTOP_UA).normalize('/messages')).toBe('/desktop/chat');
|
|
|
expect(make(DESKTOP_UA).normalize('/tabs')).toBe('/desktop/chat');
|
|
|
- expect(make(IPHONE_UA, { width: 390 }).normalize('/messages')).toBe('/mobile/messages');
|
|
|
- expect(make(IPHONE_UA, { width: 390 }).normalize('/tabs')).toBe('/mobile/messages');
|
|
|
+ expect(make(`${IPHONE_UA} FmodeApp/2.0`, { width: 390 }).normalize('/messages')).toBe('/mobile/messages');
|
|
|
+ expect(make(`${IPHONE_UA} FmodeApp/2.0`, { width: 390 }).normalize('/tabs')).toBe('/mobile/messages');
|
|
|
});
|
|
|
|
|
|
it('/chat/:id 保留 id 并加端前缀', () => {
|
|
|
expect(make(DESKTOP_UA).normalize('/chat/agent-node-xinting')).toBe(
|
|
|
'/desktop/chat/agent-node-xinting',
|
|
|
);
|
|
|
- expect(make(IPHONE_UA, { width: 390 }).normalize('/chat/agent-node-xinting')).toBe(
|
|
|
+ expect(make(`${IPHONE_UA} FmodeApp/2.0`, { width: 390 }).normalize('/chat/agent-node-xinting')).toBe(
|
|
|
'/mobile/chat/agent-node-xinting',
|
|
|
);
|
|
|
});
|
|
|
|
|
|
it('/chat 无 id 时落端会话页', () => {
|
|
|
expect(make(DESKTOP_UA).normalize('/chat')).toBe('/desktop/chat');
|
|
|
- expect(make(IPHONE_UA, { width: 390 }).normalize('/chat')).toBe('/mobile/chat');
|
|
|
+ expect(make(`${IPHONE_UA} FmodeApp/2.0`, { width: 390 }).normalize('/chat')).toBe('/mobile/chat');
|
|
|
});
|
|
|
|
|
|
it('/agent/:id 保留 id', () => {
|
|
|
@@ -82,13 +82,13 @@ describe('DeviceService', () => {
|
|
|
|
|
|
it('/call/:agentId 落详情页(FR-11 裁决:语音暂不实现,禁建通话路由)', () => {
|
|
|
expect(make(DESKTOP_UA).normalize('/call/agent-a')).toBe('/desktop/agent/agent-a');
|
|
|
- expect(make(IPHONE_UA, { width: 390 }).normalize('/call/agent-a')).toBe(
|
|
|
+ expect(make(`${IPHONE_UA} FmodeApp/2.0`, { width: 390 }).normalize('/call/agent-a')).toBe(
|
|
|
'/mobile/agent/agent-a',
|
|
|
);
|
|
|
});
|
|
|
|
|
|
it('简单旧路径按端加前缀(含 tasks/home)', () => {
|
|
|
- const mob = make(IPHONE_UA, { width: 390 });
|
|
|
+ const mob = make(`${IPHONE_UA} FmodeApp/2.0`, { width: 390 });
|
|
|
for (const p of [
|
|
|
'workbench',
|
|
|
'deliverables',
|
|
|
@@ -112,27 +112,32 @@ describe('DeviceService', () => {
|
|
|
|
|
|
it('未知路径 / 空值回落到端默认页', () => {
|
|
|
expect(make(DESKTOP_UA).normalize('/unknown-thing')).toBe('/desktop/chat');
|
|
|
- expect(make(IPHONE_UA, { width: 390 }).normalize('/unknown-thing')).toBe('/mobile/messages');
|
|
|
+ expect(make(`${IPHONE_UA} FmodeApp/2.0`, { width: 390 }).normalize('/unknown-thing')).toBe('/mobile/messages');
|
|
|
expect(make(DESKTOP_UA).normalize('')).toBe('/desktop/chat');
|
|
|
});
|
|
|
|
|
|
it('查询串被保留(登录回跳等场景需要)', () => {
|
|
|
expect(make(DESKTOP_UA).normalize('/chat/abc?x=1')).toBe('/desktop/chat/abc?x=1');
|
|
|
- expect(make(IPHONE_UA, { width: 390 }).normalize('/messages?tab=unread')).toBe(
|
|
|
+ // 2026-11-18:mobile 只认 App UA(手机浏览器也走桌面版)
|
|
|
+ expect(make(`${IPHONE_UA} FmodeApp/2.0`, { width: 390 }).normalize('/messages?tab=unread')).toBe(
|
|
|
'/mobile/messages?tab=unread',
|
|
|
);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
describe('detect(UA / 视口判定)', () => {
|
|
|
- it('iPhone UA → mobile', () => {
|
|
|
- expect(make(IPHONE_UA, { width: 390 }).mode()).toBe('mobile');
|
|
|
+ it('🔴 iPhone UA(浏览器)→ desktop(2026-11-18 手机浏览器也用桌面版)', () => {
|
|
|
+ /*
|
|
|
+ * 用户裁决:「手机浏览器也使用桌面版」。
|
|
|
+ * 移动版布局是为 App 容器设计的,只有 UA 带 FmodeApp 才走 mobile。
|
|
|
+ */
|
|
|
+ expect(make(IPHONE_UA, { width: 390 }).mode()).toBe('desktop');
|
|
|
});
|
|
|
|
|
|
- it('Android 手机 UA(含 Mobile)→ mobile', () => {
|
|
|
+ it('🔴 Android 手机 UA(浏览器)→ desktop', () => {
|
|
|
expect(
|
|
|
make('Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 Mobile').mode(),
|
|
|
- ).toBe('mobile');
|
|
|
+ ).toBe('desktop');
|
|
|
});
|
|
|
|
|
|
it('Android 平板(无 Mobile 标记)→ desktop', () => {
|
|
|
@@ -217,14 +222,16 @@ describe('DeviceService', () => {
|
|
|
describe('entryPath(AC-17.1 两端默认落地页)', () => {
|
|
|
it('桌面落 /desktop/chat、移动落 /mobile/messages(会话入口)', () => {
|
|
|
expect(make(DESKTOP_UA).entryPath()).toBe('/desktop/chat');
|
|
|
- expect(make(IPHONE_UA, { width: 390 }).entryPath()).toBe('/mobile/messages');
|
|
|
+ // 2026-11-18:mobile 只认 App UA
|
|
|
+ expect(make(`${IPHONE_UA} FmodeApp/2.0`, { width: 390 }).entryPath()).toBe('/mobile/messages');
|
|
|
});
|
|
|
});
|
|
|
|
|
|
describe('path(逻辑路径 → 带端前缀)', () => {
|
|
|
it('按当前端拼前缀', () => {
|
|
|
expect(make(DESKTOP_UA).path('/chat/a')).toBe('/desktop/chat/a');
|
|
|
- expect(make(IPHONE_UA, { width: 390 }).path('/chat/a')).toBe('/mobile/chat/a');
|
|
|
+ // 2026-11-18:mobile 只认 App UA
|
|
|
+ expect(make(`${IPHONE_UA} FmodeApp/2.0`, { width: 390 }).path('/chat/a')).toBe('/mobile/chat/a');
|
|
|
});
|
|
|
|
|
|
it('🔴 回归:不得重复拼端前缀(normalize 返回的已带前缀)', () => {
|
|
|
@@ -288,8 +295,8 @@ describe('DeviceService · 纯自动识别(视口优先)', () => {
|
|
|
expect(svc.detect()).toBe('desktop');
|
|
|
});
|
|
|
|
|
|
- it('🔴 手机 UA 横屏(宽度已够)→ 仍是移动端', () => {
|
|
|
- expect(make(IPHONE_UA, 844).detect()).toBe('mobile');
|
|
|
+ it('🔴 手机 UA 横屏(浏览器)→ desktop(2026-11-18 手机浏览器用桌面版)', () => {
|
|
|
+ expect(make(IPHONE_UA, 844).detect()).toBe('desktop');
|
|
|
});
|
|
|
|
|
|
it('🔴 App 内 WebView(UA 带 FmodeApp)→ 移动端', () => {
|