Skip to content

Commit 1fdf70b

Browse files
committed
✨(frontend) remove redundant aria-label on hidden icons and update tests
remove aria-label from aria-hidden icons and update tests with data-testid Signed-off-by: Cyril <c.gromoff@gmail.com>
1 parent 8ab21ef commit 1fdf70b

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to
1818
- ♿ add pdf outline property to enable bookmarks display #1368
1919
- ♿ hide decorative icons from assistive tech with aria-hidden #1404
2020
- ♿ remove redundant aria-label to avoid over-accessibility #1420
21+
- ♿ remove redundant aria-label on hidden icons and update tests #1432
2122
- ♿ improve semantic structure and aria roles of leftpanel #1431
2223
- ♿ add default background to left panel for better accessibility #1423
2324

src/frontend/apps/e2e/__tests__/app-impress/doc-grid.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ test.describe('Document grid item options', () => {
117117
await page.getByText('push_pin').click();
118118

119119
// Check is pinned
120-
await expect(row.locator('[data-testid^="doc-pinned-"]')).toBeVisible();
120+
await expect(row.getByTestId('doc-pinned-icon')).toBeVisible();
121121
const leftPanelFavorites = page.getByTestId('left-panel-favorites');
122122
await expect(leftPanelFavorites.getByText(docTitle)).toBeVisible();
123123

@@ -126,7 +126,7 @@ test.describe('Document grid item options', () => {
126126
await page.getByText('Unpin').click();
127127

128128
// Check is unpinned
129-
await expect(row.locator('[data-testid^="doc-pinned-"]')).toBeHidden();
129+
await expect(row.getByTestId('doc-pinned-icon')).toBeHidden();
130130
await expect(leftPanelFavorites.getByText(docTitle)).toBeHidden();
131131
});
132132

src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ test.describe('Doc Header', () => {
7575
// Check the tree
7676
const docTree = page.getByTestId('doc-tree');
7777
await expect(docTree.getByText('Hello Emoji World')).toBeVisible();
78-
await expect(docTree.getByLabel('Document emoji icon')).toBeVisible();
79-
await expect(docTree.getByLabel('Simple document icon')).toBeHidden();
78+
await expect(docTree.getByTestId('doc-emoji-icon')).toBeVisible();
79+
await expect(docTree.getByTestId('doc-simple-icon')).toBeHidden();
8080

8181
await page.getByTestId('home-button').click();
8282

8383
// Check the documents grid
8484
const gridRow = await getGridRow(page, 'Hello Emoji World');
85-
await expect(gridRow.getByLabel('Document emoji icon')).toBeVisible();
86-
await expect(gridRow.getByLabel('Simple document icon')).toBeHidden();
85+
await expect(gridRow.getByTestId('doc-emoji-icon')).toBeVisible();
86+
await expect(gridRow.getByTestId('doc-simple-icon')).toBeHidden();
8787
});
8888

8989
test('it deletes the doc', async ({ page, browserName }) => {
@@ -456,7 +456,7 @@ test.describe('Doc Header', () => {
456456
const row = await getGridRow(page, docTitle);
457457

458458
// Check is pinned
459-
await expect(row.locator('[data-testid^="doc-pinned-"]')).toBeVisible();
459+
await expect(row.getByTestId('doc-pinned-icon')).toBeVisible();
460460
const leftPanelFavorites = page.getByTestId('left-panel-favorites');
461461
await expect(leftPanelFavorites.getByText(docTitle)).toBeVisible();
462462

@@ -475,7 +475,7 @@ test.describe('Doc Header', () => {
475475
await page.goto('/');
476476

477477
// Check is unpinned
478-
await expect(row.locator('[data-testid^="doc-pinned-"]')).toBeHidden();
478+
await expect(row.getByTestId('doc-pinned-icon')).toBeHidden();
479479
await expect(leftPanelFavorites.getByText(docTitle)).toBeHidden();
480480
});
481481

src/frontend/apps/impress/src/features/docs/doc-management/components/DocIcon.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { useTranslation } from 'react-i18next';
2-
31
import { Text, TextType } from '@/components';
42

53
type DocIconProps = TextType & {
@@ -15,8 +13,6 @@ export const DocIcon = ({
1513
$weight = '400',
1614
...textProps
1715
}: DocIconProps) => {
18-
const { t } = useTranslation();
19-
2016
if (!emoji) {
2117
return <>{defaultIcon}</>;
2218
}
@@ -28,7 +24,7 @@ export const DocIcon = ({
2824
$variation={$variation}
2925
$weight={$weight}
3026
aria-hidden="true"
31-
aria-label={t('Document emoji icon')}
27+
data-testid="doc-emoji-icon"
3228
>
3329
{emoji}
3430
</Text>

src/frontend/apps/impress/src/features/docs/doc-management/components/SimpleDocItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const SimpleDocItem = ({
6666
{isPinned ? (
6767
<PinnedDocumentIcon
6868
aria-hidden="true"
69-
aria-label={t('Pin document icon')}
69+
data-testid="doc-pinned-icon"
7070
color={colorsTokens['primary-500']}
7171
/>
7272
) : (
@@ -75,7 +75,7 @@ export const SimpleDocItem = ({
7575
defaultIcon={
7676
<SimpleFileIcon
7777
aria-hidden="true"
78-
aria-label={t('Simple document icon')}
78+
data-testid="doc-simple-icon"
7979
color={colorsTokens['primary-500']}
8080
/>
8181
}

0 commit comments

Comments
 (0)