mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
[w9-2] Add 90d window, time-window selector, and chart/table toggle (#528)
Backend: widen usage _PeriodType to 24h/7d/30d/90d and add a 90d branch to _parse_period (daily buckets already cover it). TestParsePeriod pins the contract per window. Frontend: UsagePeriod += 90d with a scaleFor helper (replacing 6 inline ternaries) and 90 daily mock points. One generic SegmentedControl primitive (reuses Radix Tabs) drives both the metrics time-window selector (24h/7d/30d/90d) and the per-chart Chart/Table view toggle — one file, two roles. The Token Usage & Costs tab drops 8 hardcoded '24h' hooks for a single period state + selector; the stale '(24h)' cost-card parenthetical goes too. The Performance landing tab gains a TaskStatusChart donut fed by the status counts already on the page (no new hook). Agent/team bar charts gain an inline table view. Co-authored-by: Renn F <rennf93@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { TaskStatusChart } from "../task-status-chart";
|
||||
|
||||
describe("TaskStatusChart", () => {
|
||||
it("renders the card title", () => {
|
||||
render(
|
||||
<TaskStatusChart
|
||||
slices={[
|
||||
{ name: "Completed", value: 5 },
|
||||
{ name: "Pending", value: 0 },
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
expect(
|
||||
screen.getByText("Task Status Distribution"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows an empty state when every slice is zero", () => {
|
||||
render(
|
||||
<TaskStatusChart
|
||||
slices={[
|
||||
{ name: "Pending", value: 0 },
|
||||
{ name: "Completed", value: 0 },
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByText("No tasks")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("does not show the empty state while loading", () => {
|
||||
render(
|
||||
<TaskStatusChart
|
||||
slices={[{ name: "Pending", value: 0 }]}
|
||||
isLoading
|
||||
/>,
|
||||
);
|
||||
expect(screen.queryByText("No tasks")).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user