feat: publish Agent Studio integrations and setup guide
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { CmsPanel } from "../src/components/cms/CmsPanel.js";
|
||||
|
||||
afterEach(() => vi.unstubAllGlobals());
|
||||
describe("CMS panel", () => {
|
||||
it("clears passwords after failed login and never renders reflected upstream secrets", async () => {
|
||||
vi.stubGlobal("fetch", (_url: string, init?: RequestInit) => Promise.resolve(new Response(JSON.stringify(init?.method === "POST" ? { error: { code: "CMS_LOGIN_FAILED", message: "echo password-secret" } } : { connection: { configured: true, connected: false } }), { status: init?.method === "POST" ? 400 : 200 })));
|
||||
render(<CmsPanel sessionId="ses_1" busy={false} onSelect={() => undefined} />);
|
||||
const user = userEvent.setup();
|
||||
await user.click(screen.getByRole("button", { name: "CMS 连接与选剧" }));
|
||||
expect(screen.getByText(/选段审核和 10 秒 REVIEW 预览/)).toBeVisible();
|
||||
await user.type(screen.getByLabelText("CMS 邮箱"), "fixture@example.com");
|
||||
await user.type(screen.getByLabelText("CMS 密码"), "password-secret");
|
||||
await user.click(screen.getByRole("button", { name: "登录 CMS" }));
|
||||
expect(screen.getByLabelText("CMS 密码")).toHaveValue("");
|
||||
expect(await screen.findByRole("alert")).toHaveTextContent("登录失败");
|
||||
expect(screen.queryByText(/password-secret/)).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user