docbrown/app/javascript/chat/__tests__/content.test.jsx
dependabot[bot] a9449501a3
Bump @storybook/addon-a11y from 6.2.9 to 6.3.1 (#14094)
* Bump @storybook/addon-a11y from 6.2.9 to 6.3.1

Bumps [@storybook/addon-a11y](https://github.com/storybookjs/storybook/tree/HEAD/addons/a11y) from 6.2.9 to 6.3.1.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/next/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.3.1/addons/a11y)

---
updated-dependencies:
- dependency-name: "@storybook/addon-a11y"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* add TODOs and exclusions for known a11y issues waiting on bugfixes

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2021-06-29 14:19:28 +02:00

104 lines
3 KiB
JavaScript

import { h } from 'preact';
import { render } from '@testing-library/preact';
import { axe } from 'jest-axe';
import { Content } from '../content';
const getChannelRequestData = () => ({
onTriggerContent: jest.fn(),
type_of: 'channel-request',
activeChannelId: 12345,
pusherKey: 'ASDFGHJKL',
githubToken: '',
data: {
channel: {
name: 'bobby',
},
user: {
username: 'spongebob',
},
},
});
const getLoadingUserData = () => ({
onTriggerContent: jest.fn(),
type_of: 'loading-user',
activeChannelId: 1235,
pusherKey: 'ASDFGHJKL',
githubToken: '',
data: {
user: {
username: 'spongebob',
},
},
});
describe('<Content />', () => {
describe('as loading-user', () => {
it('should have no a11y violations', async () => {
// TODO: The axe custom rules here should be removed when the below issue is fixed
// https://github.com/forem/forem/issues/14101
const customAxeRules = {
'nested-interactive': { enabled: false },
};
const channelRequestResource = getChannelRequestData();
const { container } = render(
<Content resource={channelRequestResource} />,
);
const results = await axe(container, { rules: customAxeRules });
expect(results).toHaveNoViolations();
});
it('should render', () => {
const channelRequestResource = getChannelRequestData();
const { queryByText, queryByTitle } = render(
<Content resource={channelRequestResource} />,
);
// Ensure the two buttons render
expect(queryByTitle('exit')).toBeDefined();
expect(queryByTitle('fullscreen')).toBeDefined();
// Simple check if the component to request joining a channel appears.
// The component itself is tested it in it's own test suite.
expect(
queryByText(
'You are not a member of this group yet. Send a request to join.',
),
).toBeDefined();
});
});
describe('as channel-request', () => {
it('should have no a11y violations', async () => {
// TODO: The axe custom rules here should be removed when the below issue is fixed
// https://github.com/forem/forem/issues/14101
const customAxeRules = {
'nested-interactive': { enabled: false },
};
const loadinUserResource = getLoadingUserData();
const { container } = render(<Content resource={loadinUserResource} />);
const results = await axe(container, { rules: customAxeRules });
expect(results).toHaveNoViolations();
});
it('should render', () => {
const loadinUserResource = getLoadingUserData();
const { queryByTitle } = render(
<Content resource={loadinUserResource} />,
);
// Ensure the two buttons render
expect(queryByTitle('exit')).toBeDefined();
expect(queryByTitle('fullscreen')).toBeDefined();
expect(queryByTitle('Loading user')).toBeDefined();
});
});
/*
testing only as loading user since components that Content uses
are independently tested
*/
});