This commit is contained in:
2026-05-08 22:07:08 +08:00
parent 65c2b8cd79
commit 96df12cd15
4 changed files with 43 additions and 3 deletions

View File

@@ -446,6 +446,34 @@ test('右上角设置按钮打开拼图设置并支持音量调节', () => {
expect(authValue.setMusicVolume).toHaveBeenCalledWith(0.77);
});
test('推荐页嵌入拼图时隐藏返回和设置里的退出入口', () => {
renderPuzzleRuntime(
<PuzzleRuntimeShell
run={clearedRun}
embedded
hideExitControls
onBack={vi.fn()}
onRemodelWork={vi.fn()}
onSwapPieces={vi.fn()}
onDragPiece={vi.fn()}
onAdvanceNextLevel={vi.fn()}
/>,
);
const backButton = screen.getByRole('button', { name: '返回上一页' });
expect((backButton as HTMLButtonElement).disabled).toBe(true);
expect(backButton.className).toContain('invisible');
fireEvent.click(screen.getByRole('button', { name: '打开拼图设置' }));
const dialog = screen.getByRole('dialog', { name: '拼图设置' });
expect(within(dialog).getByRole('button', { name: '继续拼图' })).toBeTruthy();
expect(
within(dialog).queryByRole('button', { name: '返回上一页' }),
).toBeNull();
expect(within(dialog).queryByText('保存并退出')).toBeNull();
});
test('拼图棋盘使用贴近移动端边缘的正方形舞台承载切块', () => {
const { container } = renderPuzzleRuntime(
<PuzzleRuntimeShell

View File

@@ -962,6 +962,7 @@ export function PuzzleRuntimeShell({
canAdvanceDefaultNextLevel || hasSimilarWorkChoices;
const levelLabel = `${currentLevel.levelIndex}`;
const exitPromptProfileId = currentLevel.profileId.trim();
const shouldHideBackButton = hideBackButton || hideExitControls;
const leaderboardEntries =
(currentLevel.leaderboardEntries ?? []).length > 0
? currentLevel.leaderboardEntries
@@ -1105,9 +1106,11 @@ export function PuzzleRuntimeShell({
type="button"
onClick={handleBackRequest}
aria-label="返回上一页"
disabled={hideBackButton}
disabled={shouldHideBackButton}
className={`puzzle-runtime-icon-button h-10 w-10 items-center justify-center rounded-full sm:h-11 sm:w-11 ${
hideBackButton ? 'invisible pointer-events-none' : 'inline-flex'
shouldHideBackButton
? 'invisible pointer-events-none'
: 'inline-flex'
}`}
>
<ArrowLeft className="h-4 w-4" />
@@ -1739,7 +1742,7 @@ export function PuzzleRuntimeShell({
onBack();
}}
className={`puzzle-runtime-primary-button rounded-full px-4 py-2 text-sm font-bold transition hover:brightness-105 ${
hideBackButton ? 'hidden' : ''
shouldHideBackButton ? 'hidden' : ''
}`}
>