Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(accessibility-checker): update to versioned ruleArchive #17351

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6ec031e
test(accessibility-checker): update to versioned ruleset
tay1orjones Sep 6, 2024
8c9ecd7
chore(accessibility-checker): update to 3.1.75
tay1orjones Sep 9, 2024
db44b2e
chore(accessibility-checker): update to 3.1.75
tay1orjones Sep 9, 2024
96e8fd3
fix(inputprops): remove autoComplete property
tay1orjones Oct 21, 2024
950ef60
Merge branch 'main' of github.com:carbon-design-system/carbon into 17…
tay1orjones Oct 21, 2024
b0752ec
Merge branch 'main' of github.com:carbon-design-system/carbon into 17…
tay1orjones Oct 24, 2024
1b594f7
chore(deps): update to latest accessibility-checker
tay1orjones Oct 24, 2024
d0fd3f9
add dep cache
tay1orjones Oct 24, 2024
b8ca9d0
revert unintended file changes
tay1orjones Oct 24, 2024
33722dd
revert unintended file changes
tay1orjones Oct 24, 2024
78e309f
chore: yarn dedupe
tay1orjones Oct 24, 2024
cf50d17
chore: update accessibility-checker to 3.1.77
tay1orjones Nov 7, 2024
1e16288
Merge branch 'main' into 17149-a11y-versioned-ruleset
tay1orjones Nov 7, 2024
7f2ec8e
chore: fix a11y violations
tay1orjones Nov 7, 2024
6b9f124
Merge branch '17149-a11y-versioned-ruleset' of github.com:tay1orjones…
tay1orjones Nov 7, 2024
1cb827c
chore: wip
tay1orjones Nov 14, 2024
1caf60d
fix: updated test, snapshots, yarn format
2nikhiltom Dec 3, 2024
170d885
chore: yarn format
2nikhiltom Dec 3, 2024
03545ae
Merge branch 'main' into 17149-a11y-versioned-ruleset
2nikhiltom Dec 4, 2024
a13c4c2
test: updated tests to match ariaLabelText
2nikhiltom Dec 4, 2024
20fd5ef
chore(accessibility-checker): update to 3.1.78
2nikhiltom Dec 4, 2024
234033b
Merge branch 'main' into 17149-a11y-versioned-ruleset
2nikhiltom Dec 4, 2024
24fe65e
chore: adds cache
2nikhiltom Dec 5, 2024
294010e
Merge branch 'main' into 17149-a11y-versioned-ruleset
2nikhiltom Dec 5, 2024
2017d10
Merge branch 'main' into 17149-a11y-versioned-ruleset
2nikhiltom Dec 9, 2024
64a1173
refactor: added rules to denylist
2nikhiltom Dec 9, 2024
0cbe325
refactor: added rules to denylist
2nikhiltom Dec 9, 2024
4aca224
chore: yarn dedupe
2nikhiltom Dec 9, 2024
2736c3c
chore: nx cache
2nikhiltom Dec 9, 2024
c8125e6
chore: removes .nx/cache files
2nikhiltom Dec 9, 2024
09bdeb7
Merge branch 'main' into 17149-a11y-versioned-ruleset
tay1orjones Dec 9, 2024
e9dece9
Merge branch 'main' into 17149-a11y-versioned-ruleset
2nikhiltom Dec 10, 2024
de038d4
Merge branch 'main' into 17149-a11y-versioned-ruleset
2nikhiltom Dec 10, 2024
f7026b7
test: adds tests for SliderSkeleton
2nikhiltom Dec 12, 2024
ef04b94
refactor: revert scss change
2nikhiltom Dec 12, 2024
c412102
Merge branch 'main' into 17149-a11y-versioned-ruleset
2nikhiltom Dec 12, 2024
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
18 changes: 10 additions & 8 deletions achecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
const path = require('path');

