polish(web): oy butonlarından sayaçları kaldır
Uyumlu/Uyumsuz butonlarında oy sayıları artık görünmüyor (çoğunluğu ele vermek oyu yönlendiriyordu); özet yine çekilir — kullanıcının kendi oyu butonda işaretli kalır. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -44,7 +44,7 @@ afterEach(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("OemVoteCard", () => {
|
describe("OemVoteCard", () => {
|
||||||
it("loads the summary for the code and shows the counts", async () => {
|
it("loads the summary, marks my vote and hides the tallies", async () => {
|
||||||
vi.mocked(api.post).mockResolvedValue({
|
vi.mocked(api.post).mockResolvedValue({
|
||||||
votes: { "8V0615423E": { compatible: 4, incompatible: 1, myVote: "compatible" } },
|
votes: { "8V0615423E": { compatible: 4, incompatible: 1, myVote: "compatible" } },
|
||||||
});
|
});
|
||||||
@@ -60,10 +60,11 @@ describe("OemVoteCard", () => {
|
|||||||
const downButton = screen.getByRole("button", { name: /Uyumsuz/ });
|
const downButton = screen.getByRole("button", { name: /Uyumsuz/ });
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(api.post).toHaveBeenCalledWith("/oem-votes/lookup", { codes: ["8V0615423E"] });
|
expect(api.post).toHaveBeenCalledWith("/oem-votes/lookup", { codes: ["8V0615423E"] });
|
||||||
expect(upButton.textContent).toContain("4");
|
expect(upButton).toHaveAttribute("aria-pressed", "true");
|
||||||
expect(downButton.textContent).toContain("1");
|
|
||||||
});
|
});
|
||||||
expect(upButton).toHaveAttribute("aria-pressed", "true");
|
// sayaçlar butonlarda görünmez (çoğunluk oyu yönlendirmesin)
|
||||||
|
expect(upButton.textContent).not.toContain("4");
|
||||||
|
expect(downButton.textContent).not.toContain("1");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("casts a vote, updates the counts and reports the points", async () => {
|
it("casts a vote, updates the counts and reports the points", async () => {
|
||||||
@@ -99,7 +100,6 @@ describe("OemVoteCard", () => {
|
|||||||
expect.objectContaining({ oem_code: "X1", vote: "incompatible", surface: "oem_detail" }),
|
expect.objectContaining({ oem_code: "X1", vote: "incompatible", surface: "oem_detail" }),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
expect(downButton.textContent).toContain("1");
|
|
||||||
expect(downButton).toHaveAttribute("aria-pressed", "true");
|
expect(downButton).toHaveAttribute("aria-pressed", "true");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -104,19 +104,19 @@ export function OemVoteCard({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Sayaçlar bilinçli olarak gösterilmiyor (çoğunluğu ele vermek oyu yönlendirir);
|
||||||
|
// özet yine de çekilir — kullanıcının kendi oyu butonda işaretli kalır.
|
||||||
const options = [
|
const options = [
|
||||||
{
|
{
|
||||||
vote: "compatible" as const,
|
vote: "compatible" as const,
|
||||||
icon: ThumbsUp,
|
icon: ThumbsUp,
|
||||||
label: "Uyumlu",
|
label: "Uyumlu",
|
||||||
count: summary?.compatible ?? 0,
|
|
||||||
activeClass: "border-green-500/50 bg-green-500/10 text-green-500",
|
activeClass: "border-green-500/50 bg-green-500/10 text-green-500",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
vote: "incompatible" as const,
|
vote: "incompatible" as const,
|
||||||
icon: ThumbsDown,
|
icon: ThumbsDown,
|
||||||
label: "Uyumsuz",
|
label: "Uyumsuz",
|
||||||
count: summary?.incompatible ?? 0,
|
|
||||||
activeClass: "border-red-500/50 bg-red-500/10 text-red-500",
|
activeClass: "border-red-500/50 bg-red-500/10 text-red-500",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -137,7 +137,7 @@ export function OemVoteCard({
|
|||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
<div className="mt-3 flex gap-2">
|
<div className="mt-3 flex gap-2">
|
||||||
{options.map(({ vote, icon: Icon, label, count, activeClass }) => {
|
{options.map(({ vote, icon: Icon, label, activeClass }) => {
|
||||||
const isActive = summary?.myVote === vote;
|
const isActive = summary?.myVote === vote;
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
@@ -155,7 +155,6 @@ export function OemVoteCard({
|
|||||||
>
|
>
|
||||||
<Icon className="size-4 shrink-0" fill={isActive ? "currentColor" : "none"} />
|
<Icon className="size-4 shrink-0" fill={isActive ? "currentColor" : "none"} />
|
||||||
{label}
|
{label}
|
||||||
<span className="font-semibold tabular-nums">{count}</span>
|
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
Reference in New Issue
Block a user