Skip to content

✨(frontend) make delete buttons nvda-accessible; add close to title a… #1281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to
- #1262
- #1244
- #1270
- #1281

### Fixed

Expand Down
97 changes: 20 additions & 77 deletions src/frontend/apps/e2e/__tests__/app-impress/doc-export.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ test.describe('Doc Export', () => {
})
.click();

await expect(
page
.locator('div')
.filter({ hasText: /^Download$/ })
.first(),
).toBeVisible();
await expect(page.getByTestId('modal-export-title')).toBeVisible();
await expect(
page.getByText('Download your document in a .docx or .pdf format.'),
).toBeVisible();
Expand All @@ -45,7 +40,7 @@ test.describe('Doc Export', () => {
await expect(
page.getByRole('button', { name: 'Close the modal' }),
).toBeVisible();
await expect(page.getByRole('button', { name: 'Download' })).toBeVisible();
await expect(page.getByTestId('modal-download-button')).toBeVisible();
});

test('it exports the doc with pdf line break', async ({
Expand Down Expand Up @@ -122,7 +117,9 @@ test.describe('Doc Export', () => {
const fileChooser = await fileChooserPromise;
await fileChooser.setFiles(path.join(__dirname, 'assets/test.svg'));

const image = page.getByRole('img', { name: 'test.svg' });
const image = page
.locator('.--docs--editor-container img.bn-visual-media')
.first();

await expect(image).toBeVisible();

Expand All @@ -136,23 +133,13 @@ test.describe('Doc Export', () => {
await page.getByRole('combobox', { name: 'Format' }).click();
await page.getByRole('option', { name: 'Docx' }).click();

await expect(
page.getByRole('button', {
name: 'Download',
exact: true,
}),
).toBeVisible();
await expect(page.getByTestId('modal-download-button')).toBeVisible();

const downloadPromise = page.waitForEvent('download', (download) => {
return download.suggestedFilename().includes(`${randomDoc}.docx`);
});

void page
.getByRole('button', {
name: 'Download',
exact: true,
})
.click();
void page.getByTestId('modal-download-button').click();

const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(`${randomDoc}.docx`);
Expand Down Expand Up @@ -182,7 +169,9 @@ test.describe('Doc Export', () => {
const fileChooser = await fileChooserPromise;
await fileChooser.setFiles(path.join(__dirname, 'assets/test.svg'));

const image = page.getByRole('img', { name: 'test.svg' });
const image = page
.locator('.--docs--editor-container img.bn-visual-media')
.first();

await expect(image).toBeVisible();

Expand Down Expand Up @@ -216,11 +205,7 @@ test.describe('Doc Export', () => {

await new Promise((resolve) => setTimeout(resolve, 1000));

await expect(
page.getByRole('button', {
name: 'Download',
}),
).toBeVisible();
await expect(page.getByTestId('modal-download-button')).toBeVisible();

const responseCorsPromise = page.waitForResponse(
(response) =>
Expand All @@ -231,11 +216,7 @@ test.describe('Doc Export', () => {
return download.suggestedFilename().includes(`${randomDoc}.pdf`);
});

void page
.getByRole('button', {
name: 'Download',
})
.click();
void page.getByTestId('modal-download-button').click();

const responseCors = await responseCorsPromise;
expect(responseCors.ok()).toBe(true);
Expand Down Expand Up @@ -277,21 +258,13 @@ test.describe('Doc Export', () => {
})
.click();

await expect(
page.getByRole('button', {
name: 'Download',
}),
).toBeVisible();
await expect(page.getByTestId('modal-download-button')).toBeVisible();

const downloadPromise = page.waitForEvent('download', (download) => {
return download.suggestedFilename().includes(`${randomDoc}.pdf`);
});

void page
.getByRole('button', {
name: 'Download',
})
.click();
void page.getByTestId('modal-download-button').click();

const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(`${randomDoc}.pdf`);
Expand Down Expand Up @@ -328,23 +301,13 @@ test.describe('Doc Export', () => {
})
.click();

await expect(
page.getByRole('button', {
name: 'Download',
exact: true,
}),
).toBeVisible();
await expect(page.getByTestId('modal-download-button')).toBeVisible();

const downloadPromise = page.waitForEvent('download', (download) => {
return download.suggestedFilename().includes(`${randomDoc}.pdf`);
});

void page
.getByRole('button', {
name: 'Download',
exact: true,
})
.click();
void page.getByTestId('modal-download-button').click();

const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(`${randomDoc}.pdf`);
Expand Down Expand Up @@ -391,23 +354,13 @@ test.describe('Doc Export', () => {
})
.click();

await expect(
page.getByRole('button', {
name: 'Download',
exact: true,
}),
).toBeVisible();
await expect(page.getByTestId('modal-download-button')).toBeVisible();

const downloadPromise = page.waitForEvent('download', (download) => {
return download.suggestedFilename().includes(`${randomDoc}.pdf`);
});

void page
.getByRole('button', {
name: 'Download',
exact: true,
})
.click();
void page.getByTestId('modal-download-button').click();

const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(`${randomDoc}.pdf`);
Expand Down Expand Up @@ -470,12 +423,7 @@ test.describe('Doc Export', () => {
return download.suggestedFilename().includes(`${randomDocFrench}.pdf`);
});

void page
.getByRole('button', {
name: 'Télécharger',
exact: true,
})
.click();
void page.getByTestId('modal-download-button').click();

const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(`${randomDocFrench}.pdf`);
Expand Down Expand Up @@ -538,12 +486,7 @@ test.describe('Doc Export', () => {
})
.click();

void page
.getByRole('button', {
name: 'Download',
exact: true,
})
.click();
void page.getByTestId('modal-download-button').click();

const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(`${docChild}.pdf`);
Expand Down
1 change: 1 addition & 0 deletions src/frontend/apps/e2e/__tests__/app-impress/home.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ test.describe('Home page', () => {
await page.waitForLoadState('domcontentloaded');

// Wait a bit more for the responsive store to be initialized
// eslint-disable-next-line playwright/no-wait-for-timeout
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

await page.waitForTimeout(500);

// Check header content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export const ModalExport = ({ onClose, doc }: ModalExportProps) => {
isOpen
closeOnClickOutside
onClose={() => onClose()}
hideCloseButton
rightActions={
<>
<Button
Expand All @@ -148,16 +149,45 @@ export const ModalExport = ({ onClose, doc }: ModalExportProps) => {
fullWidth
onClick={() => void onSubmit()}
disabled={isExporting}
data-testid="modal-download-button"
>
{t('Download')}
</Button>
</>
}
size={ModalSize.MEDIUM}
title={
<Text $size="h6" $variation="1000" $align="flex-start">
{t('Download')}
</Text>
<Box
$direction="row"
$justify="space-between"
$align="center"
$width="100%"
>
<Text
$size="h6"
$variation="1000"
$align="flex-start"
data-testid="modal-export-title"
>
{t('Download')}
</Text>
<Button
aria-label={t('Close the download modal')}
size="small"
color="primary-text"
onClick={() => onClose()}
disabled={isExporting}
icon={
<Box
as="span"
aria-hidden="true"
className="material-icons-filled"
>
close
</Box>
}
/>
</Box>
}
>
<Box
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { usePathname } from 'next/navigation';
import { useRouter } from 'next/router';
import { Trans, useTranslation } from 'react-i18next';

import { Box, Text, TextErrors } from '@/components';
import { Box, Icon, Text, TextErrors } from '@/components';

import { useRemoveDoc } from '../api/useRemoveDoc';
import { Doc } from '../types';
Expand Down Expand Up @@ -53,11 +53,12 @@ export const ModalRemoveDoc = ({
<Modal
isOpen
closeOnClickOutside
hideCloseButton
onClose={() => onClose()}
rightActions={
<>
<Button
aria-label={t('Close the modal')}
aria-label={t('Close the delete modal')}
color="secondary"
fullWidth
onClick={() => onClose()}
Expand All @@ -80,15 +81,29 @@ export const ModalRemoveDoc = ({
}
size={ModalSize.MEDIUM}
title={
<Text
$size="h6"
as="h6"
$margin={{ all: '0' }}
$align="flex-start"
$variation="1000"
<Box
$direction="row"
$justify="space-between"
$align="center"
$width="100%"
>
{t('Delete a doc')}
</Text>
<Text
$size="h6"
as="h6"
$margin={{ all: '0' }}
$align="flex-start"
$variation="1000"
>
{t('Delete a doc')}
</Text>
<Button
aria-label={t('Close the delete modal')}
size="small"
color="primary-text"
onClick={() => onClose()}
icon={<Icon iconName="close" />}
/>
</Box>
}
>
<Box
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const DocShareAccessRequestItem = ({ doc, accessRequest }: Props) => {
docId: doc.id,
})
}
aria-label={t('Close the access request modal')}
>
<Icon iconName="close" $variation="600" $size="16px" />
</BoxButton>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Modal, ModalSize } from '@openfun/cunningham-react';
import { Button, Modal, ModalSize } from '@openfun/cunningham-react';
import { useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { createGlobalStyle, css } from 'styled-components';
Expand Down Expand Up @@ -137,12 +137,29 @@ export const DocShareModal = ({ doc, onClose, isRootDoc = true }: Props) => {
aria-label={t('Share modal')}
size={isDesktop ? ModalSize.LARGE : ModalSize.FULL}
onClose={onClose}
title={<Box $align="flex-start">{t('Share the document')}</Box>}
title={
<Box $direction="row" $justify="space-between" $align="center">
<Box $align="flex-start">{t('Share the document')}</Box>
<Button
aria-label={t('Close the modal')}
size="small"
color="primary-text"
onClick={onClose}
icon={
<Box aria-hidden="true" className="material-icons-filled">
close
</Box>
}
/>
</Box>
}
hideCloseButton
>
<ShareModalStyle />
<Box
aria-label={t('Share modal')}
$height={canViewAccesses ? modalContentHeight : 'auto'}
$height="auto"
$maxHeight={canViewAccesses ? modalContentHeight : 'none'}
$overflow="hidden"
className="--docs--doc-share-modal noPadding "
$justify="space-between"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export const ModalSelectVersion = ({
onClick={onClose}
size="nano"
color="primary-text"
aria-label={t('Close the version history modal')}
icon={<Icon iconName="close" />}
/>
</Box>
Expand Down
Loading
Loading