This commit is contained in:
2026-05-02 17:56:42 +08:00
parent 2311edb2e6
commit acc55d0e13
40 changed files with 2582 additions and 931 deletions

View File

@@ -171,6 +171,75 @@ test('通关后显示结算弹窗、排行榜和下一关按钮', () => {
vi.useRealTimers();
});
test('首次点击左上返回弹出作品改造引导,保存并退出后不再重复弹出', () => {
const onBack = vi.fn();
const onRemodelWork = vi.fn();
window.localStorage.clear();
renderPuzzleRuntime(
<PuzzleRuntimeShell
run={clearedRun}
onBack={onBack}
onRemodelWork={onRemodelWork}
onSwapPieces={vi.fn()}
onDragPiece={vi.fn()}
onAdvanceNextLevel={vi.fn()}
/>,
);
fireEvent.click(screen.getByRole('button', { name: '返回上一页' }));
const dialog = screen.getByRole('dialog', {
name: /\s*!/u,
});
expect(dialog).toBeTruthy();
expect(onBack).not.toHaveBeenCalled();
fireEvent.click(within(dialog).getByRole('button', { name: '保存并退出' }));
expect(onBack).toHaveBeenCalledTimes(1);
expect(
window.localStorage.getItem(
'genarrative.puzzle-runtime.exit-remodel-prompt.v1:profile-1',
),
).toBe('1');
fireEvent.click(screen.getByRole('button', { name: '返回上一页' }));
expect(screen.queryByRole('dialog')).toBeNull();
expect(onBack).toHaveBeenCalledTimes(2);
expect(onRemodelWork).not.toHaveBeenCalled();
});
test('首次退出引导的作品改造按钮进入改造流程', () => {
const onRemodelWork = vi.fn();
window.localStorage.clear();
renderPuzzleRuntime(
<PuzzleRuntimeShell
run={{
...clearedRun,
currentLevel: {
...clearedRun.currentLevel!,
profileId: 'profile-remodel',
},
}}
onBack={vi.fn()}
onRemodelWork={onRemodelWork}
onSwapPieces={vi.fn()}
onDragPiece={vi.fn()}
onAdvanceNextLevel={vi.fn()}
/>,
);
fireEvent.click(screen.getByRole('button', { name: '返回上一页' }));
fireEvent.click(screen.getByRole('button', { name: '作品改造' }));
expect(onRemodelWork).toHaveBeenCalledTimes(1);
expect(onRemodelWork).toHaveBeenCalledWith('profile-remodel');
expect(screen.queryByRole('dialog')).toBeNull();
});
test('顶部作者显示头像昵称,底部功能居中放大且不显示等待候选', () => {
const runWithoutNext: PuzzleRunSnapshot = {
...clearedRun,