feat: require cover for first project submission

This commit is contained in:
2026-08-17 21:27:34 +08:00
parent 7e8d9e3811
commit 145a6ce571
7 changed files with 318 additions and 121 deletions

View File

@@ -119,6 +119,44 @@ test.describe('Project configuration skills', () => {
await expect(page.getByTestId('resource-card-publish')).toHaveCount(0);
await expect(page.getByRole('button', { name: '一键提交审核' })).toBeVisible();
await app.evaluate(({ ipcMain }) => {
ipcMain.removeHandler('hostapi:fetch');
ipcMain.handle('hostapi:fetch', async (_event, request: { path?: string }) => {
if (/^\/api\/works\/projects\/mine\/[^/]+\/status$/.test(request.path ?? '')) {
return {
ok: true,
data: {
status: 200,
ok: true,
json: {
success: false,
status: 404,
code: 'PROJECT_NOT_FOUND',
error: 'Project not found',
},
},
};
}
return { ok: false, error: { message: `Unexpected E2E Host API request: ${request.path ?? ''}` } };
});
});
await page.getByRole('button', { name: '一键提交审核' }).click();
const publishDialog = page.getByRole('dialog', { name: '完善作品信息后提交' });
await expect(publishDialog).toBeVisible();
await expect(publishDialog.getByLabel(/项目封面/)).toBeVisible();
await publishDialog.getByLabel(/发布者姓名/).fill('E2E 作者');
await publishDialog.getByLabel(/发布者年龄/).fill('12');
await publishDialog.getByLabel(/项目简介/).fill('验证首次提审必须选择项目封面。');
await publishDialog.getByRole('button', { name: '提交审核' }).click();
await expect(publishDialog.getByRole('alert')).toContainText('首次提交必须上传');
const coverPath = path.join(process.cwd(), 'src/assets/agent-avatars/avatar-01.png');
await publishDialog.getByLabel(/项目封面/).setInputFiles(coverPath);
await expect(publishDialog.getByAltText('项目封面预览')).toBeVisible();
await expect(publishDialog.getByText('avatar-01.png')).toBeVisible();
await expect(publishDialog.getByText('重新选择')).toBeVisible();
await publishDialog.getByRole('button', { name: '取消' }).click();
const agentCard = page.getByTestId('project-agent-e2e-partner');
await expect(agentCard).toContainText('E2E伙伴');
await agentCard.click();