/* @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(); expect(await screen.findByText('邀请运营')).toBeTruthy(); expect(screen.queryByText('admin-account-internal-1')).toBeNull(); });