merge: validate PR 793 mobile wrapping

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
This commit is contained in:
XiaoSeS 2026-09-02 01:54:13 +08:00
commit 4f0f52788c
4 changed files with 43 additions and 4 deletions

View file

@ -135,6 +135,31 @@ describe('skill reviews', () => {
expect(mocks.requestedPages[mocks.requestedPages.length - 1]).toBe(0)
})
it('wraps long reviewer names and review text', () => {
const reviewer = 'review_author_1788284593_353294'
const reviewText = 'x'.repeat(200)
mocks.pages.set(0, {
items: [{
id: 8,
displayName: reviewer,
score: 5,
reviewText,
status: 'VISIBLE',
authoredByViewer: false,
createdAt: '2026-09-01T00:00:00Z',
updatedAt: '2026-09-01T00:00:00Z',
}],
total: 1,
page: 0,
size: 20,
})
render(<SkillReviews skillId={10} canInteract onRequireLogin={vi.fn()} />)
expect(screen.getByText(reviewer).className).toContain('[overflow-wrap:anywhere]')
expect(screen.getByText(reviewText).className).toContain('[overflow-wrap:anywhere]')
})
it('keeps review interaction copy in every supported locale', () => {
for (const locale of [en, zh, ru]) {
expect(locale.skillReviews.ratingDisplay).toBeTruthy()

View file

@ -186,8 +186,8 @@ function ReviewRow({ skillId, review, canModerate }: {
)}
<div className="min-w-0 flex-1">
<div className="flex flex-wrap items-center justify-between gap-2">
<div className="flex flex-wrap items-center gap-2">
<span className="font-medium text-foreground">{review.displayName}</span>
<div className="min-w-0 max-w-full flex flex-wrap items-center gap-2">
<span className="min-w-0 max-w-full break-words font-medium text-foreground [overflow-wrap:anywhere]">{review.displayName}</span>
<ReviewStars value={review.score} />
{hidden ? (
<span className="rounded-full bg-destructive/10 px-2 py-0.5 text-xs text-destructive">
@ -199,7 +199,7 @@ function ReviewRow({ skillId, review, canModerate }: {
{formatLocalDateTime(review.updatedAt, i18n.language)}
</span>
</div>
<p className="mt-2 whitespace-pre-wrap text-sm leading-6 text-foreground/90">{review.reviewText}</p>
<p className="mt-2 whitespace-pre-wrap break-words text-sm leading-6 text-foreground/90 [overflow-wrap:anywhere]">{review.reviewText}</p>
{hidden && review.moderationReason ? (
<p className="mt-2 text-xs text-muted-foreground">
{t('skillReviews.moderationReason', { reason: review.moderationReason })}

View file

@ -348,6 +348,20 @@ describe('SkillDetailPage', () => {
expect(html).not.toContain('skillDetail.deleteSkill')
})
it('wraps a long skill name instead of widening the mobile page', () => {
useSkillDetailMock.mockReturnValue({
data: createSkill({ displayName: 'review-runtime-1788284593-353294' }),
isLoading: false,
isFetching: false,
error: null,
})
const html = renderToStaticMarkup(<SkillDetailPage />)
expect(html).toContain('text-balance break-words text-4xl')
expect(html).toContain('[overflow-wrap:anywhere]')
})
it('shows the label management panel for a user who can manage the skill lifecycle', () => {
useSkillDetailMock.mockReturnValue({
data: createSkill({

View file

@ -838,7 +838,7 @@ export function SkillDetailPage() {
</span>
)}
</div>
<h1 className="text-balance text-4xl font-bold font-heading text-foreground">{skill.displayName}</h1>
<h1 className="text-balance break-words text-4xl font-bold font-heading text-foreground [overflow-wrap:anywhere]">{skill.displayName}</h1>
{skill.ownerDisplayName && (
<div className="flex min-w-0">
<div className="inline-flex max-w-full items-center gap-2 rounded-full border border-border/60 bg-background/85 px-3 py-1.5 text-sm text-muted-foreground shadow-sm backdrop-blur-sm">