Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Update app, dialog and work queue tests for the new frame

Bitti5caa8546352f
diff --git a/src/App.cuda.test.tsx b/src/App.cuda.test.tsx
index 6da8fda..a1c40dd 100644
--- a/src/App.cuda.test.tsx
+++ b/src/App.cuda.test.tsx
@@ -34,18 +34,21 @@ it("shows startup guidance, opens NVIDIA in the browser, and stays dismissed aft
render(<App />);
const dialog = await screen.findByRole("dialog", { name: "Install CUDA for faster generation" });
expect(within(dialog).getByText(/Vulkan fallback backend, with longer generation times/)).toBeInTheDocument();
+ expect(within(dialog).getByText(/RTX 5090/)).toBeInTheDocument();
+ const download = within(dialog).getByRole("button", { name: "Download CUDA" });
const proceed = within(dialog).getByRole("button", { name: "Continue with Vulkan" });
- expect(proceed).toHaveFocus();
- const download = within(dialog).getByRole("link", { name: "Download CUDA from NVIDIA" });
- expect(download).toHaveAttribute("href", "https://developer.nvidia.com/cuda-downloads");
+ // [Primary] [Close]: Download is the default (Enter), Continue is Esc.
+ expect(download).toHaveFocus();
+ // Tab wraps inside the dialog; the step between the two is the browser's.
+ proceed.focus();
fireEvent.keyDown(proceed, { key: "Tab" });
expect(download).toHaveFocus();
fireEvent.keyDown(download, { key: "Tab", shiftKey: true });
expect(proceed).toHaveFocus();
fireEvent.click(download);
await waitFor(() => expect(invoke).toHaveBeenCalledWith("open_cuda_download", { version: "latest" }));
- fireEvent.click(proceed);
- expect(screen.queryByRole("dialog", { name: "Install CUDA for faster generation" })).toBeNull();
+ // Opening the page answers the question.
+ await waitFor(() => expect(screen.queryByRole("dialog", { name: "Install CUDA for faster generation" })).toBeNull());
fireEvent.click(screen.getByRole("button", { name: "Settings" }));
fireEvent.keyDown(screen.getByRole("main", { name: "Settings" }), { key: "Escape" });
expect(screen.queryByRole("main", { name: "Settings" })).toBeNull();
@@ -57,13 +60,15 @@ it("offers the CUDA 12.8 archive for older RTX cards and allows Escape to procee
vi.mocked(getRuntimeStatus).mockResolvedValue({ ...detected, slopfab: { ...detected.slopfab, cudaDeviceNames: ["NVIDIA GeForce RTX 3080"] } });
render(<App />);
const dialog = await screen.findByRole("dialog", { name: "Install CUDA for faster generation" });
- const download = within(dialog).getByRole("link", { name: "Download CUDA 12.8 from NVIDIA" });
- expect(download).toHaveAttribute("href", "https://developer.nvidia.com/cuda-12-8-0-download-archive");
+ const download = within(dialog).getByRole("button", { name: "Download CUDA 12.8" });
vi.mocked(invoke).mockRejectedValueOnce(new Error("Browser unavailable"));
fireEvent.click(download);
- expect(await within(dialog).findByRole("alert")).toHaveTextContent("Browser unavailable");
+ const alert = await within(dialog).findByRole("alert");
+ expect(alert).toHaveTextContent("Browser unavailable");
+ // The address is still there to type in by hand.
+ expect(alert).toHaveTextContent("https://developer.nvidia.com/cuda-12-8-0-download-archive");
expect(invoke).toHaveBeenCalledWith("open_cuda_download", { version: "12.8" });
- fireEvent.keyDown(window, { key: "Escape" });
+ fireEvent.keyDown(download, { key: "Escape" });
expect(screen.queryByRole("dialog", { name: "Install CUDA for faster generation" })).toBeNull();
});
diff --git a/src/App.newProject.test.tsx b/src/App.newProject.test.tsx
index ed5e32a..c2ec93e 100644
--- a/src/App.newProject.test.tsx
+++ b/src/App.newProject.test.tsx
@@ -1,6 +1,6 @@
// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
-import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { invoke } from "@tauri-apps/api/core";
import { afterEach, beforeEach, expect, it, vi } from "vitest";
import App from "./App";
@@ -23,6 +23,8 @@ beforeEach(() => {
return undefined;
});
});
+/** The command bar's New project (the empty library offers a second one). */
+const newProject = async () => within(await screen.findByRole("toolbar", { name: "Library commands" })).getByRole("button", { name: "New project" });
afterEach(() => { cleanup(); delete (window as unknown as Record<string, unknown>).__TAURI_INTERNALS__; });
it("selects a folder before showing the form and keeps its path when the project is renamed", async () => {
@@ -33,7 +35,7 @@ it("selects a folder before showing the form and keeps its path when the project
return regular(command, args);
});
render(<App />);
- fireEvent.click(await screen.findByRole("button", { name: "New project" }));
+ fireEvent.click(await newProject());
expect(invoke).toHaveBeenCalledWith("choose_new_project_folder");
expect(screen.queryByRole("dialog", { name: "New project" })).not.toBeInTheDocument();
finish(selected);
@@ -48,7 +50,7 @@ it("selects a folder before showing the form and keeps its path when the project
it("cancels without opening the form, then blocks a nonempty folder next to Create", async () => {
selected = null;
render(<App />);
- const start = await screen.findByRole("button", { name: "New project" });
+ const start = await newProject();
fireEvent.click(start);
await waitFor(() => expect(start).toBeEnabled());
expect(screen.queryByRole("dialog", { name: "New project" })).not.toBeInTheDocument();
@@ -57,10 +59,12 @@ it("cancels without opening the form, then blocks a nonempty folder next to Crea
await screen.findByRole("dialog", { name: "New project" });
const create = screen.getByRole("button", { name: "Create project" });
expect(create).toBeDisabled();
- expect(screen.getByRole("alert").parentElement).toBe(create.parentElement);
+ // The reason is an InfoBar inside the dialog, not red text by the button.
+ const dialog = screen.getByRole("dialog", { name: "New project" });
+ expect(within(dialog).getByRole("alert")).toHaveTextContent("The selected folder is not empty.");
expect(invoke).not.toHaveBeenCalledWith("create_project", expect.anything());
selected = { folderPath: "D:/Empty", error: null };
- fireEvent.click(screen.getByRole("button", { name: "Change folder" }));
+ fireEvent.click(screen.getByRole("button", { name: "Browse…" }));
await waitFor(() => expect(screen.getByLabelText("Project folder")).toHaveValue("D:/Empty"));
expect(screen.getByLabelText("Project name")).toHaveValue("Empty");
expect(create).toBeEnabled();
@@ -68,7 +72,7 @@ it("cancels without opening the form, then blocks a nonempty folder next to Crea
it("rechecks the selected directory before creating", async () => {
render(<App />);
- fireEvent.click(await screen.findByRole("button", { name: "New project" }));
+ fireEvent.click(await newProject());
await screen.findByRole("dialog", { name: "New project" });
selected = { ...selected!, error: "The selected folder is not empty." };
fireEvent.click(screen.getByRole("button", { name: "Create project" }));
diff --git a/src/App.test.tsx b/src/App.test.tsx
index 733488c..ad1487c 100644
--- a/src/App.test.tsx
+++ b/src/App.test.tsx
@@ -1,8 +1,8 @@
// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
-import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
-import { afterEach, beforeEach, describe, expect, it } from "vitest";
+import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import App from "./App";
import { ProjectCard, relativeDate } from "./components/ProjectCard";
import { createProjectConfig, STORY_TRACK_ID } from "./lib/project";
@@ -45,7 +45,7 @@ describe("how long ago a project was edited", () => {
sourceStartMs: 750, label: "Opening shot", color: null, status: "approved",
}] } : track);
const { container } = render(<ProjectCard project={{ folderPath: "C:\\Ceramic Lamp", config }} index={0} onOpen={() => undefined} />);
- expect(container.querySelector(".project-card__art > .media-thumb")?.getAttribute("aria-label")).toBe("Opening shot");
+ expect(container.querySelector(".project-card__thumb > .media-thumb")?.getAttribute("aria-label")).toBe("Opening shot");
});
});
@@ -65,12 +65,20 @@ describe("project library controls", () => {
render(<App />);
- const card = await screen.findByRole("button", { name: "Open Saved illustration" });
+ const card = await screen.findByRole("option", { name: "Saved illustration" });
expect(card.querySelector(".media-thumb")).toHaveAttribute("aria-label", "Generated illustration");
+ // One click selects, like a GridView item; it does not open.
fireEvent.click(card);
- expect(await screen.findByRole("button", { name: "Editor" })).toHaveAttribute("aria-current", "page");
+ expect(card).toHaveAttribute("aria-selected", "true");
+ expect(screen.queryByRole("tab", { name: "Editor" })).toBeNull();
+ fireEvent.doubleClick(card);
+ expect(await screen.findByRole("tab", { name: "Editor" })).toHaveAttribute("aria-selected", "true");
fireEvent.click(screen.getByRole("button", { name: "Back to project library" }));
- expect(await screen.findByRole("button", { name: "Open Saved illustration" })).toBeInTheDocument();
+ const again = await screen.findByRole("option", { name: "Saved illustration" });
+ // The tile that was opened is still the selected one, and Enter opens it.
+ expect(again).toHaveAttribute("aria-selected", "true");
+ fireEvent.keyDown(again, { key: "Enter" });
+ expect(await screen.findByRole("tab", { name: "Editor" })).toHaveAttribute("aria-selected", "true");
});
it("uses a named New Project form with a default Look instead of a length", async () => {
@@ -93,18 +101,18 @@ describe("project library controls", () => {
expect(screen.getByRole("button", { name: "Create project" })).toBeEnabled();
});
- it("focuses search with Ctrl/Cmd+K and switches between grid and list", async () => {
+ it("puts the brand in the title bar, focuses search with Ctrl+F and switches between grid and list", async () => {
const { container } = render(<App />);
await screen.findByText("Northern Light — Brand Film");
- expect(container.querySelector(".brand__wordmark")?.textContent).toBe("Slopus");
- expect(container.querySelector(".brand__edition")?.textContent).toBe("ALPHA");
- expect(container.querySelector(".brand .slopus-logo__ticket")).toBeNull();
- const icon = container.querySelector(".brand img");
- expect(icon?.getAttribute("src")).toContain("marketing/icon.png");
- expect(icon?.nextElementSibling?.textContent).toBe("Slopus");
-
- const search = screen.getByRole("textbox", { name: "Search projects" });
- fireEvent.keyDown(window, { key: "k", ctrlKey: true });
+ // 16px icon, "Slopus" and "Preview" as the window caption; no web header.
+ expect(container.querySelector(".titlebar__title")?.textContent).toBe("Slopus");
+ expect(container.querySelector(".titlebar__secondary")?.textContent).toBe("Preview");
+ expect(container.querySelector(".titlebar__icon img")?.getAttribute("src")).toContain("marketing/icon.png");
+ expect(screen.getByRole("heading", { level: 1, name: "Projects" })).toBeInTheDocument();
+ expect(container.querySelector("kbd")).toBeNull();
+
+ const search = screen.getByRole("searchbox", { name: "Search projects" });
+ fireEvent.keyDown(document.body, { key: "f", ctrlKey: true });
expect(document.activeElement).toBe(search);
const list = screen.getByRole("button", { name: "List view" });
@@ -113,25 +121,50 @@ describe("project library controls", () => {
expect(container.querySelector(".project-grid--list")).not.toBeNull();
fireEvent.click(screen.getByRole("button", { name: "More options for Northern Light — Brand Film" }));
- await waitFor(() => expect(screen.getByRole("menuitem", { name: "Open project" })).not.toBeNull());
+ const menu = await screen.findByRole("menu");
+ expect(within(menu).getAllByRole("menuitem").map((item) => item.textContent)).toEqual(["Open", "Delete project…"]);
+ });
+
+ it("opens the tile menu with a right-click and moves the selection with the arrow keys", async () => {
+ // Opening a video project mounts the program monitor; jsdom plays nothing.
+ vi.spyOn(HTMLMediaElement.prototype, "load").mockImplementation(() => undefined);
+ render(<App />);
+ await screen.findByText("Northern Light — Brand Film");
+ const tiles = screen.getAllByRole("option");
+ expect(tiles.length).toBeGreaterThan(1);
+ expect(tiles.map((tile) => tile.tabIndex)).toEqual(tiles.map((_, index) => index === 0 ? 0 : -1));
+ fireEvent.contextMenu(tiles[1], { clientX: 40, clientY: 40 });
+ expect(tiles[1]).toHaveAttribute("aria-selected", "true");
+ fireEvent.click(await screen.findByRole("menuitem", { name: "Open" }));
+ expect(await screen.findByRole("button", { name: "Back to project library" })).toBeInTheDocument();
+ fireEvent.click(screen.getByRole("button", { name: "Back to project library" }));
+ const again = await screen.findAllByRole("option");
+ again[1].focus();
+ fireEvent.keyDown(again[1], { key: "ArrowLeft" });
+ expect(again[0]).toHaveFocus();
+ expect(again[0]).toHaveAttribute("aria-selected", "true");
+ fireEvent.keyDown(again[0], { key: "End" });
+ expect(again.at(-1)).toHaveFocus();
});
it("confirms permanent project deletion before removing it from the library", async () => {
render(<App />);
await screen.findByText("Northern Light — Brand Film");
fireEvent.click(screen.getByRole("button", { name: "More options for Northern Light — Brand Film" }));
- fireEvent.click(await screen.findByRole("menuitem", { name: "Delete Project" }));
+ fireEvent.click(await screen.findByRole("menuitem", { name: "Delete project…" }));
const dialog = screen.getByRole("alertdialog", { name: "Delete “Northern Light — Brand Film”?" });
expect(dialog.textContent).toContain("permanently deletes the project folder and every file inside it");
expect(dialog.textContent).toContain("~/Slopus/Northern Light");
+ // Cancel is the default answer.
+ expect(within(dialog).getByRole("button", { name: "Cancel" })).toHaveFocus();
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
expect(screen.getByText("Northern Light — Brand Film")).not.toBeNull();
fireEvent.click(screen.getByRole("button", { name: "More options for Northern Light — Brand Film" }));
- fireEvent.click(screen.getByRole("menuitem", { name: "Delete Project" }));
- fireEvent.click(screen.getByRole("button", { name: "Delete project" }));
+ fireEvent.click(screen.getByRole("menuitem", { name: "Delete project…" }));
+ fireEvent.click(screen.getByRole("button", { name: "Delete" }));
await waitFor(() => expect(screen.queryByText("Northern Light — Brand Film")).toBeNull());
const stored = JSON.parse(localStorage.getItem("slopus.web-projects.v1") ?? "[]") as Array<{ config: { id: string } }>;
@@ -139,6 +172,18 @@ describe("project library controls", () => {
expect(screen.getByText("2 projects")).not.toBeNull();
});
+ it("answers the app accelerators: Ctrl+N and Ctrl+,", async () => {
+ render(<App />);
+ await screen.findByText("Northern Light — Brand Film");
+ fireEvent.keyDown(document.body, { key: "n", ctrlKey: true });
+ expect(await screen.findByRole("dialog", { name: "New project" })).toBeInTheDocument();
+ fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
+ expect(screen.queryByRole("dialog", { name: "New project" })).toBeNull();
+ fireEvent.keyDown(document.body, { key: ",", ctrlKey: true });
+ expect(screen.getByRole("main", { name: "Settings" })).toBeInTheDocument();
+ expect(screen.queryByRole("heading", { level: 1, name: "Projects" })).toBeNull();
+ });
+
it("offers frame sizes MiniMax H3 can generate, relabelled when the shape changes", async () => {
render(<App />);
await screen.findByText("Northern Light — Brand Film");
@@ -164,21 +209,23 @@ describe("project library controls", () => {
"416 × 736", "544 × 960", "640 × 1152", "768 × 1376 (default)", "1088 × 1920", "1344 × 2432",
]);
- // The header stays short; the fields already show the selected format.
fireEvent.change(size, { target: { value: "544p" } });
- expect(document.querySelector(".composer__options-head")).toHaveTextContent(/^Video settings$/);
+ expect(size).toHaveValue("544p");
});
- it("opens a newly named empty project on its Agent starting page", async () => {
+ it("opens a newly named empty project with the agent pane showing", async () => {
+ localStorage.setItem("slopus.workspace.agentPane", "closed");
render(<App />);
await screen.findByText("Northern Light — Brand Film");
fireEvent.click(screen.getByRole("button", { name: "New project" }));
fireEvent.change(screen.getByRole("textbox", { name: "Project name" }), { target: { value: "Ceramic lamp film" } });
fireEvent.click(screen.getByRole("button", { name: "Create project" }));
- expect(await screen.findByRole("heading", { name: "What should we create today?" })).not.toBeNull();
- expect(screen.getByText("Ceramic lamp film")).not.toBeNull();
+ // A new project starts with the Agent, even if the pane was last closed.
+ const pane = await screen.findByRole("complementary", { name: "Agent" });
+ expect(screen.getByRole("button", { name: "Agent" })).toHaveAttribute("aria-pressed", "true");
+ expect(screen.getByRole("button", { name: "Edit project settings for Ceramic lamp film" })).toBeInTheDocument();
expect(screen.queryByText("First scene")).toBeNull();
- const draft = screen.getByRole("textbox", { name: /Ask Slop about/ });
+ const draft = within(pane).getByRole("textbox", { name: /Ask Slop about/ });
fireEvent.change(draft, { target: { value: "Keep this unfinished idea" } });
fireEvent.click(screen.getByRole("button", { name: "Settings" }));
const settings = screen.getByRole("main", { name: "Settings" });
@@ -198,7 +245,7 @@ describe("project library controls", () => {
expect(screen.getByRole("dialog", { name: "New project" })).not.toBeNull();
fireEvent.click(screen.getByRole("button", { name: "Create project" }));
- expect(await screen.findByRole("heading", { name: "What should we create today?" })).not.toBeNull();
+ expect(await screen.findByRole("complementary", { name: "Agent" })).toBeVisible();
expect(screen.getAllByText("Untitled video").length).toBeGreaterThan(0);
expect(screen.queryByText("First scene")).toBeNull();
});
@@ -215,6 +262,7 @@ describe("project library controls", () => {
expect(await screen.findByText("Readable film")).not.toBeNull();
// …and the bad one is named rather than silently vanishing.
const alert = await screen.findByRole("alert");
+ expect(alert).toHaveClass("ui-infobar");
expect(alert.textContent).toContain("couldn’t be read");
expect(alert.textContent).toContain("~/Slopus/Broken");
});
diff --git a/src/WorkQueue.integration.test.tsx b/src/WorkQueue.integration.test.tsx
index 3dcbb40..8d2c98e 100644
--- a/src/WorkQueue.integration.test.tsx
+++ b/src/WorkQueue.integration.test.tsx
@@ -2,7 +2,6 @@
import "@testing-library/jest-dom/vitest";
import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { listen } from "@tauri-apps/api/event";
-import { invoke } from "@tauri-apps/api/core";
import { afterEach, beforeEach, expect, it, vi } from "vitest";
import App from "./App";
import { saveGeneratedScene } from "./lib/generatedVideo";
@@ -10,9 +9,11 @@ import { listRecentProjects, saveProject } from "./lib/persistence";
import { createProjectConfig, type ProjectRecord } from "./lib/project";
import { enqueueSlopfabGeneration, type SlopfabStatus } from "./lib/runtime";
import { loadReferenceIconAutomation } from "./lib/referenceIconSettings";
+import { reportGenerationJobs } from "./lib/nativeShell";
vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn(async () => undefined) }));
vi.mock("@tauri-apps/api/event", () => ({ listen: vi.fn() }));
+vi.mock("./lib/nativeShell", async (original) => ({ ...await original<typeof import("./lib/nativeShell")>(), reportGenerationJobs: vi.fn(async () => undefined) }));
vi.mock("./lib/generatedVideo", () => ({ saveGeneratedScene: vi.fn(), releaseRendered: vi.fn(async () => true) }));
vi.mock("./lib/timelineThumbnails", async (original) => ({ ...await original<typeof import("./lib/timelineThumbnails")>(), purgeTimelineThumbnails: vi.fn(async () => undefined) }));
vi.mock("./lib/persistence", async (original) => ({ ...await original<typeof import("./lib/persistence")>(), isTauri: () => true, listRecentProjects: vi.fn(), saveProject: vi.fn() }));
@@ -37,17 +38,17 @@ it("keeps icon confirmation available after returning to the library", async ()
config.references = [{ id: "hero", kind: "text", name: "Hero", description: "A friendly explorer", intendedUse: ["character"], createdAt: "2026-09-08T00:00:00.000Z" }];
vi.mocked(listRecentProjects).mockResolvedValue({ projects: [{ folderPath: "C:/Icon project", config }], unreadable: [] });
render(<App />);
- fireEvent.click(await screen.findByRole("button", { name: "Open Icon project" }));
+ fireEvent.doubleClick(await screen.findByRole("option", { name: "Icon project" }));
fireEvent.click(screen.getByRole("button", { name: "Back to project library" }));
- const dialog = await screen.findByRole("alertdialog", { name: "Generate reference icons?" }, { timeout: 5000 });
+ const dialog = await screen.findByRole("dialog", { name: "Generate reference icons?" }, { timeout: 5000 });
expect(enqueueSlopfabGeneration).not.toHaveBeenCalled();
fireEvent.click(within(dialog).getByRole("button", { name: "Start generation" }));
await waitFor(() => expect(enqueueSlopfabGeneration).toHaveBeenCalledTimes(1));
expect(vi.mocked(enqueueSlopfabGeneration).mock.calls[0][0]).toMatchObject({ stillImage: true, canvasWidth: 768, steps: 20 });
- expect(screen.queryByRole("alertdialog", { name: "Generate reference icons?" })).toBeNull();
- expect(invoke).not.toHaveBeenCalledWith("set_generation_active", { active: true });
- act(() => handlers.get("app-close-requested")!({ payload: {} }));
- await waitFor(() => expect(invoke).toHaveBeenCalledWith("answer_app_close", { confirmed: true }));
+ expect(screen.queryByRole("dialog", { name: "Generate reference icons?" })).toBeNull();
+ // Icons can be interrupted safely, so they never hold the window open: the
+ // native exit question is only ever told about an empty list.
+ expect(vi.mocked(reportGenerationJobs).mock.calls.every(([jobs]) => jobs.length === 0)).toBe(true);
});
it("cancels automatic generation and exposes the remembered choice in Generator settings", async () => {
@@ -55,14 +56,14 @@ it("cancels automatic generation and exposes the remembered choice in Generator
config.references = [{ id: "hero", kind: "text", name: "Hero", description: "A friendly explorer", intendedUse: ["character"], createdAt: "2026-09-08T00:00:00.000Z" }];
vi.mocked(listRecentProjects).mockResolvedValue({ projects: [{ folderPath: "C:/Cancel icons", config }], unreadable: [] });
render(<App />);
- fireEvent.click(await screen.findByRole("button", { name: "Open Cancel icons" }));
- const dialog = await screen.findByRole("alertdialog", { name: "Generate reference icons?" }, { timeout: 5000 });
+ fireEvent.doubleClick(await screen.findByRole("option", { name: "Cancel icons" }));
+ const dialog = await screen.findByRole("dialog", { name: "Generate reference icons?" }, { timeout: 5000 });
fireEvent.click(within(dialog).getByRole("checkbox", { name: /Don't ask again/ }));
fireEvent.click(within(dialog).getByRole("button", { name: "Cancel" }));
expect(loadReferenceIconAutomation()).toBe("disabled");
expect(enqueueSlopfabGeneration).not.toHaveBeenCalled();
fireEvent.click(screen.getByRole("button", { name: "Settings" }));
- expect(screen.getByRole("checkbox", { name: "Automatic reference icon generation" })).not.toBeChecked();
+ expect(screen.getByRole("switch", { name: "Automatic reference icon generation" })).not.toBeChecked();
});
it("keeps the application queue alive while switching projects and saves results to their original project", async () => {
@@ -71,40 +72,46 @@ it("keeps the application queue alive while switching projects and saves results
first.config.generationJobs.push({ ...first.config.generationJobs[0], id: "scene-next", title: "Upcoming scene" });
vi.mocked(listRecentProjects).mockResolvedValue({ projects: [first, second], unreadable: [] });
render(<App />);
- fireEvent.click(await screen.findByRole("button", { name: "Open First project" }));
- fireEvent.click(screen.getByRole("button", { name: "Generator" }));
- fireEvent.click(screen.getByRole("button", { name: "Generate All" }));
+ fireEvent.doubleClick(await screen.findByRole("option", { name: "First project" }));
+ fireEvent.click(screen.getByRole("tab", { name: "Generator" }));
+ fireEvent.click(screen.getByRole("button", { name: /^Generate all$/i }));
await waitFor(() => expect(enqueueSlopfabGeneration).toHaveBeenCalledTimes(1));
const workId = vi.mocked(enqueueSlopfabGeneration).mock.calls[0][0].jobId;
fireEvent.click(screen.getByRole("button", { name: "Back to project library" }));
- expect(screen.queryByRole("alertdialog")).toBeNull();
- fireEvent.click(screen.getByRole("button", { name: "Open Second project" }));
- fireEvent.click(screen.getByRole("button", { name: "Work Queue" }));
- const panel = screen.getByRole("dialog", { name: "Work Queue" });
+ expect(screen.queryByRole("dialog")).toBeNull();
+ fireEvent.doubleClick(screen.getByRole("option", { name: "Second project" }));
+ // The title-bar button counts what is running or waiting.
+ expect(screen.getByRole("button", { name: "Work queue" })).toHaveTextContent("2");
+ fireEvent.click(screen.getByRole("button", { name: "Work queue" }));
+ const panel = screen.getByRole("dialog", { name: "Work queue" });
expect(within(panel).getByRole("region", { name: "In progress" })).toHaveTextContent("First project");
expect(within(panel).getByRole("region", { name: "Upcoming work" })).toHaveTextContent("Upcoming scene");
fireEvent.click(within(panel).getByRole("button", { name: "Cancel Upcoming scene in First project" }));
expect(within(panel).queryByRole("region", { name: "Upcoming work" })).toBeNull();
- fireEvent.click(within(panel).getByRole("button", { name: "Close work queue" }));
+ fireEvent.keyDown(window, { key: "Escape" });
+ expect(screen.queryByRole("dialog", { name: "Work queue" })).toBeNull();
await act(async () => { handlers.get("slopfab-job")?.({ payload: { jobId: workId, state: "framesReady", detail: "Ready" } }); });
await waitFor(() => expect(saveProject).toHaveBeenCalledWith(expect.objectContaining({ folderPath: first.folderPath, config: expect.objectContaining({ generationJobs: expect.arrayContaining([expect.objectContaining({ status: "completed", outputRelativePath: "media/generated/queued-result.mp4" })]) }) })));
expect(document.querySelector(".project-title")?.textContent).toBe("Second project");
expect(saveGeneratedScene).toHaveBeenCalledWith(expect.objectContaining({ jobId: workId, folderPath: first.folderPath }));
- expect(invoke).toHaveBeenCalledWith("set_generation_active", { active: true });
+ expect(vi.mocked(reportGenerationJobs).mock.calls.some(([jobs]) => jobs.some((job) => job.running && job.title.includes("First project")))).toBe(true);
expect(enqueueSlopfabGeneration).toHaveBeenCalledTimes(1);
fireEvent.click(screen.getByRole("button", { name: "Back to project library" }));
- fireEvent.click(screen.getByRole("button", { name: "Open First project" }));
- fireEvent.click(screen.getByRole("button", { name: "Generator" }));
- expect(screen.getByRole("region", { name: "First scene" })).toHaveTextContent("FINISHED");
+ fireEvent.doubleClick(screen.getByRole("option", { name: "First project" }));
+ fireEvent.click(screen.getByRole("tab", { name: "Generator" }));
+ expect(screen.getByRole("region", { name: "First scene" })).toHaveTextContent(/finished/i);
});
it("opens an empty queue from the library and closes it with Escape", async () => {
vi.mocked(listRecentProjects).mockResolvedValue({ projects: [], unreadable: [] });
render(<App />);
- const trigger = screen.getByRole("button", { name: "Work Queue" });
+ const trigger = screen.getByRole("button", { name: "Work queue" });
trigger.focus(); fireEvent.click(trigger);
- expect(screen.getByRole("dialog", { name: "Work Queue" })).toHaveTextContent("No work yet");
+ const flyout = screen.getByRole("dialog", { name: "Work queue" });
+ expect(flyout).toHaveTextContent("No work yet");
+ // A light-dismiss flyout, not a modal: no scrim, nothing aria-modal.
+ expect(flyout).not.toHaveAttribute("aria-modal");
fireEvent.keyDown(window, { key: "Escape" });
- expect(screen.queryByRole("dialog", { name: "Work Queue" })).toBeNull();
+ expect(screen.queryByRole("dialog", { name: "Work queue" })).toBeNull();
expect(document.activeElement).toBe(trigger);
});
diff --git a/src/components/ReferenceIconGenerationDialog.test.tsx b/src/components/ReferenceIconGenerationDialog.test.tsx
index dd10084..024c57c 100644
--- a/src/components/ReferenceIconGenerationDialog.test.tsx
+++ b/src/components/ReferenceIconGenerationDialog.test.tsx
@@ -1,4 +1,5 @@
// @vitest-environment jsdom
+import "@testing-library/jest-dom/vitest";
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, expect, it, vi } from "vitest";
import { ReferenceIconGenerationDialog } from "./ReferenceIconGenerationDialog";
@@ -8,9 +9,12 @@ afterEach(cleanup);
it("shows the batch and starts only after an explicit answer", () => {
const answer = vi.fn();
render(<ReferenceIconGenerationDialog count={3} onAnswer={answer} />);
- expect(screen.getByRole("alertdialog").textContent).toContain("3 references need icons");
+ const dialog = screen.getByRole("dialog", { name: "Generate reference icons?" });
+ expect(dialog.textContent).toContain("3 references need icons");
expect(answer).not.toHaveBeenCalled();
- expect(document.activeElement).toBe(screen.getByRole("button", { name: "Cancel" }));
+ // Windows order: [Primary] [Cancel]; Cancel is the default (Enter).
+ expect([...dialog.querySelectorAll("[data-dialog-button]")].map((button) => button.textContent)).toEqual(["Start generation", "Cancel"]);
+ expect(screen.getByRole("button", { name: "Cancel" })).toHaveClass("primary-button");
fireEvent.click(screen.getByRole("checkbox", { name: /Don't ask again/ }));
fireEvent.click(screen.getByRole("button", { name: "Start generation" }));
expect(answer).toHaveBeenCalledWith(true, true);
@@ -20,24 +24,25 @@ it("remembers Cancel only when the button is explicitly chosen", () => {
const answer = vi.fn();
render(<ReferenceIconGenerationDialog count={1} onAnswer={answer} />);
fireEvent.click(screen.getByRole("checkbox", { name: /Don't ask again/ }));
- fireEvent.keyDown(window, { key: "Escape" });
+ fireEvent.keyDown(screen.getByRole("dialog"), { key: "Escape" });
expect(answer).toHaveBeenLastCalledWith(false, false);
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
expect(answer).toHaveBeenLastCalledWith(false, true);
});
-it("traps keyboard focus and returns it when dismissed", () => {
+it("keeps keyboard focus inside and returns it when dismissed", () => {
const opener = document.createElement("button");
document.body.append(opener);
opener.focus();
const view = render(<ReferenceIconGenerationDialog count={1} onAnswer={vi.fn()} />);
const checkbox = screen.getByRole("checkbox");
- const start = screen.getByRole("button", { name: "Start generation" });
- start.focus();
- fireEvent.keyDown(window, { key: "Tab" });
+ const cancel = screen.getByRole("button", { name: "Cancel" });
expect(document.activeElement).toBe(checkbox);
- fireEvent.keyDown(window, { key: "Tab", shiftKey: true });
- expect(document.activeElement).toBe(start);
+ cancel.focus();
+ fireEvent.keyDown(cancel, { key: "Tab" });
+ expect(document.activeElement).toBe(checkbox);
+ fireEvent.keyDown(checkbox, { key: "Tab", shiftKey: true });
+ expect(document.activeElement).toBe(cancel);
view.unmount();
expect(document.activeElement).toBe(opener);
opener.remove();
diff --git a/src/components/UnsavedProject.integration.test.tsx b/src/components/UnsavedProject.integration.test.tsx
index e3c07cf..1663ab4 100644
--- a/src/components/UnsavedProject.integration.test.tsx
+++ b/src/components/UnsavedProject.integration.test.tsx
@@ -23,7 +23,7 @@ it("returns immediately when the project has no unsaved changes", () => {
const { onBack } = setup();
back();
expect(onBack).toHaveBeenCalledOnce();
- expect(screen.queryByRole("alertdialog")).not.toBeInTheDocument();
+ expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
});
it("offers back, save or discard and waits for saving before leaving", async () => {
@@ -31,11 +31,12 @@ it("offers back, save or discard and waits for saving before leaving", async ()
const writer = vi.fn((_record: ProjectRecord) => new Promise<void>((resolve) => { finish = resolve; }));
const { onBack, session } = setup(writer);
changeName(); back();
- const dialog = screen.getByRole("alertdialog", { name: "Save changes?" });
- expect(within(dialog).getAllByRole("button").map((button) => button.textContent)).toEqual(["Back", "Discard changes", "Save changes"]);
- fireEvent.click(within(dialog).getByRole("button", { name: "Save changes" }));
+ const dialog = screen.getByRole("dialog", { name: "Save changes to “My project”?" });
+ // The Windows question, in the Windows order.
+ expect(within(dialog).getAllByRole("button").map((button) => button.textContent)).toEqual(["Save", "Don't save", "Cancel"]);
+ fireEvent.click(within(dialog).getByRole("button", { name: "Save" }));
await waitFor(() => expect(writer).toHaveBeenCalledOnce());
- expect(within(dialog).getByRole("button", { name: "Back" })).toBeDisabled();
+ expect(within(dialog).getByRole("button", { name: "Don't save" })).toBeDisabled();
expect(onBack).not.toHaveBeenCalled();
expect(writer.mock.calls[0][0].config.references[0].name).toBe("Unsaved hero");
await act(async () => finish());
@@ -43,25 +44,25 @@ it("offers back, save or discard and waits for saving before leaving", async ()
expect(session.getSnapshot().dirty).toBe(false);
});
-it.each(["Back", "Escape"])("returns to editing via %s without saving or discarding changes", (action) => {
+it.each(["Cancel", "Escape"])("returns to editing via %s without saving or discarding changes", (action) => {
const { onBack, session, writer } = setup();
changeName(); back();
- const dialog = screen.getByRole("alertdialog", { name: "Save changes?" });
- if (action === "Back") fireEvent.click(within(dialog).getByRole("button", { name: "Back" }));
+ const dialog = screen.getByRole("dialog", { name: "Save changes to “My project”?" });
+ if (action === "Cancel") fireEvent.click(within(dialog).getByRole("button", { name: "Cancel" }));
else fireEvent.keyDown(dialog, { key: "Escape" });
- expect(screen.queryByRole("alertdialog")).not.toBeInTheDocument();
+ expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
expect(screen.getByRole("textbox", { name: "Reference name" })).toHaveValue("Unsaved hero");
expect(session.getSnapshot().dirty).toBe(true);
expect(writer).not.toHaveBeenCalled();
expect(onBack).not.toHaveBeenCalled();
back();
- expect(screen.getByRole("alertdialog", { name: "Save changes?" })).toBeInTheDocument();
+ expect(screen.getByRole("dialog", { name: "Save changes to “My project”?" })).toBeInTheDocument();
});
it("discards unsaved changes from the retained session so reopening restores saved values", async () => {
const { onBack, session, writer, queue, project } = setup();
changeName(); back();
- fireEvent.click(screen.getByRole("button", { name: "Discard changes" }));
+ fireEvent.click(screen.getByRole("button", { name: "Don't save" }));
await waitFor(() => expect(onBack).toHaveBeenCalledOnce());
expect(writer).not.toHaveBeenCalled();
expect(session.getSnapshot().dirty).toBe(false);
@@ -72,11 +73,11 @@ it("keeps changes and reports a save failure before allowing another save attemp
const writer = vi.fn(async (_record: ProjectRecord) => undefined).mockRejectedValueOnce(new Error("Disk locked"));
const { onBack, session } = setup(writer);
changeName(); back();
- const dialog = screen.getByRole("alertdialog");
- fireEvent.click(within(dialog).getByRole("button", { name: "Save changes" }));
+ const dialog = screen.getByRole("dialog");
+ fireEvent.click(within(dialog).getByRole("button", { name: "Save" }));
expect(await within(dialog).findByRole("alert")).toHaveTextContent("Disk locked");
expect(onBack).not.toHaveBeenCalled();
expect(session.getSnapshot().dirty).toBe(true);
- fireEvent.click(within(dialog).getByRole("button", { name: "Save changes" }));
+ fireEvent.click(within(dialog).getByRole("button", { name: "Save" }));
await waitFor(() => expect(onBack).toHaveBeenCalledOnce());
});
diff --git a/src/styles/shell.css b/src/styles/shell.css
index 4b01e11..9859460 100644
--- a/src/styles/shell.css
+++ b/src/styles/shell.css
@@ -30,9 +30,13 @@
overflow: hidden;
}
+/* Settings fills this: .settings-view is flex: 1 with its own scrolling
+ panes, so the content area is a flex column of definite height. */
.app-screen__content {
+ display: flex;
+ flex-direction: column;
flex: 1 1 auto;
min-height: 0;
min-width: 0;
- overflow: auto;
+ overflow: hidden;
}