Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(web): announce the scheduled range in calendar task bars

FVOCI12dae3b806bc
diff --git a/apps/web/src/components/calendar/calendar-task-bar.test.tsx b/apps/web/src/components/calendar/calendar-task-bar.test.tsx
new file mode 100644
index 000000000..91f2d3357
--- /dev/null
+++ b/apps/web/src/components/calendar/calendar-task-bar.test.tsx
@@ -0,0 +1,91 @@
+import enUS from "@i18n/en-US.json";
+import { cleanup, render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import CalendarTaskBar from "./calendar-task-bar";
+
+afterEach(() => {
+ cleanup();
+ document.body.innerHTML = "";
+});
+
+// Formats from local parts, so the expected label does not move with the
+// runner's timezone the way toISOString would.
+vi.mock("@/lib/format", () => ({
+ formatDateShort: (value: Date) =>
+ [
+ value.getFullYear(),
+ String(value.getMonth() + 1).padStart(2, "0"),
+ String(value.getDate()).padStart(2, "0"),
+ ].join("-"),
+}));
+
+/**
+ * Resolves against the real en-US bundle and applies i18next-style
+ * interpolation, so the assertions fail if the key stops passing a value the
+ * source string expects.
+ */
+vi.mock("react-i18next", () => ({
+ useTranslation: () => ({
+ t: (key: string, options?: Record<string, unknown>) => {
+ const [namespace, path] = key.split(":");
+ const source = path
+ .split(".")
+ .reduce<unknown>(
+ (accumulator, part) =>
+ (accumulator as Record<string, unknown> | undefined)?.[part],
+ (enUS as Record<string, unknown>)[namespace],
+ );
+
+ if (typeof source !== "string") return key;
+
+ return source.replace(/\{\{(\w+)\}\}/g, (_match, name: string) =>
+ String(options?.[name] ?? `{{${name}}}`),
+ );
+ },
+ }),
+}));
+
+const segment = {
+ task: {
+ id: "t1",
+ title: "Design review",
+ number: 12,
+ scheduleStart: new Date(2026, 7, 10),
+ scheduleEnd: new Date(2026, 7, 12),
+ },
+ lane: 0,
+ columnStart: 1,
+ columnEnd: 4,
+ continuesBefore: false,
+ continuesAfter: false,
+};
+
+describe("CalendarTaskBar", () => {
+ it("announces the task title and its scheduled range", () => {
+ render(
+ <CalendarTaskBar
+ segment={segment}
+ projectSlug="KAN"
+ onOpenTask={vi.fn()}
+ />,
+ );
+
+ expect(screen.getByRole("button")).toHaveAccessibleName(
+ "Design review, 2026-08-10 – 2026-08-12: open task",
+ );
+ });
+
+ it("leaves no interpolation placeholder unresolved", () => {
+ render(
+ <CalendarTaskBar
+ segment={segment}
+ projectSlug="KAN"
+ onOpenTask={vi.fn()}
+ />,
+ );
+
+ const label = screen.getByRole("button").getAttribute("aria-label") ?? "";
+
+ expect(label).not.toMatch(/\{\{\w+\}\}/);
+ });
+});
diff --git a/apps/web/src/components/calendar/calendar-task-bar.tsx b/apps/web/src/components/calendar/calendar-task-bar.tsx
index 066c6cd12..88397320c 100644
--- a/apps/web/src/components/calendar/calendar-task-bar.tsx
+++ b/apps/web/src/components/calendar/calendar-task-bar.tsx
@@ -52,7 +52,10 @@ export default function CalendarTaskBar({
? `${taskKey} · ${task.title} · ${range}`
: `${task.title} · ${range}`
}
- aria-label={t("tasks:calendar.taskAriaLabel", { title: task.title })}
+ aria-label={t("tasks:calendar.taskAriaLabel", {
+ title: task.title,
+ range,
+ })}
onClick={() => onOpenTask(task.id)}
className={cn(
"z-10 mb-0.5 flex h-6 min-w-0 items-center overflow-hidden border border-primary/25 bg-primary/12 px-1.5 text-left text-[11px] font-medium leading-none text-foreground transition-colors hover:border-primary/40 hover:bg-primary/18 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:h-5",
diff --git a/i18n/en-US.json b/i18n/en-US.json
index 9bf35797a..f85f5d5b4 100644
--- a/i18n/en-US.json
+++ b/i18n/en-US.json
@@ -1839,7 +1839,7 @@
"moreTasks": "+{{count}} more",
"loadError": "Failed to load tasks.",
"dayTasksAriaLabel": "Show all tasks for {{date}}",
- "taskAriaLabel": "{{title}}: open task"
+ "taskAriaLabel": "{{title}}, {{range}}: open task"
},
"gantt": {
"pageTitle": "{{name}} – Gantt",