Skip to content
Snippets Groups Projects
Unverified Commit 85fb73c1 authored by Nick Fitzpatrick's avatar Nick Fitzpatrick Committed by GitHub
Browse files

simplifying unit test, adding checks to e2e test (#31778)

parent 4a2b5dc4
No related branches found
No related tags found
No related merge requests found
......@@ -206,16 +206,18 @@ describe("scenarios > home > custom homepage", () => {
it("should give you the option to set a custom home page using home page CTA", () => {
cy.visit("/");
cy.get("main").findByText("Customize").click();
modal()
.findByText(/Select a dashboard/i)
.click();
modal().within(() => {
cy.findByRole("button", { name: "Save" }).should("be.disabled");
cy.findByText(/Select a dashboard/i).click();
});
//Ensure that personal collections have been removed
popover().contains("Your personal collection").should("not.exist");
popover().contains("All personal collections").should("not.exist");
popover().findByText("Orders in a dashboard").click();
modal().findByText("Save").click();
modal().findByRole("button", { name: "Save" }).click();
cy.location("pathname").should("equal", "/dashboard/1");
});
});
......
import userEvent from "@testing-library/user-event";
import { renderWithProviders, screen } from "__support__/ui";
import {
setupCollectionsEndpoints,
setupCollectionItemsEndpoint,
setupDashboardEndpoints,
} from "__support__/server-mocks";
import {
createMockCollection,
createMockCollectionItem,
createMockDashboard,
} from "metabase-types/api/mocks";
import { CustomHomePageModal } from "./CustomHomePageModal";
const ROOT_COLLECTION = createMockCollection({
id: "root",
can_write: true,
name: "Our Analytics",
location: undefined,
});
const COLLECTION_ITEM = createMockCollectionItem({
name: "Foo",
model: "dashboard",
});
const FOO_DASHBOARD = createMockDashboard({
name: "Foo",
});
const setup = ({ ...props } = {}) => {
const onClose = jest.fn();
setupCollectionsEndpoints({ collections: [ROOT_COLLECTION] });
setupCollectionItemsEndpoint(ROOT_COLLECTION, [COLLECTION_ITEM]);
setupDashboardEndpoints(FOO_DASHBOARD);
renderWithProviders(
<CustomHomePageModal onClose={onClose} isOpen={true} {...props} />,
);
};
describe("custom hompage modal", () => {
it("should only enable the save button if a dashboard has been selected", async () => {
it("should only enable the save button if a dashboard has been selected", () => {
setup();
expect(await screen.findByRole("button", { name: /save/i })).toBeDisabled();
userEvent.click(await screen.findByText("Select a dashboard"));
userEvent.click(await screen.findByText("Foo"));
expect(await screen.findByRole("button", { name: /save/i })).toBeEnabled();
expect(screen.getByRole("button", { name: /save/i })).toBeDisabled();
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment