Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5aa29bf
feat(grammar): persist versioned practice sessions and history (#157)
Yelihi Oct 5, 2026
6906ace
fix(grammar): exclude unreviewed examples from practice snapshots (#157)
Yelihi Oct 5, 2026
a1247c8
refactor(grammar): align reviewed code conventions for PR #172
Yelihi Oct 6, 2026
6b2139c
fix: address grammar editor review feedback (#168)
Yelihi Oct 8, 2026
f92e2c2
Merge remote-tracking branch 'origin/feature/153-grammar-note-editor'…
Yelihi Oct 8, 2026
29e90c5
refactor: apply shared review rules to example editing (#169)
Yelihi Oct 8, 2026
9da2a94
Merge remote-tracking branch 'origin/feature/155-grammar-library' int…
Yelihi Oct 8, 2026
373c231
Merge remote-tracking branch 'origin/feature/156-grammar-audio' into …
Yelihi Oct 8, 2026
7a160e3
refactor: keep audio error presentation in UI (#171)
Yelihi Oct 8, 2026
53ec936
Merge remote-tracking branch 'origin/feature/157-grammar-sessions' in…
Yelihi Oct 8, 2026
bf85fd7
refactor: return session error codes at server boundary (#172)
Yelihi Oct 8, 2026
4060df5
Merge branch 'fix/review-pr170-20261008' into fix/grammar-readable-st…
Yelihi Oct 8, 2026
5096396
style: separate logical blocks for PR #169
Yelihi Oct 8, 2026
7ac5598
Merge branch 'fix/review-pr171-20261008' into fix/grammar-readable-st…
Yelihi Oct 8, 2026
16f6239
style: separate logical blocks for PR #170
Yelihi Oct 8, 2026
19d7e7e
Merge branch 'fix/review-pr172-20261008' into fix/grammar-readable-st…
Yelihi Oct 8, 2026
2792c46
style: separate logical blocks for PR #171
Yelihi Oct 8, 2026
324fca9
style: separate logical blocks for PR #172
Yelihi Oct 8, 2026
27dc912
refactor: reuse auth checks and isolate example generation and adopti…
Yelihi Oct 8, 2026
0d8f298
fix: separate login server exports from client entry (#169)
Yelihi Oct 8, 2026
acf1a09
Merge remote-tracking branch 'origin/feature/155-grammar-library' int…
Yelihi Oct 8, 2026
c699fa8
Merge remote-tracking branch 'origin/feature/156-grammar-audio' into …
Yelihi Oct 8, 2026
658c02d
Merge remote-tracking branch 'origin/feature/157-grammar-sessions' in…
Yelihi Oct 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import type { Meta, StoryObj } from "@storybook/nextjs-vite";
import { expect, fn, userEvent, within } from "storybook/test";
import { GrammarAudioButton } from "@/features/grammar-audio";

const meta = {
title: "Features/Grammar/Audio",
component: GrammarAudioButton,
args: {
input: { noteId: "note", sentenceId: "source", noteVersion: 1 },
generate: fn(async () => ({ ok: false as const, message: "음성 생성에 실패했습니다." })),
generate: fn(async () => ({ ok: false as const, code: "GENERATION_FAILED" as const })),
},
} satisfies Meta<typeof GrammarAudioButton>;

export default meta;

type Story = StoryObj<typeof meta>;

export const GenerateFailure: Story = {
play: async ({ canvasElement, args }) => {
const canvas = within(canvasElement);

await userEvent.click(canvas.getByRole("button", { name: "문장 듣기" }));
await expect(canvas.getByRole("alert")).toHaveTextContent("음성 생성에 실패");
await userEvent.click(canvas.getByRole("button", { name: "음성 다시 생성" }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {
} from "@/features/grammar-example-generation";
import { createEditorNote } from "@/_tests/features/grammar-note-editor/fixtures";
import { createExampleCandidates } from "@/_tests/features/grammar-example-generation/fixtures";

const note = createEditorNote();

const meta = {
title: "features/grammar-example-generation/GrammarExampleManager",
component: GrammarExampleManager,
Expand All @@ -31,12 +33,17 @@ const meta = {
),
],
} satisfies Meta<typeof GrammarExampleManager>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Empty: Story = {};

export const SelectAndSave: Story = {
play: async ({ canvasElement, args }) => {
const canvas = within(canvasElement);

await userEvent.click(canvas.getByRole("button", { name: "예문 3개 생성" }));
await expect(await canvas.findAllByRole("checkbox")).toHaveLength(3);
await userEvent.click(canvas.getAllByRole("checkbox")[0]);
Expand All @@ -45,30 +52,36 @@ export const SelectAndSave: Story = {
await expect(canvas.getAllByRole("checkbox")).toHaveLength(2);
},
};

export const Retry: Story = {
args: {
generate: fn<GrammarExampleManagerProps["generate"]>(async () => ({
ok: true,
data: createExampleCandidates(),
})),
},

play: async ({ canvasElement, args }) => {
args.generate.mockResolvedValueOnce({
ok: false,
message: "생성에 실패했습니다. 다시 생성해 주세요.",
code: "FAILED",
});
const canvas = within(canvasElement);

await userEvent.click(canvas.getByRole("button", { name: "예문 3개 생성" }));
await expect(await canvas.findByRole("alert")).toBeVisible();
await userEvent.click(canvas.getByRole("button", { name: "예문 다시 생성" }));
await expect(await canvas.findAllByRole("checkbox")).toHaveLength(3);
},
};

export const EditCandidate: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);

await userEvent.click(canvas.getByRole("button", { name: "예문 3개 생성" }));
const input = (await canvas.findAllByLabelText("한국어 뜻"))[0];

await userEvent.clear(input);
await userEvent.type(input, "그는 운전사가 아니라 교사입니다.");
await expect(input).toHaveValue("그는 운전사가 아니라 교사입니다.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import type { GrammarNoteEditorProps } from "@/features/grammar-note-editor";
import { GrammarNoteEditor } from "@/features/grammar-note-editor";
import { GrammarAnalysisEditor } from "@/features/grammar-analysis-edit";
import { createEditorNote } from "@/_tests/features/grammar-note-editor/fixtures";

const note = createEditorNote();

const meta = {
title: "features/grammar-note-editor/GrammarNoteEditor",
component: GrammarNoteEditor,
Expand All @@ -29,36 +31,46 @@ const meta = {
),
],
} satisfies Meta<typeof GrammarNoteEditor>;

export default meta;

type Story = StoryObj<typeof meta>;

export const EmptyInput: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);

await userEvent.click(canvas.getByRole("button", { name: "문장 분석하기" }));
await expect(canvas.getAllByRole("alert")).toHaveLength(2);
await expect(canvas.queryByLabelText("제목")).not.toBeInTheDocument();
},
};

export const ReviewAndSave: Story = {
args: { initialNote: note },

play: async ({ canvasElement, args }) => {
const canvas = within(canvasElement);

await expect(canvas.getByRole("button", { name: "검토 완료 · 노트 저장" })).toBeDisabled();
await userEvent.click(canvas.getByRole("checkbox"));
await userEvent.click(canvas.getByRole("button", { name: "검토 완료 · 노트 저장" }));
await expect(args.onSaved).toHaveBeenCalled();
},
};

export const SaveFailure: Story = {
args: {
initialNote: note,
save: fn<GrammarNoteEditorProps["save"]>(async () => ({
ok: false as const,
message: "노트를 저장하지 못했습니다. 다시 저장해 주세요.",
code: "PERSISTENCE_FAILED",
})),
},

play: async ({ canvasElement }) => {
const canvas = within(canvasElement);

await userEvent.click(canvas.getByRole("checkbox"));
await userEvent.click(canvas.getByRole("button", { name: "검토 완료 · 노트 저장" }));
await expect(await canvas.findByRole("alert")).toBeVisible();
Expand All @@ -70,6 +82,7 @@ export const SaveFailure: Story = {
export const AnalyzeThenReview: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);

await userEvent.type(canvas.getByLabelText(/영어 문장/), note.source.sentence);
await userEvent.type(canvas.getByLabelText(/핵심 어법 설명/), note.source.learningNote);
await userEvent.click(canvas.getByRole("button", { name: "문장 분석하기" }));
Expand All @@ -78,10 +91,13 @@ export const AnalyzeThenReview: Story = {
await expect(canvas.getByLabelText(/영어 문장/)).toHaveValue(note.source.sentence);
},
};

export const UnappliedAnalysisBlocksSave: Story = {
args: { initialNote: note },

play: async ({ canvasElement }) => {
const canvas = within(canvasElement);

await userEvent.click(canvas.getByRole("button", { name: "She" }));
await userEvent.click(canvas.getByRole("button", { name: "분석 수정" }));
await userEvent.type(canvas.getByLabelText("직독직해"), " 수정");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import type { Meta, StoryObj } from "@storybook/nextjs-vite";
import { expect, within } from "storybook/test";
import { GrammarNoteList } from "@/views/grammar-library";

const meta = {
title: "Views/Grammar/Note list",
component: GrammarNoteList,
args: { query: "", data: { items: [], total: 0, page: 1, pageSize: 20 } },
} satisfies Meta<typeof GrammarNoteList>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Empty: Story = {
play: async ({ canvasElement }) => {
await expect(within(canvasElement).getByText("첫 어법 노트를 만들어보세요")).toBeVisible();
},
};

export const SearchEmpty: Story = { args: { query: "unknown" } };

export const Notes: Story = {
args: {
query: "not",
Expand All @@ -35,8 +41,10 @@ export const Notes: Story = {
],
},
},

play: async ({ canvasElement }) => {
const canvas = within(canvasElement);

await expect(canvas.getByRole("link", { name: /not A but B/ })).toHaveAttribute(
"href",
expect.stringContaining("returnTo=%2Fgrammar%3Fq%3Dnot%26page%3D2"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe("grammar analysis review below the sentence", () => {
it("selects a chunk and edits its explanation without losing the source", async () => {
const user = userEvent.setup();
const onChange = jest.fn();

render(<GrammarAnalysisEditor initialAnalysis={createGrammarAnalysis()} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "She" }));
await user.click(screen.getByRole("button", { name: "분석 수정" }));
Expand All @@ -22,9 +23,11 @@ describe("grammar analysis review below the sentence", () => {
}),
);
});

it("keeps an invalid hierarchy draft visible with a recoverable error", async () => {
const user = userEvent.setup();
const onChange = jest.fn();

render(<GrammarAnalysisEditor initialAnalysis={createGrammarAnalysis()} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "분석 수정" }));
await user.click(screen.getByRole("button", { name: "절" }));
Expand All @@ -41,6 +44,7 @@ describe("grammar analysis review below the sentence", () => {

it("asks before leaving an unapplied edit and preserves input when continuing", async () => {
const user = userEvent.setup();

render(<GrammarAnalysisEditor initialAnalysis={createGrammarAnalysis()} onChange={jest.fn()} />);
await user.click(screen.getByRole("button", { name: "She" }));
await user.click(screen.getByRole("button", { name: "분석 수정" }));
Expand All @@ -57,6 +61,7 @@ it("asks before leaving an unapplied edit and preserves input when continuing",
it("shows AI chunks for reading and keeps correction controls behind edit mode", async () => {
const user = userEvent.setup();
const onChange = jest.fn();

render(<GrammarAnalysisEditor initialAnalysis={createGrammarAnalysis()} onChange={onChange} />);
expect(screen.queryByRole("button", { name: "절" })).not.toBeInTheDocument();
await user.click(screen.getByRole("button", { name: "She" }));
Expand All @@ -72,6 +77,7 @@ it("shows AI chunks for reading and keeps correction controls behind edit mode",
it("guards returning to reading and restores the selected chunk after discarding edits", async () => {
const user = userEvent.setup();
const onChange = jest.fn();

render(<GrammarAnalysisEditor initialAnalysis={createGrammarAnalysis()} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "She" }));
await user.click(screen.getByRole("button", { name: "분석 수정" }));
Expand All @@ -92,6 +98,7 @@ it("isolates selection and edits between mounted editors", async () => {
const user = userEvent.setup();
const firstChange = jest.fn();
const secondChange = jest.fn();

render(
<>
<section aria-label="첫 번째 노트">
Expand All @@ -104,6 +111,7 @@ it("isolates selection and edits between mounted editors", async () => {
);
const first = within(screen.getByRole("region", { name: "첫 번째 노트" }));
const second = within(screen.getByRole("region", { name: "두 번째 노트" }));

await user.click(first.getByRole("button", { name: "She" }));
expect(second.getByRole("button", { name: "She" })).toHaveAttribute("aria-pressed", "false");
await user.click(first.getByRole("button", { name: "분석 수정" }));
Expand All @@ -118,16 +126,32 @@ it("preserves drafts on parent rerender and notifies the current callback", asyn
const user = userEvent.setup();
const original = jest.fn();
const current = jest.fn();
const originalDirty = jest.fn();
const currentDirty = jest.fn();
const { rerender } = render(
<GrammarAnalysisEditor initialAnalysis={createGrammarAnalysis()} onChange={original} />,
<GrammarAnalysisEditor
initialAnalysis={createGrammarAnalysis()}
onChange={original}
onDirtyChange={originalDirty}
/>,
);

await user.click(screen.getByRole("button", { name: "분석 수정" }));
await user.type(screen.getByLabelText("직독직해"), " 수정");
rerender(<GrammarAnalysisEditor initialAnalysis={createGrammarAnalysis()} onChange={current} />);
expect(originalDirty.mock.calls).toEqual([[true]]);
rerender(
<GrammarAnalysisEditor
initialAnalysis={createGrammarAnalysis()}
onChange={current}
onDirtyChange={currentDirty}
/>,
);
expect(screen.getByLabelText("직독직해")).toHaveValue("그녀는 수정");
await user.click(screen.getByRole("button", { name: "풀이 적용" }));
expect(original).not.toHaveBeenCalled();
expect(current).toHaveBeenCalledTimes(1);
expect(originalDirty.mock.calls).toEqual([[true]]);
expect(currentDirty.mock.calls).toEqual([[false]]);
});

it("starts a fresh editor when the document key changes", async () => {
Expand All @@ -140,9 +164,11 @@ it("starts a fresh editor when the document key changes", async () => {
onChange={onChange}
/>,
);

await user.click(screen.getByRole("button", { name: "분석 수정" }));
await user.type(screen.getByLabelText("직독직해"), " 수정");
const next = createGrammarAnalysis();

rerender(
<GrammarAnalysisEditor
key="note-2"
Expand All @@ -161,6 +187,7 @@ it("starts a fresh editor when the document key changes", async () => {

it("keeps the editor draft when Escape dismisses the confirmation dialog", async () => {
const user = userEvent.setup();

render(<GrammarAnalysisEditor initialAnalysis={createGrammarAnalysis()} onChange={jest.fn()} />);
await user.click(screen.getByRole("button", { name: "분석 수정" }));
await user.type(screen.getByLabelText("직독직해"), " 수정");
Expand All @@ -174,9 +201,11 @@ it("keeps the editor draft when Escape dismisses the confirmation dialog", async
it("applies current text with a boundary edit and keeps input after validation failure", async () => {
const user = userEvent.setup();
const onChange = jest.fn();

render(<GrammarAnalysisEditor initialAnalysis={createGrammarAnalysis()} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "분석 수정" }));
const input = screen.getByLabelText("직독직해");

// 도메인 길이 제한을 넘는 입력에도 다른 편집 후보를 반영하지 않는다.
fireEvent.change(input, { target: { value: "x".repeat(4001) } });
await user.selectOptions(screen.getByLabelText("다음 구간과의 경계"), "3");
Expand Down
Loading