feat: 首页滚动条展示学习残片并支持滚轮手动滚动

This commit is contained in:
2026-08-03 22:21:13 +08:00
parent 8d5c9db47f
commit 9bba684fb2
2 changed files with 208 additions and 129 deletions
+40
View File
@@ -31,4 +31,44 @@ test.describe('Welcome page', () => {
await page.locator('.quick-card').nth(1).locator('button').click();
await expect(page).toHaveURL(/\/review/);
});
test('wheel scrolls review ticker manually while hovering', async ({ page }) => {
const items = Array.from({ length: 10 }, (_, i) => ({
id: i + 1,
sessionNum: `S${i + 1}`,
taskNum: `T${i + 1}`,
taskName: `任务 ${i + 1}`,
sourceType: 'FRAGMENT',
content: `${i + 1} 条学习残片内容,用来撑起首页滚动区域。`,
createdTime: `2026-08-01 10:00:${String(i).padStart(2, '0')}`,
}));
await page.route('**/api/review/feed**', (route) =>
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ code: 200, data: items }),
}),
);
await page.goto('/welcome');
const track = page.locator('.review-scroll-track');
const content = page.locator('.review-scroll-content');
await expect(track).toBeVisible();
await track.hover();
const readTime = () =>
content.evaluate((el) => {
const anim = el.getAnimations()[0];
return anim && typeof anim.currentTime === 'number' ? anim.currentTime : -1;
});
const before = await readTime();
await page.mouse.wheel(0, 200);
await expect.poll(readTime).toBeGreaterThan(before);
await page.mouse.move(10, 10);
const after = await readTime();
await expect.poll(readTime).toBeGreaterThan(after);
});
});