071faa482c
纳入 AGC Cargo workspace 的统一 rustfmt 检查与格式化入口 完成项目 TypeScript/Prettier 与 Rust 全量格式化 修复 Pingora expected executable 门禁的空白敏感误报 同步开发运维文档与 AGC skill pack 格式化忽略规则
82 lines
3.0 KiB
TypeScript
82 lines
3.0 KiB
TypeScript
/* @vitest-environment jsdom */
|
|
|
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
import { useState } from 'react';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
|
|
import type { GenerateDialogState } from './ImageCanvasEditorTypes';
|
|
import { IMAGE_MODEL_NANOBANANA2 } from './ImageCanvasGenerationModel';
|
|
import { ImageCanvasPublicationMaterialsDemoPanelView } from './ImageCanvasPublicationMaterialsDemoPanelView';
|
|
import { getPublicationMaterialsWorkflow } from './ImageCanvasPublicationMaterialsModel';
|
|
|
|
function PublicationPanelHarness({
|
|
onRememberImageModel = vi.fn(),
|
|
}: {
|
|
onRememberImageModel?: (model: string) => void;
|
|
}) {
|
|
const [dialog, setDialog] = useState<GenerateDialogState | null>({
|
|
mode: 'publication',
|
|
prompt: '',
|
|
status: 'idle',
|
|
imageModel: IMAGE_MODEL_NANOBANANA2,
|
|
publicationWorkflowId: 'publication-cover-image',
|
|
publicationGameInfo: {
|
|
gameName: '测试游戏',
|
|
gameCategories: '休闲',
|
|
gameDescription: '点击消除三个一样的物品',
|
|
},
|
|
publicationReferences: [],
|
|
});
|
|
const workflow = getPublicationMaterialsWorkflow('publication-cover-image');
|
|
|
|
return dialog ? (
|
|
<ImageCanvasPublicationMaterialsDemoPanelView
|
|
dialog={dialog}
|
|
workflow={workflow}
|
|
style={{}}
|
|
publicationReferenceButtonRef={{ current: null }}
|
|
isPublicationReferenceMenuOpen={false}
|
|
setGenerateDialog={setDialog}
|
|
setIsPublicationReferenceMenuOpen={() => undefined}
|
|
setIsPickingPublicationReferenceFromCanvas={() => undefined}
|
|
renderEditorPortal={(node) => node}
|
|
buildPortalMenuStyle={() => ({})}
|
|
onRequestUpload={() => undefined}
|
|
onRememberImageModel={onRememberImageModel}
|
|
onSubmit={() => undefined}
|
|
/>
|
|
) : null;
|
|
}
|
|
|
|
describe('ImageCanvasPublicationMaterialsDemoPanelView', () => {
|
|
it('locks publication material model selection to gpt-image-2', () => {
|
|
const rememberImageModel = vi.fn();
|
|
render(
|
|
<PublicationPanelHarness onRememberImageModel={rememberImageModel} />,
|
|
);
|
|
|
|
const modelButton = screen.getByRole('button', {
|
|
name: '宣发素材模型 gpt-image-2',
|
|
}) as HTMLButtonElement;
|
|
const description = screen.getByRole('textbox', {
|
|
name: '游戏首图一句话描述游戏',
|
|
});
|
|
|
|
expect(description.closest('.auto-grow-text-area')?.className).toContain(
|
|
'auto-grow-text-area',
|
|
);
|
|
expect(description.className).not.toContain('platform-text-field');
|
|
expect(description.closest('.auto-grow-text-area')?.className).toContain(
|
|
'image-canvas-editor__generation-prompt',
|
|
);
|
|
expect(modelButton.disabled).toBe(true);
|
|
expect(modelButton.textContent).not.toContain('nanobanana2');
|
|
fireEvent.click(modelButton);
|
|
expect(screen.queryByRole('menu', { name: '宣发素材模型选项' })).toBeNull();
|
|
expect(rememberImageModel).not.toHaveBeenCalled();
|
|
expect(screen.getByRole('button', { name: '生成' }).textContent).toBe(
|
|
'生成3泥点',
|
|
);
|
|
});
|
|
});
|