aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/client
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-01 12:04:06 +0900
committernsfisis <nsfisis@gmail.com>2026-02-01 12:04:06 +0900
commit04c449e8f207c1874c13c88a96ae7fe4a1e640ba (patch)
tree644fc11066992bd26276d0329fb4cefa03e06873 /src/client
parenta07dada0c9ba80976692ee14e256da0a2d6b0112 (diff)
downloadkioku-04c449e8f207c1874c13c88a96ae7fe4a1e640ba.tar.gz
kioku-04c449e8f207c1874c13c88a96ae7fe4a1e640ba.tar.zst
kioku-04c449e8f207c1874c13c88a96ae7fe4a1e640ba.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'src/client')
-rw-r--r--src/client/pages/StudyPage.test.tsx26
-rw-r--r--src/client/pages/StudyPage.tsx1
2 files changed, 27 insertions, 0 deletions
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];