Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as _ from "../../../../../support/Objects/ObjectsCore";

describe(
"Checkbox Widget Functionality",
{ tags: ["@tag.Widget", "@tag.Checkbox"] },
function () {
before(() => {
_.agHelper.AddDsl("emptyDSL");
});
it("Add new widget", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please help me understand the necessity of Cypress test cases in this context? I believe unit testing might be sufficient in this scenario.
Your insights would be appreciated.

cy.dragAndDropToCanvas("checkboxwidget", { x: 300, y: 300 });
cy.get(".t--widget-checkboxwidget").should("exist");
});
it("Checkbox and it's label should be aligned in center", function () {
cy.openPropertyPane("checkboxwidget");
const checkboxLabel = ".sc-hINMOq";
const triggerStyle = "#radix-61-trigger-style > .sc-bcXHqe";
cy.get(checkboxLabel).click({ force: true });
cy.get(triggerStyle).click({ force: true });
_.propPane.EnterJSContext("Font size", "");
_.propPane.EnterJSContext("Font size", "4rem");
const checkboxControl = ".bp3-control";
cy.get(checkboxControl).should("have.css", "align-items", "center");
cy.get(checkboxControl).should("exist");
});
},
);
34 changes: 34 additions & 0 deletions app/client/src/widgets/CheckboxWidget/component/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from "react";
import { render } from "@testing-library/react";
import "jest-styled-components";
import CheckboxComponent from ".";
import { Colors } from "constants/Colors";
import { LabelPosition } from "components/constants";
import { AlignWidgetTypes } from "WidgetProvider/constants";

describe("CheckboxComponent", () => {
it("should render the StyledCheckbox with align-items set to center", () => {
const { container } = render(
<CheckboxComponent
widgetId="1"
isChecked={true}
isLoading={false}
label="Test Label"
onCheckChange={() => {}}
accentColor={Colors.GREEN_SOLID}
borderRadius="0"
labelPosition={LabelPosition.Left}
alignWidget={AlignWidgetTypes.LEFT}
isDynamicHeightEnabled={false}
isLabelInline={false}
isRequired={false}
isValid={true}
minHeight={50}
isFullWidth={true}
inputRef={() => {}}
/>,
);
const styledCheckbox = container.querySelector(".bp3-checkbox");
expect(styledCheckbox).toHaveStyleRule("align-items", "center");
});
});
4 changes: 4 additions & 0 deletions app/client/src/widgets/CheckboxWidget/component/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ export const CheckboxLabel = styled.div<{
export const StyledCheckbox = styled(Checkbox)`
&.bp3-control.bp3-align-right {
padding-right: 0px;
};
align-items: center;
&.bp3-control.bp3-checkbox .bp3-control-indicator {
margin-top: -0.05rem;
}
`;

Expand Down