Skip to content

Commit dbdf7d8

Browse files
committed
✨(frontend) improve favorite item a11y and update e2e test accordingly
enhances keyboard access to pin/unpin and syncs test with new behavior Signed-off-by: Cyril <[email protected]>
1 parent 1160f27 commit dbdf7d8

File tree

6 files changed

+36
-5
lines changed

6 files changed

+36
-5
lines changed

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
@@ -119,7 +119,7 @@ test.describe('Document grid item options', () => {
119119
await page.getByText('push_pin').click();
120120

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

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

130130
// Check is unpinned
131-
await expect(row.getByLabel('Pin document icon')).toBeHidden();
131+
await expect(row.locator('[data-testid^="doc-pinned-"]')).toBeHidden();
132132
await expect(leftPanelFavorites.getByText(docTitle)).toBeHidden();
133133
});
134134

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ test.describe('Doc Header', () => {
409409
const row = await getGridRow(page, docTitle);
410410

411411
// Check is pinned
412-
await expect(row.getByLabel('Pin document icon')).toBeVisible();
412+
await expect(row.locator('[data-testid^="doc-pinned-"]')).toBeVisible();
413413
const leftPanelFavorites = page.getByTestId('left-panel-favorites');
414414
await expect(leftPanelFavorites.getByText(docTitle)).toBeVisible();
415415

@@ -424,7 +424,7 @@ test.describe('Doc Header', () => {
424424
await page.goto('/');
425425

426426
// Check is unpinned
427-
await expect(row.getByLabel('Pin document icon')).toBeHidden();
427+
await expect(row.locator('[data-testid^="doc-pinned-"]')).toBeHidden();
428428
await expect(leftPanelFavorites.getByText(docTitle)).toBeHidden();
429429
});
430430

src/frontend/apps/impress/src/components/DropButton.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ const StyledButton = styled(Button)<StyledButtonProps>`
3333
font-size: 0.938rem;
3434
padding: 0;
3535
${({ $css }) => $css};
36+
37+
&:focus-visible {
38+
outline: 2px solid var(--c--theme--colors--primary-500);
39+
outline-offset: 2px;
40+
border-radius: 4px;
41+
transition: none;
42+
}
3643
`;
3744

3845
export interface DropButtonProps {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,17 @@ export const SimpleDocItem = ({
5252
filter: drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.05));
5353
`}
5454
$padding={`${spacingsTokens['3xs']} 0`}
55+
data-testid={isPinned ? `doc-pinned-${doc.id}` : undefined}
5556
>
5657
{isPinned ? (
5758
<PinnedDocumentIcon
59+
aria-hidden="true"
5860
aria-label={t('Pin document icon')}
5961
color={colorsTokens['primary-500']}
6062
/>
6163
) : (
6264
<SimpleFileIcon
65+
aria-hidden="true"
6366
aria-label={t('Simple document icon')}
6467
color={colorsTokens['primary-500']}
6568
/>

src/frontend/apps/impress/src/features/docs/docs-grid/components/DocsGridActions.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { useModal } from '@openfun/cunningham-react';
22
import { useTranslation } from 'react-i18next';
3+
import { css } from 'styled-components';
34

45
import { DropdownMenu, DropdownMenuOption, Icon } from '@/components';
6+
import { useCunninghamTheme } from '@/cunningham';
57
import {
68
Doc,
79
KEY_LIST_DOC,
@@ -31,6 +33,8 @@ export const DocsGridActions = ({
3133
const makeFavoriteDoc = useCreateFavoriteDoc({
3234
listInvalideQueries: [KEY_LIST_DOC],
3335
});
36+
const { colorsTokens: _colorsTokens, spacingsTokens: _spacingsTokens } =
37+
useCunninghamTheme();
3438

3539
const options: DropdownMenuOption[] = [
3640
{
@@ -83,6 +87,13 @@ export const DocsGridActions = ({
8387
iconName="more_horiz"
8488
$theme="primary"
8589
$variation="600"
90+
aria-label={t('More options')}
91+
$css={css`
92+
cursor: pointer;
93+
&:hover {
94+
opacity: 0.8;
95+
}
96+
`}
8697
/>
8798
</DropdownMenu>
8899

src/frontend/apps/impress/src/i18n/translations.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@
266266
"Modal confirmation to download the attachment": "Modale Bestätigung zum Herunterladen des Anhangs",
267267
"Modal confirmation to restore the version": "Modale Bestätigung um die Version wiederherzustellen",
268268
"More docs": "Weitere Dokumente",
269+
"More options": "Weitere Optionen",
269270
"Move": "Verschieben",
270271
"Move document": "Dokument verschieben",
271272
"Move to my docs": "In \"Meine Dokumente\" verschieben",
@@ -346,6 +347,7 @@
346347
"Unnamed document": "Unbenanntes Dokument",
347348
"Unpin": "Lösen",
348349
"Untitled document": "Unbenanntes Dokument",
350+
"Updated": "Aktualisiert",
349351
"Updated at": "Aktualisiert am",
350352
"Use as prompt": "Als Prompt verwenden",
351353
"Version history": "Versionsverlauf",
@@ -369,11 +371,13 @@
369371
"en": {
370372
"translation": {
371373
"Search docs": "Search docs",
374+
"More options": "More options",
372375
"Pinned documents": "Pinned documents",
373376
"Share with {{count}} users_one": "Share with {{count}} user",
374377
"Shared with {{count}} users_many": "Shared with {{count}} users",
375378
"Shared with {{count}} users_one": "Shared with {{count}} user",
376-
"Shared with {{count}} users_other": "Shared with {{count}} users"
379+
"Shared with {{count}} users_other": "Shared with {{count}} users",
380+
"Updated": "Updated"
377381
}
378382
},
379383
"es": {
@@ -474,6 +478,7 @@
474478
"Modal confirmation to download the attachment": "Modal de confirmación para descargar el archivo adjunto",
475479
"Modal confirmation to restore the version": "Modal de confirmación para restaurar la versión",
476480
"More docs": "Más documentos",
481+
"More options": "Más opciones",
477482
"My docs": "Mis documentos",
478483
"Name": "Nombre",
479484
"New doc": "Nuevo documento",
@@ -543,6 +548,7 @@
543548
"Type the name of a document": "Escribe el nombre de un documento",
544549
"Unpin": "Desanclar",
545550
"Untitled document": "Documento sin título",
551+
"Updated": "Actualizado",
546552
"Updated at": "Actualizado a las",
547553
"Use as prompt": "Usar como prompt",
548554
"Version history": "Historial de versiones",
@@ -684,6 +690,7 @@
684690
"Modal confirmation to download the attachment": "Modale de confirmation pour télécharger la pièce jointe",
685691
"Modal confirmation to restore the version": "Modale de confirmation pour restaurer la version",
686692
"More docs": "Plus de documents",
693+
"More options": "Plus d'options",
687694
"Move": "Déplacer",
688695
"Move document": "Déplacer le document",
689696
"Move to my docs": "Déplacer vers mes docs",
@@ -768,6 +775,7 @@
768775
"Type a name or email": "Tapez un nom ou un email",
769776
"Type the name of a document": "Tapez le nom d'un document",
770777
"Unnamed document": "Document sans titre",
778+
"Updated": "Mise à jour",
771779
"Unpin": "Désépingler",
772780
"Untitled document": "Document sans titre",
773781
"Updated at": "Mise à jour le",
@@ -1034,6 +1042,7 @@
10341042
"Modal confirmation to download the attachment": "Venster bevestiging om bijlage te downloaden",
10351043
"Modal confirmation to restore the version": "Bevestiging modal om de versie te herstellen",
10361044
"More docs": "Meer documenten",
1045+
"More options": "Meer opties",
10371046
"My docs": "Mijn documenten",
10381047
"Name": "Naam",
10391048
"New doc": "Nieuw document",
@@ -1101,6 +1110,7 @@
11011110
"Type the name of a document": "Vul de naam van een document in",
11021111
"Unpin": "Losmaken",
11031112
"Untitled document": "Naamloos document",
1113+
"Updated": "Bijgewerkt",
11041114
"Updated at": "Geüpdate op",
11051115
"Use as prompt": "Gebruik als prompt",
11061116
"Version history": "Versie historie",

0 commit comments

Comments
 (0)