Skip to content
代码片段 群组 项目
未验证 提交 e3b42087 编辑于 作者: Lorenz van Herwaarden's avatar Lorenz van Herwaarden 提交者: GitLab
浏览文件

Merge branch '511802-project-notifications-button-a11y' into 'master'

No related branches found
No related tags found
无相关合并请求
......@@ -72,15 +72,14 @@ export default {
return this.selectedNotificationLevel === 'disabled' ? 'notifications-off' : 'notifications';
},
buttonText() {
return this.showLabel
? this.$options.i18n.notificationTitles[this.selectedNotificationLevel]
: null;
},
buttonTooltip() {
const notificationTitle =
this.$options.i18n.notificationTitles[this.selectedNotificationLevel] ||
this.selectedNotificationLevel;
if (this.showLabel) {
return notificationTitle;
}
return this.emailsDisabled
? this.$options.i18n.notificationDescriptions.owner_disabled
: sprintf(this.$options.i18n.notificationTooltipTitle, {
......@@ -122,7 +121,7 @@ export default {
<template>
<div :class="containerClass">
<gl-dropdown
v-gl-tooltip="{ title: buttonTooltip }"
v-gl-tooltip="{ title: buttonText }"
data-testid="notification-dropdown"
:size="buttonSize"
:icon="buttonIcon"
......@@ -130,6 +129,7 @@ export default {
:disabled="emailsDisabled"
:split="isCustomNotification"
:text="buttonText"
:text-sr-only="!showLabel"
:no-flip="noFlip"
:aria-label="__('Notification setting - Custom')"
@click="openNotificationsModal"
......
......@@ -47,6 +47,7 @@ describe('NotificationsDropdown', () => {
const findDropdownItemAt = (index) =>
findAllNotificationsDropdownItems().at(index).findComponent(GlDropdownItem);
const findNotificationsModal = () => wrapper.findComponent(CustomNotificationsModal);
const tooltipTitlePrefix = 'Notification setting';
const clickDropdownItemAt = async (index) => {
const dropdownItem = findDropdownItemAt(index);
......@@ -85,13 +86,13 @@ describe('NotificationsDropdown', () => {
expect(findDropdown().props().text).toBe('Custom');
});
it("doesn't show the button text when showLabel is false", () => {
it('shows the tooltip text when showLabel is false', () => {
wrapper = createComponent({
initialNotificationLevel: 'custom',
showLabel: false,
});
expect(findDropdown().props().text).toBe(null);
expect(findDropdown().props().text).toBe(`${tooltipTitlePrefix} - Custom`);
});
it('opens the modal when the user clicks the button', async () => {
......@@ -127,17 +128,16 @@ describe('NotificationsDropdown', () => {
expect(findDropdown().props('text')).toBe('Global');
});
it("doesn't show the button text when showLabel is false", () => {
it('shows the tooltip text when showLabel is false', () => {
wrapper = createComponent({
showLabel: false,
});
expect(findDropdown().props('text')).toBe(null);
expect(findDropdown().props('text')).toBe(`${tooltipTitlePrefix} - Global`);
});
});
describe('button tooltip', () => {
const tooltipTitlePrefix = 'Notification setting';
it.each`
level | title
${'global'} | ${'Global'}
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册