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

adding more pages to a11y testing #4435

Merged
merged 6 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ No public interface changes since `31.3.0`.
- Added a `textSize` prop to `EuiHealth` ([#4420](https://github.com/elastic/eui/pull/4420))
- Removed selected item of `EuiSelect` when `hasNoInitialSelection=true` and value reset to `undefined` ([#4428](https://github.com/elastic/eui/pull/4428))

**Bug Fixes**
myasonik marked this conversation as resolved.
Show resolved Hide resolved

- Fixed id usage throughout `EuiTreeView` to respect custom ids and stop conflicts in generated ids ([#4435](https://github.com/elastic/eui/pull/4435))
myasonik marked this conversation as resolved.
Show resolved Hide resolved
- Stopped rendering an empty tab container in `EuiTabs` if no tabs are passed in ([#4435](https://github.com/elastic/eui/pull/4435))

## [`31.2.0`](https://github.com/elastic/eui/tree/v31.2.0)

- Added support for adjusting `buffer` for individual window sides of `EuiPopover`. ([#4417](https://github.com/elastic/eui/pull/4417))
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@
"@typescript-eslint/parser": "^4.8.1",
"argparse": "^2.0.1",
"autoprefixer": "^9.8.6",
"axe-core": "^4.0.1",
"axe-puppeteer": "^1.1.0",
"axe-core": "^4.1.1",
"axe-puppeteer": "^1.1.1",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^24.1.0",
Expand Down Expand Up @@ -179,7 +179,7 @@
"prettier-stylelint": "^0.4.2",
"prompt": "^1.0.0",
"prop-types": "^15.6.0",
"puppeteer": "^5.3.0",
"puppeteer": "^5.5.0",
"raw-loader": "^4.0.1",
"react": "^16.12.0",
"react-docgen-typescript": "^1.20.5",
Expand Down
17 changes: 6 additions & 11 deletions scripts/a11y-testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ const { AxePuppeteer } = require('axe-puppeteer');
const docsPages = async (root, page) => {
const pagesToSkip = [
`${root}#/layout/resizable-container`,
`${root}#/navigation/button`,
`${root}#/navigation/tree-view`,
`${root}#/navigation/side-nav`,
`${root}#/tabular-content/tables`,
`${root}#/tabular-content/in-memory-tables`,
`${root}#/display/aspect-ratio`,
Expand All @@ -42,21 +39,19 @@ const docsPages = async (root, page) => {
`${root}#/forms/super-date-picker`,
`${root}#/elastic-charts/creating-charts`,
`${root}#/elastic-charts/part-to-whole-comparisons`,
`${root}#/utilities/css-utility-classes`,
`${root}#/utilities/focus-trap`,
];

return [
root,
...(await page.$$eval('nav a', anchors => anchors.map(a => a.href))),
].filter(link => !pagesToSkip.includes(link));
...(await page.$$eval('nav a', (anchors) => anchors.map((a) => a.href))),
].filter((link) => !pagesToSkip.includes(link));
};

const printResult = result =>
const printResult = (result) =>
console.log(`[${result.id}]: ${result.description}
Help: ${chalk.blue(result.helpUrl)}
Elements:
- ${result.nodes.map(node => node.target).join('\n - ')}`);
- ${result.nodes.map((node) => node.target).join('\n - ')}`);

(async () => {
let totalViolationsCount = 0;
Expand Down Expand Up @@ -114,7 +109,7 @@ const printResult = result =>
console.log(chalk.red(`Errors on ${pageName}`));
}

violations.forEach(result => {
violations.forEach((result) => {
printResult(result);
});
}
Expand All @@ -136,4 +131,4 @@ Firefox: https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/`);
} else {
console.log(chalk.green('axe found no accessibility errors!'));
}
})().catch(e => console.error(e));
})().catch((e) => console.error(e));
2 changes: 1 addition & 1 deletion src-docs/src/views/button/button_ghost.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default () => {
return (
<EuiPanel
paddingSize="l"
color="transparent"
color="ghost"
myasonik marked this conversation as resolved.
Show resolved Hide resolved
className="guideDemo__ghostBackground">
<EuiFlexGroup wrap gutterSize="s" alignItems="center">
<EuiFlexItem grow={false}>
Expand Down
10 changes: 7 additions & 3 deletions src-docs/src/views/button/button_group.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ export default () => {
},
];

const toggleButtonsIconsMultiCompressed = toggleButtonsIconsMulti.map(
(config) => ({ ...config, id: `${config.id}-compressed` })
);

const [toggleIdSelected, setToggleIdSelected] = useState(`${idPrefix}1`);
const [toggleIdDisabled, setToggleIdDisabled] = useState(`${idPrefix}4`);
const [toggleIdToSelectedMap, setToggleIdToSelectedMap] = useState({
Expand All @@ -137,7 +141,7 @@ export default () => {
setToggleIconIdToSelectedMapIcon,
] = useState({});
const [toggleCompressedIdSelected, setToggleCompressedIdSelected] = useState(
`${idPrefix2}4`
`${idPrefix2}4-compressed`
);

const onChange = (optionId) => {
Expand Down Expand Up @@ -268,9 +272,9 @@ export default () => {
</EuiTitle>
<EuiSpacer size="s" />
<EuiButtonGroup
legend="Text style"
legend="Text style compressed"
className="eui-displayInlineBlock"
options={toggleButtonsIconsMulti}
options={toggleButtonsIconsMultiCompressed}
idToSelectedMap={toggleIconIdToSelectedMapIcon}
onChange={(id) => onChangeIconsMultiIcons(id)}
type="multi"
Expand Down
1 change: 1 addition & 0 deletions src-docs/src/views/side_nav/side_nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default () => {

return (
<EuiSideNav
aria-label="Basic example"
mobileTitle="Navigate within $APP_NAME"
toggleOpenOnMobile={() => toggleOpenOnMobile()}
isOpenOnMobile={isSideNavOpenOnMobile}
Expand Down
1 change: 1 addition & 0 deletions src-docs/src/views/side_nav/side_nav_complex.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default () => {

return (
<EuiSideNav
aria-label="Complex example"
mobileTitle="Navigate within $APP_NAME"
toggleOpenOnMobile={toggleOpenOnMobile}
isOpenOnMobile={isSideNavOpenOnMobile}
Expand Down
1 change: 1 addition & 0 deletions src-docs/src/views/side_nav/side_nav_force_open.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default () => {

return (
<EuiSideNav
aria-label="Force-open example"
mobileTitle="Navigate within $APP_NAME"
toggleOpenOnMobile={toggleOpenOnMobile}
isOpenOnMobile={isSideNavOpenOnMobile}
Expand Down
13 changes: 7 additions & 6 deletions src-docs/src/views/utility_classes/utility_classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const wrappingExampleStyle = {

export default () => (
<EuiText>
<h4>Display</h4>
<h2>Display</h2>

<EuiCode className="eui-displayBlock">.eui-displayBlock</EuiCode>

Expand All @@ -42,7 +42,7 @@ export default () => (

<EuiSpacer />

<h4>Text</h4>
<h2>Text</h2>

<EuiSpacer />

Expand Down Expand Up @@ -105,7 +105,7 @@ export default () => (

<EuiSpacer />

<h4>Overflows</h4>
<h2>Overflows</h2>

<div
style={{
Expand Down Expand Up @@ -141,6 +141,7 @@ export default () => (
padding: 0,
}}>
<div
tabIndex="0"
className="eui-xScrollWithShadows"
style={{ padding: wrappingExampleStyle.padding }}>
<EuiText size="s" style={{ width: '150%' }}>
Expand All @@ -155,7 +156,7 @@ export default () => (
</div>

<EuiSpacer />
<h4>Vertical alignment</h4>
<h2>Vertical alignment</h2>
<EuiSpacer />

<div>
Expand Down Expand Up @@ -190,7 +191,7 @@ export default () => (

<EuiSpacer />

<h4>Responsive</h4>
<h2>Responsive</h2>

<EuiCode className="eui-hideFor--xs">.eui-hideFor--xs</EuiCode>
<EuiSpacer />
Expand All @@ -212,7 +213,7 @@ export default () => (

<EuiSpacer />

<h5>Modifiers</h5>
<h3>Modifiers</h3>
<p>
The <EuiCode>.eui-showFor--[size]</EuiCode> classes will force display of{' '}
<EuiCode>inline</EuiCode> when showing the element. You can modify this
Expand Down
16 changes: 12 additions & 4 deletions src/components/tabs/__snapshots__/tabs.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@ exports[`EuiTabs props display can be condensed 1`] = `
<div
class="euiTabs euiTabs--condensed"
role="tablist"
/>
>
children
</div>
`;

exports[`EuiTabs props expand is rendered 1`] = `
<div
class="euiTabs euiTabs--expand"
role="tablist"
/>
>
children
</div>
`;

exports[`EuiTabs props size can be small 1`] = `
<div
class="euiTabs euiTabs--small"
role="tablist"
/>
>
children
</div>
`;

exports[`EuiTabs renders 1`] = `
Expand All @@ -27,5 +33,7 @@ exports[`EuiTabs renders 1`] = `
class="euiTabs testClass1 testClass2"
data-test-subj="test subject string"
role="tablist"
/>
>
children
</div>
`;
10 changes: 6 additions & 4 deletions src/components/tabs/tabs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,31 @@ import { EuiTabs } from './tabs';

describe('EuiTabs', () => {
test('renders', () => {
const component = <EuiTabs {...requiredProps} />;
const component = <EuiTabs {...requiredProps}>children</EuiTabs>;

expect(render(component)).toMatchSnapshot();
});

describe('props', () => {
describe('size', () => {
test('can be small', () => {
const component = render(<EuiTabs size="s" />);
const component = render(<EuiTabs size="s">children</EuiTabs>);
expect(component).toMatchSnapshot();
});
});

describe('display', () => {
test('can be condensed', () => {
const component = render(<EuiTabs display="condensed" />);
const component = render(
<EuiTabs display="condensed">children</EuiTabs>
);
expect(component).toMatchSnapshot();
});
});

describe('expand', () => {
test('is rendered', () => {
const component = render(<EuiTabs expand />);
const component = render(<EuiTabs expand>children</EuiTabs>);
expect(component).toMatchSnapshot();
});
});
Expand Down
2 changes: 2 additions & 0 deletions src/components/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export const EuiTabs = forwardRef<EuiTabRef, PropsWithChildren<EuiTabsProps>>(
className
);

if (!children) return <></>;
myasonik marked this conversation as resolved.
Show resolved Hide resolved

return (
<div ref={ref} role="tablist" className={classes} {...rest}>
{children}
Expand Down
Loading