Merge branch 'codex/feature-1'

# Conflicts:
#	docs/【玩法创作】平台入口与玩法链路-2026-05-15.md
#	src/components/platform-entry/PlatformEntryFlowShellImpl.tsx
#	src/components/rpg-entry/RpgEntryFlowShell.agent.interaction.test.tsx
#	src/services/miniGameDraftGenerationProgress.ts
This commit is contained in:
2026-06-03 03:56:25 +08:00
51 changed files with 3075 additions and 482 deletions

View File

@@ -1,6 +1,6 @@
/* @vitest-environment jsdom */
import { fireEvent, render, screen } from '@testing-library/react';
import { act, fireEvent, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { afterEach, expect, test, vi } from 'vitest';
@@ -43,9 +43,9 @@ const testEntryConfig = {
visible: true,
open: true,
sortOrder: 10,
categoryId: 'recent',
categoryLabel: '最近创作',
categorySortOrder: 10,
categoryId: 'recommended',
categoryLabel: '热门推荐',
categorySortOrder: 20,
updatedAtMicros: 1,
},
{
@@ -57,9 +57,9 @@ const testEntryConfig = {
visible: true,
open: true,
sortOrder: 30,
categoryId: 'recent',
categoryLabel: '最近创作',
categorySortOrder: 10,
categoryId: 'recommended',
categoryLabel: '热门推荐',
categorySortOrder: 20,
updatedAtMicros: 1,
},
{
@@ -71,9 +71,9 @@ const testEntryConfig = {
visible: true,
open: true,
sortOrder: 40,
categoryId: 'recent',
categoryLabel: '最近创作',
categorySortOrder: 10,
categoryId: 'recommended',
categoryLabel: '热门推荐',
categorySortOrder: 20,
updatedAtMicros: 1,
},
{
@@ -85,9 +85,9 @@ const testEntryConfig = {
visible: false,
open: true,
sortOrder: 50,
categoryId: 'recent',
categoryLabel: '最近创作',
categorySortOrder: 10,
categoryId: 'recommended',
categoryLabel: '热门推荐',
categorySortOrder: 20,
updatedAtMicros: 1,
},
{
@@ -99,9 +99,9 @@ const testEntryConfig = {
visible: false,
open: false,
sortOrder: 60,
categoryId: 'recent',
categoryLabel: '最近创作',
categorySortOrder: 10,
categoryId: 'recommended',
categoryLabel: '热门推荐',
categorySortOrder: 20,
updatedAtMicros: 1,
},
{
@@ -113,9 +113,9 @@ const testEntryConfig = {
visible: true,
open: false,
sortOrder: 70,
categoryId: 'recent',
categoryLabel: '最近创作',
categorySortOrder: 10,
categoryId: 'recommended',
categoryLabel: '热门推荐',
categorySortOrder: 20,
updatedAtMicros: 1,
},
],
@@ -128,6 +128,7 @@ const testCreationTypes = derivePlatformCreationTypes(
const originalClipboard = navigator.clipboard;
afterEach(() => {
vi.useRealTimers();
window.sessionStorage.clear();
Object.defineProperty(navigator, 'clipboard', {
configurable: true,
@@ -135,6 +136,57 @@ afterEach(() => {
});
});
test('creation entry banner automatically rotates through backend configured banners', () => {
vi.useFakeTimers();
render(
<CustomWorldCreationHub
items={[]}
loading={false}
error={null}
onRetry={() => {}}
onCreateType={noopCreateType}
onOpenDraft={() => {}}
onEnterPublished={() => {}}
entryConfig={{
...testEntryConfig,
eventBanners: [
{
...testEntryConfig.eventBanner,
title: '第一张后台 Banner',
},
{
...testEntryConfig.eventBanner,
title: '第二张后台 Banner',
coverImageSrc: '/creation-type-references/match3d.webp',
},
],
}}
creationTypes={testCreationTypes}
mode="start-only"
/>,
);
const bannerTrack = screen.getByLabelText('创作公告横幅');
Object.defineProperty(bannerTrack, 'clientWidth', {
configurable: true,
value: 360,
});
const scrollTo = vi.fn();
Object.defineProperty(bannerTrack, 'scrollTo', {
configurable: true,
value: scrollTo,
});
act(() => {
vi.advanceTimersByTime(4200);
});
expect(scrollTo).toHaveBeenCalledWith({
left: 360,
behavior: 'smooth',
});
});
test('creation hub shows published metric growth from cached page snapshot', async () => {
window.sessionStorage.setItem(
'genarrative.creationHub.publishedMetrics.v1',