diff --git a/cypress/components/date/date.cy.tsx b/cypress/components/date/date.cy.tsx index 9c28bc31dc..81d4b5e8e5 100644 --- a/cypress/components/date/date.cy.tsx +++ b/cypress/components/date/date.cy.tsx @@ -527,6 +527,34 @@ context("Test for DateInput component", () => { .parent() .should("have.css", "max-width", "100%"); }); + + it("should render Date with disabled prop", () => { + CypressMountWithProviders(); + + dateInput().should("be.disabled").and("have.attr", "disabled"); + }); + + it("should render Date icon with disabled style", () => { + CypressMountWithProviders(); + + dateIcon() + .should("be.visible") + .and("have.css", "color", "rgba(0, 0, 0, 0.3)"); + }); + + it("should render Date with read only prop", () => { + CypressMountWithProviders(); + + dateInput().should("have.attr", "readOnly"); + }); + + it("should render Date icon with read only style", () => { + CypressMountWithProviders(); + + dateIcon() + .should("be.visible") + .and("have.css", "color", "rgba(0, 0, 0, 0.3)"); + }); }); it("should check the pickerProps prop", () => { diff --git a/cypress/components/select/filterable-select/filterable-select.cy.tsx b/cypress/components/select/filterable-select/filterable-select.cy.tsx index deb9422c8d..3b0c855ee7 100644 --- a/cypress/components/select/filterable-select/filterable-select.cy.tsx +++ b/cypress/components/select/filterable-select/filterable-select.cy.tsx @@ -201,6 +201,14 @@ context("Tests for FilterableSelect component", () => { .and("have.attr", "disabled"); }); + it("should render FilterableSelect icon with disabled style", () => { + CypressMountWithProviders(); + + dropdownButton() + .should("be.visible") + .and("have.css", "color", "rgba(0, 0, 0, 0.3)"); + }); + it("should render FilterableSelect as read only", () => { CypressMountWithProviders(); @@ -209,6 +217,14 @@ context("Tests for FilterableSelect component", () => { selectListWrapper().should("not.be.visible"); }); + it("should render FilterableSelect icon with read only style", () => { + CypressMountWithProviders(); + + dropdownButton() + .should("be.visible") + .and("have.css", "color", "rgba(0, 0, 0, 0.3)"); + }); + it.each([ [SIZE.SMALL, 32], [SIZE.MEDIUM, 40], diff --git a/cypress/components/select/multi-select/multi-select.cy.tsx b/cypress/components/select/multi-select/multi-select.cy.tsx index 1d02f47d98..f489129f92 100644 --- a/cypress/components/select/multi-select/multi-select.cy.tsx +++ b/cypress/components/select/multi-select/multi-select.cy.tsx @@ -212,6 +212,14 @@ context("Tests for MultiSelect component", () => { .and("have.attr", "disabled"); }); + it("should render MultiSelect icon with disabled style", () => { + CypressMountWithProviders(); + + dropdownButton() + .should("be.visible") + .and("have.css", "color", "rgba(0, 0, 0, 0.3)"); + }); + it("should render MultiSelect as read only", () => { CypressMountWithProviders(); @@ -220,6 +228,14 @@ context("Tests for MultiSelect component", () => { selectListWrapper().should("not.be.visible"); }); + it("should render MultiSelect icon with read only style", () => { + CypressMountWithProviders(); + + dropdownButton() + .should("be.visible") + .and("have.css", "color", "rgba(0, 0, 0, 0.3)"); + }); + it.each([ [SIZE.SMALL, 32], [SIZE.MEDIUM, 40], diff --git a/cypress/components/select/simple-select/simple-select.cy.tsx b/cypress/components/select/simple-select/simple-select.cy.tsx index 15c3d319a6..7a96cd582f 100644 --- a/cypress/components/select/simple-select/simple-select.cy.tsx +++ b/cypress/components/select/simple-select/simple-select.cy.tsx @@ -175,6 +175,14 @@ context("Tests for SimpleSelect component", () => { .and("have.attr", "disabled"); }); + it("should render SimpleSelect icon with disabled style", () => { + CypressMountWithProviders(); + + dropdownButton() + .should("be.visible") + .and("have.css", "color", "rgba(0, 0, 0, 0.3)"); + }); + it("should render SimpleSelect as read only", () => { CypressMountWithProviders(); @@ -184,6 +192,14 @@ context("Tests for SimpleSelect component", () => { selectListWrapper().should("not.be.visible"); }); + it("should render SimpleSelect icon with read only style", () => { + CypressMountWithProviders(); + + dropdownButton() + .should("be.visible") + .and("have.css", "color", "rgba(0, 0, 0, 0.3)"); + }); + it("should render SimpleSelect as transparent", () => { CypressMountWithProviders(); diff --git a/cypress/components/textarea/textarea.cy.tsx b/cypress/components/textarea/textarea.cy.tsx index d365f18293..9b78bbbe37 100644 --- a/cypress/components/textarea/textarea.cy.tsx +++ b/cypress/components/textarea/textarea.cy.tsx @@ -307,6 +307,15 @@ context("Tests for Textarea component", () => { textareaChildren().should("be.disabled").and("have.attr", "disabled"); }); + it("should render Textarea icon with disabled style", () => { + CypressMountWithProviders(); + + textarea() + .find(ICON) + .should("be.visible") + .and("have.css", "color", "rgba(0, 0, 0, 0.3)"); + }); + it.each(testData)( "should render Textarea with placeholder prop set to %s", (placeholder) => { @@ -364,6 +373,15 @@ context("Tests for Textarea component", () => { textareaChildren().and("have.attr", "readOnly"); }); + it("should render Textarea icon with readOnly style", () => { + CypressMountWithProviders(); + + textarea() + .find(ICON) + .should("be.visible") + .and("have.css", "color", "rgba(0, 0, 0, 0.3)"); + }); + it.each(["error", "warning", "info"])( "should verify Textarea is displayed with %s validation icon on input", (type) => { diff --git a/cypress/components/textbox/textbox.cy.tsx b/cypress/components/textbox/textbox.cy.tsx index 989eefa888..61e98c0f72 100644 --- a/cypress/components/textbox/textbox.cy.tsx +++ b/cypress/components/textbox/textbox.cy.tsx @@ -363,6 +363,17 @@ context("Tests for Textbox component", () => { textboxInput().should("be.disabled").and("have.attr", "disabled"); }); + it("should render Textbox icon with disabled style", () => { + CypressMountWithProviders( + + ); + + textbox() + .find(ICON) + .should("be.visible") + .and("have.css", "color", "rgba(0, 0, 0, 0.3)"); + }); + it.each(testData)( "should render Textbox with placeholder prop set to %s", (placeholder) => { @@ -420,6 +431,17 @@ context("Tests for Textbox component", () => { textboxInput().and("have.attr", "readOnly"); }); + it("should render Textbox icon with readOnly style", () => { + CypressMountWithProviders( + + ); + + textbox() + .find(ICON) + .should("be.visible") + .and("have.css", "color", "rgba(0, 0, 0, 0.3)"); + }); + it.each(["error", "warning", "info"])( "should verify Textbox is displayed with %s validation icon on input", (type) => { diff --git a/src/__internal__/input-icon-toggle/input-icon-toggle.component.tsx b/src/__internal__/input-icon-toggle/input-icon-toggle.component.tsx index ee30f6ef67..caaeaf9eee 100644 --- a/src/__internal__/input-icon-toggle/input-icon-toggle.component.tsx +++ b/src/__internal__/input-icon-toggle/input-icon-toggle.component.tsx @@ -75,7 +75,7 @@ const InputIconToggle = ({ ); } - if (type && !(disabled || readOnly)) { + if (type) { return ( - + ); } diff --git a/src/__internal__/input-icon-toggle/input-icon-toggle.spec.tsx b/src/__internal__/input-icon-toggle/input-icon-toggle.spec.tsx index bbe7c99d58..a40b2d88d7 100644 --- a/src/__internal__/input-icon-toggle/input-icon-toggle.spec.tsx +++ b/src/__internal__/input-icon-toggle/input-icon-toggle.spec.tsx @@ -17,14 +17,6 @@ function renderInputIconToggle(props: InputIconToggleProps) { } describe("InputIconToggle", () => { - describe("when initiated with the disabled prop set to true", () => { - it("does not render anything", () => { - const wrapper = shallow(renderInputIconToggle({ disabled: true })); - - expect(wrapper.isEmptyRender()).toBeTruthy(); - }); - }); - describe("tooltip positioning", () => { const testCases: [InputIconToggleProps["align"], string][] = [ ["left", "right"], @@ -64,7 +56,7 @@ describe("InputIconToggle", () => { }); describe("with disabled prop", () => { - it("does not render an icon", () => { + it("does render an icon", () => { const wrapper = mount( renderInputIconToggle({ [validationProp]: "Message", @@ -73,7 +65,7 @@ describe("InputIconToggle", () => { }) ); expect(wrapper.find(ValidationIcon).exists()).toBe(false); - expect(wrapper.find(Icon).exists()).toBe(false); + expect(wrapper.find(Icon).exists()).toBe(true); }); }); @@ -86,8 +78,8 @@ describe("InputIconToggle", () => { readOnly: true, }) ); - const validationIcon = wrapper.find(ValidationIcon); - expect(validationIcon.exists()).toBe(true); + expect(wrapper.find(ValidationIcon).exists()).toBe(true); + expect(wrapper.find(Icon).exists()).toBe(false); }); }); }); @@ -154,18 +146,33 @@ describe("InputIconToggle", () => { } ); - describe("does not render input icon", () => { + describe("renders input icon", () => { it("when disabled prop is true", () => { const wrapper = mount( renderInputIconToggle({ inputIcon: "dropdown", disabled: true }) ); - expect(wrapper.find(Icon).exists()).toBe(false); + expect(wrapper.find(Icon).exists()).toBe(true); + expect(wrapper.find(Icon).prop("disabled")).toBe(true); + assertStyleMatch( + { + cursor: "not-allowed", + }, + wrapper.find(InputIconToggleStyle) + ); }); it("when readOnly prop is true", () => { const wrapper = mount( renderInputIconToggle({ inputIcon: "dropdown", readOnly: true }) ); - expect(wrapper.find(Icon).exists()).toBe(false); + + expect(wrapper.find(Icon).exists()).toBe(true); + expect(wrapper.find(Icon).prop("disabled")).toBe(true); + assertStyleMatch( + { + cursor: "default", + }, + wrapper.find(InputIconToggleStyle) + ); }); }); diff --git a/src/__internal__/input-icon-toggle/input-icon-toggle.style.ts b/src/__internal__/input-icon-toggle/input-icon-toggle.style.ts index 0041d2686d..efb3d00c10 100644 --- a/src/__internal__/input-icon-toggle/input-icon-toggle.style.ts +++ b/src/__internal__/input-icon-toggle/input-icon-toggle.style.ts @@ -9,6 +9,8 @@ const oldFocusStyling = ` export interface InputIconToggleStyleProps extends ValidationProps { size?: "small" | "medium" | "large"; + disabled?: boolean; + readOnly?: boolean; onClick?: ( event: | React.MouseEvent @@ -37,6 +39,18 @@ const InputIconToggleStyle = styled.span.attrs( width: ${sizes[size].height}; `} + ${({ disabled }) => + disabled && + css` + cursor: not-allowed; + `} + + ${({ readOnly }) => + readOnly && + css` + cursor: default; + `} + ${({ theme }) => ` &:focus {