The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
import userEvent from "@testing-library/user-event";
import {
setupCreateLibraryEndpoint,
setupCreateLibraryEndpointError,
} from "__support__/server-mocks";
import { renderWithProviders, screen, waitFor } from "__support__/ui";
import { LibraryEmptyState } from "./LibraryEmptyState";
type SetupOpts = {
hasCreateError?: boolean;
};
function setup({ hasCreateError }: SetupOpts = {}) {
if (hasCreateError) {
setupCreateLibraryEndpointError();
} else {
setupCreateLibraryEndpoint();
}
renderWithProviders(<LibraryEmptyState />);
}
describe("LibraryEmptyState", () => {
it("should be able to create the library", async () => {
setup();
await userEvent.click(screen.getByText("Create my semantic layer"));
await waitFor(() =>
expect(
screen.queryByText("Create my semantic layer"),
).not.toBeInTheDocument(),
);
});
it("should show a library creation error", async () => {
setup({ hasCreateError: true });
await userEvent.click(screen.getByText("Create my semantic layer"));
expect(await screen.findByText("Something went wrong")).toBeInTheDocument();
});
});