-
Notifications
You must be signed in to change notification settings - Fork 0
fix(ui): Stabilize WatchButton text #814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
01d95c7
920b2a4
858f4d6
0716313
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,40 @@ | ||||||||||||||||||||||||||||||
| import { render, screen, fireEvent, waitFor } from "@testing-library/react"; | ||||||||||||||||||||||||||||||
| import { describe, it, expect, vi } from "vitest"; | ||||||||||||||||||||||||||||||
| import { WatchButton } from "./WatchButton"; | ||||||||||||||||||||||||||||||
| import React from "react"; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // Mock the server action | ||||||||||||||||||||||||||||||
| vi.mock("~/app/(app)/issues/watcher-actions", () => ({ | ||||||||||||||||||||||||||||||
| toggleWatcherAction: vi.fn(), | ||||||||||||||||||||||||||||||
| })); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| import { toggleWatcherAction } from "~/app/(app)/issues/watcher-actions"; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| import React from "react"; | |
| // Mock the server action | |
| vi.mock("~/app/(app)/issues/watcher-actions", () => ({ | |
| toggleWatcherAction: vi.fn(), | |
| })); | |
| import { toggleWatcherAction } from "~/app/(app)/issues/watcher-actions"; | |
| import { toggleWatcherAction } from "~/app/(app)/issues/watcher-actions"; | |
| // Mock the server action | |
| vi.mock("~/app/(app)/issues/watcher-actions", () => ({ | |
| toggleWatcherAction: vi.fn(), | |
| })); |
Outdated
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using any type violates the TypeScript strictest patterns guideline. Instead, mock the function with proper typing. For example: vi.mocked(toggleWatcherAction).mockResolvedValue({ ok: true, value: { isWatching: true } }) after importing the function, or create a properly typed mock variable.
Outdated
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test should verify that the loading spinner is shown during the pending state, similar to how login-form.test.tsx validates the spinner presence (lines 59-61 in that file). Since the PR's purpose is to rely on the loading spinner instead of dynamic text, validating spinner behavior is important to ensure the change achieves its stated goal of indicating loading state.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,12 +48,12 @@ export function WatchButton({ | |
| {isWatching ? ( | ||
| <> | ||
| {!isPending && <EyeOff className="size-4" />} | ||
| {isPending ? "Unwatching..." : "Unwatch Issue"} | ||
| Unwatch Issue | ||
| </> | ||
| ) : ( | ||
| <> | ||
| {!isPending && <Eye className="size-4" />} | ||
| {isPending ? "Watching..." : "Watch Issue"} | ||
| Watch Issue | ||
|
Comment on lines
+51
to
+56
|
||
| </> | ||
| )} | ||
| </Button> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test file should be located in
src/test/unit/components/issues/instead of directly alongside the component file. This follows the established pattern seen insrc/test/unit/components/auth/login-form.test.tsxand maintains clear separation between source and test code as documented insrc/test/README.md.