Files
Genarrative/apps/admin-web/src/pages/AdminInviteCodePage.test.tsx
T
kdletters bddc25b4e0 后台支持多账号与页面访问权限
保留环境变量管理员作为 owner,并新增可持久化管理的 member 账号
建立一级页面权限、实时会话失效和后端逐请求鉴权
统一操作记录与配置记录展示管理员显示名称,隐藏内部主体标识
补充账号管理页面、生成绑定、定向测试和技术文档
2026-07-14 19:21:33 +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();
});