适配图片生成面板测试
更新角色生成面板断言,匹配远端画面比例与模型按钮交互 移除旧尺寸和模型下拉字段断言 验证角色生成提交不再携带旧尺寸字段
This commit is contained in:
@@ -1831,49 +1831,24 @@ describe('ImageCanvasEditorView', () => {
|
||||
const characterPanel = screen.getByRole('dialog', {
|
||||
name: '生成角色形象',
|
||||
});
|
||||
expect(within(characterPanel).getByText('尺寸比例')).toBeTruthy();
|
||||
expect(within(characterPanel).getByText('大小尺寸')).toBeTruthy();
|
||||
expect(within(characterPanel).getByText('画面比例')).toBeTruthy();
|
||||
expect(within(characterPanel).getByText('模型')).toBeTruthy();
|
||||
expect(
|
||||
(within(characterPanel).getByLabelText('角色模型') as HTMLSelectElement)
|
||||
.selectedOptions[0]?.textContent,
|
||||
).toBe('nanobanana2');
|
||||
within(characterPanel).getByRole('button', { name: '1:1' }),
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
(
|
||||
within(characterPanel).getByLabelText(
|
||||
'角色尺寸比例',
|
||||
) as HTMLSelectElement
|
||||
).value,
|
||||
).toBe('1:1');
|
||||
expect(
|
||||
(
|
||||
within(characterPanel).getByLabelText(
|
||||
'角色大小尺寸',
|
||||
) as HTMLSelectElement
|
||||
).value,
|
||||
).toBe('1K');
|
||||
expect(
|
||||
Array.from(
|
||||
(
|
||||
within(characterPanel).getByLabelText(
|
||||
'角色尺寸比例',
|
||||
) as HTMLSelectElement
|
||||
).options,
|
||||
).map((option) => option.value),
|
||||
).toContain('1:8');
|
||||
within(characterPanel).getByRole('button', { name: 'GPT Image' }),
|
||||
).toBeTruthy();
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: '生成图标素材' }));
|
||||
const iconPanel = screen.getByRole('dialog', { name: '生成图标素材' });
|
||||
expect(within(iconPanel).getByText('模型')).toBeTruthy();
|
||||
expect(
|
||||
(within(iconPanel).getByLabelText('图标模型') as HTMLSelectElement)
|
||||
.selectedOptions[0]?.textContent,
|
||||
).toBe('nanobanana2');
|
||||
expect(
|
||||
(within(iconPanel).getByLabelText('图标大小尺寸') as HTMLSelectElement)
|
||||
.value,
|
||||
).toBe('1K');
|
||||
within(iconPanel).getByRole('button', { name: 'nanobanana2' }),
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
it('remembers the edited image model and submits character dimension options', async () => {
|
||||
it('submits character generation without legacy dimension options', async () => {
|
||||
generateEditorImageMock.mockResolvedValueOnce({
|
||||
imageSrc: 'data:image/png;base64,character-model-options',
|
||||
width: 1024,
|
||||
@@ -1892,24 +1867,6 @@ describe('ImageCanvasEditorView', () => {
|
||||
const characterPanel = screen.getByRole('dialog', {
|
||||
name: '生成角色形象',
|
||||
});
|
||||
fireEvent.change(within(characterPanel).getByLabelText('角色模型'), {
|
||||
target: { value: 'gpt-image-2' },
|
||||
});
|
||||
expect(
|
||||
Array.from(
|
||||
(
|
||||
within(characterPanel).getByLabelText(
|
||||
'角色尺寸比例',
|
||||
) as HTMLSelectElement
|
||||
).options,
|
||||
).map((option) => option.value),
|
||||
).not.toContain('1:8');
|
||||
fireEvent.change(within(characterPanel).getByLabelText('角色尺寸比例'), {
|
||||
target: { value: '2:3' },
|
||||
});
|
||||
fireEvent.change(within(characterPanel).getByLabelText('角色大小尺寸'), {
|
||||
target: { value: '1K' },
|
||||
});
|
||||
fireEvent.change(within(characterPanel).getByLabelText('角色设定'), {
|
||||
target: { value: '高个子游侠' },
|
||||
});
|
||||
@@ -1919,18 +1876,18 @@ describe('ImageCanvasEditorView', () => {
|
||||
expect(generateEditorImageMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
kind: 'character',
|
||||
model: 'gpt-image-2',
|
||||
aspectRatio: '2:3',
|
||||
imageSize: '1K',
|
||||
prompt: '高个子游侠',
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: '生成图标素材' }));
|
||||
const iconPanel = screen.getByRole('dialog', { name: '生成图标素材' });
|
||||
expect(
|
||||
(within(iconPanel).getByLabelText('图标模型') as HTMLSelectElement).value,
|
||||
).toBe('gpt-image-2');
|
||||
generateEditorImageMock.mock.calls[0]?.[0],
|
||||
).not.toEqual(
|
||||
expect.objectContaining({
|
||||
aspectRatio: expect.any(String),
|
||||
imageSize: expect.any(String),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('keeps the bottom AI toolbar visible while generation panels are open', () => {
|
||||
|
||||
Reference in New Issue
Block a user