Skip to content

Commit 51d4ceb

Browse files
oscharkoclaude
andcommitted
test(git-ui): cover empty repository and empty history states (#1576)
The #1576 acceptance criterion "Empty repository and no-repository states guide users to clone or open a local repository" and its "empty states" verification gate were satisfied in production code (RepositoryListSearch and HistoryPane) but lacked dedicated regression tests. An acceptance audit of Epic #1571 confirmed the behaviour is correct yet untested. Add two GitClientWindow regression tests: - no-repository state renders the add-repository guidance and affordance - an initialized repository with zero commits renders the no-commits history guidance and omits the commit listbox No production behaviour changes; this closes the one evidence gap found during the Epic #1571 acceptance-criteria audit. Refs #1571 Refs #1576 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent db33a48 commit 51d4ceb

1 file changed

Lines changed: 41 additions & 3 deletions

File tree

packages/keiko-ui/src/app/components/desktop/widgets/cards/git-client/GitClientWindow.test.tsx

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,9 @@ describe("GitClientWindow — branch, history, and sync workflows (Issue #1576)"
962962
expect(client.getHistory).not.toHaveBeenCalled();
963963

964964
await user.click(screen.getByRole("tab", { name: "History" }));
965-
await waitFor(() => expect(client.getHistory).toHaveBeenCalledWith({ root: REPO_A.path, limit: 50 }));
965+
await waitFor(() =>
966+
expect(client.getHistory).toHaveBeenCalledWith({ root: REPO_A.path, limit: 50 }),
967+
);
966968

967969
expect(screen.getByRole("listbox", { name: "Commit history" })).toBeInTheDocument();
968970
expect(screen.getByRole("option", { name: /feat: add history/ })).toHaveAttribute(
@@ -1089,7 +1091,9 @@ describe("GitClientWindow — branch, history, and sync workflows (Issue #1576)"
10891091
getStatus: vi.fn(async () => makeStatus({ detached: true, branch: undefined })),
10901092
getSummary: vi.fn(async () => makeSummary({ detached: true, branch: undefined })),
10911093
});
1092-
const { rerender } = render(<GitClientWindow projectId={REPO_A.path} client={detachedClient} />);
1094+
const { rerender } = render(
1095+
<GitClientWindow projectId={REPO_A.path} client={detachedClient} />,
1096+
);
10931097

10941098
expect(await screen.findByRole("alert")).toHaveTextContent("Detached HEAD");
10951099
expect(await screen.findByRole("button", { name: "Run sync: Detached HEAD" })).toBeDisabled();
@@ -1232,6 +1236,39 @@ describe("GitClientWindow — empty / loading / error states", () => {
12321236

12331237
await waitFor(() => expect(screen.getByText("No changes")).toBeInTheDocument());
12341238
});
1239+
1240+
// AC (Issue #1576): "Empty repository and no-repository states guide users to clone or
1241+
// open a local repository." The no-repository state must surface guidance plus the
1242+
// add-repository affordance rather than an empty void.
1243+
it("shows the no-repository empty state guiding users to add a repository", async () => {
1244+
const client = makeClient({
1245+
listRepositories: vi.fn(async () => ({ projects: [] })),
1246+
});
1247+
render(<GitClientWindow client={client} />);
1248+
1249+
await waitFor(() => expect(client.listRepositories).toHaveBeenCalled());
1250+
expect(screen.getByText("No repositories yet. Add a repository to begin.")).toBeInTheDocument();
1251+
// The add-repository affordance stays reachable from the empty list.
1252+
expect(screen.getByRole("button", { name: "Add repository" })).toBeInTheDocument();
1253+
});
1254+
1255+
// AC (Issue #1576): the empty repository state (initialized repo with zero commits) must
1256+
// explain how to start history instead of rendering an empty commit listbox.
1257+
it("shows the no-commits history empty state for an initialized repository", async () => {
1258+
const user = userEvent.setup();
1259+
const client = makeClient({
1260+
getHistory: vi.fn(async () => makeHistory({ entries: [] })),
1261+
});
1262+
render(<GitClientWindow projectId={REPO_A.path} client={client} />);
1263+
await waitFor(() => expect(client.getStatus).toHaveBeenCalled());
1264+
1265+
await user.click(screen.getByRole("tab", { name: "History" }));
1266+
await waitFor(() => expect(client.getHistory).toHaveBeenCalled());
1267+
1268+
expect(screen.getByText("No commits yet. Make a commit to start history.")).toBeInTheDocument();
1269+
// An empty history must not render the commit listbox.
1270+
expect(screen.queryByRole("listbox", { name: "Commit history" })).not.toBeInTheDocument();
1271+
});
12351272
});
12361273

12371274
describe("GitClientWindow — changed-files list and diff selection", () => {
@@ -1695,7 +1732,8 @@ describe("GitClientWindow — diff scope (Issue #1575)", () => {
16951732
unstagedCount: 0,
16961733
changes: [change("README.md", { indexStatus: "M", staged: true })],
16971734
});
1698-
const getStatus = vi.fn<GitClientSeam["getStatus"]>()
1735+
const getStatus = vi
1736+
.fn<GitClientSeam["getStatus"]>()
16991737
.mockResolvedValueOnce(before)
17001738
.mockResolvedValueOnce(after);
17011739
const client = makeClient({

0 commit comments

Comments
 (0)