-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: continue to tests a11y and fix
- Loading branch information
1 parent
2bf2726
commit 2437d0f
Showing
9 changed files
with
226 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@talend/scripts-config-jest': minor | ||
--- | ||
|
||
feat: add api to set a fetch MockResponse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import { describe, it, expect } from '@jest/globals'; | ||
import { axe } from 'jest-axe'; | ||
import { render } from '@testing-library/react'; | ||
import { Icon } from './'; | ||
|
||
describe('Icon', () => { | ||
it('should render a11y html', async () => { | ||
global.self.fetch.mockResponse = { | ||
status: 200, | ||
ok: true, | ||
text: () => | ||
new Promise(resolve => { | ||
resolve(undefined); | ||
}), | ||
}; | ||
const { container } = render( | ||
<main> | ||
<Icon name="pencil" /> | ||
<Icon name="src-https://statics-dev.cloud.talend.com/@talend/common/images/favicon-logo-square.ico" /> | ||
<Icon name="remote-https://unpkg.com/@talend/[email protected]/src/svg/core/abc.svg" /> | ||
</main>, | ||
); | ||
expect(container.firstChild).toMatchSnapshot(); | ||
const results = await axe(document.body); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/design-system/src/components/Icon/__snapshots__/Icon.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Icon should render a11y html 1`] = ` | ||
<main> | ||
<svg | ||
aria-hidden="true" | ||
class="tc-svg-icon tc-icon theme-svg tc-icon-name-pencil" | ||
focusable="false" | ||
name="pencil" | ||
pointer-events="none" | ||
shape-rendering="geometricPrecision" | ||
/> | ||
<img | ||
alt="icon" | ||
aria-hidden="true" | ||
class="tc-icon theme-svg" | ||
focusable="false" | ||
src="https://statics-dev.cloud.talend.com/@talend/common/images/favicon-logo-square.ico" | ||
/> | ||
<svg | ||
aria-hidden="true" | ||
class="tc-svg-icon tc-icon theme-svg" | ||
focusable="false" | ||
pointer-events="none" | ||
shape-rendering="geometricPrecision" | ||
/> | ||
</main> | ||
`; |
33 changes: 33 additions & 0 deletions
33
packages/design-system/src/components/InlineEditing/InlineEditing.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import { describe, it, expect } from '@jest/globals'; | ||
import { axe } from 'jest-axe'; | ||
import { render } from '@testing-library/react'; | ||
import { InlineEditing } from './'; | ||
|
||
jest.mock('@talend/utils', () => { | ||
let i = 0; | ||
return { | ||
// we need stable but different uuid (is fixed to 42 by current mock) | ||
randomUUID: () => `mocked-uuid-${i++}`, | ||
}; | ||
}); | ||
|
||
describe('InlineEditing', () => { | ||
it('should render a11y html', async () => { | ||
const { container } = render( | ||
<main> | ||
<InlineEditing | ||
label="Edit the value" | ||
placeholder="What is your Lorem Ipsum?" | ||
defaultValue="Lorem Ipsum" | ||
onEdit={jest.fn()} | ||
/> | ||
</main>, | ||
); | ||
// eslint-disable-next-line testing-library/no-container | ||
container.querySelector('button')?.click(); | ||
expect(container.firstChild).toMatchSnapshot(); | ||
const results = await axe(document.body); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
}); |
103 changes: 103 additions & 0 deletions
103
...ages/design-system/src/components/InlineEditing/__snapshots__/InlineEditing.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`InlineEditing should render a11y html 1`] = ` | ||
<main> | ||
<div | ||
class="theme-inlineEditor" | ||
data-test="inlineediting" | ||
data-testid="inlineediting" | ||
> | ||
<div | ||
class="theme-inlineEditor__editor" | ||
> | ||
<div | ||
class="theme-stack theme-justify-start theme-align-stretch theme-nowrap theme-column theme-block theme-height-100 theme-noShrink theme-gap-x-XXS theme-gap-y-XXS" | ||
> | ||
<span | ||
class="theme-hidden" | ||
> | ||
<label | ||
class="theme-label" | ||
for="field--mocked-uuid-5" | ||
> | ||
Edit the value | ||
</label> | ||
</span> | ||
<div | ||
class="theme-inputShell" | ||
> | ||
<input | ||
class="theme-input" | ||
data-padding-override="true" | ||
data-test="inlineediting.input" | ||
data-testid="inlineediting.input" | ||
id="field--mocked-uuid-5" | ||
name="Editthevalue" | ||
placeholder="What is your Lorem Ipsum?" | ||
type="text" | ||
value="Lorem Ipsum" | ||
/> | ||
</div> | ||
</div> | ||
<div | ||
class="theme-inlineEditor__editor__actions" | ||
> | ||
<div | ||
class="theme-stack theme-justify-space-between theme-align-center theme-nowrap theme-row theme-inline theme-gap-x-XXS theme-gap-y-XXS theme-padding-top-0 theme-padding-right-XXS theme-padding-bottom-0 theme-padding-left-XXS" | ||
> | ||
<button | ||
aria-describedby="id-mocked-uuid-6" | ||
aria-label="Cancel" | ||
class="theme-clickable theme-buttonIcon theme-size_XS" | ||
data-test="inlineediting.button.cancel" | ||
data-testid="inlineediting.button.cancel" | ||
tabindex="0" | ||
type="button" | ||
> | ||
<span | ||
aria-hidden="true" | ||
class="theme-buttonIcon__icon" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
pointer-events="none" | ||
shape-rendering="geometricPrecision" | ||
style="width: 1.2rem; height: 1.2rem;" | ||
> | ||
<use | ||
xlink:href="#cross-filled:S" | ||
/> | ||
</svg> | ||
</span> | ||
</button> | ||
<button | ||
aria-describedby="id-mocked-uuid-7" | ||
aria-label="Submit" | ||
class="theme-clickable theme-buttonIcon theme-size_XS" | ||
data-test="inlineediting.button.submit" | ||
data-testid="inlineediting.button.submit" | ||
tabindex="0" | ||
type="button" | ||
> | ||
<span | ||
aria-hidden="true" | ||
class="theme-buttonIcon__icon" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
pointer-events="none" | ||
shape-rendering="geometricPrecision" | ||
style="width: 1.2rem; height: 1.2rem;" | ||
> | ||
<use | ||
xlink:href="#check-filled:S" | ||
/> | ||
</svg> | ||
</span> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</main> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters