refactor: 清理迁移相关的未使用变量
- 移除 permission-helper.test.ts 中未使用的 RoleDefinition 导入 - 使用下划线前缀标记 permission-helper.ts 中有意未使用的参数 - 删除 role-auth-manager.ts 中未使用的 generateSignatureHeaders 方法及相关导入 - 为 test-data-manager.ts 添加 getPage 方法以使用 _page 变量 修复所有迁移相关的 TS6133 类型错误
This commit was merged in pull request #1.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { PermissionHelper } from '../permission-helper';
|
||||
import type { RoleDefinition } from '../../roles/base.role';
|
||||
|
||||
// Mock Playwright
|
||||
vi.mock('@playwright/test', () => ({
|
||||
|
||||
@@ -26,13 +26,13 @@ export class PermissionHelper {
|
||||
return await deniedMessage.count() > 0;
|
||||
}
|
||||
|
||||
async verifyCanCreate(resource: string, createButtonSelector: string): Promise<void> {
|
||||
async verifyCanCreate(_resource: string, createButtonSelector: string): Promise<void> {
|
||||
const createButton = this.page.locator(createButtonSelector);
|
||||
await expect(createButton).toBeVisible();
|
||||
await expect(createButton).toBeEnabled();
|
||||
}
|
||||
|
||||
async verifyCannotCreate(resource: string, createButtonSelector: string): Promise<void> {
|
||||
async verifyCannotCreate(_resource: string, createButtonSelector: string): Promise<void> {
|
||||
const createButton = this.page.locator(createButtonSelector);
|
||||
const count = await createButton.count();
|
||||
|
||||
@@ -41,13 +41,13 @@ export class PermissionHelper {
|
||||
}
|
||||
}
|
||||
|
||||
async verifyCanEdit(resourceId: string, editButtonSelector: string): Promise<void> {
|
||||
async verifyCanEdit(_resourceId: string, editButtonSelector: string): Promise<void> {
|
||||
const editButton = this.page.locator(editButtonSelector);
|
||||
await expect(editButton).toBeVisible();
|
||||
await expect(editButton).toBeEnabled();
|
||||
}
|
||||
|
||||
async verifyCannotEdit(resourceId: string, editButtonSelector: string): Promise<void> {
|
||||
async verifyCannotEdit(_resourceId: string, editButtonSelector: string): Promise<void> {
|
||||
const editButton = this.page.locator(editButtonSelector);
|
||||
const count = await editButton.count();
|
||||
|
||||
@@ -56,13 +56,13 @@ export class PermissionHelper {
|
||||
}
|
||||
}
|
||||
|
||||
async verifyCanDelete(resourceId: string, deleteButtonSelector: string): Promise<void> {
|
||||
async verifyCanDelete(_resourceId: string, deleteButtonSelector: string): Promise<void> {
|
||||
const deleteButton = this.page.locator(deleteButtonSelector);
|
||||
await expect(deleteButton).toBeVisible();
|
||||
await expect(deleteButton).toBeEnabled();
|
||||
}
|
||||
|
||||
async verifyCannotDelete(resourceId: string, deleteButtonSelector: string): Promise<void> {
|
||||
async verifyCannotDelete(_resourceId: string, deleteButtonSelector: string): Promise<void> {
|
||||
const deleteButton = this.page.locator(deleteButtonSelector);
|
||||
const count = await deleteButton.count();
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import { RoleFactory } from '../roles/role-factory';
|
||||
import crypto from 'crypto';
|
||||
|
||||
interface TokenCache {
|
||||
token: string;
|
||||
expiresAt: number;
|
||||
}
|
||||
|
||||
const SIGNATURE_SECRET = 'NovalonManageSystemSecretKey2026';
|
||||
|
||||
export class RoleAuthManager {
|
||||
private static tokenCache: Map<string, TokenCache> = new Map();
|
||||
private static readonly API_BASE_URL = process.env.VITE_API_BASE_URL || 'http://localhost:8084';
|
||||
@@ -31,31 +28,6 @@ export class RoleAuthManager {
|
||||
return token;
|
||||
}
|
||||
|
||||
private static generateSignatureHeaders(method: string, path: string, body: string): Record<string, string> {
|
||||
const timestamp = Date.now();
|
||||
const nonce = `${timestamp.toString(36)}-${Math.random().toString(36).substring(2, 15)}`;
|
||||
|
||||
const stringToSign = [
|
||||
method.toUpperCase(),
|
||||
path,
|
||||
'',
|
||||
'',
|
||||
timestamp.toString(),
|
||||
nonce
|
||||
].join('\n');
|
||||
|
||||
const signature = crypto
|
||||
.createHmac('sha256', SIGNATURE_SECRET)
|
||||
.update(stringToSign)
|
||||
.digest('base64');
|
||||
|
||||
return {
|
||||
'X-Signature': signature,
|
||||
'X-Timestamp': timestamp.toString(),
|
||||
'X-Nonce': nonce
|
||||
};
|
||||
}
|
||||
|
||||
private static async authenticateWithBackend(credentials: { username: string; password: string }): Promise<string> {
|
||||
const path = '/api/auth/login';
|
||||
const body = JSON.stringify(credentials);
|
||||
|
||||
@@ -10,7 +10,7 @@ export interface TestData {
|
||||
export class TestDataManager {
|
||||
private static instance: TestDataManager;
|
||||
private createdData: Map<string, TestData[]> = new Map();
|
||||
private page: Page | null = null;
|
||||
private _page: Page | null = null;
|
||||
private static readonly API_BASE_URL = process.env.VITE_API_BASE_URL || 'http://localhost:8084';
|
||||
|
||||
static getInstance(): TestDataManager {
|
||||
@@ -21,7 +21,11 @@ export class TestDataManager {
|
||||
}
|
||||
|
||||
setPage(page: Page): void {
|
||||
this.page = page;
|
||||
this._page = page;
|
||||
}
|
||||
|
||||
getPage(): Page | null {
|
||||
return this._page;
|
||||
}
|
||||
|
||||
async createUser(userData: {
|
||||
|
||||
Reference in New Issue
Block a user