fix: refine profile shortcuts and puzzle next button

This commit is contained in:
2026-06-01 16:45:39 +00:00
parent fae4db6a09
commit 1cb11bc1dd
6 changed files with 113 additions and 32 deletions

View File

@@ -617,7 +617,11 @@ test('通关后显示结算弹窗、排行榜和下一关按钮', () => {
expect(within(dialog).getByText('#1')).toBeTruthy();
expect(within(dialog).getByText('测试作者')).toBeTruthy();
fireEvent.click(within(dialog).getByRole('button', { name: '下一关' }));
const nextButton = within(dialog).getByRole('button', { name: '下一关' });
expect(nextButton.textContent).toContain('下一关');
expect(nextButton.querySelector('[data-puzzle-ui-sprite="next"]')).toBeNull();
fireEvent.click(nextButton);
expect(onAdvanceNextLevel).toHaveBeenCalledTimes(1);
vi.useRealTimers();
@@ -876,13 +880,16 @@ test('运行态用 UI spritesheet 原图检测矩形裁切返回设置下一关
expect(
screen.getByRole('button', { name: '打开拼图设置' }).className,
).not.toContain('rounded-full');
const nextSprite = screen
.getByRole('button', { name: '下一关' })
.querySelector('[data-puzzle-ui-sprite="next"]') as HTMLElement | null;
expect(nextSprite).toBeTruthy();
expect(nextSprite?.style.backgroundSize).toBe('320% 480%');
expect(nextSprite?.style.backgroundPosition).toBe('50% 57.89473684210527%');
expect(screen.getByRole('button', { name: '下一关' }).textContent).toBe('');
const nextButton = screen.getByRole('button', { name: '下一关' });
expect(nextButton.dataset.puzzleUiSprite).toBe('next');
expect(nextButton.querySelector('[data-puzzle-ui-sprite="next"]')).toBeNull();
expect(nextButton.style.backgroundSize).toBe('320% 480%');
expect(nextButton.style.backgroundPosition).toBe('50% 57.89473684210527%');
expect(nextButton.className).not.toContain('puzzle-runtime-primary-button');
expect(nextButton.className).not.toContain('rounded-full');
expect(nextButton.className).not.toContain('px-5');
expect(nextButton.className).not.toContain('py-2.5');
expect(nextButton.textContent).toBe('');
expect(
screen
.getByRole('button', { name: '提示' })
@@ -962,7 +969,7 @@ test('运行态在只有 UI 背景 objectKey 时仍渲染生成背景', () => {
expect(backgroundImage).toBeTruthy();
});
test('关闭通关弹窗后保留底部下一关入口', () => {
test('关闭通关弹窗后保留底部下一关入口', async () => {
vi.useFakeTimers();
const onAdvanceNextLevel = vi.fn();
const runWithoutRecommendedNextProfile: PuzzleRunSnapshot = {
@@ -988,10 +995,31 @@ test('关闭通关弹窗后保留底部下一关入口', () => {
onAdvanceNextLevel={onAdvanceNextLevel}
/>,
);
await act(async () => {});
act(() => {
vi.advanceTimersByTime(1_400);
});
const dialog = screen.getByRole('dialog', { name: '通关完成' });
const dialogNextButton = within(dialog).getByRole('button', {
name: '下一关',
});
expect(dialogNextButton.dataset.puzzleUiSprite).toBe('next');
expect(
dialogNextButton.querySelector('[data-puzzle-ui-sprite="next"]'),
).toBeNull();
expect(dialogNextButton.style.backgroundSize).toBe('320% 480%');
expect(dialogNextButton.style.backgroundPosition).toBe(
'50% 57.89473684210527%',
);
expect(dialogNextButton.className).not.toContain(
'puzzle-runtime-primary-button',
);
expect(dialogNextButton.className).not.toContain('rounded-full');
expect(dialogNextButton.className).not.toContain('px-5');
expect(dialogNextButton.className).not.toContain('py-2.5');
expect(dialogNextButton.textContent).toBe('');
act(() => {
fireEvent.click(screen.getByRole('button', { name: '关闭通关弹窗' }));
});
@@ -1050,9 +1078,8 @@ test('推荐页关闭通关弹窗后保留底部下一关入口且不叠加下
expect(screen.queryByRole('dialog', { name: '通关完成' })).toBeNull();
const nextButton = screen.getByRole('button', { name: //u });
expect(nextButton).toBeTruthy();
expect(
nextButton.querySelector('[data-puzzle-ui-sprite="next"]'),
).toBeTruthy();
expect(nextButton.dataset.puzzleUiSprite).toBe('next');
expect(nextButton.querySelector('[data-puzzle-ui-sprite="next"]')).toBeNull();
expect(nextButton.textContent?.trim()).toBe('');
vi.useRealTimers();
});