Skip to content

Commit

Permalink
modified-common-locator
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaHariprasad5123 committed Aug 20, 2024
1 parent bc182d1 commit b41fbe8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,11 @@ describe(
agHelper.AssertExistingToggleState("Required", "false");
propPane.TogglePropertyState("Required", "On");
deployMode.DeployApp(locators._widgetInDeployed(draggableWidgets.FORM));
cy.get(commonlocators.selectClearButton).should("not.exist");
const cancelButton = commonlocators.selectClearButton
.split("=")[1]
.replace("']", "")
.replace("'", "");
cy.get(cancelButton).should("not.exist");
});
},
);
2 changes: 1 addition & 1 deletion app/client/cypress/locators/commonlocators.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"singleSelectMenuItem": ".bp3-menu-item.single-select div",
"singleSelectWidgetMenuItem": ".menu-item-link",
"singleSelectActiveMenuItem": ".menu-item-active div",
"selectClearButton": "selectbutton.btn.cancel",
"selectClearButton": "[data-testid='selectbutton.btn.cancel']",
"selectInputSearch": ".select-popover-wrapper .bp3-input",
"multiSelectMenuItem": "rc-select-item.rc-select-item-option div",
"selectMenuItem": ".bp3-menu li>a>div",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { fireEvent, render } from "@testing-library/react";

import type { SelectButtonProps } from "./SelectButton";
import SelectButton from "./SelectButton";
import commonlocators from "../../../../cypress/locators/commonlocators.json";

// It is necessary to make a mock of the Icon component as the error falls due to React.lazy in importIconImpl
jest.mock("@design-system/widgets-old", () => {
Expand Down Expand Up @@ -60,18 +61,22 @@ describe("SelectButton", () => {
});

it("should not render cancel button when select widget required is true", () => {
const { queryByTestId } = renderComponent({
const { container } = renderComponent({
...defaultProps,
isRequired: true,
});
expect(queryByTestId("selectbutton.btn.cancel")).toBeNull();
expect(
container.querySelector(commonlocators.selectClearButton),
).toBeNull();
});

it("should render cancel button when select widget required is false", () => {
const { getByTestId } = renderComponent({
const { container } = renderComponent({
...defaultProps,
isRequired: false,
});
expect(getByTestId("selectbutton.btn.cancel")).not.toBeNull();
expect(
container.querySelector(commonlocators.selectClearButton),
).not.toBeNull();
});
});

0 comments on commit b41fbe8

Please sign in to comment.