Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,44 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import type { ApiSpecsDto } from "../services/ApiSpecsService";
|
||||
import ApiSpecs from "./ApiSpecs";
|
||||
|
||||
vi.mock("~/components/editors/MonacoEditor", () => ({ default: ({ value }: { value: string }) => <pre data-testid="monaco">{value}</pre> }));
|
||||
vi.mock("~/components/ui/icons/ExternalLinkEmptyIcon", () => ({ default: () => null }));
|
||||
vi.mock("react-i18next", () => ({ useTranslation: () => ({ t: (key: string) => key }) }));
|
||||
|
||||
const item = {
|
||||
openApi: { openapi: "3.1.0" },
|
||||
postmanCollection: { info: { name: "API" }, item: [] },
|
||||
apiDocsUrl: "https://api.example.com/v1/docs",
|
||||
} as unknown as ApiSpecsDto;
|
||||
|
||||
describe("ApiSpecs", () => {
|
||||
it("can hide the admin-only Postman download while still rendering the collection preview", () => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<ApiSpecs item={item} postmanCollectionUrl={null} />
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expect(screen.getByText("docs.openApi")).toBeInTheDocument();
|
||||
expect(screen.queryByText("docs.downloadPostmanCollection")).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole("link", { name: /postman/i })).not.toBeInTheDocument();
|
||||
expect(screen.getAllByTestId("monaco")).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("can hide the full Postman collection preview on tenant-facing docs", () => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<ApiSpecs item={item} postmanCollectionUrl={null} showPostmanCollection={false} />
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expect(screen.queryByText("docs.downloadPostmanCollection")).not.toBeInTheDocument();
|
||||
expect(screen.getAllByTestId("monaco")).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user