编辑卡片类型徽标不随题干换行(shrink-0+min-w-0);新增题目按钮去掉双加号(图标+文字)
test / test (push) Failing after 43s

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
jacobxu666
2026-08-20 15:59:20 +08:00
co-authored by Claude Haiku 4.5
parent 95994b14d0
commit 890e7ef3ac
2 changed files with 7 additions and 7 deletions
+3 -3
View File
@@ -25,7 +25,7 @@ describe("QuestionList 结构化编辑", () => {
const user = userEvent.setup(); const user = userEvent.setup();
let saved: QuizQ[] = []; let saved: QuizQ[] = [];
render(<QuestionList value={[]} onChange={(v) => (saved = v)} />); render(<QuestionList value={[]} onChange={(v) => (saved = v)} />);
await user.click(screen.getByText("+ 新增题目")); await user.click(screen.getByText("新增题目"));
await user.selectOptions(screen.getByLabelText("题型"), "choice"); await user.selectOptions(screen.getByLabelText("题型"), "choice");
await user.type(screen.getByLabelText("题干"), "2+2=?"); await user.type(screen.getByLabelText("题干"), "2+2=?");
await user.click(screen.getByText("+ 添加选项")); await user.click(screen.getByText("+ 添加选项"));
@@ -43,7 +43,7 @@ describe("QuestionList 结构化编辑", () => {
it("新建应用题仅 answer 模式(无判分模式 select)", async () => { it("新建应用题仅 answer 模式(无判分模式 select)", async () => {
const user = userEvent.setup(); const user = userEvent.setup();
render(<QuestionList value={[]} onChange={() => {}} />); render(<QuestionList value={[]} onChange={() => {}} />);
await user.click(screen.getByText("+ 新增题目")); await user.click(screen.getByText("新增题目"));
await user.selectOptions(screen.getByLabelText("题型"), "solve"); await user.selectOptions(screen.getByLabelText("题型"), "solve");
expect(screen.queryByLabelText("判分模式")).not.toBeInTheDocument(); expect(screen.queryByLabelText("判分模式")).not.toBeInTheDocument();
expect(screen.getByText("仅最终答案(秒判)")).toBeInTheDocument(); expect(screen.getByText("仅最终答案(秒判)")).toBeInTheDocument();
@@ -77,7 +77,7 @@ describe("QuestionList 结构化编辑", () => {
const user = userEvent.setup(); const user = userEvent.setup();
let saved: QuizQ[] = []; let saved: QuizQ[] = [];
render(<QuestionList value={[]} onChange={(v) => (saved = v)} />); render(<QuestionList value={[]} onChange={(v) => (saved = v)} />);
await user.click(screen.getByText("+ 新增题目")); await user.click(screen.getByText("新增题目"));
await user.click(screen.getByText("完成")); await user.click(screen.getByText("完成"));
expect(saved.length).toBe(0); expect(saved.length).toBe(0);
expect(screen.getByText(/缺少题干/)).toBeInTheDocument(); expect(screen.getByText(/缺少题干/)).toBeInTheDocument();
+4 -4
View File
@@ -214,9 +214,9 @@ export function QuestionList({
<Fragment key={i}> <Fragment key={i}>
<div className="rounded-xl border border-slate-100 bg-slate-50/60 p-3"> <div className="rounded-xl border border-slate-100 bg-slate-50/60 p-3">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<span className="rounded-full bg-indigo-100 px-2 py-0.5 text-xs font-medium text-indigo-700">{TYPE_LABEL[def.type]}</span> <span className="shrink-0 rounded-full bg-indigo-100 px-2 py-0.5 text-xs font-medium text-indigo-700">{TYPE_LABEL[def.type]}</span>
<span className="truncate text-sm font-medium text-slate-800">{def.stem}</span> <span className="min-w-0 flex-1 truncate text-sm font-medium text-slate-800">{def.stem}</span>
<span className="ml-auto flex items-center gap-1"> <span className="ml-auto flex shrink-0 items-center gap-1">
<button type="button" aria-label={`上移第 ${i + 1} 题`} className="text-muted-foreground hover:text-indigo-600" onClick={() => move(i, -1)}> <button type="button" aria-label={`上移第 ${i + 1} 题`} className="text-muted-foreground hover:text-indigo-600" onClick={() => move(i, -1)}>
<ArrowUp className="size-4" /> <ArrowUp className="size-4" />
</button> </button>
@@ -240,7 +240,7 @@ export function QuestionList({
{draft && editIndex == null && draftForm} {draft && editIndex == null && draftForm}
{!draft && ( {!draft && (
<Button variant="outline" onClick={startNew}> <Button variant="outline" onClick={startNew}>
<Plus className="size-4" /> + 新增题目 <Plus className="size-4" /> 新增题目
</Button> </Button>
)} )}
</div> </div>