From 04c449e8f207c1874c13c88a96ae7fe4a1e640ba Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 1 Feb 2026 12:04:06 +0900 Subject: feat(study): add Space key as Good rating shortcut when card is flipped Allow continuous study flow by pressing Space repeatedly - first to flip the card, then to rate as Good (3). Co-Authored-By: Claude Opus 4.5 --- src/client/pages/StudyPage.test.tsx | 26 ++++++++++++++++++++++++++ src/client/pages/StudyPage.tsx | 1 + 2 files changed, 27 insertions(+) (limited to 'src/client') diff --git a/src/client/pages/StudyPage.test.tsx b/src/client/pages/StudyPage.test.tsx index dfadea9..68a7bb3 100644 --- a/src/client/pages/StudyPage.test.tsx +++ b/src/client/pages/StudyPage.test.tsx @@ -518,6 +518,32 @@ describe("StudyPage", () => { ); }); + it("rates card as Good with Space key when card is flipped", async () => { + const user = userEvent.setup(); + + mockStudyPost.mockResolvedValue({ + card: { ...mockFirstCard, reps: 1 }, + }); + + renderWithProviders({ + initialStudyData: { deck: mockDeck, cards: mockDueCards }, + }); + + await user.keyboard(" "); // Flip + await user.keyboard(" "); // Rate as Good (Space) + + await waitFor(() => { + expect(screen.getByTestId("card-front").textContent).toBe("Goodbye"); + }); + + expect(mockStudyPost).toHaveBeenCalledWith( + expect.objectContaining({ + param: { deckId: "deck-1", cardId: "card-1" }, + json: expect.objectContaining({ rating: 3 }), + }), + ); + }); + it("supports all rating keys (1, 2, 3, 4)", async () => { const user = userEvent.setup(); diff --git a/src/client/pages/StudyPage.tsx b/src/client/pages/StudyPage.tsx index dd82b27..9c79752 100644 --- a/src/client/pages/StudyPage.tsx +++ b/src/client/pages/StudyPage.tsx @@ -110,6 +110,7 @@ function StudySession({ deckId }: { deckId: string }) { "2": 2, "3": 3, "4": 4, + " ": 3, }; const rating = keyRatingMap[e.key]; -- cgit v1.3-1-g0d28