test(quick-pane): cover settings load
This commit is contained in:
+15
-2
@@ -1,7 +1,7 @@
|
|||||||
import { act, render, screen, waitFor } from "@testing-library/react";
|
import { act, render, screen, waitFor } from "@testing-library/react";
|
||||||
import userEvent from "@testing-library/user-event";
|
import userEvent from "@testing-library/user-event";
|
||||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import type { RuntimeSummary, Workspace } from "./workspace/types";
|
import type { RuntimeSummary, UiState, Workspace } from "./workspace/types";
|
||||||
import {
|
import {
|
||||||
initialWorkspaceState,
|
initialWorkspaceState,
|
||||||
reconcileWorkspace,
|
reconcileWorkspace,
|
||||||
@@ -44,6 +44,14 @@ const otherSummary: RuntimeSummary = {
|
|||||||
agentId: "agent-b",
|
agentId: "agent-b",
|
||||||
label: "Session B",
|
label: "Session B",
|
||||||
};
|
};
|
||||||
|
const uiState: UiState = {
|
||||||
|
version: 1,
|
||||||
|
directoryOrder: [],
|
||||||
|
runtimeOrderByDirectory: {},
|
||||||
|
drafts: {},
|
||||||
|
scroll: {},
|
||||||
|
lastSeen: {},
|
||||||
|
};
|
||||||
|
|
||||||
function workspaceState() {
|
function workspaceState() {
|
||||||
const workspace: Workspace = {
|
const workspace: Workspace = {
|
||||||
@@ -82,6 +90,7 @@ function deferred<T>() {
|
|||||||
describe("App command progress and errors", () => {
|
describe("App command progress and errors", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
|
mocks.invoke.mockResolvedValue(uiState);
|
||||||
mocks.refresh.mockResolvedValue(undefined);
|
mocks.refresh.mockResolvedValue(undefined);
|
||||||
mocks.loadSnapshot.mockResolvedValue(true);
|
mocks.loadSnapshot.mockResolvedValue(true);
|
||||||
mocks.useWorkspace.mockReturnValue({
|
mocks.useWorkspace.mockReturnValue({
|
||||||
@@ -118,7 +127,11 @@ describe("App command progress and errors", () => {
|
|||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
expect(screen.getByRole("main")).toHaveAttribute("aria-busy", "true");
|
expect(screen.getByRole("main")).toHaveAttribute("aria-busy", "true");
|
||||||
await user.click(restarting);
|
await user.click(restarting);
|
||||||
expect(mocks.invoke).toHaveBeenCalledTimes(1);
|
expect(mocks.invoke).toHaveBeenCalledTimes(2);
|
||||||
|
expect(mocks.invoke).toHaveBeenNthCalledWith(1, "load_ui_state");
|
||||||
|
expect(mocks.invoke).toHaveBeenNthCalledWith(2, "restart", {
|
||||||
|
agentId: "agent-a",
|
||||||
|
});
|
||||||
|
|
||||||
await act(async () => restart.resolve(undefined));
|
await act(async () => restart.resolve(undefined));
|
||||||
expect(screen.getByRole("button", { name: "Restarting Pi…" })).toBeDisabled();
|
expect(screen.getByRole("button", { name: "Restarting Pi…" })).toBeDisabled();
|
||||||
|
|||||||
Reference in New Issue
Block a user