feat: unify creation entry templates
This commit is contained in:
@@ -7,6 +7,11 @@ import { buildCreationWorkShelfItems } from './creationWorkShelf';
|
||||
import { CustomWorldCreationHub } from './CustomWorldCreationHub';
|
||||
|
||||
const noopCreateType = () => {};
|
||||
const DAY_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
function buildUpdatedAtDaysAgo(daysAgo: number) {
|
||||
return new Date(Date.now() - daysAgo * DAY_MS).toISOString();
|
||||
}
|
||||
|
||||
const testEntryConfig = {
|
||||
startCard: {
|
||||
@@ -90,6 +95,20 @@ const testEntryConfig = {
|
||||
categorySortOrder: 20,
|
||||
updatedAtMicros: 1,
|
||||
},
|
||||
{
|
||||
id: 'jump-hop',
|
||||
title: '跳一跳',
|
||||
subtitle: '节奏跳跃挑战',
|
||||
badge: '可创建',
|
||||
imageSrc: '/creation-type-references/jump-hop.webp',
|
||||
visible: true,
|
||||
open: true,
|
||||
sortOrder: 45,
|
||||
categoryId: 'recommended',
|
||||
categoryLabel: '热门推荐',
|
||||
categorySortOrder: 20,
|
||||
updatedAtMicros: 1,
|
||||
},
|
||||
{
|
||||
id: 'square-hole',
|
||||
title: '方洞',
|
||||
@@ -285,7 +304,7 @@ test('creation start card renders html banner in an empty-permission sandbox', (
|
||||
expect(html).toContain('<section><h1>自定义横幅</h1></section>');
|
||||
});
|
||||
|
||||
test('creation start card renders recent tab from real shelf summaries', () => {
|
||||
test('creation start card renders recent tab with the same template cards', () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<CustomWorldCreationHub
|
||||
items={[
|
||||
@@ -297,7 +316,7 @@ test('creation start card renders recent tab from real shelf summaries', () => {
|
||||
subtitle: '待完善草稿',
|
||||
summary: '这条内容来自作品架摘要。',
|
||||
coverImageSrc: null,
|
||||
updatedAt: new Date('2026-06-01T12:00:00.000Z').toISOString(),
|
||||
updatedAt: buildUpdatedAtDaysAgo(1),
|
||||
publishedAt: null,
|
||||
stage: 'clarifying',
|
||||
stageLabel: '待完善草稿',
|
||||
@@ -317,7 +336,6 @@ test('creation start card renders recent tab from real shelf summaries', () => {
|
||||
onEnterPublished={() => {}}
|
||||
entryConfig={testEntryConfig}
|
||||
creationTypes={testCreationTypes}
|
||||
getWorkState={() => ({ isGenerating: true })}
|
||||
mode="start-only"
|
||||
/>,
|
||||
);
|
||||
@@ -325,12 +343,16 @@ test('creation start card renders recent tab from real shelf summaries', () => {
|
||||
expect(html).toContain('aria-label="创作入口页签"');
|
||||
expect(html).toContain('role="tab"');
|
||||
expect(html).toContain('aria-selected="true"');
|
||||
expect(html).toContain('creation-recent-work-grid');
|
||||
expect(html).toContain('aria-label="打开最近创作 1"');
|
||||
expect(html).toContain('creation-template-list__grid');
|
||||
expect(html).toContain('creation-template-card');
|
||||
expect(html).toContain('最近创作');
|
||||
expect(html).toContain('后端返回的最近草稿');
|
||||
expect(html).toContain('这条内容来自作品架摘要');
|
||||
expect(html).toContain('生成中');
|
||||
expect(html).toContain('仅显示最近7天内使用过的模板');
|
||||
expect(html).toContain('文字冒险');
|
||||
expect(html).toContain('经典 RPG 体验');
|
||||
expect(html).not.toContain('creation-recent-work-grid');
|
||||
expect(html).not.toContain('打开最近创作');
|
||||
expect(html).not.toContain('后端返回的最近草稿');
|
||||
expect(html).not.toContain('这条内容来自作品架摘要');
|
||||
});
|
||||
|
||||
test('creation start card prefers backend recent summaries over local pending placeholders', () => {
|
||||
@@ -344,7 +366,7 @@ test('creation start card prefers backend recent summaries over local pending pl
|
||||
subtitle: '真实作品架摘要',
|
||||
summary: '最近创作应该只读取后端摘要。',
|
||||
coverImageSrc: null,
|
||||
updatedAt: new Date('2026-06-03T12:00:00.000Z').toISOString(),
|
||||
updatedAt: buildUpdatedAtDaysAgo(1),
|
||||
publishedAt: null,
|
||||
stage: 'failed',
|
||||
stageLabel: '生成失败',
|
||||
@@ -370,7 +392,7 @@ test('creation start card prefers backend recent summaries over local pending pl
|
||||
subtitle: '本地占位',
|
||||
summary: '这条占位不应该进入最近创作。',
|
||||
coverImageSrc: null,
|
||||
updatedAt: new Date('2026-06-04T12:00:00.000Z').toISOString(),
|
||||
updatedAt: buildUpdatedAtDaysAgo(0),
|
||||
publishedAt: null,
|
||||
stage: 'generating',
|
||||
stageLabel: '生成中',
|
||||
@@ -396,12 +418,56 @@ test('creation start card prefers backend recent summaries over local pending pl
|
||||
);
|
||||
|
||||
expect(html).toContain('最近创作');
|
||||
expect(html).toContain('后端最近草稿');
|
||||
expect(html).toContain('最近创作应该只读取后端摘要');
|
||||
expect(html).toContain('文字冒险');
|
||||
expect(html).toContain('经典 RPG 体验');
|
||||
expect(html).not.toContain('后端最近草稿');
|
||||
expect(html).not.toContain('最近创作应该只读取后端摘要');
|
||||
expect(html).not.toContain('本地生成中占位');
|
||||
});
|
||||
|
||||
test('creation start card marks backend jump-hop generating draft in recent tab', () => {
|
||||
test('creation start card excludes works older than the recent window', () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<CustomWorldCreationHub
|
||||
items={[
|
||||
{
|
||||
workId: 'draft:old-session',
|
||||
sourceType: 'agent_session',
|
||||
status: 'draft',
|
||||
title: '八天前的草稿',
|
||||
subtitle: '旧草稿',
|
||||
summary: '这条草稿已经超过最近创作期限。',
|
||||
coverImageSrc: null,
|
||||
updatedAt: buildUpdatedAtDaysAgo(8),
|
||||
publishedAt: null,
|
||||
stage: 'clarifying',
|
||||
stageLabel: '待完善草稿',
|
||||
playableNpcCount: 0,
|
||||
landmarkCount: 0,
|
||||
sessionId: 'old-session',
|
||||
profileId: null,
|
||||
canResume: true,
|
||||
canEnterWorld: false,
|
||||
},
|
||||
]}
|
||||
loading={false}
|
||||
error={null}
|
||||
onRetry={() => {}}
|
||||
onCreateType={noopCreateType}
|
||||
onOpenDraft={() => {}}
|
||||
onEnterPublished={() => {}}
|
||||
entryConfig={testEntryConfig}
|
||||
creationTypes={testCreationTypes}
|
||||
mode="start-only"
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(html).not.toContain('最近创作');
|
||||
expect(html).not.toContain('仅显示最近7天内使用过的模板');
|
||||
expect(html).not.toContain('八天前的草稿');
|
||||
expect(html).not.toContain('这条草稿已经超过最近创作期限');
|
||||
});
|
||||
|
||||
test('creation start card maps backend jump-hop draft to template card', () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<CustomWorldCreationHub
|
||||
items={[]}
|
||||
@@ -420,7 +486,7 @@ test('creation start card marks backend jump-hop generating draft in recent tab'
|
||||
coverImageSrc: null,
|
||||
publicationStatus: 'draft',
|
||||
playCount: 0,
|
||||
updatedAt: new Date('2026-06-03T13:00:00.000Z').toISOString(),
|
||||
updatedAt: buildUpdatedAtDaysAgo(1),
|
||||
publishedAt: null,
|
||||
publishReady: false,
|
||||
generationStatus: 'generating',
|
||||
@@ -440,9 +506,11 @@ test('creation start card marks backend jump-hop generating draft in recent tab'
|
||||
);
|
||||
|
||||
expect(html).toContain('最近创作');
|
||||
expect(html).toContain('跳一跳生成草稿');
|
||||
expect(html).toContain('后端仍在生成跳一跳玩法');
|
||||
expect(html).toContain('生成中');
|
||||
expect(html).toContain('跳一跳');
|
||||
expect(html).toContain('节奏跳跃挑战');
|
||||
expect(html).toContain('creation-template-card');
|
||||
expect(html).not.toContain('跳一跳生成草稿');
|
||||
expect(html).not.toContain('后端仍在生成跳一跳玩法');
|
||||
});
|
||||
|
||||
test('creation start card includes failed drafts in the recent tab', () => {
|
||||
@@ -457,7 +525,7 @@ test('creation start card includes failed drafts in the recent tab', () => {
|
||||
subtitle: '生成失败',
|
||||
summary: '失败草稿也来自真实作品架摘要。',
|
||||
coverImageSrc: null,
|
||||
updatedAt: new Date('2026-06-02T12:00:00.000Z').toISOString(),
|
||||
updatedAt: buildUpdatedAtDaysAgo(1),
|
||||
publishedAt: null,
|
||||
stage: 'failed',
|
||||
stageLabel: '生成失败',
|
||||
@@ -482,13 +550,15 @@ test('creation start card includes failed drafts in the recent tab', () => {
|
||||
);
|
||||
|
||||
expect(html).toContain('最近创作');
|
||||
expect(html).toContain('creation-recent-work-grid');
|
||||
expect(html).toContain('失败但仍可恢复的草稿');
|
||||
expect(html).toContain('失败草稿也来自真实作品架摘要');
|
||||
expect(html).toContain('生成失败');
|
||||
expect(html).toContain('creation-template-list__grid');
|
||||
expect(html).toContain('文字冒险');
|
||||
expect(html).toContain('经典 RPG 体验');
|
||||
expect(html).not.toContain('creation-recent-work-grid');
|
||||
expect(html).not.toContain('失败但仍可恢复的草稿');
|
||||
expect(html).not.toContain('失败草稿也来自真实作品架摘要');
|
||||
});
|
||||
|
||||
test('creation start card maps failed mini-game drafts into recent status labels', () => {
|
||||
test('creation start card maps failed mini-game drafts into recent template cards', () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<CustomWorldCreationHub
|
||||
items={[]}
|
||||
@@ -514,7 +584,7 @@ test('creation start card maps failed mini-game drafts into recent status labels
|
||||
difficulty: 1,
|
||||
publicationStatus: 'draft',
|
||||
playCount: 0,
|
||||
updatedAt: '2026-06-02T13:00:00.000Z',
|
||||
updatedAt: buildUpdatedAtDaysAgo(1),
|
||||
publishedAt: null,
|
||||
publishReady: false,
|
||||
generationStatus: 'failed',
|
||||
@@ -525,9 +595,11 @@ test('creation start card maps failed mini-game drafts into recent status labels
|
||||
);
|
||||
|
||||
expect(html).toContain('最近创作');
|
||||
expect(html).toContain('失败抓大鹅草稿');
|
||||
expect(html).toContain('失败的小玩法草稿也应该进入最近创作。');
|
||||
expect(html).toContain('生成失败');
|
||||
expect(html).toContain('抓大鹅');
|
||||
expect(html).toContain('3D 消除关卡');
|
||||
expect(html).toContain('creation-template-card');
|
||||
expect(html).not.toContain('失败抓大鹅草稿');
|
||||
expect(html).not.toContain('失败的小玩法草稿也应该进入最近创作。');
|
||||
});
|
||||
|
||||
test('creation start card keeps typography in compact UI scale', () => {
|
||||
|
||||
Reference in New Issue
Block a user