Skip to content

Commit 3a2a0b3

Browse files
committed
feat(knowledge): 向导内嵌示例行(具象化·不预填)
1 parent 087edec commit 3a2a0b3

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

‎app/src/components/KnowledgeSystemWizard.test.tsx‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,19 @@ describe("KnowledgeSystemWizard 三步校验", () => {
117117
expect(firstAddIdx).toBeGreaterThan(createIdx);
118118
await waitFor(() => expect(onCreated).toHaveBeenCalled());
119119
});
120+
121+
it("每步显示「例如」示例行(不写入输入框)", async () => {
122+
renderWizard();
123+
await screen.findByTestId("knowledge-wizard");
124+
expect(screen.getByTestId("wizard-example-1").textContent).toContain("化妆又快又自然");
125+
// 填核心问题以允许前进到第 2 步;但例不会被预填到输入框
126+
fireEvent.change(screen.getByTestId("wizard-core-question"), { target: { value: "如何练好化妆" } });
127+
// 第 1 步确认:输入框未被示例预填,值为用户键入内容
128+
expect((screen.getByTestId("wizard-core-question") as HTMLTextAreaElement).value).toBe("如何练好化妆");
129+
fireEvent.click(screen.getByTestId("wizard-next"));
130+
expect(await screen.findByTestId("wizard-example-2")).toBeTruthy();
131+
// 第 3 步的示例行
132+
fireEvent.click(screen.getByTestId("wizard-next"));
133+
expect(await screen.findByTestId("wizard-example-3")).toBeTruthy();
134+
});
120135
});

‎app/src/components/KnowledgeSystemWizard.tsx‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ const GUIDE = {
3232
step3: "本周你想产出的第一个可验证输出(可选)。写下一个具体成果,它会成为一个「场景」节点,提醒你体系要产出、不要囤积。",
3333
};
3434

35+
/** 每步示例行(纯参考·不预填——示例≠预填纪律) */
36+
const EXAMPLES: Record<1 | 2 | 3, string> = {
37+
1: "例如:如何让化妆又快又自然?",
38+
2: "例如:底妆 / 眼妆 / 发型",
39+
3: "例如:本周完成一个 5 分钟通勤妆视频",
40+
};
41+
3542
export default function KnowledgeSystemWizard({ onClose, onCreated }: Props) {
3643
const [step, setStep] = useState<1 | 2 | 3>(1);
3744
const [name, setName] = useState("");
@@ -170,6 +177,9 @@ export default function KnowledgeSystemWizard({ onClose, onCreated }: Props) {
170177
<div style={{ padding: "16px 18px" }}>
171178
<div style={{ fontSize: 13, fontWeight: 600, marginBottom: 8 }}>{stepTitle(step)}</div>
172179
<p style={{ fontSize: 12, color: "#6b7280", margin: "0 0 12px", lineHeight: 1.6 }}>{GUIDE[`step${step}`]}</p>
180+
<p data-testid={`wizard-example-${step}`} style={{ fontSize: 11, color: "#0f766e", background: "#f0fdfa", border: "1px dashed #99f6e4", borderRadius: 6, padding: "6px 10px", margin: "0 0 12px" }}>
181+
{EXAMPLES[step]}
182+
</p>
173183

174184
{step === 1 && (
175185
<div style={{ display: "flex", flexDirection: "column", gap: 10 }}>

0 commit comments

Comments
 (0)