- Add global updateCheckEnabled setting to core schema/types and wire dashboard command to cache update checks in the CLI - Implement dashboard server update-check cache module plus REST routes for status and refresh behavior - Add dashboard client hook, legacy API helpers, and UpdateAvailableBanner UI to show cached CLI update notices - Cover update-check server routes, hook behavior, banner rendering, and route registration with focused tests - Document update-check configuration and API behavior in architecture and settings reference docs
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
import { describe, it, expect, vi } from "vitest";
|
|
import { fireEvent, render, screen } from "@testing-library/react";
|
|
import { useState } from "react";
|
|
import { UpdateAvailableBanner } from "../UpdateAvailableBanner";
|
|
|
|
describe("UpdateAvailableBanner", () => {
|
|
it("renders version information and release notes link", () => {
|
|
render(
|
|
<UpdateAvailableBanner latestVersion="0.7.0" currentVersion="0.6.0" onDismiss={vi.fn()} />,
|
|
);
|
|
|
|
expect(screen.getByText(/Update available: v0.7.0 \(current: v0.6.0\)/)).toBeInTheDocument();
|
|
expect(screen.getByText("npm i -g @runfusion/fusion")).toBeInTheDocument();
|
|
expect(screen.getByRole("link", { name: "Release notes" })).toHaveAttribute(
|
|
"href",
|
|
"https://github.com/Runfusion/Fusion/releases",
|
|
);
|
|
});
|
|
|
|
it("dismiss button calls onDismiss", () => {
|
|
const onDismiss = vi.fn();
|
|
|
|
render(
|
|
<UpdateAvailableBanner latestVersion="0.7.0" currentVersion="0.6.0" onDismiss={onDismiss} />,
|
|
);
|
|
|
|
fireEvent.click(screen.getByRole("button", { name: "Dismiss update notice" }));
|
|
expect(onDismiss).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it("can be hidden by parent on dismiss", () => {
|
|
function Harness() {
|
|
const [visible, setVisible] = useState(true);
|
|
if (!visible) return null;
|
|
return (
|
|
<UpdateAvailableBanner
|
|
latestVersion="0.7.0"
|
|
currentVersion="0.6.0"
|
|
onDismiss={() => setVisible(false)}
|
|
/>
|
|
);
|
|
}
|
|
|
|
render(<Harness />);
|
|
expect(screen.getByRole("status")).toBeInTheDocument();
|
|
|
|
fireEvent.click(screen.getByRole("button", { name: "Dismiss update notice" }));
|
|
expect(screen.queryByRole("status")).toBeNull();
|
|
});
|
|
});
|