53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { flushSync } from "react-dom";
|
|
import { createRoot, type Root } from "react-dom/client";
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { OnboardingWizardVariant } from "./OnboardingWizardVariant";
|
|
|
|
const mockInstanceSettingsApi = vi.hoisted(() => ({
|
|
getExperimental: vi.fn(),
|
|
}));
|
|
|
|
vi.mock("@/api/instanceSettings", () => ({
|
|
instanceSettingsApi: mockInstanceSettingsApi,
|
|
}));
|
|
|
|
vi.mock("./OnboardingWizard", () => ({
|
|
OnboardingWizard: () => <div data-testid="wizard-capsule" />,
|
|
}));
|
|
|
|
describe("OnboardingWizardVariant (PAP-138)", () => {
|
|
let container: HTMLDivElement;
|
|
let root: Root | null = null;
|
|
|
|
function renderVariant() {
|
|
root = createRoot(container);
|
|
flushSync(() => {
|
|
root!.render(<OnboardingWizardVariant />);
|
|
});
|
|
}
|
|
|
|
beforeEach(() => {
|
|
container = document.createElement("div");
|
|
document.body.appendChild(container);
|
|
});
|
|
|
|
afterEach(() => {
|
|
flushSync(() => {
|
|
root?.unmount();
|
|
});
|
|
root = null;
|
|
container.remove();
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("renders the capsule wizard without reading the chat flag", () => {
|
|
mockInstanceSettingsApi.getExperimental.mockResolvedValue({});
|
|
renderVariant();
|
|
|
|
expect(container.querySelector('[data-testid="wizard-capsule"]')).not.toBeNull();
|
|
expect(mockInstanceSettingsApi.getExperimental).not.toHaveBeenCalled();
|
|
});
|
|
});
|