Skip to content
代码片段 群组 项目
未验证 提交 08c442c6 编辑于 作者: Miguel Rincon's avatar Miguel Rincon 提交者: GitLab
浏览文件

Merge branch 'a11y-fix-pipeline-status' into 'master'

No related branches found
No related tags found
无相关合并请求
<script> <script>
import { GlBadge, GlTooltipDirective, GlIcon } from '@gitlab/ui'; import { GlBadge, GlTooltipDirective, GlIcon } from '@gitlab/ui';
import { sprintf, __ } from '~/locale';
/** /**
* Renders CI icon based on API response shared between all places where it is used. * Renders CI icon based on API response shared between all places where it is used.
...@@ -58,11 +59,7 @@ export default { ...@@ -58,11 +59,7 @@ export default {
return null; return null;
}, },
ariaLabel() { ariaLabel() {
// show aria-label only when text is not rendered return sprintf(__('Status: %{status}'), { status: this.status?.text });
if (!this.showStatusText) {
return this.status?.text;
}
return null;
}, },
href() { href() {
// href can come from GraphQL (camelCase) or REST API (snake_case) // href can come from GraphQL (camelCase) or REST API (snake_case)
......
...@@ -48067,6 +48067,9 @@ msgstr "" ...@@ -48067,6 +48067,9 @@ msgstr ""
msgid "Status:" msgid "Status:"
msgstr "" msgstr ""
   
msgid "Status: %{status}"
msgstr ""
msgid "Status: %{title}" msgid "Status: %{title}"
msgstr "" msgstr ""
   
...@@ -30,14 +30,14 @@ describe('CI Icon component', () => { ...@@ -30,14 +30,14 @@ describe('CI Icon component', () => {
}); });
describe.each` describe.each`
showStatusText | showTooltip | expectedText | expectedTooltip | expectedAriaLabel showStatusText | showTooltip | expectedText | expectedTooltip
${true} | ${true} | ${'Success'} | ${undefined} | ${undefined} ${true} | ${true} | ${'Success'} | ${undefined}
${true} | ${false} | ${'Success'} | ${undefined} | ${undefined} ${true} | ${false} | ${'Success'} | ${undefined}
${false} | ${true} | ${''} | ${'Success'} | ${'Success'} ${false} | ${true} | ${''} | ${'Success'}
${false} | ${false} | ${''} | ${undefined} | ${'Success'} ${false} | ${false} | ${''} | ${undefined}
`( `(
'when showStatusText is %{showStatusText} and showTooltip is %{showTooltip}', 'when showStatusText is %{showStatusText} and showTooltip is %{showTooltip}',
({ showStatusText, showTooltip, expectedText, expectedTooltip, expectedAriaLabel }) => { ({ showStatusText, showTooltip, expectedText, expectedTooltip }) => {
beforeEach(() => { beforeEach(() => {
createComponent({ createComponent({
props: { props: {
...@@ -47,15 +47,15 @@ describe('CI Icon component', () => { ...@@ -47,15 +47,15 @@ describe('CI Icon component', () => {
}); });
}); });
it(`aria-label is ${expectedAriaLabel}`, () => { it(`aria-label is set`, () => {
expect(wrapper.attributes('aria-label')).toBe(expectedAriaLabel); expect(wrapper.attributes('aria-label')).toBe('Status: Success');
}); });
it(`text shown is ${expectedAriaLabel}`, () => { it(`text shown is ${expectedText}`, () => {
expect(wrapper.text()).toBe(expectedText); expect(wrapper.text()).toBe(expectedText);
}); });
it(`tooltip shown is ${expectedAriaLabel}`, () => { it(`tooltip shown is ${expectedTooltip}`, () => {
expect(wrapper.attributes('title')).toBe(expectedTooltip); expect(wrapper.attributes('title')).toBe(expectedTooltip);
}); });
}, },
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册