module.exports = {
ruleArchive: '17June2024',
ruleArchive: 'versioned',
policies: ['Custom_Ruleset'],
failLevels: ['violation'],
reportLevels: [
'violation',
'potentialviolation',
'recommendation',
'potentialrecommendation',
'manual',
],
reportLevels: !process.env.CI
? ['violation']
: [
'violation',
'potentialviolation',
'recommendation',
'potentialrecommendation',
'manual',
],
outputFormat: ['json'],
outputFolder: path.join('.avt', 'reports'),
baselineFolder: path.join('.avt', 'baseline'),
Expand Down
3 changes: 3 additions & 0 deletions config/jest-config-carbon/matchers/toHaveNoACViolations.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ async function toHaveNoACViolations(node, label) {
'html_skipnav_exists',
'aria_content_in_landmark',
'aria_child_tabbable',
'aria_attribute_conflict',
'label_name_visible',
'target_spacing_sufficient',
]);
const ruleset = await aChecker.getRuleset('IBM_Accessibility');
const customRuleset = JSON.parse(JSON.stringify(ruleset));
Expand Down
2 changes: 1 addition & 1 deletion config/jest-config-carbon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@babel/preset-env": "^7.24.7",
"@babel/preset-react": "^7.24.7",
"@babel/runtime": "^7.24.7",
"accessibility-checker": "^3.1.74",
"accessibility-checker": "^3.1.78",
"axe-core": "^4.3.5",
"babel-jest": "^28.1.0",
"chalk": "^4.1.1",
Expand Down
2 changes: 1 addition & 1 deletion e2e/components/AILabel/AILabel-test.avt.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test.describe('@avt AILabel', () => {
},
});
const slug = page.getByRole('button', {
name: 'AI - Show information',
name: 'AI Show information',
});
const callout = page.locator('.cds--popover--open');
await expect(slug).toBeVisible();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/react-is": "~18.3.0",
"accessibility-checker": "^3.1.48",
"accessibility-checker": "^3.1.78",
"all-contributors-cli": "^6.19.0",
"cross-env": "^7.0.0",
"cross-spawn": "^7.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7448,6 +7448,9 @@ Map {
},
"SliderSkeleton" => Object {
"propTypes": Object {
"ariaLabel": Object {
"type": "string",
},
"className": Object {
"type": "string",
},
Expand All @@ -7457,6 +7460,9 @@ Map {
"twoHandles": Object {
"type": "bool",
},
"unstable_ariaLabelHandleUpper": Object {
"type": "string",
},
},
},
"Stack" => Object {
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/AILabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ export const AILabel = React.forwardRef<HTMLDivElement, AILabelProps>(

const ariaLabelText =
!aiTextLabel && !textLabel
? `${aiText} - ${slugLabel || ariaLabel}`
: `${aiText} - ${aiTextLabel || textLabel}`;
? `${aiText} ${slugLabel || ariaLabel}`
: `${aiText} ${aiTextLabel || textLabel}`;

return (
<div className={aiLabelClasses} ref={ref} id={id}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ describe('ComposedModal', () => {
);

expect(
screen.getByRole('button', { name: 'AI - Show information' })
screen.getByRole('button', { name: 'AI Show information' })
).toBeInTheDocument();
spy.mockRestore();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('NumberInput', () => {
);

expect(
screen.getByRole('button', { name: 'AI - Show information' })
screen.getByRole('button', { name: 'AI Show information' })
).toBeInTheDocument();
});

Expand All @@ -84,7 +84,7 @@ describe('NumberInput', () => {
render(<NumberInput label="test-label" id="test" slug={<AILabel />} />);

expect(
screen.getByRole('button', { name: 'AI - Show information' })
screen.getByRole('button', { name: 'AI Show information' })
).toBeInTheDocument();
spy.mockRestore();
});
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/Popover/Popover.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const TabTip = () => {
<PopoverContent className="p-3">
<RadioButtonGroup
style={{ alignItems: 'flex-start', flexDirection: 'column' }}
legendText="Row height"
legendText="Row height 1"
name="radio-button-group"
defaultSelected="small">
<RadioButton labelText="Small" value="small" id="radio-small" />
Expand Down Expand Up @@ -146,7 +146,7 @@ export const TabTip = () => {
<PopoverContent className="p-3">
<RadioButtonGroup
style={{ alignItems: 'flex-start', flexDirection: 'column' }}
legendText="Row height"
legendText="Row height 2"
name="radio-button-group-2"
defaultSelected="small-2">
<RadioButton labelText="Small" value="small-2" id="radio-small-2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,10 @@ describe('Select', () => {
it('should have no Accessibility Checker violations', async () => {
const { container } = render(
<main>
<Select id="select" labelText="Select">
<Select
id="select"
labelText="Select an option"
aria-label="Select an option">
<SelectItem value="option-1" text="Option 1" />
<SelectItem value="option-2" text="Option 2" />
</Select>
Expand Down
30 changes: 26 additions & 4 deletions packages/react/src/components/Slider/Slider.Skeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
import { LowerHandle, UpperHandle } from './SliderHandles';

export interface SliderSkeletonProps extends HTMLAttributes<HTMLDivElement> {
/**
* The `ariaLabel` for the handle icon.
*/
ariaLabel?: string;

/**
* The `ariaLabel` for the upper bound slider handle when there are two handles.
*/
unstable_ariaLabelHandleUpper?: string;

/**
* Specify an optional className to add to the form item wrapper.
*/
Expand All @@ -31,6 +41,8 @@
}

const SliderSkeleton = ({
ariaLabel = 'slider handle',
unstable_ariaLabelHandleUpper: ariaLabelHandleUpper = 'upper slider handle',
hideLabel,
className,
twoHandles,
Expand Down Expand Up @@ -82,19 +94,19 @@
<div className={lowerThumbWrapperClasses}>
<div className={lowerThumbClasses}>
{twoHandles && !isRtl ? (
<LowerHandle />
<LowerHandle aria-label={ariaLabel} />
) : twoHandles && isRtl ? (
<UpperHandle />
<UpperHandle aria-label={ariaLabelHandleUpper} />

Check warning on line 99 in packages/react/src/components/Slider/Slider.Skeleton.tsx

View check run for this annotation

Codecov / codecov/patch

packages/react/src/components/Slider/Slider.Skeleton.tsx#L99

Added line #L99 was not covered by tests
) : undefined}
</div>
</div>
{twoHandles ? (
<div className={upperThumbWrapperClasses}>
<div className={upperThumbClasses}>
{twoHandles && !isRtl ? (
<UpperHandle />
<UpperHandle aria-label={ariaLabelHandleUpper} />
) : twoHandles && isRtl ? (
<LowerHandle />
<LowerHandle aria-label={ariaLabel} />

Check warning on line 109 in packages/react/src/components/Slider/Slider.Skeleton.tsx

View check run for this annotation

Codecov / codecov/patch

packages/react/src/components/Slider/Slider.Skeleton.tsx#L109

Added line #L109 was not covered by tests
) : undefined}
</div>
</div>
Expand All @@ -107,6 +119,16 @@
};

SliderSkeleton.propTypes = {
/**
* The `ariaLabel` for the handle icon.
*/
ariaLabel: PropTypes.string,

/**
* The `ariaLabel` for the upper bound slider handle when there are two handles.
*/
unstable_ariaLabelHandleUpper: PropTypes.string,

/**
* Specify an optional className to add to the form item wrapper.
*/
Expand Down
18 changes: 10 additions & 8 deletions packages/react/src/components/Slider/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1533,13 +1533,13 @@ class Slider extends PureComponent<SliderProps> {
}>
{twoHandles && !isRtl ? (
<>
<LowerHandle />
<LowerHandleFocus />
<LowerHandle aria-label={ariaLabelInput} />
<LowerHandleFocus aria-label={ariaLabelInput} />
</>
) : twoHandles && isRtl ? (
<>
<UpperHandle />
<UpperHandleFocus />
<UpperHandle aria-label={ariaLabelInputUpper} />
<UpperHandleFocus aria-label={ariaLabelInputUpper} />
</>
) : undefined}
</div>
Expand All @@ -1565,13 +1565,15 @@ class Slider extends PureComponent<SliderProps> {
}>
{twoHandles && !isRtl ? (
<>
<UpperHandle />
<UpperHandleFocus />
<UpperHandle aria-label={ariaLabelInputUpper} />
<UpperHandleFocus
aria-label={ariaLabelInputUpper}
/>
</>
) : twoHandles && isRtl ? (
<>
<LowerHandle />
<LowerHandleFocus />
<LowerHandle aria-label={ariaLabelInput} />
<LowerHandleFocus aria-label={ariaLabelInput} />
</>
) : undefined}
</div>
Expand Down
20 changes: 12 additions & 8 deletions packages/react/src/components/Slider/SliderHandles.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
import { PrefixContext } from '../../internal/usePrefix';
import React from 'react';

export const LowerHandle = () => (
export const LowerHandle = (props) => (
<PrefixContext.Consumer>
{(prefix) => (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 24"
className={`${prefix}--slider__thumb-icon ${prefix}--slider__thumb-icon--lower`}>
className={`${prefix}--slider__thumb-icon ${prefix}--slider__thumb-icon--lower`}
{...props}>
<path d="M15.08 6.46H16v11.08h-.92zM4.46 17.54c-.25 0-.46-.21-.46-.46V6.92a.465.465 0 0 1 .69-.4l8.77 5.08a.46.46 0 0 1 0 .8l-8.77 5.08c-.07.04-.15.06-.23.06Z" />
<path fill="none" d="M-4 0h24v24H-4z" />
</svg>
)}
</PrefixContext.Consumer>
);

export const LowerHandleFocus = () => (
export const LowerHandleFocus = (props) => (
<PrefixContext.Consumer>
{(prefix) => (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 24"
className={`${prefix}--slider__thumb-icon ${prefix}--slider__thumb-icon--lower ${prefix}--slider__thumb-icon--focus`}>
className={`${prefix}--slider__thumb-icon ${prefix}--slider__thumb-icon--lower ${prefix}--slider__thumb-icon--focus`}
{...props}>
<path d="M15.08 6.46H16v11.08h-.92zM4.46 17.54c-.25 0-.46-.21-.46-.46V6.92a.465.465 0 0 1 .69-.4l8.77 5.08a.46.46 0 0 1 0 .8l-8.77 5.08c-.07.04-.15.06-.23.06Z" />
<path fill="none" d="M-4 0h24v24H-4z" />
<path d="M15.08 0H16v6.46h-.92z" />
Expand All @@ -32,27 +34,29 @@ export const LowerHandleFocus = () => (
</PrefixContext.Consumer>
);

export const UpperHandle = () => (
export const UpperHandle = (props) => (
<PrefixContext.Consumer>
{(prefix) => (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 24"
className={`${prefix}--slider__thumb-icon ${prefix}--slider__thumb-icon--upper`}>
className={`${prefix}--slider__thumb-icon ${prefix}--slider__thumb-icon--upper`}
{...props}>
<path d="M0 6.46h.92v11.08H0zM11.54 6.46c.25 0 .46.21.46.46v10.15a.465.465 0 0 1-.69.4L2.54 12.4a.46.46 0 0 1 0-.8l8.77-5.08c.07-.04.15-.06.23-.06Z" />
<path fill="none" d="M-4 0h24v24H-4z" />
</svg>
)}
</PrefixContext.Consumer>
);

export const UpperHandleFocus = () => (
export const UpperHandleFocus = (props) => (
<PrefixContext.Consumer>
{(prefix) => (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 24"
className={`${prefix}--slider__thumb-icon ${prefix}--slider__thumb-icon--upper ${prefix}--slider__thumb-icon--focus`}>
className={`${prefix}--slider__thumb-icon ${prefix}--slider__thumb-icon--upper ${prefix}--slider__thumb-icon--focus`}
{...props}>
<path d="M0 6.46h.92v11.08H0zM11.54 6.46c.25 0 .46.21.46.46v10.15a.465.465 0 0 1-.69.4L2.54 12.4a.46.46 0 0 1 0-.8l8.77-5.08c.07-.04.15-.06.23-.06Z" />
<path fill="none" d="M-4 0h24v24H-4z" />
<path d="M.92 24H0v-6.46h.92z" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React from 'react';
import Slider from './Slider';
import Slider from '../Slider';
import userEvent from '@testing-library/user-event';
import { fireEvent, render, screen } from '@testing-library/react';

Expand Down Expand Up @@ -574,9 +574,9 @@ describe('Slider', () => {
it('should render children as expected', () => {
renderTwoHandleSlider();
const lowerElems = screen.getAllByLabelText(defaultAriaLabelInput);
expect(lowerElems).toHaveLength(2);
expect(lowerElems).toHaveLength(4);
const upperElems = screen.getAllByLabelText(defaultAriaLabelInputUpper);
expect(upperElems).toHaveLength(2);
expect(upperElems).toHaveLength(4);
});

it('should apply the expected classes', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import SliderSkeleton from '../Slider.Skeleton';

describe('SliderSkeleton', () => {
describe('behaves as expected - Component API', () => {
it('should apply the expected classes', () => {
const { container } = render(<SliderSkeleton />);
expect(container.firstChild.firstChild).toHaveClass(
'cds--label cds--skeleton'
);
});

it('should pass custom class via className', () => {
const customSliderClass = 'slider-custom-class';
const { container } = render(
<SliderSkeleton twoHandles={true} className={customSliderClass} />
);
expect(container.firstChild).toHaveClass(customSliderClass);
});

it('renders without label when hideLabel is true', () => {
const { container } = render(<SliderSkeleton hideLabel={true} />);
const label = container.querySelector('.cds--label.cds--skeleton');
expect(label).not.toBeInTheDocument();
});

describe('Accessibility labels', () => {
it('applies default aria labels', () => {
render(<SliderSkeleton twoHandles={true} />);
const lowerHandle = screen.getByLabelText('slider handle');
const upperHandle = screen.getByLabelText('upper slider handle');
expect(lowerHandle).toBeInTheDocument();
expect(upperHandle).toBeInTheDocument();
});

it('allows custom aria labels', () => {
render(
<SliderSkeleton
twoHandles={true}
ariaLabel="Custom Lower Handle"
unstable_ariaLabelHandleUpper="Custom Upper Handle"
/>
);
const lowerHandle = screen.getByLabelText('Custom Lower Handle');
const upperHandle = screen.getByLabelText('Custom Upper Handle');
expect(lowerHandle).toBeInTheDocument();
expect(upperHandle).toBeInTheDocument();
});
});
});
});
Loading
Loading