Files
Genarrative/apps/ai-game-creator-shell/tests/clientRuntimeErrorBoundary.test.ts
kdletters aa5c857060
Project CI / Repository checks (push) Successful in 1m8s
Project CI / Frontend tests (push) Successful in 2m59s
Project CI / Backend tests (push) Successful in 4m0s
Project CI / Native shell tests (push) Successful in 13m41s
修复 Godot 项目提交后的 CI 门禁
移除根 H5 包中冗余的 Tauri HTTP 依赖并同步锁文件
修正客户端错误边界测试的 import 顺序
固定两项后台 Runtime 恢复测试使用 Provider 模式
补充 AGC 原生 HTTP 依赖归属约束
2026-08-11 14:34:42 +08:00

38 lines
1.1 KiB
TypeScript

/** @vitest-environment jsdom */
import { fireEvent, render, screen } from '@testing-library/react';
import { createElement } from 'react';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { ClientRuntimeErrorBoundary } from '../src/app/AuthenticatedClient';
function BrokenAuthenticatedContent() {
throw new Error('首页渲染失败');
}
describe('AGC authenticated client error boundary', () => {
afterEach(() => {
vi.restoreAllMocks();
});
it('replaces a render crash with a recoverable login action', () => {
vi.spyOn(console, 'error').mockImplementation(() => undefined);
const onLogout = vi.fn();
render(
createElement(
ClientRuntimeErrorBoundary,
{ onLogout },
createElement(BrokenAuthenticatedContent),
),
);
expect(
screen.getByRole('main', { name: '客户端页面加载失败' }),
).toBeTruthy();
expect(screen.getByText('首页渲染失败')).toBeTruthy();
fireEvent.click(screen.getByRole('button', { name: '返回登录' }));
expect(onLogout).toHaveBeenCalledTimes(1);
});
});