Skip to content

Commit

Permalink
feat(react): add prop to customise tooltip label for chip
Browse files Browse the repository at this point in the history
Add prop to customise tooltip label for chip. Add Cypress test and stories

. mi6#2839
  • Loading branch information
GCHQ-Developer-530 authored and jk15926 committed Jan 2, 2025
1 parent 5aa56ef commit 0f34046
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions packages/react/src/component-tests/IcChip/IcChip.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
WithIcon,
WithBadgeSlot,
InAGGrid,
CustomDismissLabel,
} from "./IcChipTestData";
import {
HAVE_BEEN_CALLED_ONCE,
Expand Down Expand Up @@ -148,6 +149,20 @@ describe("IcChip visual regression and a11y tests", () => {
});
});

it("should render dismissible chip with custom tooltip label", () => {
mount(<CustomDismissLabel />);

cy.checkHydrated("ic-chip#default-chip");

cy.findShadowEl("ic-chip#default-chip", "button").eq(0).focus();

cy.checkA11yWithWait();
cy.compareSnapshot({
name: "custom-dismiss-label",
testThreshold: setThresholdBasedOnEnv(DEFAULT_TEST_THRESHOLD),
});
});

it("should render disabled chip", () => {
mount(<Disabled />);

Expand Down
13 changes: 13 additions & 0 deletions packages/react/src/component-tests/IcChip/IcChipTestData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ export const Dismissible = () => {
);
};

export const CustomDismissLabel = () => {
return (
<div style={{ padding: "8px" }}>
<IcChip
id="default-chip"
label="Default"
dismissible
dismissLabel="Custom dismiss"
/>
</div>
);
};

export const WithIcon = () => {
return (
<div style={{ padding: "8px" }}>
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/stories/ic-chip.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ export const defaultArgs = {
customColor: null,
disabled: false,
dismissible: false,
dismissLabel: "Dismiss",
label: "Default",
size: "default",
transparentBackground: true,
Expand Down Expand Up @@ -555,6 +556,7 @@ export const defaultArgs = {
label={args.label}
customColor={args.customColor}
dismissible={args.dismissible}
dismissLabel={args.dismissLabel}
disabled={args.disabled}
size={args.size}
variant={args.variant}
Expand Down

0 comments on commit 0f34046

Please sign in to comment.