Files
kandev/apps/web/components/watcher-repository-fields.test.tsx
T
João Salavisa d58a1df32d fix(i18n): localize watcher fallback labels (#2596)
Co-authored-by: Kandev Agent <agent@kandev.dev>
2026-08-13 01:00:32 +01:00

50 lines
1.5 KiB
TypeScript

import { cleanup, render, screen } from "@testing-library/react";
import { afterEach, describe, expect, it, vi } from "vitest";
import { WatcherRepositoryFields } from "./watcher-repository-fields";
const branchState = vi.hoisted(() => ({ loading: false }));
vi.mock("@/hooks/domains/workspace/use-repositories", () => ({
useRepositories: () => ({ repositories: [] }),
}));
vi.mock("@/hooks/domains/workspace/use-repository-branches", () => ({
useBranches: () => ({ branches: [], isLoading: branchState.loading }),
}));
afterEach(() => {
cleanup();
branchState.loading = false;
});
describe("WatcherRepositoryFields", () => {
it("shows the repository-first placeholder while the branch selector is disabled", () => {
render(
<WatcherRepositoryFields
workspaceId="workspace-1"
repositoryId=""
baseBranch=""
onRepositoryChange={vi.fn()}
onBaseBranchChange={vi.fn()}
/>,
);
expect(screen.getByLabelText("Base Branch").textContent).toContain("Pick a repository first");
});
it("shows the loading placeholder instead of selecting the default branch", () => {
branchState.loading = true;
render(
<WatcherRepositoryFields
workspaceId="workspace-1"
repositoryId="repository-1"
baseBranch=""
onRepositoryChange={vi.fn()}
onBaseBranchChange={vi.fn()}
/>,
);
expect(screen.getByLabelText("Base Branch").textContent).toContain("Loading…");
});
});