Files
kandev/apps/web/components/settings/workflow-synced-badge.test.tsx
T
João Salavisa 03d5f98cb6 feat(i18n): localize Settings → Workflows (#2201)
Co-authored-by: Kandev Agent <agent@kandev.dev>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 15:30:27 +02:00

41 lines
1.6 KiB
TypeScript

import { afterEach, describe, expect, it } from "vitest";
import { cleanup, render, screen } from "@testing-library/react";
import { TooltipProvider } from "@kandev/ui/tooltip";
import { WorkflowSyncedBadge } from "./workflow-synced-badge";
/**
* The tooltip interpolates `sourcePath` — a repository path, i.e. data — and
* falls back to a translated phrase when the workflow carries none. jsdom does
* not open a Radix tooltip from synthetic hover, so the sentence is asserted
* through the keyboard-focus path (see apps/web/AGENTS.md).
*/
describe("WorkflowSyncedBadge", () => {
afterEach(cleanup);
it("interpolates the source path into the read-only explanation", async () => {
render(
<TooltipProvider>
<WorkflowSyncedBadge sourcePath=".kandev/workflows/review.yml" />
</TooltipProvider>,
);
screen.getByTestId("workflow-synced-badge").focus();
const tooltip = await screen.findAllByText(
"Read-only - managed by workflow sync from .kandev/workflows/review.yml. Edit or remove it in the synced repository.",
);
expect(tooltip.length).toBeGreaterThan(0);
});
it("falls back to a translated phrase when no source path is known", async () => {
render(
<TooltipProvider>
<WorkflowSyncedBadge />
</TooltipProvider>,
);
screen.getByTestId("workflow-synced-badge").focus();
const tooltip = await screen.findAllByText(
"Read-only - managed by workflow sync from a configured repository. Edit or remove it in the synced repository.",
);
expect(tooltip.length).toBeGreaterThan(0);
});
});