promote: Parça Uzmanları programı (flag-gated) + revert düzeltmesi #132
@@ -44,7 +44,7 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
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({
|
||||
votes: { "8V0615423E": { compatible: 4, incompatible: 1, myVote: "compatible" } },
|
||||
});
|
||||
@@ -60,10 +60,11 @@ describe("OemVoteCard", () => {
|
||||
const downButton = screen.getByRole("button", { name: /Uyumsuz/ });
|
||||
await waitFor(() => {
|
||||
expect(api.post).toHaveBeenCalledWith("/oem-votes/lookup", { codes: ["8V0615423E"] });
|
||||
expect(upButton.textContent).toContain("4");
|
||||
expect(downButton.textContent).toContain("1");
|
||||
expect(upButton).toHaveAttribute("aria-pressed", "true");
|
||||
});
|
||||
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 () => {
|
||||
@@ -99,7 +100,6 @@ describe("OemVoteCard", () => {
|
||||
expect.objectContaining({ oem_code: "X1", vote: "incompatible", surface: "oem_detail" }),
|
||||
);
|
||||
});
|
||||
expect(downButton.textContent).toContain("1");
|
||||
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 = [
|
||||
{
|
||||
vote: "compatible" as const,
|
||||
icon: ThumbsUp,
|
||||
label: "Uyumlu",
|
||||
count: summary?.compatible ?? 0,
|
||||
activeClass: "border-green-500/50 bg-green-500/10 text-green-500",
|
||||
},
|
||||
{
|
||||
vote: "incompatible" as const,
|
||||
icon: ThumbsDown,
|
||||
label: "Uyumsuz",
|
||||
count: summary?.incompatible ?? 0,
|
||||
activeClass: "border-red-500/50 bg-red-500/10 text-red-500",
|
||||
},
|
||||
];
|
||||
@@ -137,7 +137,7 @@ export function OemVoteCard({
|
||||
</p>
|
||||
)}
|
||||
<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;
|
||||
return (
|
||||
<button
|
||||
@@ -155,7 +155,6 @@ export function OemVoteCard({
|
||||
>
|
||||
<Icon className="size-4 shrink-0" fill={isActive ? "currentColor" : "none"} />
|
||||
{label}
|
||||
<span className="font-semibold tabular-nums">{count}</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
|
||||
Reference in New Issue
Block a user