fix: render prompt museum media
This commit is contained in:
@@ -1,6 +1,94 @@
|
||||
import { closeElectronApp, expect, getStableWindow, test } from './fixtures/electron';
|
||||
|
||||
test.describe('AI Design workspace', () => {
|
||||
test('keeps Prompt Museum cards usable when relative media fails', async ({ launchElectronApp }) => {
|
||||
test.setTimeout(90_000);
|
||||
const app = await launchElectronApp({
|
||||
imageWorkspaceMode: 'local',
|
||||
skipSetup: true,
|
||||
});
|
||||
|
||||
try {
|
||||
const page = await getStableWindow(app);
|
||||
await expect(page.getByTestId('ai-module-selection-page')).toBeVisible();
|
||||
await page.getByTestId('ai-module-option-painting').click();
|
||||
const imageSidebar = page.getByTestId('sidebar-image-workspace');
|
||||
await expect(imageSidebar.getByTestId('sidebar-open-image-prompt-museum')).toBeVisible();
|
||||
|
||||
await app.evaluate(({ ipcMain }) => {
|
||||
const image = {
|
||||
url: '/api/image-prompt-museum/e2e-entry/media/thumbnail',
|
||||
width: 1200,
|
||||
height: 900,
|
||||
alt: 'E2E museum thumbnail',
|
||||
};
|
||||
const card = {
|
||||
id: 'e2e-entry',
|
||||
slug: 'e2e-entry',
|
||||
title: '相对媒体 E2E',
|
||||
summary: '验证图片失败不会阻断卡片。',
|
||||
thumbnail: image,
|
||||
categories: [],
|
||||
model: { id: 'e2e-model', name: 'E2E Model' },
|
||||
language: 'zh-CN',
|
||||
attribution: {
|
||||
author: { name: 'E2E 作者' },
|
||||
source: { name: 'E2E 来源' },
|
||||
license: { name: '测试许可', attributionText: 'E2E attribution' },
|
||||
},
|
||||
publishedAt: '2026-08-18T00:00:00.000Z',
|
||||
updatedAt: '2026-08-18T00:00:00.000Z',
|
||||
};
|
||||
const respond = (json: unknown) => ({
|
||||
ok: true,
|
||||
data: { status: 200, ok: true, json },
|
||||
});
|
||||
|
||||
ipcMain.removeHandler('hostapi:fetch');
|
||||
ipcMain.handle('hostapi:fetch', async (_event, request: { path?: string }) => {
|
||||
const path = request.path ?? '';
|
||||
if (path === '/api/works/image-prompt-museum') {
|
||||
return respond({
|
||||
success: true,
|
||||
data: {
|
||||
items: [card],
|
||||
facets: { useCases: [], styles: [], subjects: [] },
|
||||
nextCursor: null,
|
||||
total: 1,
|
||||
},
|
||||
});
|
||||
}
|
||||
if (path === '/api/works/image-prompt-museum/e2e-entry') {
|
||||
return respond({
|
||||
success: true,
|
||||
data: {
|
||||
...card,
|
||||
prompt: 'Create a resilient image card.',
|
||||
variables: [],
|
||||
images: [image],
|
||||
requiresReferenceImages: false,
|
||||
},
|
||||
});
|
||||
}
|
||||
if (path === '/api/works/image-prompt-museum/e2e-entry/media/thumbnail') {
|
||||
return respond({ mimeType: 'text/html', dataBase64: 'PGgxPnVuc2FmZTwvaDE+' });
|
||||
}
|
||||
return { ok: false, error: { message: `Unexpected E2E Host API request: ${path}` } };
|
||||
});
|
||||
});
|
||||
|
||||
await imageSidebar.getByTestId('sidebar-open-image-prompt-museum').click();
|
||||
const cardButton = page.getByRole('button', { name: '查看 相对媒体 E2E' });
|
||||
await expect(cardButton).toBeVisible();
|
||||
await expect(page.getByLabel('E2E museum thumbnail加载失败')).toBeVisible();
|
||||
await expect(cardButton).toBeEnabled();
|
||||
await cardButton.click();
|
||||
await expect(page.getByRole('button', { name: '关闭详情' })).toBeVisible();
|
||||
} finally {
|
||||
await closeElectronApp(app);
|
||||
}
|
||||
});
|
||||
|
||||
test('keeps the conversation and generation task panes full height', async ({ launchElectronApp }) => {
|
||||
test.setTimeout(150_000);
|
||||
const app = await launchElectronApp({
|
||||
|
||||
Reference in New Issue
Block a user