import { render, waitFor } from '@testing-library/react' import BrandFluidField from './BrandFluidField' describe('BrandFluidField', () => { const originalGetContext = HTMLCanvasElement.prototype.getContext afterEach(() => { HTMLCanvasElement.prototype.getContext = originalGetContext }) it('在 WebGL 不可用时保留静态品牌光晕', async () => { HTMLCanvasElement.prototype.getContext = jest.fn(() => null) as typeof originalGetContext const { getByTestId, container } = render() const field = getByTestId('brand-fluid-field') const canvas = container.querySelector('canvas') expect(field).toHaveAttribute('aria-hidden', 'true') expect(field).toHaveStyle({ background: 'linear-gradient(90deg, #fafafa 0%, #fafafa 56%, #fff7fb 70%, #ffdceb 86%, #ffedf5 100%)', }) await waitFor(() => expect(canvas).toHaveAttribute('data-webgl', 'unavailable')) }) })