UI 改进: - 设置页面内嵌显示(不再弹窗) - 临时邮箱卡片添加验证码提取按钮 - 导入账号弹窗 textarea 样式优化 - 账号头像 8 色渐变轮转 - 临时邮箱页顶栏邮箱点击复制 - 邮箱管理页自动选中默认分组 - 切换分组时重置邮件列 UI - 修复收件箱/垃圾邮件 Tab 切换(.folder-tab → .email-tab) - 修复从临时邮箱返回后账号列数据残留 - 仪表盘分组列表可点击导航 恢复: - 恢复 .github/ CI 工作流 - 恢复 tests/ 测试目录 - 恢复 docs/ 文档目录 - 恢复 CONTRIBUTING.md, SECURITY.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
83 lines
2.5 KiB
JavaScript
83 lines
2.5 KiB
JavaScript
/**
|
||
* 集成测试 - 多用户隔离(TASK-04-004)
|
||
*
|
||
* 覆盖:
|
||
* - TC-F4-004-P: 多用户布局隔离
|
||
*/
|
||
|
||
const LayoutManager = require('../../../static/js/layout-manager.js');
|
||
const { createLayoutDOM, getCSSVariable, simulateDrag } = require('../test-utils.js');
|
||
|
||
describe('多用户隔离集成测试(TASK-04-004)', () => {
|
||
beforeEach(() => {
|
||
createLayoutDOM();
|
||
Object.defineProperty(window, 'innerWidth', {
|
||
writable: true,
|
||
configurable: true,
|
||
value: 1600
|
||
});
|
||
});
|
||
|
||
test('TC-F4-004-P: 不同用户的布局应独立存储(save 使用 userId key)', () => {
|
||
jest.useFakeTimers();
|
||
try {
|
||
window.currentUserId = 'userA';
|
||
|
||
const layoutManager = new LayoutManager();
|
||
layoutManager.init();
|
||
|
||
const resizer = document.querySelector('[data-resizer="groups"]');
|
||
simulateDrag(resizer, 200, 260);
|
||
|
||
// 500ms 到达后写入 outlook_layout_state_userA
|
||
jest.advanceTimersByTime(500);
|
||
|
||
const savedRaw = window.localStorage.getItem('outlook_layout_state_userA');
|
||
expect(savedRaw).toBeTruthy();
|
||
|
||
const saved = JSON.parse(savedRaw);
|
||
expect(saved.userId).toBe('userA');
|
||
expect(saved.panels.groups.width).toBe('260px');
|
||
|
||
// 不应污染 guest key
|
||
expect(window.localStorage.getItem('outlook_layout_state_guest')).toBeNull();
|
||
} finally {
|
||
jest.useRealTimers();
|
||
delete window.currentUserId;
|
||
}
|
||
});
|
||
|
||
test('TC-F4-004-P: 用户切换后应加载各自的布局(userB 不应看到 userA 的布局)', () => {
|
||
// userA 保存一个自定义布局
|
||
window.currentUserId = 'userA';
|
||
window.localStorage.setItem(
|
||
'outlook_layout_state_userA',
|
||
JSON.stringify({
|
||
version: '1.1',
|
||
userId: 'userA',
|
||
timestamp: Date.now(),
|
||
panels: {
|
||
groups: { width: '250px', collapsed: false },
|
||
accounts: { width: '320px', collapsed: false },
|
||
emails: { width: '450px', collapsed: false }
|
||
}
|
||
})
|
||
);
|
||
|
||
// “切换用户”相当于换一个 userId 并重新进入页面
|
||
createLayoutDOM();
|
||
window.currentUserId = 'userB';
|
||
|
||
const layoutManager = new LayoutManager();
|
||
layoutManager.init();
|
||
|
||
// userB 无保存数据,应保持默认宽度(createLayoutDOM 初始化的 CSS 变量)
|
||
expect(getCSSVariable('--group-panel-width')).toBe('200px');
|
||
expect(getCSSVariable('--account-panel-width')).toBe('260px');
|
||
expect(getCSSVariable('--email-list-panel-width')).toBe('380px');
|
||
|
||
delete window.currentUserId;
|
||
});
|
||
});
|
||
|