Files
Genarrative/apps/admin-web/src/pages/AdminInviteCodePage.test.tsx
T
kdletters 071faa482c 统一 Rust 与 TypeScript 格式化门禁
纳入 AGC Cargo workspace 的统一 rustfmt 检查与格式化入口

完成项目 TypeScript/Prettier 与 Rust 全量格式化

修复 Pingora expected executable 门禁的空白敏感误报

同步开发运维文档与 AGC skill pack 格式化忽略规则
2026-09-01 16:28:34 +08:00

42 lines
1.2 KiB
TypeScript

/* @vitest-environment jsdom */
import { render, screen } from '@testing-library/react';
import { beforeEach, expect, test, vi } from 'vitest';
import { listProfileInviteCodes } from '../api/adminApiClient';
import { AdminInviteCodePage } from './AdminInviteCodePage';
vi.mock('../api/adminApiClient', () => ({
formatAdminApiError: vi.fn((error: unknown) =>
error instanceof Error ? error.message : '请求失败',
),
isAdminApiError: vi.fn(() => false),
listProfileInviteCodes: vi.fn(),
upsertProfileInviteCode: vi.fn(),
}));
beforeEach(() => {
vi.clearAllMocks();
vi.mocked(listProfileInviteCodes).mockResolvedValue({
entries: [],
operations: [
{
operationId: 'operation-1',
codeKind: 'invite',
code: 'TEAM',
action: 'create',
operatorUserId: 'admin-account-internal-1',
operatorDisplayName: '邀请运营',
createdAt: '2026-07-14T10:00:00Z',
},
],
});
});
test('操作记录只展示管理员显示名称', async () => {
render(<AdminInviteCodePage token="admin-token" onUnauthorized={vi.fn()} />);
expect(await screen.findByText('邀请运营')).toBeTruthy();
expect(screen.queryByText('admin-account-internal-1')).toBeNull();
});