diff --git a/frontend/src/components/IssueBacklog.test.tsx b/frontend/src/components/IssueBacklog.test.tsx index e67a96e..7c251a6 100644 --- a/frontend/src/components/IssueBacklog.test.tsx +++ b/frontend/src/components/IssueBacklog.test.tsx @@ -1,79 +1,3 @@ -import { render, screen, fireEvent } from "@testing-library/react"; -import { describe, expect, it } from "vitest"; -import { IssueBacklog } from "./IssueBacklog"; -import { OpenIssue } from "../types/stream"; -const issues: OpenIssue[] = [ - { - id: "medium-api", - title: "Add API pagination", - labels: ["api", "backend"], - summary: "Paginate API responses.", - complexity: "Medium", - points: 150, - }, - { - id: "trivial-docs", - title: "Document local setup", - labels: ["documentation"], - summary: "Add local setup notes.", - complexity: "Trivial", - points: 100, - }, - { - id: "high-ui", - title: "Improve dashboard filters", - labels: ["frontend", "ux"], - summary: "Add better filtering controls.", - complexity: "High", - points: 200, - }, -]; - -describe("IssueBacklog", () => { - it("sorts issues by points from high to low by default", () => { - render(); - - const titles = screen - .getAllByRole("heading", { level: 3 }) - .map((heading) => heading.textContent); - - expect(titles).toEqual([ - "Improve dashboard filters", - "Add API pagination", - "Document local setup", - ]); - }); - - it("filters issues by label", () => { - render(); - - fireEvent.change(screen.getByLabelText("Filter issues by label"), { - target: { value: "documentation" }, - }); - - expect(screen.getByText("Document local setup")).toBeInTheDocument(); - expect(screen.queryByText("Add API pagination")).not.toBeInTheDocument(); - expect( - screen.queryByText("Improve dashboard filters"), - ).not.toBeInTheDocument(); - }); - - it("sorts issues by title", () => { - render(); - - fireEvent.change(screen.getByLabelText("Sort issues"), { - target: { value: "title" }, - }); - - const titles = screen - .getAllByRole("heading", { level: 3 }) - .map((heading) => heading.textContent); - - expect(titles).toEqual([ - "Add API pagination", - "Document local setup", - "Improve dashboard filters", - ]); }); }); diff --git a/frontend/src/components/IssueBacklog.tsx b/frontend/src/components/IssueBacklog.tsx index ebcaeed..e866782 100644 --- a/frontend/src/components/IssueBacklog.tsx +++ b/frontend/src/components/IssueBacklog.tsx @@ -1,6 +1,14 @@ -import { useMemo, useState } from "react"; + import { OpenIssue } from "../types/stream"; +type SortKey = "none" | "complexity-asc" | "points-asc" | "points-desc"; + +const COMPLEXITY_ORDER: Record = { + Trivial: 0, + Medium: 1, + High: 2, +}; + interface IssueBacklogProps { issues: OpenIssue[]; loading?: boolean; @@ -15,35 +23,7 @@ const complexityRank: Record = { }; export function IssueBacklog({ issues, loading }: IssueBacklogProps) { - const [selectedLabel, setSelectedLabel] = useState(""); - const [sortBy, setSortBy] = useState("points-desc"); - const labels = useMemo( - () => Array.from(new Set(issues.flatMap((issue) => issue.labels))).sort(), - [issues], - ); - - const visibleIssues = useMemo(() => { - const filtered = selectedLabel - ? issues.filter((issue) => issue.labels.includes(selectedLabel)) - : issues; - - return [...filtered].sort((a, b) => { - if (sortBy === "points-asc") { - return a.points - b.points; - } - - if (sortBy === "complexity") { - return complexityRank[a.complexity] - complexityRank[b.complexity]; - } - - if (sortBy === "title") { - return a.title.localeCompare(b.title); - } - - return b.points - a.points; - }); - }, [issues, selectedLabel, sortBy]); if (loading) { return ( @@ -51,11 +31,7 @@ export function IssueBacklog({ issues, loading }: IssueBacklogProps) {

Maintainer Backlog

{[1, 2, 3].map((i) => ( -
+ ))}
@@ -65,40 +41,7 @@ export function IssueBacklog({ issues, loading }: IssueBacklogProps) { return (

Maintainer Backlog

-

- Open these as GitHub issues after publishing the repository. -

- -
- -
{visibleIssues.length === 0 ? (