功能:游戏广场展示真实评分摘要
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 2m23s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m24s
Project CI / Backend tests (pull_request) Failing after 19s
Project CI / Frontend tests (pull_request) Successful in 2m4s
Project CI / Repository checks (pull_request) Failing after 19s
Project CI / AI game creator shell web tests (pull_request) Successful in 1m45s
Project CI / Native shell tests (pull_request) Successful in 5m47s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 11m13s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 11m22s

公开游戏列表与详情在同一读取快照中返回有效评价均分和人数
同步共享契约、公开投影映射、生成绑定与 no-store 响应
广场与详情复用评分文本组件,区分无人评分与摘要不可用
扩展必要展示和响应契约测试,保留原有目录交互
更新规范、实施计划与本地定向测试及联调验证证据
This commit is contained in:
2026-10-01 08:40:58 +00:00
parent 5aaa030129
commit b5069fd3e3
18 changed files with 152 additions and 42 deletions
@@ -120,6 +120,18 @@ beforeEach(() => {
});
describe('GameGalleryPage', () => {
it.each([
[{ averageScore: 8.2, ratingCount: 26 }, '8.2/10 · 26 人评分'],
[{ averageScore: 9, ratingCount: 1 }, '9.0/10 · 1 人评分'],
[{ averageScore: null, ratingCount: 0 }, '暂无评分'],
[undefined, '评分暂不可用'],
])('显示列表返回的评分摘要 %#', async (ratingSummary, expected) => {
listGamesMock.mockResolvedValueOnce([createGame({ ratingSummary })]);
render(<GameGalleryPage onOpenDetail={vi.fn()} />);
expect(await screen.findByText(expected)).toBeTruthy();
});
it('ignores a stale response after search keyword changes', async () => {
const first = deferred<GameDistributionGame[]>();
const second = deferred<GameDistributionGame[]>();
@@ -1,6 +1,7 @@
import './gameDistribution.css';
import './gameDistributionShowcase.css';
import { GameRatingSummaryText } from '@genarrative/shared/components';
import { Gamepad2, Monitor, Search, Smartphone, Sparkles } from 'lucide-react';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
@@ -104,6 +105,9 @@ function GameCard({
</span>
</span>
<span className="game-card__summary">{game.summary}</span>
<span className="game-card__rating">
<GameRatingSummaryText summary={game.ratingSummary} />
</span>
<span className="game-card__meta">
<span>{game.category}</span>
<span>·</span>
@@ -1,5 +1,7 @@
import './gameReviews.css';
import { GameRatingSummaryText } from '@genarrative/shared/components';
import type { GameDistributionReview } from '../../services/gameDistributionClient';
import { PlatformActionButton } from '../common/PlatformActionButton';
import { PlatformEmptyState } from '../common/PlatformEmptyState';
@@ -15,13 +17,7 @@ type ReviewsState = ReturnType<typeof useGameReviews>;
export function GameRatingSummary({ state }: { state: ReviewsState }) {
if (state.summary) {
return (
<span>
{state.summary.ratingCount === 0
? '暂无评分'
: `${state.summary.averageScore!.toFixed(1)}/10 · ${state.summary.ratingCount} 人评分`}
</span>
);
return <GameRatingSummaryText summary={state.summary} />;
}
if (state.listError) {
return (
@@ -238,6 +238,14 @@
text-overflow: ellipsis;
white-space: nowrap;
}
.game-card__rating {
display: block;
margin-top: 0.42rem;
color: var(--platform-text-base);
font-size: 0.78rem;
line-height: 1.55;
overflow-wrap: anywhere;
}
.game-card__meta {
display: flex;
gap: 0.38rem;