6f2cd315ff
- 移除 permission-helper.test.ts 中未使用的 RoleDefinition 导入 - 使用下划线前缀标记 permission-helper.ts 中有意未使用的参数 - 删除 role-auth-manager.ts 中未使用的 generateSignatureHeaders 方法及相关导入 - 为 test-data-manager.ts 添加 getPage 方法以使用 _page 变量 修复所有迁移相关的 TS6133 类型错误
69 lines
1.8 KiB
TypeScript
69 lines
1.8 KiB
TypeScript
import { describe, it, expect, vi } from 'vitest';
|
|
import { PermissionHelper } from '../permission-helper';
|
|
|
|
// Mock Playwright
|
|
vi.mock('@playwright/test', () => ({
|
|
expect: Object.assign(vi.fn(), {
|
|
extend: vi.fn().mockReturnValue(expect),
|
|
}),
|
|
}));
|
|
|
|
describe('PermissionHelper', () => {
|
|
it('should create PermissionHelper instance', () => {
|
|
const mockPage = {
|
|
goto: vi.fn(),
|
|
url: vi.fn().mockReturnValue('http://localhost:3000/dashboard'),
|
|
locator: vi.fn().mockReturnValue({
|
|
count: vi.fn().mockResolvedValue(0),
|
|
}),
|
|
} as any;
|
|
|
|
const helper = new PermissionHelper(mockPage);
|
|
expect(helper).toBeDefined();
|
|
});
|
|
|
|
it('should have verifyCanAccess method', () => {
|
|
const mockPage = {
|
|
goto: vi.fn(),
|
|
url: vi.fn().mockReturnValue('http://localhost:3000/dashboard'),
|
|
locator: vi.fn(),
|
|
} as any;
|
|
|
|
const helper = new PermissionHelper(mockPage);
|
|
expect(typeof helper.verifyCanAccess).toBe('function');
|
|
});
|
|
|
|
it('should have verifyCannotAccess method', () => {
|
|
const mockPage = {
|
|
goto: vi.fn(),
|
|
url: vi.fn(),
|
|
locator: vi.fn(),
|
|
} as any;
|
|
|
|
const helper = new PermissionHelper(mockPage);
|
|
expect(typeof helper.verifyCannotAccess).toBe('function');
|
|
});
|
|
|
|
it('should have verifyRolePermissions method', () => {
|
|
const mockPage = {
|
|
goto: vi.fn(),
|
|
url: vi.fn(),
|
|
locator: vi.fn(),
|
|
} as any;
|
|
|
|
const helper = new PermissionHelper(mockPage);
|
|
expect(typeof helper.verifyRolePermissions).toBe('function');
|
|
});
|
|
|
|
it('should have verifyPermissionBoundary method', () => {
|
|
const mockPage = {
|
|
goto: vi.fn(),
|
|
url: vi.fn(),
|
|
locator: vi.fn(),
|
|
} as any;
|
|
|
|
const helper = new PermissionHelper(mockPage);
|
|
expect(typeof helper.verifyPermissionBoundary).toBe('function');
|
|
});
|
|
});
|