feat(FN-3505): add node onboarding mapping flow with asset-gated bundling
- Add onboarding project-mapping API contracts and dashboard UI wiring in AddNodeModal/NodesView - Persist node-to-project mappings with rollback-safe failure handling and expanded hook/API test coverage - Document node onboarding mapping behavior in architecture and multi-project docs - Add tsup bundle asset gates for openclaw bridge and droid runtime, with changesets and bundle output tests Fusion-Task-Id: FN-3505
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { render, screen, fireEvent } from "@testing-library/react";
|
||||
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
|
||||
import { NodesView } from "../NodesView";
|
||||
import type { NodeInfo, ProjectInfo } from "../../api";
|
||||
import { useNodes } from "../../hooks/useNodes";
|
||||
@@ -217,6 +217,35 @@ describe("NodesView", () => {
|
||||
expect(screen.getByRole("dialog", { name: "Add Node" })).toBeDefined();
|
||||
});
|
||||
|
||||
it("refreshes projects after node registration succeeds", async () => {
|
||||
const register = vi.fn().mockResolvedValue(makeNode({ id: "node-new", name: "New Node" }));
|
||||
const refreshProjects = vi.fn().mockResolvedValue(undefined);
|
||||
mockUseNodes.mockReturnValue(makeUseNodesResult({ nodes: [], register }));
|
||||
mockUseProjects.mockReturnValue({
|
||||
projects: [makeProject()],
|
||||
loading: false,
|
||||
error: null,
|
||||
refresh: refreshProjects,
|
||||
register: vi.fn(),
|
||||
update: vi.fn(),
|
||||
unregister: vi.fn(),
|
||||
});
|
||||
|
||||
render(<NodesView addToast={vi.fn()} onClose={vi.fn()} />);
|
||||
|
||||
fireEvent.click(screen.getByText("Add Node"));
|
||||
fireEvent.change(screen.getByPlaceholderText("Build Machine"), { target: { value: "New Node" } });
|
||||
fireEvent.click(screen.getByTestId("add-node-submit"));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(register).toHaveBeenCalledWith(expect.objectContaining({
|
||||
name: "New Node",
|
||||
projectMappings: [],
|
||||
}));
|
||||
expect(refreshProjects).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
it("opens Node Detail modal when a node card is clicked", () => {
|
||||
mockUseProjects.mockReturnValue({
|
||||
projects: [makeProject({ nodeId: "node-1" })],
|
||||
|
||||
Reference in New Issue
Block a user