From 4c4cdfd778c4c5d5f7f2daf80d71de821e54dcc7 Mon Sep 17 00:00:00 2001 From: margrop <1731827+margrop@users.noreply.github.com> Date: Fri, 4 Dec 2026 15:43:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BB=83=E4=B9=A0=E9=A1=B5=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=9B=9E=E8=BD=A6=E6=8F=90=E4=BA=A4=E7=AD=94=E6=A1=88?= =?UTF-8?q?=E3=80=81=E6=9F=A5=E7=9C=8B=E5=8E=9F=E9=A2=98=E4=B8=8E=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF=E6=A0=87=E9=A2=98=E6=8D=A2=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 答案输入框在非输入法组合态按 Enter 直接提交 - 顶部增加查看原题入口;直达链接无站内历史时返回原错题详情 - 练习题卡片标题改为可换行,窄屏不挤压右侧控件 - 补充回车提交、查看原题、直达返回与手机换行 E2E Refs: https://github.com/margrop/wrong-notebook/issues/93 --- e2e/practice.spec.ts | 28 +++++++++++++++++++++++++++- src/app/practice/page.tsx | 27 +++++++++++++++++++++++---- src/lib/i18n/en.ts | 1 + src/lib/i18n/zh.ts | 1 + 4 files changed, 52 insertions(+), 5 deletions(-) diff --git a/e2e/practice.spec.ts b/e2e/practice.spec.ts index 6bb9da3f..01ca1093 100644 --- a/e2e/practice.spec.ts +++ b/e2e/practice.spec.ts @@ -18,7 +18,7 @@ for (const profile of viewports) { expect(records[0]).toMatchObject({ errorItemId: item.id, source: 'practice', result: 'correct' }); expect(records[0].questionText).toContain(`${scenario.marker}变式`); await expect.poll(async () => (await scenario.db.errorItem.findUniqueOrThrow({ where: { id: item.id } })).masteryProbability).toBe(0.7); - await page.locator(`a[href="/error-items/${item.id}"]`).click(); + await page.locator(`a[href="/error-items/${item.id}"]`).first().click(); await page.getByRole('button', { name: /做对.*单题练习/ }).click(); await expect(page.getByText(`${scenario.marker}变式`, { exact: false })).toBeVisible(); await page.goto(`/practice?id=${item.id}`); @@ -50,3 +50,29 @@ test('[E2E-M06] 判题失败不自动判错,用户手工确认后保存', asyn await expect(page.getByText(`${scenario.marker}变式`, { exact: false })).toBeVisible(); expect(await scenario.records()).toHaveLength(1); }); + +test('[E2E-M07] 练习页回车提交答案、查看原题入口与手机标题换行', async ({ page, scenario }) => { + test.setTimeout(90000); + const item = await generatePractice(page, scenario); + await page.setViewportSize({ width: 390, height: 844 }); + const title = page.getByTestId('practice-question-title'); + await expect(title).toBeVisible(); + expect(await title.evaluate((element) => element.scrollWidth <= element.clientWidth)).toBe(true); + + await page.getByPlaceholder('输入你的答案...').fill('令连续整数为 k 与 k+1,因此和为 2k+1,按奇数定义可得结论。'); + await page.getByPlaceholder('输入你的答案...').press('Enter'); + await expect(page.getByText('测试夹具判定:结论及论证完整', { exact: false })).toBeVisible({ timeout: 20000 }); + + await page.getByRole('link', { name: '查看原题', exact: true }).click(); + await expect(page).toHaveURL(`/error-items/${item.id}`); +}); + +test('[E2E-M08] 直达练习页时返回按钮回到原错题详情', async ({ page, scenario }) => { + const item = await scenario.item(); + await scenario.login(page); + const fresh = await page.context().newPage(); + await scenario.guardPage(fresh); + await fresh.goto(`/practice?id=${item.id}`); + await fresh.getByRole('button', { name: '返回', exact: true }).click(); + await expect(fresh).toHaveURL(`/error-items/${item.id}`); +}); diff --git a/src/app/practice/page.tsx b/src/app/practice/page.tsx index 516ba8ba..4072040b 100644 --- a/src/app/practice/page.tsx +++ b/src/app/practice/page.tsx @@ -1,8 +1,9 @@ "use client"; import { Suspense } from "react"; +import Link from "next/link"; import { useSearchParams, useRouter } from "next/navigation"; -import { Loader2, ArrowLeft } from "lucide-react"; +import { Loader2, ArrowLeft, Eye } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Textarea } from "@/components/ui/textarea"; @@ -37,13 +38,25 @@ function PracticeContent() { return