efbdf7031e
Project CI / AI game creator shell Rust crates (push) Successful in 1m30s
Project CI / AI game creator shell Rust smoke (push) Successful in 1m57s
Project CI / Backend tests (push) Successful in 3m54s
Project CI / Frontend tests (push) Successful in 2m5s
Project CI / Native shell tests (push) Successful in 6m4s
Project CI / AI game creator shell Rust lane 2/2 (push) Successful in 8m14s
Project CI / AI game creator shell Rust lane 1/2 (push) Successful in 9m19s
Project CI / AI game creator shell web tests (push) Successful in 1m23s
Project CI / Repository checks (push) Successful in 1m55s
客户端维护响应统一识别并广播维护事件 AGC 与网页端根部展示维护大弹窗,收口发布、上传、资源换签和登录错误 补充维护态弹窗测试、类型检查与实施计划说明
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
/** @vitest-environment jsdom */
|
|
import { act, cleanup, render, screen } from '@testing-library/react';
|
|
import { afterEach, describe, expect, it } from 'vitest';
|
|
|
|
import { MaintenanceNotice } from '../src/components/modal/MaintenanceNotice';
|
|
import {
|
|
CLIENT_MAINTENANCE_EVENT,
|
|
ClientAuthRequestError,
|
|
emitClientMaintenanceNotice,
|
|
} from '../src/services/clientApi';
|
|
|
|
afterEach(() => cleanup());
|
|
|
|
describe('客户端维护大弹窗', () => {
|
|
it('收到维护事件时统一展示大弹窗', () => {
|
|
render(<MaintenanceNotice />);
|
|
|
|
act(() => {
|
|
window.dispatchEvent(
|
|
new CustomEvent(CLIENT_MAINTENANCE_EVENT, {
|
|
detail: { code: 'MAINTENANCE', status: 503 },
|
|
}),
|
|
);
|
|
});
|
|
|
|
expect(screen.getByRole('dialog', { name: '系统维护中' })).toBeTruthy();
|
|
expect(
|
|
screen.getByText('服务正在维护,当前操作暂时无法完成。请稍后再试。'),
|
|
).toBeTruthy();
|
|
expect(screen.getByRole('button', { name: '我知道了' })).toBeTruthy();
|
|
});
|
|
|
|
it('普通业务错误不会上报维护事件', () => {
|
|
const received: Event[] = [];
|
|
const handler = (event: Event) => received.push(event);
|
|
window.addEventListener(CLIENT_MAINTENANCE_EVENT, handler);
|
|
|
|
emitClientMaintenanceNotice(
|
|
new ClientAuthRequestError('创建平台游戏失败', { status: 500 }),
|
|
);
|
|
|
|
expect(received).toHaveLength(0);
|
|
window.removeEventListener(CLIENT_MAINTENANCE_EVENT, handler);
|
|
});
|
|
});
|