7a88b74016
- Artifacts hub: upload a file from the computer; make a skill by uploading a Markdown file, files, a folder or a .zip/.skill, or by writing it in the dialog; add plugins by picking from the list a marketplace link answers (POST /api/artifacts/plugin/inspect); Settings → AI tools → Artifacts Hub. - Console tabs are combos of up to four split panes (ConsoleTabs, PaneGrid). - Accounts: an own avatar (PUT/DELETE /api/me/avatar, raster only, ≤ 1 MB, <data dir>/avatars/), shown with name and role at the sidebar's foot and on the workspace owner groups (GET /api/users/:id/avatar, owner_avatar_at). - Users page: per-user storage (GET /api/users/storage, measured in a worker) and account-pool spend/tokens per account (server/lib/pool-usage.js). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
1.9 KiB
TypeScript
47 lines
1.9 KiB
TypeScript
/**
|
|
* @file Tests for ArtifactsHubSettings — the admin's Hub install switch in
|
|
* Settings → AI tools: hidden in local mode and for a non-manager, and a
|
|
* toggle saves through PUT /api/artifacts/settings.
|
|
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
|
*/
|
|
|
|
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
import "../../../i18n";
|
|
import { ArtifactsHubSettings } from "../ArtifactsHubSettings";
|
|
import { api } from "../../../lib/api";
|
|
|
|
vi.mock("../../../lib/api", () => ({
|
|
api: { artifacts: { settings: vi.fn(), setInstallsEnabled: vi.fn() } },
|
|
}));
|
|
|
|
const settings = vi.mocked(api.artifacts.settings);
|
|
const setInstalls = vi.mocked(api.artifacts.setInstallsEnabled);
|
|
const base = { serverMode: true, canShare: true, installsEnabled: true, canManage: true };
|
|
|
|
describe("ArtifactsHubSettings", () => {
|
|
beforeEach(() => vi.clearAllMocks());
|
|
|
|
it("lets an admin turn Hub installs off", async () => {
|
|
settings.mockResolvedValue(base);
|
|
setInstalls.mockResolvedValue({ installsEnabled: false });
|
|
render(<ArtifactsHubSettings />);
|
|
const sw = await screen.findByRole("switch", { name: "Allow installing from the Hub" });
|
|
fireEvent.click(sw);
|
|
await waitFor(() => expect(setInstalls).toHaveBeenCalledWith(false));
|
|
await waitFor(() => expect(sw).toHaveAttribute("aria-checked", "false"));
|
|
});
|
|
|
|
it("renders nothing for a non-manager or in local mode", async () => {
|
|
settings.mockResolvedValue({ ...base, canManage: false });
|
|
const { container, unmount } = render(<ArtifactsHubSettings />);
|
|
await waitFor(() => expect(settings).toHaveBeenCalled());
|
|
expect(container).toBeEmptyDOMElement();
|
|
unmount();
|
|
settings.mockResolvedValue({ ...base, serverMode: false });
|
|
const r = render(<ArtifactsHubSettings />);
|
|
await waitFor(() => expect(settings).toHaveBeenCalledTimes(2));
|
|
expect(r.container).toBeEmptyDOMElement();
|
|
});
|
|
});
|