feat: 添加管理后台页面和功能,优化测试和性能配置
refactor: 重构页面导航和滚动逻辑,提升用户体验 test: 更新测试配置和用例,增加覆盖率和稳定性 perf: 优化性能指标和阈值,适应开发环境需求 ci: 添加Lighthouse CI工作流,集成性能测试 docs: 更新API文档和健康检查端点 fix: 修复登录页面和表单提交问题 style: 调整响应式布局和可访问性改进 chore: 更新依赖项和脚本配置
This commit is contained in:
@@ -35,7 +35,7 @@ describe('check-permission', () => {
|
||||
mockAuth.mockResolvedValue({
|
||||
user: {
|
||||
id: 'user-1',
|
||||
role: 'admin',
|
||||
isAdmin: true,
|
||||
},
|
||||
} as any);
|
||||
|
||||
@@ -50,7 +50,7 @@ describe('check-permission', () => {
|
||||
mockAuth.mockResolvedValue({
|
||||
user: {
|
||||
id: 'user-2',
|
||||
role: 'viewer',
|
||||
isAdmin: false,
|
||||
},
|
||||
} as any);
|
||||
|
||||
@@ -61,11 +61,11 @@ describe('check-permission', () => {
|
||||
expect(result.role).toBe('viewer');
|
||||
});
|
||||
|
||||
it('should return allowed: true for editor with valid permission', async () => {
|
||||
it('should return allowed: true for admin with update permission', async () => {
|
||||
mockAuth.mockResolvedValue({
|
||||
user: {
|
||||
id: 'user-3',
|
||||
role: 'editor',
|
||||
isAdmin: true,
|
||||
},
|
||||
} as any);
|
||||
|
||||
@@ -73,14 +73,14 @@ describe('check-permission', () => {
|
||||
|
||||
expect(result.allowed).toBe(true);
|
||||
expect(result.userId).toBe('user-3');
|
||||
expect(result.role).toBe('editor');
|
||||
expect(result.role).toBe('admin');
|
||||
});
|
||||
|
||||
it('should return allowed: false for editor with delete permission', async () => {
|
||||
it('should return allowed: false for viewer with delete permission', async () => {
|
||||
mockAuth.mockResolvedValue({
|
||||
user: {
|
||||
id: 'user-4',
|
||||
role: 'editor',
|
||||
isAdmin: false,
|
||||
},
|
||||
} as any);
|
||||
|
||||
@@ -93,7 +93,7 @@ describe('check-permission', () => {
|
||||
mockAuth.mockResolvedValue({
|
||||
user: {
|
||||
id: 'user-5',
|
||||
role: 'admin',
|
||||
isAdmin: true,
|
||||
},
|
||||
} as any);
|
||||
|
||||
@@ -108,7 +108,7 @@ describe('check-permission', () => {
|
||||
mockAuth.mockResolvedValue({
|
||||
user: {
|
||||
id: 'user-6',
|
||||
role: 'viewer',
|
||||
isAdmin: false,
|
||||
},
|
||||
} as any);
|
||||
|
||||
@@ -119,7 +119,7 @@ describe('check-permission', () => {
|
||||
mockAuth.mockResolvedValue({
|
||||
user: {
|
||||
id: 'user-7',
|
||||
role: 'admin',
|
||||
isAdmin: true,
|
||||
},
|
||||
} as any);
|
||||
|
||||
@@ -137,25 +137,25 @@ describe('check-permission', () => {
|
||||
await expect(requirePermission('content', 'read')).rejects.toThrow('无权限执行此操作');
|
||||
});
|
||||
|
||||
it('should allow editor to publish content', async () => {
|
||||
it('should allow admin to publish content', async () => {
|
||||
mockAuth.mockResolvedValue({
|
||||
user: {
|
||||
id: 'user-8',
|
||||
role: 'editor',
|
||||
isAdmin: true,
|
||||
},
|
||||
} as any);
|
||||
|
||||
const result = await requirePermission('content', 'publish');
|
||||
|
||||
expect(result.userId).toBe('user-8');
|
||||
expect(result.role).toBe('editor');
|
||||
expect(result.role).toBe('admin');
|
||||
});
|
||||
|
||||
it('should deny viewer to update config', async () => {
|
||||
mockAuth.mockResolvedValue({
|
||||
user: {
|
||||
id: 'user-9',
|
||||
role: 'viewer',
|
||||
isAdmin: false,
|
||||
},
|
||||
} as any);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user